27 releases

0.8.0 Jul 27, 2020
0.7.1 Nov 19, 2019
0.6.5 Aug 2, 2019
0.6.4 Mar 15, 2019
0.1.0 Jul 3, 2015

#7 in Math

Download history 77/week @ 2020-04-18 117/week @ 2020-04-25 108/week @ 2020-05-02 307/week @ 2020-05-09 269/week @ 2020-05-16 142/week @ 2020-05-23 335/week @ 2020-05-30 538/week @ 2020-06-06 602/week @ 2020-06-13 363/week @ 2020-06-20 370/week @ 2020-06-27 751/week @ 2020-07-04 583/week @ 2020-07-11 480/week @ 2020-07-18 511/week @ 2020-07-25 834/week @ 2020-08-01

1,669 downloads per month
Used in less than 11 crates

MIT/Apache

350KB
8K SLoC

sprs, sparse matrices for Rust

Build status crates.io

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 :)

Features

Structures

  • CSR/CSC matrix
  • triplet matrix
  • Sparse vector

Operations

  • sparse matrix / sparse vector product
  • sparse matrix / sparse matrix product
  • sparse matrix / sparse matrix addition, subtraction
  • sparse vector / sparse vector addition, subtraction, dot product
  • sparse/dense matrix operations

Algorithms

  • 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

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_csr());

For a more complete example, be sure to check out the heat diffusion example.

Documentation

Documentation is available at docs.rs.

Changelog

See the changelog.

License

Licensed under either of

at your option.

Contribution

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.

Dependencies

~3MB
~60K SLoC