Struct sprs::CsMatBase

source ·
pub struct CsMatBase<N, I, IptrStorage, IndStorage, DataStorage, Iptr = I>where
    I: SpIndex,
    Iptr: SpIndex,
    IptrStorage: Deref<Target = [Iptr]>,
    IndStorage: Deref<Target = [I]>,
    DataStorage: Deref<Target = [N]>,{ /* private fields */ }
Expand description

Compressed matrix in the CSR or CSC format, with sorted indices.

This sparse matrix format is the preferred format for performing arithmetic operations. Constructing a sparse matrix directly in this format requires a deep knowledge of its internals. For easier matrix construction, the triplet format is preferred.

The CsMatBase type is parameterized by the scalar type N, the indexing type I, the indexing storage backend types IptrStorage and IndStorage, and the value storage backend type DataStorage. Convenient aliases are available to specify frequent variants: CsMat refers to a sparse matrix that owns its data, similar to Vec<T>; CsMatView refers to a sparse matrix that borrows its data, similar to & [T]; and CsMatViewMut refers to a sparse matrix borrowing its data, with a mutable borrow for its values. No mutable borrow is allowed for the structure of the matrix, allowing the invariants to be preserved.

Additionaly, the type aliases CsMatI, CsMatViewI and CsMatViewMutI can be used to choose an index type different from the default usize.

Storage format

In the compressed storage format, the non-zero values of a sparse matrix are stored as the row and column location of the non-zero values, with a compression along the rows (CSR) or columns (CSC) indices. The dimension along which the storage is compressed is referred to as the outer dimension, the other dimension is called the inner dimension. For clarity, the remaining explanation will assume a CSR matrix, but the information stands for CSC matrices as well.

Indptr

An index pointer array indptr of size corresponding to the number of rows stores the cumulative sum of non-zero elements for each row. For instance, the number of non-zero elements of the i-th row can be obtained by computing indptr[i + 1] - indptr[i]. The total number of non-zero elements is thus nnz = indptr[nb_rows + 1]. This index pointer array can then be used to efficiently index the indices and data array, which respectively contain the column indices and the values of the non-zero elements.

Indices and data

The non-zero locations and values are stored in arrays of size nnz, indices and data. For row i, the non-zeros are located in the slices indices[indptr[i]..indptr[i+1]] and data[indptr[i]..indptr[i+1]]. We require and enforce sorted indices for each row.

Construction

A sparse matrix can be directly constructed by providing its index pointer, indices and data arrays. The coherence of the provided structure is then verified.

For situations where the compressed structure is hard to figure out up front, the triplet format can be used. A matrix in the triplet format can then be efficiently converted to a CsMat.

Alternately, a sparse matrix can be constructed from other sparse matrices using vstack, hstack or bmat.

Implementations§

source§

impl<N, I: SpIndex, Iptr: SpIndex, IptrStorage, IStorage, DStorage> CsMatBase<N, I, IptrStorage, IStorage, DStorage, Iptr>where IptrStorage: Deref<Target = [Iptr]>, IStorage: Deref<Target = [I]>, DStorage: Deref<Target = [N]>,

source

pub fn new( shape: (usize, usize), indptr: IptrStorage, indices: IStorage, data: DStorage ) -> Self

Create a new CSR sparse matrix

See new_csc for the CSC equivalent

This constructor can be used to construct all sparse matrix types. By using the type aliases one helps constrain the resulting type, as shown below

Example
// This creates an owned matrix
let owned_matrix = CsMat::new((2, 2), vec![0, 1, 1], vec![1], vec![4_u8]);
// This creates a matrix which only borrows the elements
let borrow_matrix = CsMatView::new((2, 2), &[0, 1, 1], &[1], &[4_u8]);
// A combination of storage types may also be used for a
// general sparse matrix
let mixed_matrix = CsMatBase::new((2, 2), &[0, 1, 1] as &[_], vec![1_i64].into_boxed_slice(), vec![4_u8]);
source

pub fn new_csc( shape: (usize, usize), indptr: IptrStorage, indices: IStorage, data: DStorage ) -> Self

Create a new CSC sparse matrix

See new for the CSR equivalent

source

pub fn try_new( shape: (usize, usize), indptr: IptrStorage, indices: IStorage, data: DStorage ) -> Result<Self, (IptrStorage, IStorage, DStorage, StructureError)>

Try to create a new CSR sparse matrix

See try_new_csc for the CSC equivalent

source

pub fn try_new_csc( shape: (usize, usize), indptr: IptrStorage, indices: IStorage, data: DStorage ) -> Result<Self, (IptrStorage, IStorage, DStorage, StructureError)>

Try to create a new CSC sparse matrix

See new for the CSR equivalent

source

pub unsafe fn new_unchecked( storage: CompressedStorage, shape: Shape, indptr: IptrStorage, indices: IStorage, data: DStorage ) -> Self

Create a CsMat matrix from raw data, without checking their validity

Safety

This is unsafe because algorithms are free to assume that properties guaranteed by check_compressed_structure are enforced. For instance, non out-of-bounds indices can be relied upon to perform unchecked slice access.

source§

impl<N, I: SpIndex, Iptr: SpIndex, IptrStorage, IStorage, DStorage> CsMatBase<N, I, IptrStorage, IStorage, DStorage, Iptr>where IptrStorage: Deref<Target = [Iptr]>, IStorage: DerefMut<Target = [I]>, DStorage: DerefMut<Target = [N]>,

source

pub fn new_from_unsorted( shape: Shape, indptr: IptrStorage, indices: IStorage, data: DStorage ) -> Result<Self, (IptrStorage, IStorage, DStorage, StructureError)>where N: Clone,

Try create a CSR matrix which acts as an owner of its data.

A CSC matrix can be created with new_from_unsorted_csc().

If necessary, the indices will be sorted in place.

source

pub fn new_from_unsorted_csc( shape: Shape, indptr: IptrStorage, indices: IStorage, data: DStorage ) -> Result<Self, (IptrStorage, IStorage, DStorage, StructureError)>where N: Clone,

Try create a CSC matrix which acts as an owner of its data.

A CSR matrix can be created with new_from_unsorted_csr().

If necessary, the indices will be sorted in place.

source§

impl<N, I: SpIndex, Iptr: SpIndex> CsMatBase<N, I, Vec<Iptr, Global>, Vec<I, Global>, Vec<N, Global>, Iptr>

source

pub fn eye(dim: usize) -> Selfwhere N: Num + Clone,

Identity matrix, stored as a CSR matrix.

use sprs::{CsMat, CsVec};
let eye = CsMat::eye(5);
assert!(eye.is_csr());
let x = CsVec::new(5, vec![0, 2, 4], vec![1., 2., 3.]);
let y = &eye * &x;
assert_eq!(x, y);
source

pub fn eye_csc(dim: usize) -> Selfwhere N: Num + Clone,

Identity matrix, stored as a CSC matrix.

use sprs::{CsMat, CsVec};
let eye = CsMat::eye_csc(5);
assert!(eye.is_csc());
let x = CsVec::new(5, vec![0, 2, 4], vec![1., 2., 3.]);
let y = &eye * &x;
assert_eq!(x, y);
source

pub fn empty(storage: CompressedStorage, inner_size: usize) -> Self

Create an empty CsMat for building purposes

source

pub fn zero(shape: Shape) -> Self

Create a new CsMat representing the zero matrix. Hence it has no non-zero elements.

