Crate sprs[−][src]
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.
Features
- sparse matrix/sparse matrix addition, multiplication.
- sparse vector/sparse vector addition, dot product.
- sparse matrix/dense matrix addition, multiplication.
- sparse triangular solves.
- powerful iteration over the sparse structure, enabling easy extension of the library.
- matrix construction using the triplet format, vertical and horizontal stacking, block construction.
- sparse cholesky solver in the separate crate
sprs-ldl
. - fully generic integer type for the storage of indices, enabling compact representations.
- planned interoperability with existing sparse solvers such as SuiteSparse.
Quick Examples
Matrix construction:
use sprs::{CsMat, CsVec}; let eye : CsMat<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());
Re-exports
pub use indexing::SpIndex; |
pub use sparse::CompressedStorage::CSR; |
pub use sparse::CompressedStorage::CSC; |
Modules
array_backend |
Fixed size arrays usable for sparse matrices. |
binop | |
errors |
Error type for sprs |
indexing | |
io |
Serialization and deserialization of sparse matrices |
linalg | |
prod | |
stack | |
vec |
Structs
CsMatBase |
Compressed matrix in the CSR or CSC format, with sorted indices. |
CsVecBase |
A sparse vector, storing the indices of its non-zero data. |
Permutation | |
TriMatBase |
Sparse matrix in the triplet format. |
TriMatIter |
An iterator over elements of a sparse matrix, in the triplet format |
Enums
CompressedStorage |
Describe the storage of a CsMat |
Traits
SparseMat |
A trait for common members of sparse matrices |
Functions
assign_to_dense |
Assign a sparse matrix into a dense matrix |
bmat |
Specify a sparse matrix by constructing it from blocks of other matrices |
csc_from_dense |
Create a CSC matrix from a dense matrix, ignoring elements
lower than |
csr_from_dense |
Create a CSR matrix from a dense matrix, ignoring elements
lower than |
hstack |
Construct a sparse matrix by horizontally stacking other matrices |
is_symmetric | |
vstack |
Construct a sparse matrix by vertically stacking other matrices |
Type Definitions
CsMat | |
CsMatI | |
CsMatVecView | |
CsMatView | |
CsMatViewI | |
CsMatViewMut | |
CsMatViewMutI | |
CsVec | |
CsVecI | |
CsVecView | |
CsVecViewI | |
CsVecViewMut | |
CsVecViewMutI | |
Ix1 | |
Ix2 | |
Ix_ |
Deprecated type alias, will be removed on next breaking change |
PermOwned | |
PermOwnedI | |
PermView | |
PermViewI | |
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 | |
TriMat | |
TriMatI | |
TriMatView | |
TriMatViewI | |
TriMatViewMut | |
TriMatViewMutI |