Struct matrix::format::compressed::Compressed [] [src]

pub struct Compressed<T: Element> {
    pub rows: usize,
    pub columns: usize,
    pub nonzeros: usize,
    pub variant: Variant,
    pub values: Vec<T>,
    pub indices: Vec<usize>,
    pub offsets: Vec<usize>,
}

A compressed matrix.

Fields

rows: usize

The number of rows.

columns: usize

The number of columns.

nonzeros: usize

The number of nonzero elements.

variant: Variant

The format variant.

values: Vec<T>

The values of the nonzero elements.

indices: Vec<usize>

The indices of rows when variant = Column or columns when variant = Row of the nonzero elements.

offsets: Vec<usize>

The offsets of columns when variant = Column or rows when variant = Row such that the values and indices of the ith column when variant = Column or the ith row when variant = Row are stored starting from values[j] and indices[j], respectively, where j = offsets[i]. The vector has one additional element, which is always equal to nonzeros.

Methods

impl<T: Element> Compressed<T>
[src]

fn new<S: Size>(size: S, variant: Variant) -> Self

Create a zero matrix.

fn with_capacity<S: Size>(size: S, variant: Variant, capacity: usize) -> Self

Create a zero matrix with a specific capacity.

fn get<P: Position>(&self, position: P) -> T

Read an element.

fn set<P: Position>(&mut self, position: P, value: T)

Assign a value to an element.

Note that the function treats zero values as any other.

fn iter<'l>(&'l self) -> Iterator<'l, T>

Return a sparse iterator.

fn iter_mut<'l>(&'l mut self) -> IteratorMut<'l, T>

Return a sparse iterator allowing mutation.

fn resize<S: Size>(&mut self, size: S)

Resize the matrix.

fn retain<F>(&mut self, condition: F) where F: FnMut(usize, usize, &T) -> bool

Retain the elements that satisfy a condition and discard the rest.

Trait Implementations

impl<'l, T: Element> From<&'l Conventional<T>> for Compressed<T>
[src]

fn from(conventional: &'l Conventional<T>) -> Self

Performs the conversion.

impl<T: Element> From<Conventional<T>> for Compressed<T>
[src]

fn from(matrix: Conventional<T>) -> Self

Performs the conversion.

impl<'l, T: Element> From<&'l Diagonal<T>> for Compressed<T>
[src]

fn from(matrix: &'l Diagonal<T>) -> Self

Performs the conversion.

impl<T: Element> From<Diagonal<T>> for Compressed<T>
[src]

fn from(matrix: Diagonal<T>) -> Self

Performs the conversion.

impl<T> Multiply<Diagonal<T>, Compressed<T>> for Compressed<T> where T: Element + Number
[src]

fn multiply(&self, right: &Diagonal<T>) -> Self

Perform the multiplication.

impl<'l, T> MultiplyInto<[T][T]> for Compressed<T> where T: Element + Number
[src]

fn multiply_into(&self, right: &[T], result: &mut [T])

Perform the multiplication.

impl<T> MultiplySelf<Diagonal<T>> for Compressed<T> where T: Element + Number
[src]

fn multiply_self(&mut self, right: &Diagonal<T>)

Perform the multiplication.

impl<T: Element> Transpose for Compressed<T>
[src]

fn transpose(&self) -> Self

Perform the transpose.

impl<T: Element> Size for Compressed<T>
[src]

fn rows(&self) -> usize

Return the number of rows.

fn columns(&self) -> usize

Return the number of columns.

fn dimensions(&self) -> (usize, usize)

Return the number of rows and columns.

impl<T: Element> Matrix for Compressed<T>
[src]

type Element = T

The element type.

fn nonzeros(&self) -> usize

Count nonzero elements.

fn zero<S: Size>(size: S) -> Self

Create a zero matrix.

Derived Implementations

impl<T: PartialEq + Element> PartialEq for Compressed<T>
[src]

fn eq(&self, __arg_0: &Compressed<T>) -> bool

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, __arg_0: &Compressed<T>) -> bool

This method tests for !=.

impl<T: Debug + Element> Debug for Compressed<T>
[src]

fn fmt(&self, __arg_0: &mut Formatter) -> Result

Formats the value using the given formatter.

impl<T: Clone + Element> Clone for Compressed<T>
[src]

fn clone(&self) -> Compressed<T>

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)
1.0.0

Performs copy-assignment from source. Read more