source

pub fn reserve_outer_dim(&mut self, outer_dim_additional: usize)

Reserve the storage for the given additional number of nonzero data

source

pub fn reserve_nnz(&mut self, nnz_additional: usize)

Reserve the storage for the given additional number of nonzero data

source

pub fn reserve_outer_dim_exact(&mut self, outer_dim_lim: usize)

Reserve the storage for the given number of nonzero data

source

pub fn reserve_nnz_exact(&mut self, nnz_lim: usize)

Reserve the storage for the given number of nonzero data

source

pub fn csr_from_dense(m: ArrayView<'_, N, Ix2>, epsilon: N) -> Selfwhere N: Num + Clone + PartialOrd + Signed,

Create a CSR matrix from a dense matrix, ignoring elements lower than epsilon.

If epsilon is negative, it will be clamped to zero.

source

pub fn csc_from_dense(m: ArrayView<'_, N, Ix2>, epsilon: N) -> Selfwhere N: Num + Clone + PartialOrd + Signed,

Create a CSC matrix from a dense matrix, ignoring elements lower than epsilon.

If epsilon is negative, it will be clamped to zero.

source

pub fn append_outer(self, data: &[N]) -> Selfwhere N: Clone + Zero,

Append an outer dim to an existing matrix, compressing it in the process

source

pub fn append_outer_iter<Iter>(self, iter: Iter) -> Selfwhere N: Zero, Iter: Iterator<Item = (usize, N)>,

Append an outer dim to an existing matrix, increasing the size along the outer dimension by one.

Panics

if the iterator index is not monotonically increasing

source

pub unsafe fn append_outer_iter_unchecked<Iter>(self, iter: Iter) -> Selfwhere Iter: Iterator<Item = (usize, N)>,

Append an outer dim to an existing matrix, increasing the size along the outer dimension by one.

Safety

This is unsafe since indices for each inner dim should be monotonically increasing which is not checked. The data values are additionally not checked for zero. See append_outer_iter for the checked version

source

pub fn append_outer_csvec(self, vec: CsVecViewI<'_, N, I>) -> Selfwhere N: Clone,

Append an outer dim to an existing matrix, provided by a sparse vector

source

pub fn insert(&mut self, row: usize, col: usize, val: N)

Insert an element in the matrix. If the element is already present, its value is overwritten.

Warning: this is not an efficient operation, as it requires a non-constant lookup followed by two Vec insertions.

The insertion will be efficient, however, if the elements are inserted according to the matrix’s order, eg following the row order for a CSR matrix.

source§

impl<'a, N: 'a, I: 'a + SpIndex, Iptr: 'a + SpIndex> CsMatBase<N, I, &'a [Iptr], &'a [I], &'a [N], Iptr>

Constructor methods for sparse matrix views

These constructors can be used to create views over non-matrix data such as slices.

source

pub fn middle_outer_views( &self, i: usize, count: usize ) -> CsMatViewI<'a, N, I, Iptr>

👎Deprecated since 0.10.0: Please use the slice_outer method instead

Get a view into count contiguous outer dimensions, starting from i.

eg this gets the rows from i to i + count in a CSR matrix

This function is now deprecated, as using an index and a count is not ergonomic. The replacement, slice_outer, leverages the std::ops::Range family of types, which is better integrated into the ecosystem.

source

pub fn iter_rbr(&self) -> CsIter<'a, N, I, Iptr>

Get an iterator that yields the non-zero locations and values stored in this matrix, in the fastest iteration order.

This method will yield the correct lifetime for iterating over a sparse matrix view.

source§

impl<N, I, Iptr, IptrStorage, IndStorage, DataStorage> CsMatBase<N, I, IptrStorage, IndStorage, DataStorage, Iptr>where I: SpIndex, Iptr: SpIndex, IptrStorage: Deref<Target = [Iptr]>, IndStorage: Deref<Target = [I]>, DataStorage: Deref<Target = [N]>,

source

pub fn storage(&self) -> CompressedStorage

The underlying storage of this matrix

source

pub fn rows(&self) -> usize

The number of rows of this matrix

source

pub fn cols(&self) -> usize

The number of cols of this matrix

source

pub fn shape(&self) -> Shape

The shape of the matrix. Equivalent to let shape = (a.rows(), a.cols()).

source

pub fn nnz(&self) -> usize

The number of non-zero elements this matrix stores. This is often relevant for the complexity of most sparse matrix algorithms, which are often linear in the number of non-zeros.

source

pub fn density(&self) -> f64

The density of the sparse matrix, defined as the number of non-zero elements divided by the maximum number of elements

source

pub fn outer_dims(&self) -> usize

Number of outer dimensions, that ie equal to self.rows() for a CSR matrix, and equal to self.cols() for a CSC matrix

source

pub fn inner_dims(&self) -> usize

Number of inner dimensions, that ie equal to self.cols() for a CSR matrix, and equal to self.rows() for a CSC matrix

source

pub fn get(&self, i: usize, j: usize) -> Option<&N>

Access the element located at row i and column j. Will return None if there is no non-zero element at this location.

This access is logarithmic in the number of non-zeros in the corresponding outer slice. It is therefore advisable not to rely on this for algorithms, and prefer outer_iterator which accesses elements in storage order.

source

pub fn indptr(&self) -> IndPtrView<'_, Iptr>

The array of offsets in the indices() and data() slices. The elements of the slice at outer dimension i are available between the elements indptr[i] and indptr[i+1] in the indices() and data() slices.

Example
use sprs::{CsMat};
let eye : CsMat<f64> = CsMat::eye(5);
// get the element of row 3
// there is only one element in this row, with a column index of 3
// and a value of 1.
let range = eye.indptr().outer_inds_sz(3);
assert_eq!(range.start, 3);
assert_eq!(range.end, 4);
assert_eq!(eye.indices()[range.start], 3);
assert_eq!(eye.data()[range.start], 1.);
source

pub fn proper_indptr(&self) -> Cow<'_, [Iptr]>

Get an indptr representation suitable for ffi, cloning if necessary to get a compatible representation.

Warning

For ffi usage, one needs to call Cow::as_ptr, but it’s important to keep the Cow alive during the lifetime of the pointer. Example of a correct and incorrect ffi usage:

let mat: sprs::CsMat<f64> = sprs::CsMat::eye(5);
let mid = mat.view().middle_outer_views(1, 2);
let ptr = {
    let indptr_proper = mid.proper_indptr();
    println!(
        "ptr {:?} is valid as long as _indptr_proper_owned is in scope",
        indptr_proper.as_ptr()
    );
    indptr_proper.as_ptr()
};
// This line is UB.
// println!("ptr deref: {}", *ptr);
source

pub fn indices(&self) -> &[I]

The inner dimension location for each non-zero value. See the documentation of indptr() for more explanations.

source

pub fn data(&self) -> &[N]

The non-zero values. See the documentation of indptr() for more explanations.

source

pub fn into_raw_storage(self) -> (IptrStorage, IndStorage, DataStorage)

Destruct the matrix object and recycle its storage containers.

Example
use sprs::{CsMat};
let (indptr, indices, data) = CsMat::<i32>::eye(3).into_raw_storage();
assert_eq!(indptr, vec![0, 1, 2, 3]);
assert_eq!(indices, vec![0, 1, 2]);
assert_eq!(data, vec![1, 1, 1]);
source

pub fn is_csc(&self) -> bool

Test whether the matrix is in CSC storage

source

pub fn is_csr(&self) -> bool

Test whether the matrix is in CSR storage

source

pub fn transpose_mut(&mut self)

Transpose a matrix in place No allocation required (this is simply a storage order change)

source

pub fn transpose_into(self) -> Self

Transpose a matrix in place No allocation required (this is simply a storage order change)

source

pub fn transpose_view(&self) -> CsMatViewI<'_, N, I, Iptr>

Transposed view of this matrix No allocation required (this is simply a storage order change)

source

pub fn to_owned(&self) -> CsMatI<N, I, Iptr>where N: Clone,

Get an owned version of this matrix. If the matrix was already owned, this will make a deep copy.

source

pub fn to_inner_onehot(&self) -> CsMatI<N, I, Iptr>where N: Clone + Float + PartialOrd,

Generate a one-hot matrix, compressing the inner dimension.

Returns a matrix with the same size, the same CSR/CSC type, and a single value of 1.0 within each populated inner vector.

See into_csc and into_csr if you need to prepare a matrix for one-hot compression.

source

pub fn to_other_types<I2, N2, Iptr2>(&self) -> CsMatI<N2, I2, Iptr2>where N: Clone + Into<N2>, I2: SpIndex, Iptr2: SpIndex,

Clone the matrix with another integer type for indptr and indices

Panics

If the indices or indptr values cannot be represented by the requested integer type.

source

pub fn view(&self) -> CsMatViewI<'_, N, I, Iptr>

Return a view into the current matrix

source

pub fn structure_view(&self) -> CsStructureViewI<'_, I, Iptr>

source

pub fn to_dense(&self) -> Array<N, Ix2>where N: Clone + Zero,

source

pub fn outer_iterator( &self ) -> impl DoubleEndedIterator<Item = CsVecViewI<'_, N, I>> + ExactSizeIterator<Item = CsVecViewI<'_, N, I>> + '_

Return an outer iterator for the matrix

This can be used for iterating over the rows (resp. cols) of a CSR (resp. CSC) matrix.

use sprs::{CsMat};
let eye = CsMat::eye(5);
for (row_ind, row_vec) in eye.outer_iterator().enumerate() {
    let (col_ind, &val): (_, &f64) = row_vec.iter().next().unwrap();
    assert_eq!(row_ind, col_ind);
    assert_eq!(val, 1.);
}
source

pub fn max_outer_nnz(&self) -> usize

Get the max number of nnz for each outer dim

source

pub fn degrees(&self) -> Vec<usize>

Get the degrees of each vertex on a symmetric matrix

The nonzero pattern of a symmetric matrix can be interpreted as an undirected graph. In such a graph, a vertex i is connected to another vertex j if there is a corresponding nonzero entry in the matrix at location (i, j).

This function returns a vector containing the degree of each vertex, that is to say the number of neighbor of each vertex. We do not count diagonal entries as a neighbor.

source

pub fn outer_view(&self, i: usize) -> Option<CsVecViewI<'_, N, I>>

Get a view into the i-th outer dimension (eg i-th row for a CSR matrix)

source

pub fn diag(&self) -> CsVecI<N, I>where N: Clone,

Get the diagonal of a sparse matrix

source

pub fn diag_iter( &self ) -> impl ExactSizeIterator<Item = Option<&N>> + DoubleEndedIterator<Item = Option<&N>>

Iteration over all entries on the diagonal

source

pub fn outer_block_iter( &self, block_size: usize ) -> impl DoubleEndedIterator<Item = CsMatViewI<'_, N, I, Iptr>> + ExactSizeIterator<Item = CsMatViewI<'_, N, I, Iptr>> + '_

Iteration on outer blocks of size block_size

Panics

If the block size is 0.

source

pub fn map<F, N2>(&self, f: F) -> CsMatI<N2, I, Iptr>where F: FnMut(&N) -> N2,

Return a new sparse matrix with the same sparsity pattern, with all non-zero values mapped by the function f.

source

pub fn get_outer_inner(&self, outer_ind: usize, inner_ind: usize) -> Option<&N>

Access an element given its outer_ind and inner_ind. Will return None if there is no non-zero element at this location.

This access is logarithmic in the number of non-zeros in the corresponding outer slice. It is therefore advisable not to rely on this for algorithms, and prefer outer_iterator which accesses elements in storage order.

source

pub fn nnz_index(&self, row: usize, col: usize) -> Option<NnzIndex>

Find the non-zero index of the element specified by row and col

Searching this index is logarithmic in the number of non-zeros in the corresponding outer slice. Once it is available, the NnzIndex enables retrieving the data with O(1) complexity.

source

pub fn nnz_index_outer_inner( &self, outer_ind: usize, inner_ind: usize ) -> Option<NnzIndex>

Find the non-zero index of the element specified by outer_ind and inner_ind.

Searching this index is logarithmic in the number of non-zeros in the corresponding outer slice.

source

pub fn check_compressed_structure(&self) -> Result<(), StructureError>

Check the structure of CsMat components This will ensure that:

  • indptr is of length outer_dim() + 1
  • indices and data have the same length, nnz == indptr[outer_dims()]
  • indptr is sorted
  • indptr values do not exceed usize::MAX/ 2, as that would mean indices and indptr would take more space than the addressable memory
  • indices is sorted for each outer slice
  • indices are lower than inner_dims()
source

pub fn iter(&self) -> CsIter<'_, N, I, Iptr>

Get an iterator that yields the non-zero locations and values stored in this matrix, in the fastest iteration order.

source§

impl<N, I, Iptr, IptrStorage, IndStorage, DataStorage> CsMatBase<N, I, IptrStorage, IndStorage, DataStorage, Iptr>where N: Default, I: SpIndex, Iptr: SpIndex, IptrStorage: Deref<Target = [Iptr]>, IndStorage: Deref<Target = [I]>, DataStorage: Deref<Target = [N]>,

source

pub fn to_other_storage(&self) -> CsMatI<N, I, Iptr>where N: Clone,

Create a matrix mathematically equal to this one, but with the opposed storage (a CSC matrix will be converted to CSR, and vice versa)

source

pub fn to_csc(&self) -> CsMatI<N, I, Iptr>where N: Clone,

Create a new CSC matrix equivalent to this one. A new matrix will be created even if this matrix was already CSC.

source

pub fn to_csr(&self) -> CsMatI<N, I, Iptr>where N: Clone,

Create a new CSR matrix equivalent to this one. A new matrix will be created even if this matrix was already CSR.

source§

impl<N, I, Iptr> CsMatBase<N, I, Vec<Iptr, Global>, Vec<I, Global>, Vec<N, Global>, Iptr>where N: Default, I: SpIndex, Iptr: SpIndex,

source

pub fn into_csc(self) -> Selfwhere N: Clone,

Create a new CSC matrix equivalent to this one. If this matrix is CSR, it is converted to CSC If this matrix is CSC, it is returned by value

source

pub fn into_csr(self) -> Selfwhere N: Clone,

Create a new CSR matrix equivalent to this one. If this matrix is CSC, it is converted to CSR If this matrix is CSR, it is returned by value

source§

impl<N, I, Iptr, IptrStorage, IndStorage, DataStorage> CsMatBase<N, I, IptrStorage, IndStorage, DataStorage, Iptr>where I: SpIndex, Iptr: SpIndex, IptrStorage: Deref<Target = [Iptr]>, IndStorage: Deref<Target = [I]>, DataStorage: DerefMut<Target = [N]>,

source

pub fn data_mut(&mut self) -> &mut [N]

Mutable access to the non zero values

This enables changing the values without changing the matrix’s structure. To also change the matrix’s structure, see modify

source

pub fn scale(&mut self, val: N)where for<'r> N: MulAssign<&'r N>,

Sparse matrix self-multiplication by a scalar

source

pub fn outer_view_mut(&mut self, i: usize) -> Option<CsVecViewMutI<'_, N, I>>

Get a mutable view into the i-th outer dimension (eg i-th row for a CSR matrix)

source

pub fn get_mut(&mut self, i: usize, j: usize) -> Option<&mut N>

Get a mutable reference to the element located at row i and column j. Will return None if there is no non-zero element at this location.

This access is logarithmic in the number of non-zeros in the corresponding outer slice. It is therefore advisable not to rely on this for algorithms, and prefer outer_iterator_mut which accesses elements in storage order. TODO: outer_iterator_mut is not yet implemented

source

pub fn get_outer_inner_mut( &mut self, outer_ind: usize, inner_ind: usize ) -> Option<&mut N>

Get a mutable reference to an element given its outer_ind and inner_ind. Will return None if there is no non-zero element at this location.

This access is logarithmic in the number of non-zeros in the corresponding outer slice. It is therefore advisable not to rely on this for algorithms, and prefer outer_iterator_mut which accesses elements in storage order.

source

pub fn set(&mut self, row: usize, col: usize, val: N)

Set the value of the non-zero element located at (row, col)

Panics
  • on out-of-bounds access
  • if no non-zero element exists at the given location
source

pub fn map_inplace<F>(&mut self, f: F)where F: FnMut(&N) -> N,

Apply a function to every non-zero element

source

pub fn outer_iterator_mut( &mut self ) -> impl DoubleEndedIterator<Item = CsVecViewMutI<'_, N, I>> + ExactSizeIterator<Item = CsVecViewMutI<'_, N, I>> + '_

Return a mutable outer iterator for the matrix

This iterator yields mutable sparse vector views for each outer dimension. Only the non-zero values can be modified, the structure is kept immutable.

source

pub fn view_mut(&mut self) -> CsMatViewMutI<'_, N, I, Iptr>

Return a mutable view into the current matrix

source

pub fn diag_iter_mut( &mut self ) -> impl ExactSizeIterator<Item = Option<&mut N>> + DoubleEndedIterator<Item = Option<&mut N>> + '_

Iteration over all entries on the diagonal

source§

impl<N, I, Iptr, IptrStorage, IndStorage, DataStorage> CsMatBase<N, I, IptrStorage, IndStorage, DataStorage, Iptr>where I: SpIndex, Iptr: SpIndex, IptrStorage: DerefMut<Target = [Iptr]>, IndStorage: DerefMut<Target = [I]>, DataStorage: DerefMut<Target = [N]>,

source

pub fn modify<F>(&mut self, f: F)where F: FnMut(&mut [Iptr], &mut [I], &mut [N]),

Modify the matrix’s structure without changing its nonzero count.

The coherence of the structure will be checked afterwards.

Panics

If the resulting matrix breaks the CsMat invariants (sorted indices, no out of bounds indices).

Example
use sprs::CsMat;
// |   1   |
// | 1     |
// |   1 1 |
let mut mat = CsMat::new_csc((3, 3),
                                  vec![0, 1, 3, 4],
                                  vec![1, 0, 2, 2],
                                  vec![1.; 4]);

// | 1 2   |
// | 1     |
// |   1   |
mat.modify(|indptr, indices, data| {
    indptr[1] = 2;
    indptr[2] = 4;
    indices[0] = 0;
    indices[1] = 1;
    indices[2] = 0;
    data[2] = 2.;
});
source§

impl<N, I: SpIndex, Iptr: SpIndex, IptrStorage, IStorage, DStorage> CsMatBase<N, I, IptrStorage, IStorage, DStorage, Iptr>where IptrStorage: Deref<Target = [Iptr]>, IStorage: Deref<Target = [I]>, DStorage: Deref<Target = [N]>,

source

pub fn slice_outer<S: Range>(&self, range: S) -> CsMatViewI<'_, N, I, Iptr>

Slice the outer dimension of the matrix according to the specified range.

source§

impl<N, I: SpIndex, Iptr: SpIndex, IptrStorage, IStorage, DStorage> CsMatBase<N, I, IptrStorage, IStorage, DStorage, Iptr>where IptrStorage: Deref<Target = [Iptr]>, IStorage: Deref<Target = [I]>, DStorage: DerefMut<Target = [N]>,

source

pub fn slice_outer_mut<S: Range>( &mut self, range: S ) -> CsMatViewMutI<'_, N, I, Iptr>

Slice the outer dimension of the matrix according to the specified range.

source§

impl<'a, N, I, Iptr> CsMatBase<N, I, &'a [Iptr], &'a [I], &'a [N], Iptr>where I: SpIndex, Iptr: SpIndex,

source

pub fn slice_outer_rbr<S>(&self, range: S) -> CsMatViewI<'a, N, I, Iptr>where S: Range,

Slice the outer dimension of the matrix according to the specified range.

Trait Implementations§

source§

impl<N, I, Iptr, IS1, DS1, ISptr1, IS2, ISptr2, DS2> AbsDiffEq<CsMatBase<N, I, ISptr2, IS2, DS2, Iptr>> for CsMatBase<N, I, ISptr1, IS1, DS1, Iptr>where I: SpIndex, Iptr: SpIndex, CsMatBase<N, I, ISptr1, IS1, DS1, Iptr>: PartialEq<CsMatBase<N, I, ISptr2, IS2, DS2, Iptr>>, IS1: Deref<Target = [I]>, IS2: Deref<Target = [I]>, ISptr1: Deref<Target = [Iptr]>, ISptr2: Deref<Target = [Iptr]>, DS1: Deref<Target = [N]>, DS2: Deref<Target = [N]>, N: AbsDiffEq + Zero, N::Epsilon: Clone,

§

type Epsilon = <N as AbsDiffEq<N>>::Epsilon

Used for specifying relative comparisons.
source§

fn default_epsilon() -> N::Epsilon

The default tolerance to use when testing values that are close together. Read more
source§

fn abs_diff_eq( &self, other: &CsMatBase<N, I, ISptr2, IS2, DS2, Iptr>, epsilon: N::Epsilon ) -> bool

A test for equality that uses the absolute difference to compute the approximate equality of two numbers.
source§

fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool

The inverse of AbsDiffEq::abs_diff_eq.
source§

impl<'a, 'b, N, I, Iptr, IpS, IS, DS, DS2> Add<&'b ArrayBase<DS2, Dim<[usize; 2]>>> for &'a CsMatBase<N, I, IpS, IS, DS, Iptr>where N: 'a + Copy + Num + Default, for<'r> &'r N: Mul<Output = N>, I: 'a + SpIndex, Iptr: 'a + SpIndex, IpS: 'a + Deref<Target = [Iptr]>, IS: 'a + Deref<Target = [I]>, DS: 'a + Deref<Target = [N]>, DS2: 'b + Data<Elem = N>,

§

type Output = ArrayBase<OwnedRepr<N>, Dim<[usize; 2]>>

The resulting type after applying the + operator.
source§

fn add(self, rhs: &'b ArrayBase<DS2, Ix2>) -> Array<N, Ix2>

Performs the + operation. Read more
source§

impl<'a, 'b, Lhs, Rhs, Res, I, Iptr, IpStorage, IStorage, DStorage, IpS2, IS2, DS2> Add<&'b CsMatBase<Rhs, I, IpS2, IS2, DS2, Iptr>> for &'a CsMatBase<Lhs, I, IpStorage, IStorage, DStorage, Iptr>where Lhs: Zero, Rhs: Zero + Clone + Default, Res: Zero + Clone, for<'r> &'r Lhs: Add<&'r Rhs, Output = Res>, I: 'a + SpIndex, Iptr: 'a + SpIndex, IpStorage: 'a + Deref<Target = [Iptr]>, IStorage: 'a + Deref<Target = [I]>, DStorage: 'a + Deref<Target = [Lhs]>, IpS2: 'b + Deref<Target = [Iptr]>, IS2: 'b + Deref<Target = [I]>, DS2: 'b + Deref<Target = [Rhs]>,

§

type Output = CsMatBase<Res, I, Vec<Iptr, Global>, Vec<I, Global>, Vec<Res, Global>, Iptr>

The resulting type after applying the + operator.
source§

fn add(self, rhs: &'b CsMatBase<Rhs, I, IpS2, IS2, DS2, Iptr>) -> Self::Output

Performs the + operation. Read more
source§

impl<N: Clone, I, IptrStorage, IndStorage, DataStorage, Iptr> Clone for CsMatBase<N, I, IptrStorage, IndStorage, DataStorage, Iptr>where I: SpIndex + Clone, Iptr: SpIndex + Clone, IptrStorage: Deref<Target = [Iptr]> + Clone, IndStorage: Deref<Target = [I]> + Clone, DataStorage: Deref<Target = [N]> + Clone,

source§

fn clone(&self) -> CsMatBase<N, I, IptrStorage, IndStorage, DataStorage, Iptr>

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
source§

impl<N: Debug, I, IptrStorage, IndStorage, DataStorage, Iptr> Debug for CsMatBase<N, I, IptrStorage, IndStorage, DataStorage, Iptr>where I: SpIndex + Debug, Iptr: SpIndex + Debug, IptrStorage: Deref<Target = [Iptr]> + Debug, IndStorage: Deref<Target = [I]> + Debug, DataStorage: Deref<Target = [N]> + Debug,

source§

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

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

impl<'de, N, I, IptrStorage, IndStorage, DataStorage, Iptr> Deserialize<'de> for CsMatBase<N, I, IptrStorage, IndStorage, DataStorage, Iptr>where I: SpIndex, Iptr: SpIndex + Deserialize<'de>, IptrStorage: Deref<Target = [Iptr]> + Deserialize<'de>, IndStorage: Deref<Target = [I]> + Deserialize<'de>, DataStorage: Deref<Target = [N]> + Deserialize<'de>,

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<'a, I, Iptr, IpStorage, IStorage, DStorage, T> DivAssign<T> for CsMatBase<T, I, IpStorage, IStorage, DStorage, Iptr>where I: 'a + SpIndex, Iptr: 'a + SpIndex, IpStorage: 'a + Deref<Target = [Iptr]>, IStorage: 'a + Deref<Target = [I]>, DStorage: 'a + DerefMut<Target = [T]>, T: DivAssign<T> + Clone,

source§

fn div_assign(&mut self, rhs: T)

Performs the /= operation. Read more
source§

impl<'a, 'b, N, I, Iptr, IpS, IS, DS, DS2> Dot<ArrayBase<DS2, Dim<[usize; 1]>>> for CsMatBase<N, I, IpS, IS, DS, Iptr>where N: 'a + Clone + MulAcc + Zero, I: 'a + SpIndex, Iptr: 'a + SpIndex, IpS: 'a + Deref<Target = [Iptr]>, IS: 'a + Deref<Target = [I]>, DS: 'a + Deref<Target = [N]>, DS2: 'b + Data<Elem = N>,

§

type Output = ArrayBase<OwnedRepr<N>, Dim<[usize; 1]>>

The result of the operation. Read more
source§

fn dot(&self, rhs: &ArrayBase<DS2, Ix1>) -> Array<N, Ix1>

source§

impl<'a, 'b, N, I, Iptr, IpS, IS, DS, DS2> Dot<ArrayBase<DS2, Dim<[usize; 2]>>> for CsMatBase<N, I, IpS, IS, DS, Iptr>where N: 'a + Clone + MulAcc + Zero, I: 'a + SpIndex, Iptr: 'a + SpIndex, IpS: 'a + Deref<Target = [Iptr]>, IS: 'a + Deref<Target = [I]>, DS: 'a + Deref<Target = [N]>, DS2: 'b + Data<Elem = N>,

§

type Output = ArrayBase<OwnedRepr<N>, Dim<[usize; 2]>>

The result of the operation. Read more
source§

fn dot(&self, rhs: &ArrayBase<DS2, Ix2>) -> Array<N, Ix2>

source§

impl<'a, 'b, N, I, IpS, IS, DS, DS2> Dot<CsMatBase<N, I, IpS, IS, DS, I>> for ArrayBase<DS2, Ix2>where N: 'a + Clone + MulAcc + Zero + Debug, I: 'a + SpIndex, IpS: 'a + Deref<Target = [I]>, IS: 'a + Deref<Target = [I]>, DS: 'a + Deref<Target = [N]>, DS2: 'b + Data<Elem = N>,

§

type Output = ArrayBase<OwnedRepr<N>, Dim<[usize; 2]>>

The result of the operation. Read more
source§

fn dot(&self, rhs: &CsMatBase<N, I, IpS, IS, DS>) -> Array<N, Ix2>

source§

impl<N: Hash, I, IptrStorage, IndStorage, DataStorage, Iptr> Hash for CsMatBase<N, I, IptrStorage, IndStorage, DataStorage, Iptr>where I: SpIndex + Hash, Iptr: SpIndex + Hash, IptrStorage: Deref<Target = [Iptr]> + Hash, IndStorage: Deref<Target = [I]> + Hash, DataStorage: Deref<Target = [N]> + Hash,

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<N, I, Iptr, IpS, IS, DS> Index<[usize; 2]> for CsMatBase<N, I, IpS, IS, DS, Iptr>where I: SpIndex, Iptr: SpIndex, IpS: Deref<Target = [Iptr]>, IS: Deref<Target = [I]>, DS: Deref<Target = [N]>,

§

type Output = N

The returned type after indexing.
source§

fn index(&self, index: [usize; 2]) -> &N

Performs the indexing (container[index]) operation. Read more
source§

impl<N, I, Iptr, IpS, IS, DS> IndexMut<[usize; 2]> for CsMatBase<N, I, IpS, IS, DS, Iptr>where I: SpIndex, Iptr: SpIndex, IpS: Deref<Target = [Iptr]>, IS: Deref<Target = [I]>, DS: DerefMut<Target = [N]>,

source§

fn index_mut(&mut self, index: [usize; 2]) -> &mut N

Performs the mutable indexing (container[index]) operation. Read more
source§

impl<'a, N, I, IpS, IS, DS, Iptr> IntoIterator for &'a CsMatBase<N, I, IpS, IS, DS, Iptr>where I: 'a + SpIndex, Iptr: 'a + SpIndex, N: 'a, IpS: Deref<Target = [Iptr]>, IS: Deref<Target = [I]>, DS: Deref<Target = [N]>,

§

type Item = (&'a N, (I, I))

The type of the elements being iterated over.
§

type IntoIter = CsIter<'a, N, I, Iptr>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<'a, 'b, N, I, Iptr, IpS, IS, DS, DS2> Mul<&'b ArrayBase<DS2, Dim<[usize; 1]>>> for &'a CsMatBase<N, I, IpS, IS, DS, Iptr>where N: 'a + Clone + MulAcc + Zero, I: 'a + SpIndex, Iptr: 'a + SpIndex, IpS: 'a + Deref<Target = [Iptr]>, IS: 'a + Deref<Target = [I]>, DS: 'a + Deref<Target = [N]>, DS2: 'b + Data<Elem = N>,

§

type Output = ArrayBase<OwnedRepr<N>, Dim<[usize; 1]>>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &'b ArrayBase<DS2, Ix1>) -> Array<N, Ix1>

Performs the * operation. Read more
source§

impl<'a, 'b, N, I, Iptr, IpS, IS, DS, DS2> Mul<&'b ArrayBase<DS2, Dim<[usize; 2]>>> for &'a CsMatBase<N, I, IpS, IS, DS, Iptr>where N: 'a + MulAcc + Zero + Clone, I: 'a + SpIndex, Iptr: 'a + SpIndex, IpS: 'a + Deref<Target = [Iptr]>, IS: 'a + Deref<Target = [I]>, DS: 'a + Deref<Target = [N]>, DS2: 'b + Data<Elem = N>,

§

type Output = ArrayBase<OwnedRepr<N>, Dim<[usize; 2]>>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &'b ArrayBase<DS2, Ix2>) -> Array<N, Ix2>

Performs the * operation. Read more
source§

impl<'a, 'b, N, I, Iptr, IpS1, IS1, DS1, IpS2, IS2, DS2> Mul<&'b CsMatBase<N, I, IpS2, IS2, DS2, Iptr>> for &'a CsMatBase<N, I, IpS1, IS1, DS1, Iptr>where N: 'a + Clone + MulAcc + Zero + Default + Send + Sync, I: 'a + SpIndex, Iptr: 'a + SpIndex, IpS1: 'a + Deref<Target = [Iptr]>, IS1: 'a + Deref<Target = [I]>, DS1: 'a + Deref<Target = [N]>, IpS2: 'b + Deref<Target = [Iptr]>, IS2: 'b + Deref<Target = [I]>, DS2: 'b + Deref<Target = [N]>,

§

type Output = CsMatBase<N, I, Vec<Iptr, Global>, Vec<I, Global>, Vec<N, Global>, Iptr>

The resulting type after applying the * operator.
source§

fn mul( self, rhs: &'b CsMatBase<N, I, IpS2, IS2, DS2, Iptr> ) -> CsMatI<N, I, Iptr>

Performs the * operation. Read more
source§

impl<'a, 'b, N, I, Iptr, IS1, DS1, IpS2, IS2, DS2> Mul<&'b CsMatBase<N, I, IpS2, IS2, DS2, Iptr>> for &'a CsVecBase<IS1, DS1, N, I>where N: 'a + Clone + MulAcc + Zero + Default + Send + Sync, I: 'a + SpIndex, Iptr: 'a + SpIndex, IS1: 'a + Deref<Target = [I]>, DS1: 'a + Deref<Target = [N]>, IpS2: 'b + Deref<Target = [Iptr]>, IS2: 'b + Deref<Target = [I]>, DS2: 'b + Deref<Target = [N]>,

§

type Output = CsVecBase<Vec<I, Global>, Vec<N, Global>, N, I>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &CsMatBase<N, I, IpS2, IS2, DS2, Iptr>) -> Self::Output

Performs the * operation. Read more
source§

impl<'a, 'b, N, I, Iptr, IpS1, IS1, DS1, IS2, DS2> Mul<&'b CsVecBase<IS2, DS2, N, I>> for &'a CsMatBase<N, I, IpS1, IS1, DS1, Iptr>where N: Clone + MulAcc + Zero + PartialEq + Default + Send + Sync, I: SpIndex, Iptr: SpIndex, IpS1: Deref<Target = [Iptr]>, IS1: Deref<Target = [I]>, DS1: Deref<Target = [N]>, IS2: Deref<Target = [I]>, DS2: Deref<Target = [N]>,

§

type Output = CsVecBase<Vec<I, Global>, Vec<N, Global>, N, I>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &CsVecBase<IS2, DS2, N, I>) -> Self::Output

Performs the * operation. Read more
source§

impl<'a, I, Iptr, IpStorage, IStorage, DStorage> Mul<f32> for &'a CsMatBase<f32, I, IpStorage, IStorage, DStorage, Iptr>where I: 'a + SpIndex, Iptr: 'a + SpIndex, IpStorage: 'a + Deref<Target = [Iptr]>, IStorage: 'a + Deref<Target = [I]>, DStorage: 'a + Deref<Target = [f32]>,

§

type Output = CsMatBase<f32, I, Vec<Iptr, Global>, Vec<I, Global>, Vec<f32, Global>, Iptr>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: f32) -> Self::Output

Performs the * operation. Read more
source§

impl<'a, I, Iptr, IpStorage, IStorage, DStorage> Mul<f64> for &'a CsMatBase<f64, I, IpStorage, IStorage, DStorage, Iptr>where I: 'a + SpIndex, Iptr: 'a + SpIndex, IpStorage: 'a + Deref<Target = [Iptr]>, IStorage: 'a + Deref<Target = [I]>, DStorage: 'a + Deref<Target = [f64]>,

§

type Output = CsMatBase<f64, I, Vec<Iptr, Global>, Vec<I, Global>, Vec<f64, Global>, Iptr>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: f64) -> Self::Output

Performs the * operation. Read more
source§

impl<'a, I, Iptr, IpStorage, IStorage, DStorage> Mul<i16> for &'a CsMatBase<i16, I, IpStorage, IStorage, DStorage, Iptr>where I: 'a + SpIndex, Iptr: 'a + SpIndex, IpStorage: 'a + Deref<Target = [Iptr]>, IStorage: 'a + Deref<Target = [I]>, DStorage: 'a + Deref<Target = [i16]>,

§

type Output = CsMatBase<i16, I, Vec<Iptr, Global>, Vec<I, Global>, Vec<i16, Global>, Iptr>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: i16) -> Self::Output

Performs the * operation. Read more
source§

impl<'a, I, Iptr, IpStorage, IStorage, DStorage> Mul<i32> for &'a CsMatBase<i32, I, IpStorage, IStorage, DStorage, Iptr>where I: 'a + SpIndex, Iptr: 'a + SpIndex, IpStorage: 'a + Deref<Target = [Iptr]>, IStorage: 'a + Deref<Target = [I]>, DStorage: 'a + Deref<Target = [i32]>,

§

type Output = CsMatBase<i32, I, Vec<Iptr, Global>, Vec<I, Global>, Vec<i32, Global>, Iptr>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: i32) -> Self::Output

Performs the * operation. Read more
source§

impl<'a, I, Iptr, IpStorage, IStorage, DStorage> Mul<i64> for &'a CsMatBase<i64, I, IpStorage, IStorage, DStorage, Iptr>where I: 'a + SpIndex, Iptr: 'a + SpIndex, IpStorage: 'a + Deref<Target = [Iptr]>, IStorage: 'a + Deref<Target = [I]>, DStorage: 'a + Deref<Target = [i64]>,

§

type Output = CsMatBase<i64, I, Vec<Iptr, Global>, Vec<I, Global>, Vec<i64, Global>, Iptr>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: i64) -> Self::Output

