Struct extendr_api::prelude::sparse::SymbolicSparseColMat
pub struct SymbolicSparseColMat<I>where
I: Index,{
pub(crate) nrows: usize,
pub(crate) ncols: usize,
pub(crate) col_ptr: Vec<I>,
pub(crate) col_nnz: Option<Vec<I>>,
pub(crate) row_ind: Vec<I>,
}
Expand description
Symbolic structure of sparse matrix in column format, either compressed or uncompressed.
Requires:
-
nrows <= I::Signed::MAX
(always checked) -
ncols <= I::Signed::MAX
(always checked) -
col_ptrs
has lengthncols + 1
(always checked) -
col_ptrs
is non-decreasing -
col_ptrs[0]..col_ptrs[ncols]
is a valid range in row_indices (always checked, assuming non-decreasing) -
if
nnz_per_col
isNone
, elements ofrow_indices[col_ptrs[j]..col_ptrs[j + 1]]
are less thannrows
-
nnz_per_col[j] <= col_ptrs[j+1] - col_ptrs[j]
-
if
nnz_per_col
isSome(_)
, elements ofrow_indices[col_ptrs[j]..][..nnz_per_col[j]]
are less thannrows
-
Within each column, row 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
§col_ptr: Vec<I>
§col_nnz: Option<Vec<I>>
§row_ind: Vec<I>
Implementations§
§impl<I> SymbolicSparseColMat<I>where
I: Index,
impl<I> SymbolicSparseColMat<I>where
I: Index,
pub fn new_checked(
nrows: usize,
ncols: usize,
col_ptrs: Vec<I>,
nnz_per_col: Option<Vec<I>>,
row_indices: Vec<I>,
) -> SymbolicSparseColMat<I>
pub fn new_checked( nrows: usize, ncols: usize, col_ptrs: Vec<I>, nnz_per_col: Option<Vec<I>>, row_indices: Vec<I>, ) -> SymbolicSparseColMat<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,
col_ptrs: Vec<I>,
nnz_per_col: Option<Vec<I>>,
row_indices: Vec<I>,
) -> SymbolicSparseColMat<I>
pub fn new_unsorted_checked( nrows: usize, ncols: usize, col_ptrs: Vec<I>, nnz_per_col: Option<Vec<I>>, row_indices: Vec<I>, ) -> SymbolicSparseColMat<I>
Creates a new symbolic matrix view from data containing duplicate and/or unsorted row indices per column, after asserting its other invariants.
§Panics
See type level documentation.
pub unsafe fn new_unchecked(
nrows: usize,
ncols: usize,
col_ptrs: Vec<I>,
nnz_per_col: Option<Vec<I>>,
row_indices: Vec<I>,
) -> SymbolicSparseColMat<I>
pub unsafe fn new_unchecked( nrows: usize, ncols: usize, col_ptrs: Vec<I>, nnz_per_col: Option<Vec<I>>, row_indices: Vec<I>, ) -> SymbolicSparseColMat<I>
Creates a new symbolic matrix view without asserting its invariants.
§Safety
See type level documentation.
pub fn into_parts(self) -> (usize, usize, Vec<I>, Option<Vec<I>>, Vec<I>)
pub fn into_parts(self) -> (usize, usize, Vec<I>, Option<Vec<I>>, Vec<I>)
Returns the components of the matrix in the order:
- row count,
- column count,
- column pointers,
- nonzeros per column,
- row indices.
pub fn as_ref(&self) -> SymbolicSparseColMatRef<'_, I>
pub fn as_ref(&self) -> SymbolicSparseColMatRef<'_, I>
Returns a view over the symbolic structure of self
.
pub fn into_transpose(self) -> SymbolicSparseRowMat<I>
pub fn into_transpose(self) -> SymbolicSparseRowMat<I>
Consumes the matrix, and returns its transpose in row-major format without reallocating.
§Note
Allows unsorted matrices, producing an unsorted output.
pub fn to_owned(&self) -> Result<SymbolicSparseColMat<I>, FaerError>
pub fn to_owned(&self) -> Result<SymbolicSparseColMat<I>, FaerError>
Copies the current matrix into a newly allocated matrix.
§Note
Allows unsorted matrices, producing an unsorted output.
pub fn to_row_major(&self) -> Result<SymbolicSparseRowMat<I>, FaerError>
pub fn to_row_major(&self) -> Result<SymbolicSparseRowMat<I>, FaerError>
Copies the current matrix into a newly allocated matrix, with row-major order.
§Note
Allows unsorted matrices, producing a sorted output. Duplicate entries are kept, however.
pub 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.
pub fn nnz_per_col(&self) -> Option<&[I]>
pub fn nnz_per_col(&self) -> Option<&[I]>
Returns the count of non-zeros per column of the matrix.
pub fn row_indices(&self) -> &[I]
pub fn row_indices(&self) -> &[I]
Returns the row indices.
pub fn row_indices_of_col_raw(&self, j: usize) -> &[I]
pub fn row_indices_of_col_raw(&self, j: usize) -> &[I]
pub fn row_indices_of_col(
&self,
j: usize,
) -> impl ExactSizeIterator + DoubleEndedIterator
pub fn row_indices_of_col( &self, j: usize, ) -> impl ExactSizeIterator + DoubleEndedIterator
pub fn col_range(&self, j: usize) -> Range<usize>
pub fn col_range(&self, j: usize) -> Range<usize>
Returns the range that the column j
occupies in self.row_indices()
.
§Panics
Panics if j >= self.ncols()
.
pub unsafe fn col_range_unchecked(&self, j: usize) -> Range<usize>
pub unsafe fn col_range_unchecked(&self, j: usize) -> Range<usize>
Returns the range that the column j
occupies in self.row_indices()
.
§Safety
The behavior is undefined if j >= self.ncols()
.
§impl<I> SymbolicSparseColMat<I>where
I: Index,
impl<I> SymbolicSparseColMat<I>where
I: Index,
pub fn try_new_from_indices(
nrows: usize,
ncols: usize,
indices: &[(I, I)],
) -> Result<(SymbolicSparseColMat<I>, ValuesOrder<I>), CreationError>
pub fn try_new_from_indices( nrows: usize, ncols: usize, indices: &[(I, I)], ) -> Result<(SymbolicSparseColMat<I>, ValuesOrder<I>), CreationError>
Create a new symbolic structure, and the corresponding order for the numerical values
from pairs of indices (row, col)
.
pub fn try_new_from_nonnegative_indices(
nrows: usize,
ncols: usize,
indices: &[(<I as Index>::Signed, <I as Index>::Signed)],
) -> Result<(SymbolicSparseColMat<I>, ValuesOrder<I>), CreationError>
pub fn try_new_from_nonnegative_indices( nrows: usize, ncols: usize, indices: &[(<I as Index>::Signed, <I as Index>::Signed)], ) -> Result<(SymbolicSparseColMat<I>, 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§
§impl<I> Clone for SymbolicSparseColMat<I>
impl<I> Clone for SymbolicSparseColMat<I>
§fn clone(&self) -> SymbolicSparseColMat<I>
fn clone(&self) -> SymbolicSparseColMat<I>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl<I> Freeze for SymbolicSparseColMat<I>
impl<I> RefUnwindSafe for SymbolicSparseColMat<I>where
I: RefUnwindSafe,
impl<I> Send for SymbolicSparseColMat<I>
impl<I> Sync for SymbolicSparseColMat<I>
impl<I> Unpin for SymbolicSparseColMat<I>where
I: Unpin,
impl<I> UnwindSafe for SymbolicSparseColMat<I>where
I: UnwindSafe,
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)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