[][src]Struct finiteelement::Sparse

pub struct Sparse<F: Float> { /* fields omitted */ }

A data structure to represent sparse matrix.

A sparse matrix is represented as a Vec of rows, where each row is a HashMap whose keys space is the set of columns. If a key does not exist in the HashMap but is smaller that the number of column the corresponding value is 0. Attempt to access an out of bound value result in a panic.

Example

extern crate finiteelement;
use finiteelement::Sparse;
let mut sprs = Sparse::new(3, 3);
sprs[1][2] = 3.;
assert_eq!(sprs[1][2], 3.);
assert_eq!(sprs[2][2], 0.);
let access_out_of_bound = std::panic::catch_unwind(|| sprs[1][3]);
assert!(access_out_of_bound.is_err());

Methods

impl<A: Float + Clone> Sparse<A>[src]

pub fn nb_columns(&self) -> usize[src]

Returns the number of column of self.

pub fn nb_rows(&self) -> usize[src]

Returns the number of rows of self.

pub fn mul_vec0(&self, x: &Vec<A>, y: &mut Vec<A>)[src]

perform y <- y + self*x where * is a matrix/vector product

pub fn mul_vec1(&self, x: &mut Vec<A>, y: &Vec<A>)[src]

perform x <- x + self^T * y where self^T is the transpose of self and * is a matrix/vector prouct

pub fn new(nb_rows: usize, nb_columns: usize) -> Self[src]

Returns a nb_rows x nb_columns Sparse full of zeroes.

pub fn reset(&mut self)[src]

Set self to the null matrix, preserve the dimension.

pub fn pretty_print(&self) -> String[src]

Returns a String representing self.

Trait Implementations

impl<A: Clone + Float> Display for Sparse<A>[src]

impl<A: Float> Index<usize> for Sparse<A>[src]

type Output = SparseVec<A>

The returned type after indexing.

impl<A: Float> Index<(usize, usize)> for Sparse<A>[src]

type Output = A

The returned type after indexing.

impl<A: Float> IndexMut<usize> for Sparse<A>[src]

impl<A: Float> IndexMut<(usize, usize)> for Sparse<A>[src]

Auto Trait Implementations

impl<F> Unpin for Sparse<F> where
    F: Unpin

impl<F> Sync for Sparse<F> where
    F: Sync

impl<F> Send for Sparse<F> where
    F: Send

impl<F> RefUnwindSafe for Sparse<F> where
    F: RefUnwindSafe

impl<F> UnwindSafe for Sparse<F> where
    F: UnwindSafe

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]