Performs the * operation. Read more
source§

impl<'a, I, Iptr, IpStorage, IStorage, DStorage> Mul<i8> for &'a CsMatBase<i8, I, IpStorage, IStorage, DStorage, Iptr>where I: 'a + SpIndex, Iptr: 'a + SpIndex, IpStorage: 'a + Deref<Target = [Iptr]>, IStorage: 'a + Deref<Target = [I]>, DStorage: 'a + Deref<Target = [i8]>,

§

type Output = CsMatBase<i8, I, Vec<Iptr, Global>, Vec<I, Global>, Vec<i8, Global>, Iptr>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: i8) -> Self::Output

Performs the * operation. Read more
source§

impl<'a, I, Iptr, IpStorage, IStorage, DStorage> Mul<isize> for &'a CsMatBase<isize, I, IpStorage, IStorage, DStorage, Iptr>where I: 'a + SpIndex, Iptr: 'a + SpIndex, IpStorage: 'a + Deref<Target = [Iptr]>, IStorage: 'a + Deref<Target = [I]>, DStorage: 'a + Deref<Target = [isize]>,

§

type Output = CsMatBase<isize, I, Vec<Iptr, Global>, Vec<I, Global>, Vec<isize, Global>, Iptr>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: isize) -> Self::Output

Performs the * operation. Read more
source§

