mathru
mathru is a numeric library containing algorithms for linear algebra, analysis and statistics written in pure Rust with BLAS/LAPACK support.
Features
- Linear algebra
- Vector
- Matrix
- Basic matrix operations(+,-,*)
- Transposition
- LU decomposition (native/lapack)
- QR decomposition (native/lapack)
- Hessenberg decomposition (native/lapack)
- Singular value decomposition
- Inverse (native/lapack)
- Pseudo inverse (native/lapack)
- Determinant (native/lapack)
- Trace
- Eigenvalue (native/lapack)
- Ordinary differential equation (ODE)
- Explicit methods
- Heun's method
- Euler method
- Midpoint method
- Ralston's method
- Kutta 3rd order
- Runge-Kutta 4th order
- Runge-Kutta-Felhberg 4(5)
- Dormand-Prince 4(5)
- Cash-Karp 4(5)
- Tsitouras 4(5)
- Bogacki-Shampine 2(3)
- Adams-Bashforth
- Automatic step size control with starting step size
- Optimization
- Gauss-Newton algorithm
- Gradient descent
- Newton method
- Levenberg-Marquardt algorithm
- Conjugate gradient method
- Statistics
- probability distribution
- Bernoulli
- Beta
- Binomial
- Chisquared
- Exponential
- Gamma
- Chi-squared
- Normal
- Poisson
- Raised cosine
- Student-t
- Uniform
- test
- Chi-squared
- G
- Student-t
- elementary functions
- trigonometric functions
- hyperbolic functions
- exponential functions
- special functions
- gamma functions
- beta functions
- hypergeometrical functions
Usage
Add this to your Cargo.toml
for the native Rust implementation:
[]
= "0.6"
Add the following lines to 'Cargo.toml' if the blas/lapack backend should be used:
[]
= "0.6"
= false
= ["blaslapack"]
Then import the modules and it is ready to be used.
Example
use ;
// Compute the LU decomposition of a 2x2 matrix
let a: = new;
let l_ref: = new;
let : = a.dec_lu;
assert_eq!;
Solve an initial value problem with Dormand-Prince method :
use *;
use ;
use ;
use ExplicitODE;
// Define the ODE
// x' = (5t^2 - x) / e^(t + x) `$
// x(0) = 1
Fitting with Levenberg-Marquardt
///y = a + b * exp(c * t) = f(t)
License
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Any contribution is welcome!