Crate russell_lab[−][src]
Expand description
Russell - Rust Scientific Library
lab: Matrix-vector laboratory including linear algebra tools
Examples
Vector addition
use russell_lab::*;
let u = Vector::from(&[10.0, 20.0, 30.0, 40.0]);
let v = Vector::from(&[2.0, 1.5, 1.0, 0.5]);
let mut w = Vector::new(4);
add_vectors(&mut w, 0.1, &u, 2.0, &v);
let correct = "┌ ┐\n\
│ 5 │\n\
│ 5 │\n\
│ 5 │\n\
│ 5 │\n\
└ ┘";
assert_eq!(format!("{}", w), correct);
Matrix-Matrix multiplication
use russell_lab::*;
let a = Matrix::from(&[
&[1.0, 2.0],
&[3.0, 4.0],
&[5.0, 6.0],
]);
let b = Matrix::from(&[
&[-1.0, -2.0, -3.0],
&[-4.0, -5.0, -6.0],
]);
let mut c = Matrix::new(3, 3);
mat_mat_mul(&mut c, 1.0, &a, &b);
let correct = "┌ ┐\n\
│ -9 -12 -15 │\n\
│ -19 -26 -33 │\n\
│ -29 -40 -51 │\n\
└ ┘";
assert_eq!(format!("{}", c), correct);
Structs
Functions
Performs the addition of two vectors
Performs the addition of two vectors
Copies matrix
Copies vector
Returns package description
Performs the inner (dot) product between two vectors resulting in a scalar value
Returns evenly spaced numbers over a specified closed interval
Performs the matrix-matrix multiplication resulting in a matrix
Performs the matrix-vector multiplication resulting in a vector
Performs the outer (tensor) product between two vectors resulting in a matrix
Updates matrix based on another matrix (axpy)
Updates vector based on another vector (axpy)