impl<'a, I, Iptr, IpStorage, IStorage, DStorage> Mul<u16> for &'a CsMatBase<u16, I, IpStorage, IStorage, DStorage, Iptr>where I: 'a + SpIndex, Iptr: 'a + SpIndex, IpStorage: 'a + Deref<Target = [Iptr]>, IStorage: 'a + Deref<Target = [I]>, DStorage: 'a + Deref<Target = [u16]>,

§

type Output = CsMatBase<u16, I, Vec<Iptr, Global>, Vec<I, Global>, Vec<u16, Global>, Iptr>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: u16) -> Self::Output

Performs the * operation. Read more
source§

impl<'a, I, Iptr, IpStorage, IStorage, DStorage> Mul<u32> for &'a CsMatBase<u32, I, IpStorage, IStorage, DStorage, Iptr>where I: 'a + SpIndex, Iptr: 'a + SpIndex, IpStorage: 'a + Deref<Target = [Iptr]>, IStorage: 'a + Deref<Target = [I]>, DStorage: 'a + Deref<Target = [u32]>,

§

type Output = CsMatBase<u32, I, Vec<Iptr, Global>, Vec<I, Global>, Vec<u32, Global>, Iptr>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: u32) -> Self::Output

Performs the * operation. Read more
source§

impl<'a, I, Iptr, IpStorage, IStorage, DStorage> Mul<u64> for &'a CsMatBase<u64, I, IpStorage, IStorage, DStorage, Iptr>where I: 'a + SpIndex, Iptr: 'a + SpIndex, IpStorage: 'a + Deref<Target = [Iptr]>, IStorage: 'a + Deref<Target = [I]>, DStorage: 'a + Deref<Target = [u64]>,

