Mathru is a numeric library containing algorithms for linear algebra, analysis ,statistics and optimization written in pure Rust with optional BLAS/LAPACK as backend.
The following features are implemented in this create: * Algebra * Abstract * Polynomial * Legendre polynomial * Chebyshev polynomial first & second kind * Linear algebra * Vector * Matrix * Basic matrix operations(+,-,*) * Transposition (In-place) * LU decomposition * QR decomposition * Hessenberg decomposition * Cholesky decomposition * Eigen decomposition * Singular value decomposition * Inverse * Pseudo inverse * Determinant * Trace * Solve linear system
Analysis
Elementary functions
Add this to your Cargo.toml
for the native Rust implementation:
toml
[dependencies.mathru]
version = "0.13"
Add the following lines to 'Cargo.toml' if the openblas library should be used:
toml
[dependencies.mathru]
version = "0.13"
default-features = false
features = "openblas"
One of the following implementations for linear algebra can be activated as a feature: - native: Native Rust implementation(activated by default) - openblas: Optimized BLAS library - netlib: Collection of mathematical software, papers, and databases - intel-mkl: Intel Math Kernel Library - accelerate Make large-scale mathematical computations and image calculations, optimized for high performance and low-energy consumption.(macOS only)
```rust use mathru::{ algebra::linear::{ matrix::{LUDec, Solve}, Matrix, Vector, }, matrix, vector, };
/// Solves a system of linear equations
fn main()
{
let a: Matrix
// Decompose a into a lower and upper matrix
let lu_dec: LUDec<f64> = a.dec_lu().unwrap();
// Solve the system of linear equations with the decomposed matrix
let _x1: Vector<f64> = lu_dec.solve(&b).unwrap();
// Solve it directly
let _x2: Vector<f64> = a.solve(&b).unwrap();
} ```
```rust use mathru::{ algebra::linear::Vector, analysis::differential_equation::ordinary::{problem, DormandPrince54, ExplicitODE}, };
fn main()
{
// Create an ODE instance
let problem: problem::Euler
let (x_start, x_end) = problem.time_span();
// Create a ODE solver instance
let h_0: f64 = 0.0001;
let n_max: u32 = 800;
let abs_tol: f64 = 10e-7;
let solver: DormandPrince54<f64> = DormandPrince54::new(abs_tol, h_0, n_max);
// Solve ODE
let (x, y): (Vec<f64>, Vec<Vector<f64>>) = solver.solve(&problem).unwrap();
} ```
For further examples, see project page
See project page for more information and examples. The API is documented on docs.rs.
Licensed under
Any contribution is welcome!