Crate sprs [−] [src]
sprs
sprs is a sparse linear algebra library for Rust.
It features a sparse matrix type, CsMat, and a sparse vector type, CsVec, both based on the compressed storage scheme.
All matrix algebra operations are supported, and support for direct sparse solvers is planned.
Examples
Matrix construction
use sprs::{CsMat, CsMatOwned, CsVec}; let eye : CsMatOwned<f64> = CsMat::eye(3); let a = CsMat::new_csc((3, 3), vec![0, 2, 4, 5], vec![0, 1, 0, 2, 2], vec![1., 2., 3., 4., 5.]);
Matrix vector multiplication
use sprs::{CsMat, CsVec}; let eye = CsMat::eye(5); let x = CsVec::new(5, vec![0, 2, 4], vec![1., 2., 3.]); let y = &eye * &x; assert_eq!(x, y);
Matrix matrix multiplication, addition
use sprs::{CsMat, CsVec}; let eye = CsMat::eye(3); let a = CsMat::new_csc((3, 3), vec![0, 2, 4, 5], vec![0, 1, 0, 2, 2], vec![1., 2., 3., 4., 5.]); let b = &eye * &a; assert_eq!(a, b.to_csc());
Reexports
pub use sparse::{CsMat, CsMatOwned, CsMatView, CsVec, CsVecView, CsVecOwned}; |
pub use sparse::CompressedStorage::{CSR, CSC}; |
pub use sparse::construct::{vstack, hstack, bmat}; |
Modules
| errors |
Error type for sprs |
| sparse | |
| stack |
Type Definitions
| Ix2 | |
| Ix_ | |
| Shape |
The shape of a matrix. This a 2-tuple with the first element indicating the number of rows, and the second element indicating the number of columns. |
| SpRes |