§

type Output = CsMatBase<u64, I, Vec<Iptr, Global>, Vec<I, Global>, Vec<u64, Global>, Iptr>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: u64) -> Self::Output

Performs the * operation. Read more
source§

impl<'a, I, Iptr, IpStorage, IStorage, DStorage> Mul<u8> for &'a CsMatBase<u8, I, IpStorage, IStorage, DStorage, Iptr>where I: 'a + SpIndex, Iptr: 'a + SpIndex, IpStorage: 'a + Deref<Target = [Iptr]>, IStorage: 'a + Deref<Target = [I]>, DStorage: 'a + Deref<Target = [u8]>,

§

type Output = CsMatBase<u8, I, Vec<Iptr, Global>, Vec<I, Global>, Vec<u8, Global>, Iptr>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: u8) -> Self::Output

Performs the * operation. Read more
source§

impl<'a, I, Iptr, IpStorage, IStorage, DStorage> Mul<usize> for &'a CsMatBase<usize, I, IpStorage, IStorage, DStorage, Iptr>where I: 'a + SpIndex, Iptr: 'a + SpIndex, IpStorage: 'a + Deref<Target = [Iptr]>, IStorage: 'a + Deref<Target = [I]>, DStorage: 'a + Deref<Target = [usize]>,

§

