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.]);Run

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);Run

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

Reexports

pub use sparse::CompressedStorage::{CSR, CSC};

Modules

binop
errors

Error type for sprs

linalg
prod
stack
vec

Structs

CsMat

Compressed matrix in the CSR or CSC format.

CsVec

A sparse vector, storing the indices of its non-zero data. The indices should be sorted.

TripletMat

Triplet matrix owning its data

TripletMatView

Triplet matrix view

TripletMatViewMut

Triplet matrix mutable view

Enums

CompressedStorage

Describe the storage of a CsMat

Permutation

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 epsilon.

csr_from_dense

Create a CSR matrix from a dense matrix, ignoring elements lower than epsilon.

hstack

Construct a sparse matrix by horizontally stacking other matrices

is_symmetric
vstack

Construct a sparse matrix by vertically stacking other matrices

Type Definitions

CsMatOwned
CsMatView
CsVecOwned
CsVecView
Ix2
Ix_

Array index type

PermOwned
PermView
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