CsrMatrixRowConstructor

Struct CsrMatrixRowConstructor 

Source
pub struct CsrMatrixRowConstructor<'a, DS, US> { /* private fields */ }
Expand description

Constructs a new valid row in a easy and interactive manner, abstracting away the complexity of the CSR format.

This struct may panic when out of scope. Please see the Drop documentation in the Trait Implementations section for more information.

Implementations§

Source§

impl<'a, DS, US> CsrMatrixRowConstructor<'a, DS, US>
where DS: DynDenseStoMut, US: DynDenseStoMut<Item = usize>,

Source

pub fn commit(self)

Commits the row construction, modifying the internal structure.

§Examples
use mop_structs::{
    doc_tests::csr_matrix_empty_vec_array,
    matrix::csr_matrix::CsrMatrixRef
};
let mut a = csr_matrix_empty_vec_array();
a.row_constructor().commit();
assert_eq!(a.as_ref(), CsrMatrixRef::new([1, 5], &[], &[], &[0, 0]));
§Assertions
  • Inserted indices must be less than the number of columns of Self.
use mop_structs::doc_tests::csr_matrix_empty_vec_array;
let mut a = csr_matrix_empty_vec_array();
a.row_constructor().set_value(10, 1).commit();
  • Inserted indices must be unique.
use mop_structs::doc_tests::csr_matrix_empty_vec_array;
let mut a = csr_matrix_empty_vec_array();
a.row_constructor().set_value(1, 1).set_value(1, 10).commit();
Source

pub unsafe fn commit_unchecked(self)

A faster and unsafe version of commit.

Source

pub fn copy_values_from_row(self, row: &CssSlice<'_, DS::Item>) -> Self
where DS::Item: Copy,

Copies all values of row into the current row.

§Examples
use mop_structs::{
    doc_tests::csr_matrix_empty_vec_array,
    matrix::csr_matrix::CsrMatrixRef,
    vec::css::CssSlice
};
let mut a = csr_matrix_empty_vec_array();
let b = CssSlice::new(5, &[1, 2], &[0, 1]);
a.row_constructor().copy_values_from_row(&b).commit();
assert_eq!(a.as_ref(), CsrMatrixRef::new(
    [1, 5],
    &[1, 2],
    &[0, 1],
    &[0, 2]
));
Source

pub fn set_value(self, column_idx: usize, value: DS::Item) -> Self

Sets a new value in the current row and column index column_idx.

§Examples
use mop_structs::{
    doc_tests::csr_matrix_empty_vec_array,
    matrix::csr_matrix::CsrMatrixRef
};
let mut a = csr_matrix_empty_vec_array();
a.row_constructor().set_value(1, 1).commit();
assert_eq!(a.as_ref(), CsrMatrixRef::new([1, 5], &[1], &[1], &[0, 1]));

Trait Implementations§

Source§

impl<'a, DS: Debug, US: Debug> Debug for CsrMatrixRowConstructor<'a, DS, US>

Source§

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

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

impl<'a, DS, US> Drop for CsrMatrixRowConstructor<'a, DS, US>

Source§

fn drop(&mut self)

Some measures are taken to ensure the CSR format and avoid unexpected runtime behavior.

§Assertions
  • Every single nonempty instance of CsrRowLayerConstructor must end with a call to the commit method.
use mop_structs::doc_tests::csr_matrix_empty_vec_array;
let mut a = csr_matrix_empty_vec_array();
a.row_constructor().set_value(1, 1);
Source§

impl<'a, DS: PartialEq, US: PartialEq> PartialEq for CsrMatrixRowConstructor<'a, DS, US>

Source§

fn eq(&self, other: &CsrMatrixRowConstructor<'a, DS, US>) -> 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<'a, DS, US> StructuralPartialEq for CsrMatrixRowConstructor<'a, DS, US>

Auto Trait Implementations§

§

impl<'a, DS, US> Freeze for CsrMatrixRowConstructor<'a, DS, US>

§

impl<'a, DS, US> RefUnwindSafe for CsrMatrixRowConstructor<'a, DS, US>

§

impl<'a, DS, US> Send for CsrMatrixRowConstructor<'a, DS, US>
where DS: Send, US: Send,

§

impl<'a, DS, US> Sync for CsrMatrixRowConstructor<'a, DS, US>
where DS: Sync, US: Sync,

§

impl<'a, DS, US> Unpin for CsrMatrixRowConstructor<'a, DS, US>

§

impl<'a, DS, US> !UnwindSafe for CsrMatrixRowConstructor<'a, DS, US>

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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.