Peroxide
Rust numeric library contains linear algebra, numerical analysis, statistics and machine learning tools with R, MATLAB, Python like macros.
Why Peroxide?
1. Customize features
Peroxide provides various features.
default
- Pure Rust (No dependencies of architecture - Perfect cross compilation)O3
- SIMD + OpenBLAS (Perfect performance but hard to set-up - Strongly recommend to read OpenBLAS for Rust)plot
- With matplotlib of python, we can draw any plots.dataframe
- Dataframe & netcdfserde
- serialization with Serde.
If you want to do high performance computation, 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 & SIMD. 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,
extern crate peroxide;
use *;
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.)
extern crate peroxide;
use *;
In fuga
, use various norms. But you should write longer than prelude
.
extern crate peroxide;
use *;
5. Batteries included
Peroxide can do many things.
- Linear Algebra
- Effective Matrix structure
- Transpose, Determinant, Diagonal
- LU Decomposition, Inverse matrix, Block partitioning
- QR Decomposition
- 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 elementscol_map
: map for column vectorsrow_map
: map for row vectors
- More easy functional programming with
- Automatic Differentiation
- Dual number system - for 1st order AD
- Hyper dual number system - for 2nd order AD
- Exact jacobian
Real
trait to constrain forf64
andDual
Number
structure to unifyf64
andDual
- Numerical Analysis
- Lagrange interpolation
- Cubic spline
- Non-linear regression
- Gradient Descent
- Gauss Newton
- Levenberg Marquardt
- Ordinary Differential Equation
- Euler
- Runge Kutta 4th order
- Backward Euler
- Gauss Legendre 4th order
- Numerical Integration
- Gauss-Legendre Quadrature
- Statistics
- More easy random with
rand
crate - Ordered Statistics
- Median
- Quantile (Matched with R quantile)
- Probability Distributions
- Bernoulli
- Uniform
- Normal
- Gamma
- Beta
- Student's-t
- RNG algorithms
- Acceptance Rejection
- Marsaglia Polar
- Ziggurat
- Wrapper for
rand-dist
crate
- More easy random with
- Special functions
- Wrapper for
puruspe
crate (pure rust)
- Wrapper for
- Utils
- R-like macro & functions
- Matlab-like macro & functions
- Numpy-like macro & functions
- Julia-like macro & functions
- Plotting
- With
pyo3
&matplotlib
- With
- DataFrame
- Convert with Matrix
- Read & Write
csv
files - Read & Write
netcdf
files
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.23.0
Pre-requisite
- For
O3
feature - NeedOpenBLAS
- For
plot
feature - Needmatplotlib
of python - For
dataframe
feature - Neednetcdf
Install
- Add next block to your
cargo.toml
- Default
[] = "0.23"
- OpenBLAS + SIMD
[] = "0.23" = false = ["O3"]
- Plot
[] = "0.23" = false = ["plot"]
- DataFrame
[] = "0.23" = false = ["dataframe"]
- OpenBLAS + SIMD & Plot & DataFrame
[] = "0.23" = false = ["O3", "plot", "dataframe"]
Useful tips for features
- After
0.21.4
, if size of matrix is smaller than1000 x 1000
, default is more effective thanO3
feature. - To plot, use
dataframe
to export data as netcdf format and use python to draw plot.plot
feature has limited plot abilities.- There is a template of python code. - Socialst
Module Structure
- src
- lib.rs :
mod
andre-export
- fuga : Fuga for controlling numerical algorithms.
- macros : Macro files
- julia_macro.rs : Julia like macro
- matlab_macro.rs : MATLAB like macro
- mod.rs
- r_macro.rs : R like macro
- ml : For machine learning (Beta)
- numerical : To do numerical things
- bdf.rs : Backward Differentiation Formula (deprecated)
- eigen.rs : Eigenvalue, Eigenvector algorithm
- interp.rs : Interpolation
- mod.rs
- newton.rs : Newton's Method
- ode.rs : Main ODE solver with various algorithms
- optimize.rs : Non-linear regression
- spline.rs : Natural Spline
- utils.rs : Utils to do numerical things (e.g. jacobian)
- prelude : Prelude for using simple
- mod.rs
- simpler.rs : Provides more simple api
- special : Special functions written in pure Rust (Wrapper of
puruspe
)- mod.rs
- function.rs : Special functions
- statistics : Statistical Tools
- structure : Fundamental data structures
- dataframe.rs : Dataframe
- dual.rs : Dual number system for automatic differentiation
- hyper_dual.rs : Hyper dual number system for automatic differentiation
- matrix.rs : Matrix
- multinomial.rs : For multinomial (Beta)
- mod.rs
- polynomial.rs : Polynomial
- sparse.rs : For sparse structure (Beta)
- vector.rs : Extra tools for
Vec<f64>
- traits
- fp.rs : Functional programming toolbox
- general.rs : General algorithms
- math.rs : Mathematics
- mod.rs
- mutable.rs : Mutable toolbox
- num.rs : Number, Real and more operations
- pointer.rs : Matrix pointer and Vector pointer for convenience
- util
- mod.rs
- api.rs : Matrix constructor for various language style
- low_level.rs : Low-level tools
- mod.rs
- non_macro.rs : Primordial version of macros
- plot.rs : To draw plot (using
pyo3
) - print.rs : To print conveniently
- useful.rs : Useful utils to implement library
- wrapper.rs : Wrapper for other crates (e.g. rand)
- writer.rs : More convenient write system
- lib.rs :
Documentation
Example
Version Info
To see RELEASES.md
Contributes Guide
See CONTRIBUTES.md
TODO
To see TODO.md