peroxide/prelude/mod.rs
1//! Do not disturbed. Just use.
2//!
3//! # Philosophy
4//!
5//! For complicated computations like as physics, statistics and etc, too many options of library disturbes theory.
6//! Many computations where numerical algorithms are not very critical do not require many options.
7//! L2 norm is enough, and what integration algorithms you use is not important.
8//! `prelude` makes you free.
9//!
10//! # Usage
11//!
12//! ```ignore
13//! #[macro_use]
14//! extern crate peroxide;
15//! use peroxide::prelude::*;
16//!
17//! // Then you can use almost everything in peroxide.
18//! ```
19//!
20//! # Compare with `fuga`
21//!
22//! * Norm
23//! ```
24//! #[macro_use]
25//! extern crate peroxide;
26//! use peroxide::prelude::*;
27//!
28//! fn main() {
29//! let a = c!(1, 2, 3);
30//! let l2 = a.norm(); // L2 is default vector norm
31//!
32//! assert_eq!(l2, 14f64.sqrt());
33//! }
34//! ```
35//!
36//! ```
37//! #[macro_use]
38//! extern crate peroxide;
39//! use peroxide::fuga::*;
40//!
41//! fn main() {
42//! let a = c!(1, 2, 3);
43//! let l2 = a.norm(Norm::L2);
44//! assert_eq!(l2, 14f64.sqrt());
45//! }
46//! ```
47//!
48//! * Numerical integration
49//!
50//! ```
51//! #[macro_use]
52//! extern crate peroxide;
53//! use peroxide::prelude::*;
54//! use std::f64::consts::PI;
55//!
56//! fn main() {
57//! let sin = |x: f64| x.sin();
58//! integrate(sin, (0f64, PI)).print();
59//! // Default integration = G7K15R(1e-4, 20)
60//! }
61//! ```
62//!
63//! ```
64//! #[macro_use]
65//! extern crate peroxide;
66//! use peroxide::fuga::*;
67//! use std::f64::consts::PI;
68//!
69//! fn main() {
70//! let sin = |x: f64| x.sin();
71//! integrate(sin, (0f64, PI), G7K15R(1e-4, 20)).print();
72//! }
73//! ```
74//!
75//! * Solve
76//!
77//! ```
78//! #[macro_use]
79//! extern crate peroxide;
80//! use peroxide::fuga::*;
81//!
82//! fn main() {
83//! let a = ml_matrix("1 2;3 4");
84//! let b = c!(3, 7);
85//! a.solve(&b, LU).print(); // [1, 1]
86//! a.solve(&b, WAZ).print(); // [1, 1]
87//! }
88//! ```
89//!
90//! ```
91//! #[macro_use]
92//! extern crate peroxide;
93//! use peroxide::prelude::*;
94//!
95//! fn main() {
96//! let a = ml_matrix("1 2;3 4");
97//! let b = c!(3, 7);
98//! // Prelude can only solve with LU
99//! a.solve(&b).print(); // [1, 1]
100//! }
101//! ```
102//!
103//! * DataFrame with Parquet
104//!
105//! ```
106//! extern crate peroxide;
107//! use peroxide::fuga::*;
108//!
109//! fn main() {
110//! let x = seq(0, 1, 0.1);
111//! let y = x.fmap(|t| t.powi(2));
112//!
113//! let mut df = DataFrame::new(vec![]);
114//! df.push("x", Series::new(x));
115//! df.push("y", Series::new(y));
116//!
117//! df.print();
118//!
119//! # #[cfg(feature="parquet")] {
120//! df.write_parquet("example_data/test.parquet", SNAPPY).unwrap();
121//! # }
122//! }
123//! ```
124//!
125//! ```
126//! extern crate peroxide;
127//! use peroxide::prelude::*;
128//!
129//! fn main() {
130//! let x = seq(0, 1, 0.1);
131//! let y = x.fmap(|t| t.powi(2));
132//!
133//! let mut df = DataFrame::new(vec![]);
134//! df.push("x", Series::new(x));
135//! df.push("y", Series::new(y));
136//!
137//! df.print();
138//!
139//! # #[cfg(feature="parquet")] {
140//! df.write_parquet("example_data/test.parquet").unwrap();
141//! # }
142//! }
143//! ```
144
145#[allow(unused_imports)]
146pub use crate::macros::{julia_macro::*, matlab_macro::*, r_macro::*};
147
148pub use peroxide_ad::{ad_closure, ad_function};
149
150pub mod simpler;
151
152pub use crate::traits::{
153 fp::{FPMatrix, FPVector},
154 general::Algorithm,
155 math::{InnerProduct, LinearOp, MatrixProduct, Vector, VectorProduct},
156 matrix::{MatrixTrait, PQLU, QR, WAZD},
157 mutable::{MutFP, MutMatrix},
158 num::Real,
159 pointer::{MatrixPtr, Oxide, Redox, RedoxCommon},
160 sugar::{ConvToMat, Scalable, ScalableMut, VecOps},
161};
162
163pub use peroxide_num::{ExpLogOps, PowOps, TrigOps};
164
165pub use simpler::SimpleNorm;
166
167#[cfg(feature = "csv")]
168pub use crate::structure::dataframe::WithCSV;
169#[allow(unused_imports)]
170pub use crate::structure::{
171 ad::*,
172 dataframe::{
173 DType, DTypeArray, DTypeValue, DataFrame, Scalar, Series, TypedScalar, TypedVector,
174 },
175 matrix::{
176 combine, diag, gemm, gemv, gen_householder, inv_l, inv_u, matrix, ml_matrix, py_matrix,
177 r_matrix, Col, Matrix, Row, Shape,
178 },
179 polynomial::{lagrange_polynomial, legendre_polynomial, poly, Calculus, Polynomial},
180 vector::*,
181};
182
183#[cfg(feature = "nc")]
184pub use crate::structure::dataframe::WithNetCDF;
185
186#[cfg(feature = "complex")]
187#[allow(ambiguous_glob_reexports)]
188#[allow(unused_imports)]
189pub use crate::complex::{integral::*, matrix::*, vector::*, C64};
190
191pub use simpler::{solve, SimplerLinearAlgebra};
192
193#[allow(unused_imports)]
194pub use crate::util::{api::*, low_level::*, non_macro::*, print::*, useful::*, wrapper::*};
195
196#[allow(unused_imports)]
197pub use crate::statistics::{dist::*, ops::*, rand::*, stat::*};
198
199#[allow(unused_imports)]
200pub use crate::special::function::{
201 beta, erf, erfc, gamma, gaussian, inc_beta, inc_gamma, inv_erf, inv_erfc, inv_inc_beta,
202 inv_inc_gamma, ln_gamma, phi, poch,
203};
204
205#[allow(unused_imports)]
206pub use crate::numerical::{
207 eigen::Eigen,
208 interp::*,
209 ode::*,
210 optimize::*,
211 root::*,
212 spline::{cubic_spline, CubicHermiteSpline, CubicSpline, Spline},
213 utils::*,
214};
215
216pub use simpler::{
217 chebyshev_polynomial, cubic_hermite_spline, eigen, integrate, lambert_w0, lambert_wm1,
218};
219
220#[allow(unused_imports)]
221pub use crate::statistics::stat::Metric::*;
222
223#[cfg(feature = "parquet")]
224pub use simpler::SimpleParquet;
225
226#[cfg(feature = "plot")]
227pub use crate::util::plot::*;
228
229pub use anyhow;
230pub use paste;
231pub use rand::prelude::*;