Struct sprs::TriMatBase[][src]

pub struct TriMatBase<IStorage, DStorage> { /* fields omitted */ }

Sparse matrix in the triplet format.

Sparse matrices in the triplet format use three arrays of equal sizes (accessible through the methods row_inds, col_inds, data), the first one storing the row indices of non-zero values, the second storing the corresponding column indices and the last array storing the corresponding scalar value. If a non-zero location is repeated in the arrays, the non-zero value is taken as the sum of the corresponding scalar entries.

This format is useful for iteratively building a sparse matrix, since the various non-zero entries can be specified in any order, or even partially as is common in physics with partial derivatives equations.

This format cannot be used for arithmetic operations. Arithmetic operations are more efficient in the compressed format. A matrix in the triplet format can be converted to the compressed format using the methods to_csc and to_csr.

The TriMatBase type is parameterized by the storage type for the row and column indices, IStorage, and by the storage type for the non-zero values DStorage. Convenient aliases are availaible to specify frequent variant: TriMat refers to a triplet matrix owning the storage of its indices and and values, TriMatView refers to a triplet matrix with slices to store its indices and values, while TriMatViewMut refers to a a triplet matrix using mutable slices.

Additionaly, the type aliases TriMatI, TriMatViewI and TriMatViewMutI can be used to choose an index type different from the default usize.

Methods

impl<N, I: SpIndex> TriMatBase<Vec<I>, Vec<N>>
[src]

Create a new triplet matrix of shape (nb_rows, nb_cols)

Create a new triplet matrix of shape (nb_rows, nb_cols), and pre-allocate cap elements on the backing storage

Create a triplet matrix from its raw components. All arrays should have the same length.

Panics

  • if the arrays don't have the same length
  • if either the row or column indices are out of bounds.

Append a non-zero triplet to this matrix.

Reserve cap additional non-zeros

Reserve exactly cap non-zeros

impl<N, I: SpIndex, IStorage, DStorage> TriMatBase<IStorage, DStorage> where
    IStorage: Deref<Target = [I]>,
    DStorage: Deref<Target = [N]>, 
[src]

The number of rows of the matrix

The number of cols of the matrix

The shape of the matrix, as a (rows, cols) tuple

The number of non-zero entries

The non-zero row indices

The non-zero column indices

The non-zero values

Find all non-zero entries at the location given by row and col

Get a transposed view of this matrix

Important traits for TriMatIter<RI, CI, DI>

Get an iterator over non-zero elements stored by this matrix

Create a CSC matrix from this triplet matrix

Create a CSR matrix from this triplet matrix

impl<'a, N, I: SpIndex> TriMatBase<&'a [I], &'a [N]>
[src]

Important traits for TriMatIter<RI, CI, DI>

Get an iterator over non-zero elements stored by this matrix

Reborrowing version of triplet_iter().

impl<N, I: SpIndex, IStorage, DStorage> TriMatBase<IStorage, DStorage> where
    IStorage: DerefMut<Target = [I]>,
    DStorage: DerefMut<Target = [N]>, 
[src]

Replace a non-zero value at the given index. Indices can be obtained using find_locations.

Trait Implementations

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

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

impl<N, I, IS, DS> SparseMat for TriMatBase<IS, DS> where
    I: SpIndex,
    IS: Deref<Target = [I]>,
    DS: Deref<Target = [N]>, 
[src]

The number of rows of this matrix

The number of columns of this matrix

The number of nonzeros of this matrix

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

The number of rows of this matrix

The number of columns of this matrix

The number of nonzeros of this matrix

impl<IStorage: PartialEq, DStorage: PartialEq> PartialEq for TriMatBase<IStorage, DStorage>
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl<IStorage: Debug, DStorage: Debug> Debug for TriMatBase<IStorage, DStorage>
[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl<IStorage, DStorage> Send for TriMatBase<IStorage, DStorage> where
    DStorage: Send,
    IStorage: Send

impl<IStorage, DStorage> Sync for TriMatBase<IStorage, DStorage> where
    DStorage: Sync,
    IStorage: Sync