Rust numeric library with R, MATLAB & Python syntax
Rust numeric library contains linear algebra, numerical analysis, statistics and machine learning tools with R, MATLAB, Python like macros.
Peroxide provides various features.
default- Pure Rust (No dependencies of architecture - Perfect cross compilation)
O3- OpenBLAS (Perfect performance but little bit hard to set-up - Strongly recommend to read OpenBLAS for Rust)
plot- With matplotlib of python, we can draw any plots.
nc- To handle netcdf file format with DataFrame
csv- To handle csv file format with Matrix or DataFrame
serde- serialization with Serde.
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.
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.
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] extern crate peroxide; use peroxide::prelude::*;fn main() { // MATLAB like matrix constructor let 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 zeros let mut 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 operations let 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.
}
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
normis simple:
a.norm(). But it only uses L2 norm for
Vec. (For
Matrix, Frobenius norm.) ```rust
extern crate peroxide; use peroxide::prelude::*;
fn main() { let a = c!(1, 2, 3); let l2 = a.norm(); // L2 is default vector norm
assert_eq!(l2, 14f64.sqrt());
} ```
In
fuga, use various norms. But you should write longer than
prelude. ```rust
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 linf = a.norm(Norm::LInf); asserteq!(l1, 6f64); asserteq!(l2, 14f64.sqrt()); asserteq!(l_inf, 3f64); } ```
Peroxide can do many things.
O3feature)
O3feature)
Vec
fmap: map for all elements
col_map: map for column vectors
row_map: map for row vectors
Realtrait to constrain for
f64and
AD(for ODE)
randcrate
rand-distcrate
puruspecrate (pure rust)
pyo3&
matplotlib
csvfiles (
csvfeature)
netcdffiles (
ncfeature)
After
0.23.0, peroxide is compatible with mathematical structures.
Matrix,
Vec,
f64are considered as inner product vector spaces. And
Matrix,
Vecare linear operators -
Vecto
Vecand
Vecto
f64. For future, peroxide will include more & more mathematical concepts. (But still practical.)
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.
Corresponding to
0.30.2
O3feature - Need
OpenBLAS
plotfeature - Need
matplotlibof python
ncfeature - Need
netcdf
cargo.toml
toml [dependencies] peroxide = "0.30"
toml [dependencies.peroxide] version = "0.30" default-features = false features = ["O3"]
toml [dependencies.peroxide] version = "0.30" default-features = false features = ["plot"]
toml [dependencies.peroxide] version = "0.30" default-features = false features = ["nc"]
toml [dependencies.peroxide] version = "0.30" default-features = false features = ["csv"]
toml [dependencies.peroxide] version = "0.30" default-features = false features = ["O3", "plot", "nc", "csv"]
QRor
SVDthen should use
O3feature (there are no implementations for these decompositions in
default)
ncfeature and
netcdfformat. (It is much more effective than
csvand
json.)
ncfeature to export data as netcdf format and use python to draw plot.
plotfeature has limited plot abilities.
modand
re-export
puruspe)
randcrate
Vec
pyo3)
To see RELEASES.md
See CONTRIBUTES.md
To see TODO.md