Struct matrix::format::compressed::Compressed
source · 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>,
}
Expand description
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 i
th column when variant = Column
or the i
th 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
.
Implementations§
source§impl<T: Element> Compressed<T>
impl<T: Element> Compressed<T>
sourcepub fn with_capacity<S: Size>(size: S, variant: Variant, capacity: usize) -> Self
pub fn with_capacity<S: Size>(size: S, variant: Variant, capacity: usize) -> Self
Create a zero matrix with a specific capacity.
sourcepub fn set<P: Position>(&mut self, position: P, value: T)
pub 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.
sourcepub fn iter_mut<'l>(&'l mut self) -> IteratorMut<'l, T> ⓘ
pub fn iter_mut<'l>(&'l mut self) -> IteratorMut<'l, T> ⓘ
Return a sparse iterator allowing mutation.
Trait Implementations§
source§impl<T: Clone + Element> Clone for Compressed<T>
impl<T: Clone + Element> Clone for Compressed<T>
source§fn clone(&self) -> Compressed<T>
fn clone(&self) -> Compressed<T>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more