type Output = CsMatBase<usize, I, Vec<Iptr, Global>, Vec<I, Global>, Vec<usize, Global>, Iptr>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: usize) -> Self::Output

Performs the * operation. Read more
source§

impl<'a, I, Iptr, IpStorage, IStorage, DStorage, T> MulAssign<T> for CsMatBase<T, I, IpStorage, IStorage, DStorage, Iptr>where I: 'a + SpIndex, Iptr: 'a + SpIndex, IpStorage: 'a + Deref<Target = [Iptr]>, IStorage: 'a + Deref<Target = [I]>, DStorage: 'a + DerefMut<Target = [T]>, T: MulAssign<T> + Clone,

source§

fn mul_assign(&mut self, rhs: T)

Performs the *= operation. Read more
source§

impl<N: PartialEq, I, IptrStorage, IndStorage, DataStorage, Iptr> PartialEq<CsMatBase<N, I, IptrStorage, IndStorage, DataStorage, Iptr>> for CsMatBase<N, I, IptrStorage, IndStorage, DataStorage, Iptr>where I: SpIndex + PartialEq, Iptr: SpIndex + PartialEq, IptrStorage: Deref<Target = [Iptr]> + PartialEq, IndStorage: Deref<Target = [I]> + PartialEq, DataStorage: Deref<Target = [N]> + PartialEq,

