If you want to do high performance computation and more linear algebra, then choose openblas feature.
If you don't want to depend C/C++ or Fortran libraries, then choose default feature.
If you want to draw plot with some great templates, then choose plot feature.
You can choose any features simultaneously.
2. Easy to optimize
Peroxide uses 1D data structure to describe matrix. So, it's too easy to integrate BLAS.
It means peroxide guarantees perfect performance for linear algebraic computations.
3. Friendly syntax
Rust is so strange for Numpy, MATLAB, R users. Thus, it's harder to learn the more rusty libraries.
With peroxide, you can do heavy computations with R, Numpy, MATLAB like syntax.
For example,
#[macro_use]externcrate peroxide;use peroxide::prelude::*;fnmain(){// MATLAB like matrix constructorlet a = ml_matrix("1 2;3 4");// R like matrix constructor (default)let b = matrix(c!(1,2,3,4),2,2,Row);// Or use zerosletmut z = zeros(2,2);
z[(0,0)] = 1.0;
z[(0,1)] = 2.0;
z[(1,0)] = 3.0;
z[(1,1)] = 4.0;// Simple but effective operationslet c = a * b;// Matrix multiplication (BLAS integrated)// Easy to pretty print
c.print();// c[0] c[1]// r[0] 1 3// r[1] 2 4// Easy to do linear algebra
c.det().print();
c.inv().print();// and etc.}
4. Can choose two different coding styles.
In peroxide, there are two different options.
prelude: To simple use.
fuga: To choose numerical algorithms explicitly.
For examples, let's see norm.
In prelude, use norm is simple: a.norm(). But it only uses L2 norm for Vec<f64>. (For Matrix, Frobenius norm.)
#[macro_use]externcrate peroxide;use peroxide::prelude::*;fnmain(){let a = c!(1, 2, 3);let l2 = a.norm();// L2 is default vector normassert_eq!(l2, 14f64.sqrt());}
In fuga, use various norms. But you should write longer than prelude.
LU Decomposition, Inverse matrix, Block partitioning
QR Decomposition (O3 feature)
Singular Value Decomposition (SVD) (O3 feature)
Cholesky Decomposition (O3 feature)
Reduced Row Echelon form
Column, Row operations
Eigenvalue, Eigenvector
Functional Programming
More easy functional programming with Vec<f64>
For matrix, there are three maps
fmap : map for all elements
col_map : map for column vectors
row_map : map for row vectors
Automatic Differentiation
Taylor mode Forward AD - for nth order AD
Exact jacobian
Real trait to constrain for f64 and AD (for ODE)
Numerical Analysis
Lagrange interpolation
Splines
Cubic Spline
Cubic Hermite Spline
Estimate slope via Akima
Estimate slope via Quadratic interpolation
Non-linear regression
Gradient Descent
Levenberg Marquardt
Ordinary Differential Equation
Euler
Runge Kutta 4th order
Backward Euler (Implicit)
Gauss Legendre 4th order (Implicit)
Numerical Integration
Newton-Cotes Quadrature
Gauss-Legendre Quadrature (up to 30 order)
Gauss-Kronrod Quadrature (Adaptive)
G7K15, G10K21, G15K31, G20K41, G25K51, G30K61
Root Finding
Bisection
False Position (Regula Falsi)
Secant
Newton
Statistics
More easy random with rand crate
Ordered Statistics
Median
Quantile (Matched with R quantile)
Probability Distributions
Bernoulli
Uniform
Binomial
Normal
Gamma
Beta
Student's-t
RNG algorithms
Acceptance Rejection
Marsaglia Polar
Ziggurat
Wrapper for rand-dist crate
Special functions
Wrapper for puruspe crate (pure rust)
Utils
R-like macro & functions
Matlab-like macro & functions
Numpy-like macro & functions
Julia-like macro & functions
Plotting
With pyo3 & matplotlib
DataFrame
Support various types simultaneously
Read & Write csv files (csv feature)
Read & Write netcdf files (nc feature)
6. Compatible with Mathematics
After 0.23.0, peroxide is compatible with mathematical structures.
Matrix, Vec<f64>, f64 are considered as inner product vector spaces.
And Matrix, Vec<f64> are linear operators - Vec<f64> to Vec<f64> and Vec<f64> to f64.
For future, peroxide will include more & more mathematical concepts. (But still practical.)
7. Written in Rust
Rust & Cargo are awesome for scientific computations.
You can use any external packages easily with Cargo, not make.
And default runtime performance of Rust is also great. If you use many iterations for computations,
then Rust become great choice.
Latest README version
Corresponding to 0.30.11
Pre-requisite
For O3 feature - Need OpenBLAS
For plot feature - Need matplotlib of python
For nc feature - Need netcdf
Install
Add next block to your cargo.toml
Default
[dependencies]
peroxide = "0.30"
OpenBLAS
[dependencies.peroxide]
version = "0.30"default-features = falsefeatures = ["O3"]
Plot
[dependencies.peroxide]
version = "0.30"default-features = falsefeatures = ["plot"]
NetCDF dependency for DataFrame
[dependencies.peroxide]
version = "0.30"default-features = falsefeatures = ["nc"]
CSV dependency for DataFrame
[dependencies.peroxide]
version = "0.30"default-features = falsefeatures = ["csv"]
请发表评论