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

Implementations§

Source§

impl<T: Element> Compressed<T>

Source

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

Create a zero matrix.

Source

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

Create a zero matrix with a specific capacity.

Source

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

Read an element.

Source

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.

Source

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

Return a sparse iterator.

Source

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

Return a sparse iterator allowing mutation.

Source

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

Resize the matrix.

Source

pub 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§

Source§

impl<T: Clone + Element> Clone for Compressed<T>

Source§

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

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<T: Debug + Element> Debug for Compressed<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

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

Source§

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

Converts to this type from the input type.
Source§

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

Source§

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

Converts to this type from the input type.
Source§

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

Source§

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

Converts to this type from the input type.
Source§

impl<T: Element> From<Compressed<T>> for Conventional<T>

Source§

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

Converts to this type from the input type.
Source§

impl<T: Element> From<Conventional<T>> for Compressed<T>

Source§

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

Converts to this type from the input type.
Source§

impl<T: Element> From<Diagonal<T>> for Compressed<T>

Source§

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

Converts to this type from the input type.
Source§

impl<T: Element> Matrix for Compressed<T>

Source§

type Element = T

The element type.
Source§

fn nonzeros(&self) -> usize

Count nonzero elements.
Source§

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

Create a zero matrix.
Source§

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

Source§

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

Perform the multiplication.
Source§

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

Source§

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

Perform the multiplication.
Source§

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

Source§

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

Perform the multiplication.
Source§

impl<T> MultiplySelf<Diagonal<T>> for Compressed<T>
where T: Element + Number,

Source§

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

Perform the multiplication.
Source§

impl<T: PartialEq + Element> PartialEq for Compressed<T>

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: Element> Size for Compressed<T>

Source§

fn rows(&self) -> usize

Return the number of rows.
Source§

fn columns(&self) -> usize

Return the number of columns.
Source§

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

Return the number of rows and columns.
Source§

impl<T: Element> Transpose for Compressed<T>

Source§

fn transpose(&self) -> Self

Perform the transpose.
Source§

impl<T: Element> StructuralPartialEq for Compressed<T>

Auto Trait Implementations§

§

impl<T> Freeze for Compressed<T>

§

impl<T> RefUnwindSafe for Compressed<T>
where T: RefUnwindSafe,

§

impl<T> Send for Compressed<T>
where T: Send,

§

impl<T> Sync for Compressed<T>
where T: Sync,

§

impl<T> Unpin for Compressed<T>
where T: Unpin,

§

impl<T> UnwindSafe for Compressed<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.