-
Notifications
You must be signed in to change notification settings - Fork 32
/
mod.rs
230 lines (214 loc) · 5.63 KB
/
mod.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
//! Choose what you want.
//!
//! # Philosophy
//!
//! Numerical algorithms are neglected in many codes.
//! However, it is very important which algorithm is used for precise research and important numerical computation.
//! `fuga` is the best for you.
//!
//! # Usage
//!
//! ```ignore
//! #[macro_use]
//! extern crate peroxide;
//! use peroxide::fuga::*;
//!
//! // Then you can use everything in peroxide.
//! ```
//!
//! # Compare with `prelude`
//!
//! * Norm
//! ```
//! #[macro_use]
//! extern crate peroxide;
//! use peroxide::fuga::*;
//!
//! fn main() {
//! let a = c!(1, 2, 3);
//! let l1 = a.norm(Norm::L1);
//! let l2 = a.norm(Norm::L2);
//! let l_inf = a.norm(Norm::LInf);
//!
//! assert_eq!(l1, 6f64);
//! assert_eq!(l2, 14f64.sqrt());
//! assert_eq!(l_inf, 3f64);
//! }
//! ```
//!
//! ```
//! #[macro_use]
//! extern crate peroxide;
//! use peroxide::prelude::*;
//!
//! fn main() {
//! let a = c!(1, 2, 3);
//! let l2 = a.norm(); // L2 is default vector norm
//! // prelude can't compute l1 norm, l_inf norm
//! assert_eq!(l2, 14f64.sqrt());
//! }
//! ```
//!
//! * Numerical integration
//!
//! ```
//! #[macro_use]
//! extern crate peroxide;
//! use peroxide::fuga::*;
//! use std::f64::consts::PI;
//!
//! fn main() {
//! let sin = |x: f64| x.sin();
//! integrate(sin, (0f64, PI), GaussLegendre(15)).print();
//! }
//! ```
//!
//! ```
//! #[macro_use]
//! extern crate peroxide;
//! use peroxide::prelude::*;
//! use std::f64::consts::PI;
//!
//! fn main() {
//! let sin = |x: f64| x.sin();
//! integrate(sin, (0f64, PI)).print();
//! // Default integration = GaussLegendre(15)
//! }
//! ```
//!
//! * Solve
//!
//! ```
//! #[macro_use]
//! extern crate peroxide;
//! use peroxide::fuga::*;
//!
//! fn main() {
//! let a = ml_matrix("1 2;3 4");
//! let b = c!(3, 7);
//! a.solve(&b, LU).print(); // [1, 1]
//! a.solve(&b, WAZ).print(); // [1, 1]
//! }
//! ```
//!
//! ```
//! #[macro_use]
//! extern crate peroxide;
//! use peroxide::prelude::*;
//!
//! fn main() {
//! let a = ml_matrix("1 2;3 4");
//! let b = c!(3, 7);
//! // Prelude can only solve with LU
//! a.solve(&b).print(); // [1, 1]
//! }
//! ```
//!
//! * DataFrame with Parquet
//!
//! ```
//! extern crate peroxide;
//! use peroxide::fuga::*;
//!
//! fn main() {
//! let x = seq(0, 1, 0.1);
//! let y = x.fmap(|t| t.powi(2));
//!
//! let mut df = DataFrame::new(vec![]);
//! df.push("x", Series::new(x));
//! df.push("y", Series::new(y));
//!
//! df.print();
//!
//! # #[cfg(feature="parquet")] {
//! df.write_parquet("example_data/test.parquet", CompressionOptions::Uncompressed).unwrap();
//! # }
//! }
//! ```
//!
//! ```
//! extern crate peroxide;
//! use peroxide::prelude::*;
//!
//! fn main() {
//! let x = seq(0, 1, 0.1);
//! let y = x.fmap(|t| t.powi(2));
//!
//! let mut df = DataFrame::new(vec![]);
//! df.push("x", Series::new(x));
//! df.push("y", Series::new(y));
//!
//! df.print();
//!
//! # #[cfg(feature="parquet")] {
//! df.write_parquet("example_data/test.parquet").unwrap();
//! # }
//! }
//! ```
#[allow(unused_imports)]
pub use crate::macros::{julia_macro::*, matlab_macro::*, r_macro::*};
pub use peroxide_ad::{ad_closure, ad_function};
pub use peroxide_num::{ExpLogOps, PowOps, TrigOps};
pub use crate::traits::{
fp::{FPMatrix, FPVector},
general::Algorithm,
math::{InnerProduct, LinearOp, MatrixProduct, Norm, Normed, Vector, VectorProduct},
matrix::{LinearAlgebra, MatrixTrait},
mutable::{MutFP, MutMatrix},
num::Real,
pointer::{MatrixPtr, Oxide, Redox, RedoxCommon},
stable::StableFn,
sugar::{ConvToMat, Scalable, ScalableMut, VecOps},
};
#[cfg(feature = "parallel")]
pub use crate::traits::{
fp::{ParallelFPMatrix, ParallelFPVector},
math::{
ParallelInnerProduct, ParallelMatrixProduct, ParallelNormed, ParallelVector,
ParallelVectorProduct,
},
mutable::ParallelMutFP,
};
#[cfg(feature = "complex")]
#[allow(unused_imports)]
pub use crate::complex::{integral::*, matrix::*, vector::*, C64};
#[allow(unused_imports)]
#[allow(ambiguous_glob_reexports)]
pub use crate::structure::{ad::*, dataframe::*, matrix::*, polynomial::*, vector::*};
pub use crate::util::{api::*, low_level::*, non_macro::*, print::*, useful::*, wrapper::*};
#[allow(unused_imports)]
pub use crate::statistics::{dist::*, ops::*, rand::*, stat::*};
#[allow(unused_imports)]
pub use crate::special::function::*;
#[allow(unused_imports)]
pub use crate::numerical::{
eigen::*, integral::*, interp::*, ode::*, optimize::*, root::*, spline::*, utils::*,
};
#[allow(unused_imports)]
pub use crate::ml::reg::*;
#[allow(unused_imports)]
#[cfg(feature = "plot")]
pub use crate::util::plot::*;
pub use anyhow;
pub use paste;
// =============================================================================
// Enums
// =============================================================================
pub use crate::numerical::integral::Integral::{
GaussLegendre, NewtonCotes, G10K21, G10K21R, G15K31, G15K31R, G20K41, G20K41R, G25K51, G25K51R,
G30K61, G30K61R, G7K15, G7K15R,
};
pub use crate::numerical::spline::SlopeMethod::{Akima, Quadratic};
pub use crate::statistics::stat::Metric::*;
pub use crate::statistics::stat::QType::{
Type1, Type2, Type3, Type4, Type5, Type6, Type7, Type8, Type9,
};
pub use crate::structure::ad::AD::*;
pub use crate::structure::dataframe::DType::*;
pub use crate::traits::matrix::UPLO::{Lower, Upper};
pub use crate::traits::matrix::{
Form::{Diagonal, Identity},
SolveKind::{LU, WAZ},
};
#[cfg(feature = "parquet")]
pub use arrow2::io::parquet::write::CompressionOptions;