Git Product home page Git Product logo

sprs's Introduction

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.

Minimum Supported Rust Version

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.

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.

sprs's People

Contributors

aadeg avatar austinjones avatar chetmurthy avatar cxzheng avatar emberian avatar jlogan03 avatar k3yavi avatar lksriemer avatar maboesanman avatar matzhaugen avatar milibopp avatar mulimoen avatar pjoshi1 avatar pmarks avatar rth avatar shenjiangqiu avatar taketo1024 avatar tchernobog avatar toastronics avatar tomtung avatar tristancacqueray avatar usamec avatar vbarrielle avatar y-yammt avatar ztlpn avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.