[][src]Module smartcore::linalg

Diverse collection of linear algebra abstractions and methods that power SmartCore algorithms

Linear Algebra and Matrix Decomposition

Most machine learning algorithms in SmartCore depend on linear algebra and matrix decomposition methods from this module.

Traits BaseMatrix, Matrix and BaseVector define abstract methods that can be implemented for any two-dimensional and one-dimentional arrays (matrix and vector). Functions from these traits are designed for SmartCore machine learning algorithms and should not be used directly in your code. If you still want to use functions from BaseMatrix, Matrix and BaseVector please be aware that methods defined in these traits might change in the future.

One reason why linear algebra traits are public is to allow for different types of matrices and vectors to be plugged into SmartCore. Once all methods defined in BaseMatrix, Matrix and BaseVector are implemented for your favourite type of matrix and vector you should be able to run SmartCore algorithms on it. Please see nalgebra_bindings and ndarray_bindings modules for an example of how it is done for other libraries.

You will also find verious matrix decomposition methods that work for any matrix that extends Matrix. For example, to decompose matrix defined as Vec:

use smartcore::linalg::naive::dense_matrix::*;
use smartcore::linalg::svd::*;

let A = DenseMatrix::from_2d_array(&[
           &[0.9000, 0.4000, 0.7000],
           &[0.4000, 0.5000, 0.3000],
           &[0.7000, 0.3000, 0.8000],
        ]);

let svd = A.svd().unwrap();

let s: Vec<f64> = svd.s;
let v: DenseMatrix<f64> = svd.V;
let u: DenseMatrix<f64> = svd.U;

Modules

cholesky

Cholesky Decomposition

evd

The matrix is represented in terms of its eigenvalues and eigenvectors.

high_order

In this module you will find composite of matrix operations that are used elsewhere for improved efficiency.

lu

Factors a matrix as the product of a lower triangular matrix and an upper triangular matrix.

naive

Dense matrix with column-major order that wraps Vec.

qr

QR factorization that factors a matrix into a product of an orthogonal matrix and an upper triangular matrix.

stats

Various Statistical Methods

svd

Singular value decomposition.

Traits

BaseMatrix

Generic matrix type.

BaseVector

Column or row vector

Matrix

Generic matrix with additional mixins like various factorization methods.