extendr_api::prelude::sparse

Struct SymbolicSparseRowMatRef

pub struct SymbolicSparseRowMatRef<'a, I>
where I: Index,
{ pub(crate) nrows: usize, pub(crate) ncols: usize, pub(crate) row_ptr: &'a [I], pub(crate) row_nnz: Option<&'a [I]>, pub(crate) col_ind: &'a [I], }
Expand description

Symbolic view structure of sparse matrix in row format, either compressed or uncompressed.

Requires:

  • nrows <= I::Signed::MAX (always checked)

  • ncols <= I::Signed::MAX (always checked)

  • row_ptrs has length nrows + 1 (always checked)

  • row_ptrs is non-decreasing

  • row_ptrs[0]..row_ptrs[nrows] is a valid range in row_indices (always checked, assuming non-decreasing)

  • if nnz_per_row is None, elements of col_indices[row_ptrs[i]..row_ptrs[i + 1]] are less than ncols

  • nnz_per_row[i] <= row_ptrs[i+1] - row_ptrs[i]

  • if nnz_per_row is Some(_), elements of col_indices[row_ptrs[i]..][..nnz_per_row[i]] are less than ncols

  • Within each row, column indices are sorted in non-decreasing order.

§Note

Some algorithms allow working with matrices containing unsorted row indices per column.

Passing such a matrix to an algorithm that does not explicitly permit this is unspecified (though not undefined) behavior.

Fields§

§nrows: usize§ncols: usize§row_ptr: &'a [I]§row_nnz: Option<&'a [I]>§col_ind: &'a [I]

Implementations§

§

impl<'a, I> SymbolicSparseRowMatRef<'a, I>
where I: Index,

pub fn new_checked( nrows: usize, ncols: usize, row_ptrs: &'a [I], nnz_per_row: Option<&'a [I]>, col_indices: &'a [I], ) -> SymbolicSparseRowMatRef<'a, I>

Creates a new symbolic matrix view after asserting its invariants.

§Panics

See type level documentation.

pub fn new_unsorted_checked( nrows: usize, ncols: usize, row_ptrs: &'a [I], nnz_per_row: Option<&'a [I]>, col_indices: &'a [I], ) -> SymbolicSparseRowMatRef<'a, I>

Creates a new symbolic matrix view from data containing duplicate and/or unsorted column indices per row, after asserting its other invariants.

§Panics

See type level documentation.

pub unsafe fn new_unchecked( nrows: usize, ncols: usize, row_ptrs: &'a [I], nnz_per_row: Option<&'a [I]>, col_indices: &'a [I], ) -> SymbolicSparseRowMatRef<'a, I>

Creates a new symbolic matrix view without asserting its invariants.

§Safety

See type level documentation.

pub fn nrows(&self) -> usize

Returns the number of rows of the matrix.

pub fn ncols(&self) -> usize

Returns the number of columns of the matrix.

pub fn shape(&self) -> (usize, usize)

Returns the number of rows and columns of the matrix.

pub fn transpose(self) -> SymbolicSparseColMatRef<'a, I>

Returns a view over the transpose of self in column-major format.

pub fn to_owned(&self) -> Result<SymbolicSparseRowMat<I>, FaerError>

Copies the current matrix into a newly allocated matrix.

§Note

Allows unsorted matrices, producing an unsorted output.

pub fn to_col_major(&self) -> Result<SymbolicSparseColMat<I>, FaerError>

Copies the current matrix into a newly allocated matrix, with column-major order.

§Note

Allows unsorted matrices, producing a sorted output. Duplicate entries are kept, however.

pub fn compute_nnz(&self) -> usize

Returns the number of symbolic non-zeros in the matrix.

The value is guaranteed to be less than I::Signed::MAX.

§Note

Allows unsorted matrices, but the output is a count of all the entries, including the duplicate ones.

pub fn row_ptrs(&self) -> &'a [I]

Returns the column pointers.

pub fn nnz_per_row(&self) -> Option<&'a [I]>

Returns the count of non-zeros per column of the matrix.

pub fn col_indices(&self) -> &'a [I]

Returns the column indices.

pub fn col_indices_of_row_raw(&self, i: usize) -> &'a [I]

Returns the column indices of row i.

§Panics

Panics if i >= self.nrows().

pub fn col_indices_of_row( &self, i: usize, ) -> impl ExactSizeIterator + DoubleEndedIterator + 'a

Returns the column indices of row i.

§Panics

Panics if i >= self.ncols().

pub fn row_range(&self, i: usize) -> Range<usize>

Returns the range that the row i occupies in self.col_indices().

§Panics

Panics if i >= self.nrows().

pub unsafe fn row_range_unchecked(&self, i: usize) -> Range<usize>

Returns the range that the row i occupies in self.col_indices().

§Safety

The behavior is undefined if i >= self.nrows().

Trait Implementations§

§

impl<I> Clone for SymbolicSparseRowMatRef<'_, I>
where I: Index,

§

fn clone(&self) -> SymbolicSparseRowMatRef<'_, I>

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
§

impl<I> Debug for SymbolicSparseRowMatRef<'_, I>
where I: Index,

§

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

Formats the value using the given formatter. Read more
§

impl<'a, I> IntoConst for SymbolicSparseRowMatRef<'a, I>
where I: Index,

§

impl<'short, I> Reborrow<'short> for SymbolicSparseRowMatRef<'_, I>
where I: Index,

§

type Target = SymbolicSparseRowMatRef<'short, I>

§

fn rb(&self) -> <SymbolicSparseRowMatRef<'_, I> as Reborrow<'short>>::Target

§

impl<'short, I> ReborrowMut<'short> for SymbolicSparseRowMatRef<'_, I>
where I: Index,

§

type Target = SymbolicSparseRowMatRef<'short, I>

§

fn rb_mut( &mut self, ) -> <SymbolicSparseRowMatRef<'_, I> as ReborrowMut<'short>>::Target

§

impl<I> Copy for SymbolicSparseRowMatRef<'_, I>
where I: Index,

Auto Trait Implementations§

§

impl<'a, I> Freeze for SymbolicSparseRowMatRef<'a, I>

§

impl<'a, I> RefUnwindSafe for SymbolicSparseRowMatRef<'a, I>
where I: RefUnwindSafe,

§

impl<'a, I> Send for SymbolicSparseRowMatRef<'a, I>

§

impl<'a, I> Sync for SymbolicSparseRowMatRef<'a, I>

§

impl<'a, I> Unpin for SymbolicSparseRowMatRef<'a, I>

§

impl<'a, I> UnwindSafe for SymbolicSparseRowMatRef<'a, I>
where I: RefUnwindSafe,

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, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

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

impl<T> UniversalReborrow for T
where T: for<'a> Reborrow<'a>,

§

impl<T> UniversalReborrowMut for T
where T: for<'a> ReborrowMut<'a>,