source§

fn eq( &self, other: &CsMatBase<N, I, IptrStorage, IndStorage, DataStorage, Iptr> ) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<N, I, Iptr, IS1, DS1, ISptr1, IS2, ISptr2, DS2> RelativeEq<CsMatBase<N, I, ISptr2, IS2, DS2, Iptr>> for CsMatBase<N, I, ISptr1, IS1, DS1, Iptr>where I: SpIndex, Iptr: SpIndex, CsMatBase<N, I, ISptr1, IS1, DS1, Iptr>: PartialEq<CsMatBase<N, I, ISptr2, IS2, DS2, Iptr>>, IS1: Deref<Target = [I]>, IS2: Deref<Target = [I]>, ISptr1: Deref<Target = [Iptr]>, ISptr2: Deref<Target = [Iptr]>, DS1: Deref<Target = [N]>, DS2: Deref<Target = [N]>, N: RelativeEq + Zero, N::Epsilon: Clone,

source§

fn default_max_relative() -> N::Epsilon

The default relative tolerance for testing values that are far-apart. Read more
source§

fn relative_eq( &self, other: &CsMatBase<N, I, ISptr2, IS2, DS2, Iptr>, epsilon: N::Epsilon, max_relative: Self::Epsilon ) -> bool

A test for equality that uses a relative comparison if the values are far apart.
source§

