Skip to main content

Triplets

Struct Triplets 

Source
pub struct Triplets<T: Real = f64> {
    pub n_rows: usize,
    pub n_cols: usize,
    pub row: Vec<u32>,
    pub col: Vec<u32>,
    pub val: Vec<T>,
}
Expand description

Coordinate builder: push (i, j, v) in any order, duplicates summed in insertion order, then Triplets::to_csc (Algorithm C′).

The fields are public, as in the contract, so a list assembled by other means can be converted; to_csc validates them ((D1)–(D3)).

Fields§

§n_rows: usize

Number of rows m.

§n_cols: usize

Number of columns n.

§row: Vec<u32>

Row index i_k of each triplet.

§col: Vec<u32>

Column index j_k of each triplet.

§val: Vec<T>

Value v_k of each triplet.

Implementations§

Source§

impl<T: Real> Triplets<T>

Source

pub fn new(n_rows: usize, n_cols: usize) -> Self

An empty builder of an m × n matrix.

§Panics

If m or n exceeds u32::MAX ((D2); as CscMatrix::new).

Source

pub fn from_csc(a: &CscMatrix<T>) -> Self

The stored entries of a, one triplet each, column by column: a builder that Triplets::to_csc maps back to a exactly, and to which further entries can be pushed.

Source

pub fn push(&mut self, i: u32, j: u32, v: T)

Appends the triplet (i, j, v). Indices are not checked here (they are in to_csc, step C′1); a zero v is legal (step C′4).

Source

pub fn len(&self) -> usize

Number of triplets pushed so far (K; duplicates counted).

Source

pub fn is_empty(&self) -> bool

true iff no triplet has been pushed.

Source

pub fn clear(&mut self)

Removes every triplet, keeping the dimensions and the allocated buffers (for a matrix rebuilt with new values at every iteration).

Source

pub fn reserve(&mut self, additional: usize)

Reserves room for additional more triplets.

Source

pub fn check_invariants(&self) -> Result<(), SparseError>

Checks (D1)–(D3): equal lengths, dimensions in u32, indices in range, values finite. The validation step C′1 of Triplets::to_csc.

Source

pub fn to_csc(&self) -> Result<CscMatrix<T>, SparseError>

Algorithm C′: the m × n matrix the triplets denote — sorted, duplicates summed in insertion order, zero sums not stored (C3) — or the first violation of (D1)–(D3) found.

Trait Implementations§

Source§

impl<T: Clone + Real> Clone for Triplets<T>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<T: Debug + Real> Debug for Triplets<T>

Source§

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

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

impl<T: Default + Real> Default for Triplets<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<T> Forget for Triplets<T>

§

impl<T> Freeze for Triplets<T>
where Vec<T>: Freeze,

§

impl<T> RefUnwindSafe for Triplets<T>
where Vec<T>: RefUnwindSafe,

§

impl<T> Send for Triplets<T>
where Vec<T>: Send,

§

impl<T> Sync for Triplets<T>
where Vec<T>: Sync,

§

impl<T> Unpin for Triplets<T>
where Vec<T>: Unpin,

§

impl<T> UnsafeUnpin for Triplets<T>
where Vec<T>: UnsafeUnpin,

§

impl<T> UnwindSafe for Triplets<T>
where Vec<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> ByRef<T> for T

Source§

fn by_ref(&self) -> &T

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> Imply<T> for U
where T: ?Sized, U: ?Sized,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.