pub struct SymbolicSparseRowMat<I: Index, R: Shape = usize, C: Shape = usize> { /* private fields */ }Expand description
Symbolic 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_ptrshas lengthnrows + 1(always checked) -
row_ptrsis increasing -
row_ptrs[0]..row_ptrs[nrows]is a valid range in row_indices (always checked, assuming increasing) -
if
nnz_per_rowisNone, elements ofcol_indices[row_ptrs[i]..row_ptrs[i + 1]]are less thanncols -
nnz_per_row[i] <= row_ptrs[i+1] - row_ptrs[i] -
if
nnz_per_rowisSome(_), elements ofcol_indices[row_ptrs[i]..][..nnz_per_row[i]]are less thanncols -
Within each row, column indices are sorted in increasing 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.
Implementations§
Source§impl<I: Index, R: Shape, C: Shape> SymbolicSparseRowMat<I, R, C>
impl<I: Index, R: Shape, C: Shape> SymbolicSparseRowMat<I, R, C>
Sourcepub fn new_checked(
nrows: R,
ncols: C,
row_ptrs: Vec<I>,
nnz_per_row: Option<Vec<I>>,
col_indices: Vec<I>,
) -> Self
pub fn new_checked( nrows: R, ncols: C, row_ptrs: Vec<I>, nnz_per_row: Option<Vec<I>>, col_indices: Vec<I>, ) -> Self
Creates a new symbolic matrix view after asserting its invariants.
§Panics
See type level documentation.
Sourcepub fn new_unsorted_checked(
nrows: R,
ncols: C,
row_ptrs: Vec<I>,
nnz_per_row: Option<Vec<I>>,
col_indices: Vec<I>,
) -> Self
pub fn new_unsorted_checked( nrows: R, ncols: C, row_ptrs: Vec<I>, nnz_per_row: Option<Vec<I>>, col_indices: Vec<I>, ) -> Self
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.
Sourcepub unsafe fn new_unchecked(
nrows: R,
ncols: C,
row_ptrs: Vec<I>,
nnz_per_row: Option<Vec<I>>,
col_indices: Vec<I>,
) -> Self
pub unsafe fn new_unchecked( nrows: R, ncols: C, row_ptrs: Vec<I>, nnz_per_row: Option<Vec<I>>, col_indices: Vec<I>, ) -> Self
Creates a new symbolic matrix view without asserting its invariants.
§Safety
See type level documentation.
Sourcepub fn into_parts(self) -> (R, C, Vec<I>, Option<Vec<I>>, Vec<I>)
pub fn into_parts(self) -> (R, C, Vec<I>, Option<Vec<I>>, Vec<I>)
Returns the components of the matrix in the order:
- row count,
- column count,
- row pointers,
- nonzeros per row,
- column indices.
Sourcepub fn as_ref(&self) -> SymbolicSparseRowMatRef<'_, I, R, C>
pub fn as_ref(&self) -> SymbolicSparseRowMatRef<'_, I, R, C>
Returns a view over the symbolic structure of self.
Sourcepub fn into_transpose(self) -> SymbolicSparseColMat<I, C, R>
pub fn into_transpose(self) -> SymbolicSparseColMat<I, C, R>
Consumes the matrix, and returns its transpose in column-major format without reallocating.
§Note
Allows unsorted matrices, producing an unsorted output.
Sourcepub fn to_owned(&self) -> Result<SymbolicSparseRowMat<I, R, C>, FaerError>
pub fn to_owned(&self) -> Result<SymbolicSparseRowMat<I, R, C>, FaerError>
Copies the current matrix into a newly allocated matrix.
§Note
Allows unsorted matrices, producing an unsorted output.
Sourcepub fn to_col_major(&self) -> Result<SymbolicSparseColMat<I, R, C>, FaerError>
pub fn to_col_major(&self) -> Result<SymbolicSparseColMat<I, R, C>, 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.
Sourcepub fn compute_nnz(&self) -> usize
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.
Sourcepub fn nnz_per_row(&self) -> Option<&[I]>
pub fn nnz_per_row(&self) -> Option<&[I]>
Returns the count of non-zeros per row of the matrix.
Sourcepub fn col_indices(&self) -> &[I]
pub fn col_indices(&self) -> &[I]
Returns the column indices.
Sourcepub fn col_indices_of_row_raw(&self, i: Idx<R>) -> &[Idx<C, I>]
pub fn col_indices_of_row_raw(&self, i: Idx<R>) -> &[Idx<C, I>]
Sourcepub fn col_indices_of_row_raw_unbound(&self, i: Idx<R>) -> &[I]
pub fn col_indices_of_row_raw_unbound(&self, i: Idx<R>) -> &[I]
Sourcepub fn col_indices_of_row(
&self,
i: Idx<R>,
) -> impl '_ + ExactSizeIterator + DoubleEndedIterator<Item = Idx<C>>
pub fn col_indices_of_row( &self, i: Idx<R>, ) -> impl '_ + ExactSizeIterator + DoubleEndedIterator<Item = Idx<C>>
Sourcepub fn row_range(&self, i: Idx<R>) -> Range<usize> ⓘ
pub fn row_range(&self, i: Idx<R>) -> Range<usize> ⓘ
Returns the range that the row i occupies in self.col_indices().
§Panics
Panics if i >= self.nrows().
Sourcepub unsafe fn row_range_unchecked(&self, i: Idx<R>) -> Range<usize> ⓘ
pub unsafe fn row_range_unchecked(&self, i: Idx<R>) -> Range<usize> ⓘ
Returns the range that the row i occupies in self.col_indices().
§Safety
The behavior is undefined if i >= self.nrows().
Sourcepub fn try_new_from_indices(
nrows: R,
ncols: C,
indices: &[(Idx<R, I>, Idx<C, I>)],
) -> Result<(Self, ValuesOrder<I>), CreationError>
pub fn try_new_from_indices( nrows: R, ncols: C, indices: &[(Idx<R, I>, Idx<C, I>)], ) -> Result<(Self, ValuesOrder<I>), CreationError>
Create a new symbolic structure, and the corresponding order for the numerical values
from pairs of indices (row, col).
Source§impl<I: Index> SymbolicSparseRowMat<I>
impl<I: Index> SymbolicSparseRowMat<I>
Sourcepub fn try_new_from_nonnegative_indices(
nrows: usize,
ncols: usize,
indices: &[(I::Signed, I::Signed)],
) -> Result<(Self, ValuesOrder<I>), CreationError>
pub fn try_new_from_nonnegative_indices( nrows: usize, ncols: usize, indices: &[(I::Signed, I::Signed)], ) -> Result<(Self, ValuesOrder<I>), CreationError>
Create a new symbolic structure, and the corresponding order for the numerical values
from pairs of indices (row, col).
Negative indices are ignored.
Trait Implementations§
Auto Trait Implementations§
impl<I, R, C> Freeze for SymbolicSparseRowMat<I, R, C>
impl<I, R, C> RefUnwindSafe for SymbolicSparseRowMat<I, R, C>
impl<I, R, C> Send for SymbolicSparseRowMat<I, R, C>
impl<I, R, C> Sync for SymbolicSparseRowMat<I, R, C>
impl<I, R, C> Unpin for SymbolicSparseRowMat<I, R, C>
impl<I, R, C> UnwindSafe for SymbolicSparseRowMat<I, R, C>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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