fn relative_ne( &self, other: &Rhs, epsilon: Self::Epsilon, max_relative: Self::Epsilon ) -> bool

The inverse of RelativeEq::relative_eq.
source§

impl<N, I, Iptr, IptrStorage, IStorage, DStorage> Serialize for CsMatBase<N, I, IptrStorage, IStorage, DStorage, Iptr>where Iptr: Serialize + SpIndex, I: Serialize + SpIndex, N: Serialize, IptrStorage: Deref<Target = [Iptr]>, IStorage: Deref<Target = [I]>, DStorage: Deref<Target = [N]>,

source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>where S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<'a, N, I, Iptr, IpS, IS, DS> SparseMat for &'a CsMatBase<N, I, IpS, IS, DS, Iptr>where I: 'a + SpIndex, Iptr: 'a + SpIndex, N: 'a, IpS: Deref<Target = [Iptr]>, IS: Deref<Target = [I]>, DS: Deref<Target = [N]>,

source§

fn rows(&self) -> usize

The number of rows of this matrix
source§

fn cols(&self) -> usize

The number of columns of this matrix
source§

fn nnz(&self) -> usize

The number of nonzeros of this matrix
source§

impl<N, I, Iptr, IpS, IS, DS> SparseMat for CsMatBase<N, I, IpS, IS, DS, Iptr>where I: SpIndex, Iptr: SpIndex, IpS: Deref<Target = [Iptr]>, IS: Deref<Target = [I]>, DS: Deref<Target = [N]>,

source§

fn rows(&self) -> usize

The number of rows of this matrix
source§

fn cols(&self) -> usize

The number of columns of this matrix
source§

fn nnz(&self) -> usize

The number of nonzeros of this matrix
source§

impl<'a, 'b, Lhs, Rhs, Res, I, Iptr, IpStorage, IStorage, DStorage, IpS2, IS2, DS2> Sub<&'b CsMatBase<Rhs, I, IpS2, IS2, DS2, Iptr>> for &'a CsMatBase<Lhs, I, IpStorage, IStorage, DStorage, Iptr>where Lhs: Zero, Rhs: Zero + Clone + Default, Res: Zero + Clone, for<'r> &'r Lhs: Sub<&'r Rhs, Output = Res>, I: 'a + SpIndex, Iptr: 'a + SpIndex, IpStorage: 'a + Deref<Target = [Iptr]>, IStorage: 'a + Deref<Target = [I]>, DStorage: 'a + Deref<Target = [Lhs]>, IpS2: 'a + Deref<Target = [Iptr]>, IS2: 'a + Deref<Target = [I]>, DS2: 'a + Deref<Target = [Rhs]>,

§

type Output = CsMatBase<Res, I, Vec<Iptr, Global>, Vec<I, Global>, Vec<Res, Global>, Iptr>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: &'b CsMatBase<Rhs, I, IpS2, IS2, DS2, Iptr>) -> Self::Output

Performs the - operation. Read more
source§

impl<N, I, Iptr, IS1, DS1, ISptr1, IS2, ISptr2, DS2> UlpsEq<CsMatBase<N, I, ISptr2, IS2, DS2, Iptr>> for CsMatBase<N, I, ISptr1, IS1, DS1, Iptr>where I: SpIndex, Iptr: SpIndex, CsMatBase<N, I, ISptr1, IS1, DS1, Iptr>: PartialEq<CsMatBase<N, I, ISptr2, IS2, DS2, Iptr>>, IS1: Deref<Target = [I]>, IS2: Deref<Target = [I]>, ISptr1: Deref<Target = [Iptr]>, ISptr2: Deref<Target = [Iptr]>, DS1: Deref<Target = [N]>, DS2: Deref<Target = [N]>, N: UlpsEq + Zero, N::Epsilon: Clone,

source§

fn default_max_ulps() -> u32

The default ULPs to tolerate when testing values that are far-apart. Read more
source§

fn ulps_eq( &self, other: &CsMatBase<N, I, ISptr2, IS2, DS2, Iptr>, epsilon: N::Epsilon, max_ulps: u32 ) -> bool

A test for equality that uses units in the last place (ULP) if the values are far apart.
source§

fn ulps_ne(&self, other: &Rhs, epsilon: Self::Epsilon, max_ulps: u32) -> bool

The inverse of UlpsEq::ulps_eq.
source§

impl<N: Copy, I, IptrStorage, IndStorage, DataStorage, Iptr> Copy for CsMatBase<N, I, IptrStorage, IndStorage, DataStorage, Iptr>where I: SpIndex + Copy, Iptr: SpIndex + Copy, IptrStorage: Deref<Target = [Iptr]> + Copy, IndStorage: Deref<Target = [I]> + Copy, DataStorage: Deref<Target = [N]> + Copy,

source§

impl<N: Eq, I, IptrStorage, IndStorage, DataStorage, Iptr> Eq for CsMatBase<N, I, IptrStorage, IndStorage, DataStorage, Iptr>where I: SpIndex + Eq, Iptr: SpIndex + Eq, IptrStorage: Deref<Target = [Iptr]> + Eq, IndStorage: Deref<Target = [I]> + Eq, DataStorage: Deref<Target = [N]> + Eq,

source§

impl<N, I, IptrStorage, IndStorage, DataStorage, Iptr> StructuralEq for CsMatBase<N, I, IptrStorage, IndStorage, DataStorage, Iptr>where I: SpIndex, Iptr: SpIndex, IptrStorage: Deref<Target = [Iptr]>, IndStorage: Deref<Target = [I]>, DataStorage: Deref<Target = [N]>,

source§

impl<N, I, IptrStorage, IndStorage, DataStorage, Iptr> StructuralPartialEq for CsMatBase<N, I, IptrStorage, IndStorage, DataStorage, Iptr>where I: SpIndex, Iptr: SpIndex, IptrStorage: Deref<Target = [Iptr]>, IndStorage: Deref<Target = [I]>, DataStorage: Deref<Target = [N]>,

Auto Trait Implementations§

§

impl<N, I, IptrStorage, IndStorage, DataStorage, Iptr> RefUnwindSafe for CsMatBase<N, I, IptrStorage, IndStorage, DataStorage, Iptr>where DataStorage: RefUnwindSafe, IndStorage: RefUnwindSafe, IptrStorage: RefUnwindSafe,

§

impl<N, I, IptrStorage, IndStorage, DataStorage, Iptr> Send for CsMatBase<N, I, IptrStorage, IndStorage, DataStorage, Iptr>where DataStorage: Send, IndStorage: Send, IptrStorage: Send,

§

impl<N, I, IptrStorage, IndStorage, DataStorage, Iptr> Sync for CsMatBase<N, I, IptrStorage, IndStorage, DataStorage, Iptr>where DataStorage: Sync, IndStorage: Sync, IptrStorage: Sync,

§

impl<N, I, IptrStorage, IndStorage, DataStorage, Iptr> Unpin for CsMatBase<N, I, IptrStorage, IndStorage, DataStorage, Iptr>where DataStorage: Unpin, IndStorage: Unpin, IptrStorage: Unpin,

§

impl<N, I, IptrStorage, IndStorage, DataStorage, Iptr> UnwindSafe for CsMatBase<N, I, IptrStorage, IndStorage, DataStorage, Iptr>where DataStorage: UnwindSafe, IndStorage: UnwindSafe, IptrStorage: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

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<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,

source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
source§

unsafe fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
source§

impl<T> ToOwned for Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,