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::AD::*,
172 ad::*,
173 dataframe::{
174 DType, DTypeArray, DTypeValue, DataFrame, Scalar, Series, TypedScalar, TypedVector,
175 },
176 matrix::{
177 combine, diag, gemm, gemv, gen_householder, inv_l, inv_u, matrix, ml_matrix, py_matrix,
178 r_matrix, Col, Matrix, Row, Shape,
179 },
180 polynomial::{lagrange_polynomial, legendre_polynomial, poly, Calculus, Polynomial},
181 vector::*,
182};
183
184#[cfg(feature = "nc")]
185pub use crate::structure::dataframe::WithNetCDF;
186
187#[cfg(feature = "complex")]
188#[allow(ambiguous_glob_reexports)]
189#[allow(unused_imports)]
190pub use crate::complex::{integral::*, matrix::*, vector::*, C64};
191
192pub use simpler::{solve, SimplerLinearAlgebra};
193
194#[allow(unused_imports)]
195pub use crate::util::{api::*, low_level::*, non_macro::*, print::*, useful::*, wrapper::*};
196
197#[allow(unused_imports)]
198pub use crate::statistics::{dist::*, ops::*, rand::*, stat::*};
199
200#[allow(unused_imports)]
201pub use crate::special::function::{
202 beta, erf, erfc, gamma, gaussian, inc_beta, inc_gamma, inv_erf, inv_erfc, inv_inc_beta,
203 inv_inc_gamma, ln_gamma, phi, poch,
204};
205
206#[allow(unused_imports)]
207pub use crate::numerical::{
208 eigen::Eigen,
209 interp::*,
210 ode::*,
211 optimize::*,
212 root::*,
213 spline::{cubic_spline, CubicHermiteSpline, CubicSpline, Spline},
214 utils::*,
215};
216
217pub use simpler::{
218 chebyshev_polynomial, cubic_hermite_spline, eigen, integrate, lambert_w0, lambert_wm1,
219};
220
221#[allow(unused_imports)]
222pub use crate::statistics::stat::Metric::*;
223
224#[cfg(feature = "parquet")]
225pub use simpler::SimpleParquet;
226
227#[cfg(feature = "plot")]
228pub use crate::util::plot::*;
229
230pub use anyhow;
231pub use paste;
232pub use rand::prelude::*;