Crates.io | sprs |
lib.rs | sprs |
version | 0.11.2 |
source | src |
created_at | 2015-07-03 17:38:22.807087 |
updated_at | 2024-09-13 18:21:38.611704 |
description | A sparse matrix library |
homepage | |
repository | https://github.com/sparsemat/sprs |
max_upload_size | |
id | 2524 |
size | 544,980 |
sprs implements some sparse matrix data structures and linear algebra algorithms in pure Rust.
The API is a work in progress, and feedback on its rough edges is highly appreciated :)
Outer iterator on compressed sparse matrices
sparse vector iteration
sparse vectors joint non zero iterations
simple sparse Cholesky decomposition (requires opting into an LGPL license)
sparse triangular solves with dense right-hand side
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_csr());
For a more complete example, be sure to check out the heat diffusion example.
Documentation is available at docs.rs.
See the changelog.
The minimum supported Rust version currently is 1.64. Prior to a 1.0 version, bumping the MSRV will not be considered a breaking change, but breakage will be avoided on a best effort basis.
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Please see the contribution guidelines for additional information about contributing.