mathru/
lib.rs

1#![allow(unstable_name_collisions)]
2
3//! This Rust library provides a wide range of mathematical routines such as
4//! linear algebra, differential equations, integration, interpolation, statistics and numerical optimization.
5//!
6//! # Getting Started
7//!
8//! Add a new dependency to your `Cargo.toml` file.
9//! ```text
10//! [dependencies]
11//! mathru = "0.16.2"
12//! ```
13//! You can check, if it works with a simple program like this:
14//!```rust
15//! use mathru::vector;
16//! use mathru::algebra::linear::{vector::Vector, matrix::General};
17//! use mathru::algebra::linear::matrix::{Solve};
18//!
19//! fn main() {
20//!     // set inputs:
21//!     //
22//!     // a = [1.0  -3.0]    b = [1.0]
23//!     //     [2.0  -7.0]        [3.0]
24//!     let a: General<f64> = General::new(2, 2, vec![1.0, 2.0, -3.0, -7.0]);
25//!     let b: Vector<f64> = vector![1.0; 3.0];
26//!
27//!     // Solve a * x = b
28//!     let x: Vector<f64> = a.solve(&b).unwrap();
29//!     assert_eq!(&a * &x, b);
30//!
31//!     // Print result
32//!     println!("x = [{} {}]", x[0], x[1]);
33//! }
34//! ```
35//!
36//! ## BLAS/LAPACK Support
37//!
38//! Mathru has a native Rust implementation of all its functions.
39//! However, linear algebra functions are also implemented with a BLAS/LAPACK
40//! backend.
41//! The interface is identical, but the BLAS/LAPACK backend may be somewhat
42//! more efficient.
43//! BLAS/LAPACK support can be enable in the `Cargo.toml` file like so:
44//! ```text
45//! [dependencies.mathru]
46//! version = "0.16.2"
47//! default-features = false
48//! features = "openblas"
49//! ```
50//! One of the following implementations for linear algebra can be activated
51//! as a feature:
52//!
53//!   - native: Native Rust implementation(activated by default)
54//!   - [openblas](https://www.openblas.net/): Optimized BLAS library
55//!   - [netlib](https://www.netlib.org/): Collection of mathematical software,
56//!     papers, and databases
57//!   - [intel-mkl](https://software.intel.com/content/www/us/en/develop/tools/math-kernel-library.html):
58//!     Intel Math Kernel Library
59//!   - [accelerate](https://developer.apple.com/documentation/accelerate) Make
60//!     large-scale mathematical computations and image calculations, optimized
61//!     for high performance and low-energy consumption. (macOS only)
62
63#[cfg(feature = "lapack")]
64extern crate blas;
65#[cfg(feature = "lapack")]
66extern crate blas_src;
67#[cfg(feature = "lapack")]
68extern crate lapack;
69
70#[macro_use]
71pub mod algebra;
72pub mod analysis;
73pub mod elementary;
74pub mod optimization;
75pub mod special;
76pub mod statistics;