Skip to main content

CscMatrix

Struct CscMatrix 

Source
pub struct CscMatrix<T> { /* private fields */ }
Expand description

A CSC representation of a sparse matrix.

The Compressed Sparse Column (CSC) format is well-suited as a general-purpose storage format for many sparse matrix applications.

§Usage

use nalgebra_sparse::coo::CooMatrix;
use nalgebra_sparse::csc::CscMatrix;
use nalgebra::{DMatrix, Matrix3x4};
use matrixcompare::assert_matrix_eq;

// The sparsity patterns of CSC matrices are immutable. This means that you cannot dynamically
// change the sparsity pattern of the matrix after it has been constructed. The easiest
// way to construct a CSC matrix is to first incrementally construct a COO matrix,
// and then convert it to CSC.

let mut coo = CooMatrix::<f64>::new(3, 3);
coo.push(2, 0, 1.0);
let csc = CscMatrix::from(&coo);

// Alternatively, a CSC matrix can be constructed directly from raw CSC data.
// Here, we construct a 3x4 matrix
let col_offsets = vec![0, 1, 3, 4, 5];
let row_indices = vec![0, 0, 2, 2, 0];
let values = vec![1.0, 2.0, 3.0, 4.0, 5.0];

// The dense representation of the CSC data, for comparison
let dense = Matrix3x4::new(1.0, 2.0, 0.0, 5.0,
                           0.0, 0.0, 0.0, 0.0,
                           0.0, 3.0, 4.0, 0.0);

// The constructor validates the raw CSC data and returns an error if it is invalid.
let csc = CscMatrix::try_from_csc_data(3, 4, col_offsets, row_indices, values)
    .expect("CSC data must conform to format specifications");
assert_matrix_eq!(csc, dense);

// A third approach is to construct a CSC matrix from a pattern and values. Sometimes this is
// useful if the sparsity pattern is constructed separately from the values of the matrix.
let (pattern, values) = csc.into_pattern_and_values();
let csc = CscMatrix::try_from_pattern_and_values(pattern, values)
    .expect("The pattern and values must be compatible");

// Once we have constructed our matrix, we can use it for arithmetic operations together with
// other CSC matrices and dense matrices/vectors.
let x = csc;
let xTx = x.transpose() * &x;
let z = DMatrix::from_fn(4, 8, |i, j| (i as f64) * (j as f64));
let w = 3.0 * xTx * z;

// Although the sparsity pattern of a CSC matrix cannot be changed, its values can.
// Here are two different ways to scale all values by a constant:
let mut x = x;
x *= 5.0;
x.values_mut().iter_mut().for_each(|x_i| *x_i *= 5.0);

§Format

An m x n sparse matrix with nnz non-zeros in CSC format is represented by the following three arrays:

  • col_offsets, an array of integers with length n + 1.
  • row_indices, an array of integers with length nnz.
  • values, an array of values with length nnz.

The relationship between the arrays is described below.

  • Each consecutive pair of entries col_offsets[j] .. col_offsets[j + 1] corresponds to an offset range in row_indices that holds the row indices in column j.
  • For an entry represented by the index idx, row_indices[idx] stores its column index and values[idx] stores its value.

The following invariants must be upheld and are enforced by the data structure:

  • col_offsets[0] == 0
  • col_offsets[m] == nnz
  • col_offsets is monotonically increasing.
  • 0 <= row_indices[idx] < m for all idx < nnz.
  • The row indices associated with each column are monotonically increasing (see below).

The CSC format is a standard sparse matrix format (see Wikipedia article). The format represents the matrix in a column-by-column fashion. The entries associated with column j are determined as follows:

let range = col_offsets[j] .. col_offsets[j + 1];
let col_j_rows = &row_indices[range.clone()];
let col_j_vals = &values[range];

// For each pair (i, v) in (col_j_rows, col_j_vals), we obtain a corresponding entry
// (i, j, v) in the matrix.
assert_eq!(col_j_rows.len(), col_j_vals.len());

In the above example, for each column j, the row indices col_j_cols must appear in monotonically increasing order. In other words, they must be sorted. This criterion is not standard among all sparse matrix libraries, but we enforce this property as it is a crucial assumption for both correctness and performance for many algorithms.

Note that the CSR and CSC formats are essentially identical, except that CSC stores the matrix column-by-column instead of row-by-row like CSR.

Implementations§

Source§

impl<T> CscMatrix<T>

Source

pub fn identity(n: usize) -> CscMatrix<T>
where T: Scalar + One,

Constructs a CSC representation of the (square) n x n identity matrix.

Source

pub fn zeros(nrows: usize, ncols: usize) -> CscMatrix<T>

Create a zero CSC matrix with no explicitly stored entries.

Source

pub fn try_from_csc_data( num_rows: usize, num_cols: usize, col_offsets: Vec<usize>, row_indices: Vec<usize>, values: Vec<T>, ) -> Result<CscMatrix<T>, SparseFormatError>

Try to construct a CSC matrix from raw CSC data.

It is assumed that each column contains unique and sorted row indices that are in bounds with respect to the number of rows in the matrix. If this is not the case, an error is returned to indicate the failure.

An error is returned if the data given does not conform to the CSC storage format. See the documentation for CscMatrix for more information.

Source

pub fn try_from_unsorted_csc_data( num_rows: usize, num_cols: usize, col_offsets: Vec<usize>, row_indices: Vec<usize>, values: Vec<T>, ) -> Result<CscMatrix<T>, SparseFormatError>
where T: Scalar,

Try to construct a CSC matrix from raw CSC data with unsorted row indices.

It is assumed that each column contains unique row indices that are in bounds with respect to the number of rows in the matrix. If this is not the case, an error is returned to indicate the failure.

An error is returned if the data given does not conform to the CSC storage format with the exception of having unsorted row indices and values. See the documentation for CscMatrix for more information.

Source

pub fn try_from_pattern_and_values( pattern: SparsityPattern, values: Vec<T>, ) -> Result<CscMatrix<T>, SparseFormatError>

Try to construct a CSC matrix from a sparsity pattern and associated non-zero values.

Returns an error if the number of values does not match the number of minor indices in the pattern.

Source

pub fn nrows(&self) -> usize

The number of rows in the matrix.

Source

pub fn ncols(&self) -> usize

The number of columns in the matrix.

Source

pub fn nnz(&self) -> usize

The number of non-zeros in the matrix.

Note that this corresponds to the number of explicitly stored entries, not the actual number of algebraically zero entries in the matrix. Explicitly stored entries can still be zero. Corresponds to the number of entries in the sparsity pattern.

Source

pub fn col_offsets(&self) -> &[usize]

The column offsets defining part of the CSC format.

Source

pub fn row_indices(&self) -> &[usize]

The row indices defining part of the CSC format.

Source

pub fn values(&self) -> &[T]

The non-zero values defining part of the CSC format.

Source

pub fn values_mut(&mut self) -> &mut [T]

Mutable access to the non-zero values.

Source

pub fn triplet_iter(&self) -> CscTripletIter<'_, T>

An iterator over non-zero triplets (i, j, v).

The iteration happens in column-major fashion, meaning that j increases monotonically, and i increases monotonically within each row.

§Examples
let col_offsets = vec![0, 2, 3, 4];
let row_indices = vec![0, 2, 1, 0];
let values = vec![1, 3, 2, 4];
let mut csc = CscMatrix::try_from_csc_data(4, 3, col_offsets, row_indices, values)
    .unwrap();

let triplets: Vec<_> = csc.triplet_iter().map(|(i, j, v)| (i, j, *v)).collect();
assert_eq!(triplets, vec![(0, 0, 1), (2, 0, 3), (1, 1, 2), (0, 2, 4)]);
Source

pub fn triplet_iter_mut(&mut self) -> CscTripletIterMut<'_, T>

A mutable iterator over non-zero triplets (i, j, v).

Iteration happens in the same order as for triplet_iter.

§Examples
let col_offsets = vec![0, 2, 3, 4];
let row_indices = vec![0, 2, 1, 0];
let values = vec![1, 3, 2, 4];
// Using the same data as in the `triplet_iter` example
let mut csc = CscMatrix::try_from_csc_data(4, 3, col_offsets, row_indices, values)
    .unwrap();

// Zero out lower-triangular terms
csc.triplet_iter_mut()
   .filter(|(i, j, _)| j < i)
   .for_each(|(_, _, v)| *v = 0);

let triplets: Vec<_> = csc.triplet_iter().map(|(i, j, v)| (i, j, *v)).collect();
assert_eq!(triplets, vec![(0, 0, 1), (2, 0, 0), (1, 1, 2), (0, 2, 4)]);
Source

pub fn col(&self, index: usize) -> CscCol<'_, T>

Return the column at the given column index.

§Panics

Panics if column index is out of bounds.

Source

pub fn col_mut(&mut self, index: usize) -> CscColMut<'_, T>

Mutable column access for the given column index.

§Panics

Panics if column index is out of bounds.

Source

pub fn get_col(&self, index: usize) -> Option<CscCol<'_, T>>

Return the column at the given column index, or None if out of bounds.

Source

pub fn get_col_mut(&mut self, index: usize) -> Option<CscColMut<'_, T>>

Mutable column access for the given column index, or None if out of bounds.

Source

pub fn col_iter(&self) -> CscColIter<'_, T>

An iterator over columns in the matrix.

Source

pub fn col_iter_mut(&mut self) -> CscColIterMut<'_, T>

A mutable iterator over columns in the matrix.

Source

pub fn disassemble(self) -> (Vec<usize>, Vec<usize>, Vec<T>)

Disassembles the CSC matrix into its underlying offset, index and value arrays.

If the matrix contains the sole reference to the sparsity pattern, then the data is returned as-is. Otherwise, the sparsity pattern is cloned.

§Examples
let col_offsets = vec![0, 2, 3, 4];
let row_indices = vec![0, 2, 1, 0];
let values = vec![1, 3, 2, 4];
let mut csc = CscMatrix::try_from_csc_data(
    4,
    3,
    col_offsets.clone(),
    row_indices.clone(),
    values.clone())
    .unwrap();
let (col_offsets2, row_indices2, values2) = csc.disassemble();
assert_eq!(col_offsets2, col_offsets);
assert_eq!(row_indices2, row_indices);
assert_eq!(values2, values);
Source

pub fn into_pattern_and_values(self) -> (SparsityPattern, Vec<T>)

Returns the sparsity pattern and values associated with this matrix.

Source

pub fn pattern_and_values_mut(&mut self) -> (&SparsityPattern, &mut [T])

Returns a reference to the sparsity pattern and a mutable reference to the values.

Source

pub fn pattern(&self) -> &SparsityPattern

Returns a reference to the underlying sparsity pattern.

Source

pub fn transpose_as_csr(self) -> CsrMatrix<T>

Reinterprets the CSC matrix as its transpose represented by a CSR matrix.

This operation does not touch the CSC data, and is effectively a no-op.

Source

pub fn get_entry( &self, row_index: usize, col_index: usize, ) -> Option<SparseEntry<'_, T>>

Returns an entry for the given row/col indices, or None if the indices are out of bounds.

Each call to this function incurs the cost of a binary search among the explicitly stored row entries for the given column.

Source

pub fn get_entry_mut( &mut self, row_index: usize, col_index: usize, ) -> Option<SparseEntryMut<'_, T>>

Returns a mutable entry for the given row/col indices, or None if the indices are out of bounds.

Each call to this function incurs the cost of a binary search among the explicitly stored row entries for the given column.

Source

pub fn index_entry( &self, row_index: usize, col_index: usize, ) -> SparseEntry<'_, T>

Returns an entry for the given row/col indices.

Same as get_entry, except that it directly panics upon encountering row/col indices out of bounds.

§Panics

Panics if row_index or col_index is out of bounds.

Source

pub fn index_entry_mut( &mut self, row_index: usize, col_index: usize, ) -> SparseEntryMut<'_, T>

Returns a mutable entry for the given row/col indices.

Same as get_entry_mut, except that it directly panics upon encountering row/col indices out of bounds.

§Panics

Panics if row_index or col_index is out of bounds.

Source

pub fn csc_data(&self) -> (&[usize], &[usize], &[T])

Returns a triplet of slices (col_offsets, row_indices, values) that make up the CSC data.

Source

pub fn csc_data_mut(&mut self) -> (&[usize], &[usize], &mut [T])

Returns a triplet of slices (col_offsets, row_indices, values) that make up the CSC data, where the values array is mutable.

Source

pub fn filter<P>(&self, predicate: P) -> CscMatrix<T>
where T: Clone, P: Fn(usize, usize, &T) -> bool,

Creates a sparse matrix that contains only the explicit entries decided by the given predicate.

Source

pub fn upper_triangle(&self) -> CscMatrix<T>
where T: Clone,

Returns a new matrix representing the upper triangular part of this matrix.

The result includes the diagonal of the matrix.

Source

pub fn lower_triangle(&self) -> CscMatrix<T>
where T: Clone,

Returns a new matrix representing the lower triangular part of this matrix.

The result includes the diagonal of the matrix.

Source

pub fn diagonal_as_csc(&self) -> CscMatrix<T>
where T: Clone,

Returns the diagonal of the matrix as a sparse matrix.

Source

pub fn transpose(&self) -> CscMatrix<T>
where T: Scalar,

Compute the transpose of the matrix.

Trait Implementations§

Source§

impl<'a, T> Add for &'a CscMatrix<T>

Source§

type Output = CscMatrix<T>

The resulting type after applying the + operator.
Source§

fn add(self, b: &'a CscMatrix<T>) -> <&'a CscMatrix<T> as Add>::Output

Performs the + operation. Read more
Source§

impl<T> Add for CscMatrix<T>

Source§

type Output = CscMatrix<T>

The resulting type after applying the + operator.
Source§

fn add(self, b: CscMatrix<T>) -> <CscMatrix<T> as Add>::Output

Performs the + operation. Read more
Source§

impl<'a, T> Add<&'a CscMatrix<T>> for CscMatrix<T>

Source§

type Output = CscMatrix<T>

The resulting type after applying the + operator.
Source§

fn add( self, b: &'a CscMatrix<T>, ) -> <CscMatrix<T> as Add<&'a CscMatrix<T>>>::Output

Performs the + operation. Read more
Source§

impl<'a, T> Add<CscMatrix<T>> for &'a CscMatrix<T>

Source§

type Output = CscMatrix<T>

The resulting type after applying the + operator.
Source§

fn add(self, b: CscMatrix<T>) -> <&'a CscMatrix<T> as Add<CscMatrix<T>>>::Output

Performs the + operation. Read more
Source§

impl<T> AdjustByDivisionOp<CscMatrix<T>, T> for CscMatrix<T>
where T: RealField + Copy + Sum,

Source§

fn adjust_by_division_inplace(&mut self, denom: &CscMatrix<T>)

adjust each column with the corresponding column of the denom Read more
Source§

fn adjust_by_division_of_selected_inplace( &mut self, denom_db: &CscMatrix<T>, batches: &[usize], )

Adjust each column with the column of the matching batch index Read more
Source§

impl<T> AdjustByDivisionOp<Matrix<T, Dyn, Dyn, VecStorage<T, Dyn, Dyn>>, T> for CscMatrix<T>
where T: RealField + Copy + Sum,

Source§

fn adjust_by_division_of_selected_inplace( &mut self, denom_db: &Matrix<T, Dyn, Dyn, VecStorage<T, Dyn, Dyn>>, batches: &[usize], )

Adjust each column with the column of the matching batch index Read more
Source§

fn adjust_by_division_inplace( &mut self, denom: &Matrix<T, Dyn, Dyn, VecStorage<T, Dyn, Dyn>>, )

adjust each column with the corresponding column of the denom Read more
Source§

impl<T> Clone for CscMatrix<T>
where T: Clone,

Source§

fn clone(&self) -> CscMatrix<T>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T> ConvertMatOps for CscMatrix<T>
where T: RealField + Copy + WithDType,

Source§

impl<T> Debug for CscMatrix<T>
where T: Debug,

Source§

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

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

impl<T> Default for CscMatrix<T>

Source§

fn default() -> CscMatrix<T>

Returns the “default value” for a type. Read more
Source§

impl<T> DistanceOps for CscMatrix<T>
where T: RealField + Copy + Sum,

Source§

type Scalar = T

Source§

type Other = CscMatrix<T>

Source§

fn euclidean_distance( &self, other: &<CscMatrix<T> as DistanceOps>::Other, ) -> Result<Vec<(usize, usize, <CscMatrix<T> as DistanceOps>::Scalar)>, Error>

A vector of Euclidean distances between sources and targets other Read more
Source§

fn euclidean_distance_on_select_columns( &self, other: &<CscMatrix<T> as DistanceOps>::Other, select_columns_in_other: &[usize], ) -> Result<Vec<(usize, usize, <CscMatrix<T> as DistanceOps>::Scalar)>, Error>

A vector of Euclidean distances between sources and targets other Read more
Source§

impl<'a, T> Div<&'a T> for &'a CscMatrix<T>

Source§

type Output = CscMatrix<T>

The resulting type after applying the / operator.
Source§

fn div(self, scalar: &'a T) -> <&'a CscMatrix<T> as Div<&'a T>>::Output

Performs the / operation. Read more
Source§

impl<'a, T> Div<&T> for CscMatrix<T>

Source§

type Output = CscMatrix<T>

The resulting type after applying the / operator.
Source§

fn div(self, scalar: &T) -> <CscMatrix<T> as Div<&T>>::Output

Performs the / operation. Read more
Source§

impl<T> Div<T> for CscMatrix<T>

Source§

type Output = CscMatrix<T>

The resulting type after applying the / operator.
Source§

fn div(self, scalar: T) -> <CscMatrix<T> as Div<T>>::Output

Performs the / operation. Read more
Source§

impl<'a, T> Div<T> for &'a CscMatrix<T>

Source§

type Output = CscMatrix<T>

The resulting type after applying the / operator.
Source§

fn div(self, scalar: T) -> <&'a CscMatrix<T> as Div<T>>::Output

Performs the / operation. Read more
Source§

impl<'a, T> DivAssign<&'a T> for CscMatrix<T>

Source§

fn div_assign(&mut self, scalar: &'a T)

Performs the /= operation. Read more
Source§

impl<T> DivAssign<T> for CscMatrix<T>

Source§

fn div_assign(&mut self, scalar: T)

Performs the /= operation. Read more
Source§

impl<T> Eq for CscMatrix<T>
where T: Eq,

Source§

impl<'a, T> From<&'a CooMatrix<T>> for CscMatrix<T>

Source§

fn from(matrix: &'a CooMatrix<T>) -> CscMatrix<T>

Converts to this type from the input type.
Source§

impl<'a, T> From<&'a CscMatrix<T>> for Matrix<T, Dyn, Dyn, VecStorage<T, Dyn, Dyn>>

Source§

fn from( matrix: &'a CscMatrix<T>, ) -> Matrix<T, Dyn, Dyn, VecStorage<T, Dyn, Dyn>>

Converts to this type from the input type.
Source§

impl<'a, T> From<&'a CscMatrix<T>> for CsrMatrix<T>
where T: Scalar,

Source§

fn from(matrix: &'a CscMatrix<T>) -> CsrMatrix<T>

Converts to this type from the input type.
Source§

impl<'a, T> From<&'a CsrMatrix<T>> for CscMatrix<T>
where T: Scalar,

Source§

fn from(matrix: &'a CsrMatrix<T>) -> CscMatrix<T>

Converts to this type from the input type.
Source§

impl<'a, T, R, C, S> From<&'a Matrix<T, R, C, S>> for CscMatrix<T>
where T: Scalar + Zero, R: Dim, C: Dim, S: RawStorage<T, R, C>,

Source§

fn from(matrix: &'a Matrix<T, R, C, S>) -> CscMatrix<T>

Converts to this type from the input type.
Source§

impl<T> MatElemOps for CscMatrix<T>
where T: RealField + Copy,

Source§

impl<T> MatOps for CscMatrix<T>
where T: RealField + Copy,

Source§

type Mat = CscMatrix<T>

Source§

type Scalar = T

Source§

fn normalize_exp_logits_columns_inplace(&mut self)

normalize logits after taking exp (log-sum-exp)
Source§

fn normalize_exp_logits_columns(&self) -> <CscMatrix<T> as MatOps>::Mat

normalize logits after taking exp (log-sum-exp)
Source§

fn log_softmax_columns_inplace(&mut self)

column-wise log-softmax: subtract each column’s log-sum-exp so the exp of each column sums to 1. Returns log-probabilities (unlike Self::normalize_exp_logits_columns, which returns probabilities).
Source§

fn log_softmax_columns(&self) -> <CscMatrix<T> as MatOps>::Mat

column-wise log-softmax (see Self::log_softmax_columns_inplace)
Source§

fn sum_to_one_columns_inplace(&mut self)

make each column sum to 1
Source§

fn sum_to_one_columns(&self) -> <CscMatrix<T> as MatOps>::Mat

make each column sum to 1
Source§

fn sum_to_one_rows(&self) -> <CscMatrix<T> as MatOps>::Mat

make each row sum to 1
Source§

fn sum_to_one_rows_inplace(&mut self)

make each row sum to 1
Source§

fn normalize_columns_inplace(&mut self)

vector norm for each column
Source§

fn normalize_columns(&self) -> <CscMatrix<T> as MatOps>::Mat

vector norm for each column
Source§

fn scale_columns_inplace(&mut self)

standardization for each column
Source§

fn scale_rows_inplace(&mut self)

standardization for each row
Source§

fn scale_columns(&self) -> <CscMatrix<T> as MatOps>::Mat

standardization for each column
Source§

fn scale_rows(&self) -> <CscMatrix<T> as MatOps>::Mat

standardization for each row
Source§

fn centre_columns_inplace(&mut self)

centering for each column
Source§

fn centre_columns(&self) -> <CscMatrix<T> as MatOps>::Mat

centering for each column
Source§

impl<T> MatTriplets for CscMatrix<T>
where T: RealField + Float,

Source§

impl<'a, T> Mul for &'a CscMatrix<T>

Source§

type Output = CscMatrix<T>

The resulting type after applying the * operator.
Source§

fn mul(self, b: &'a CscMatrix<T>) -> <&'a CscMatrix<T> as Mul>::Output

Performs the * operation. Read more
Source§

impl<T> Mul for CscMatrix<T>

Source§

type Output = CscMatrix<T>

The resulting type after applying the * operator.
Source§

fn mul(self, b: CscMatrix<T>) -> <CscMatrix<T> as Mul>::Output

Performs the * operation. Read more
Source§

impl<'a, T> Mul<&'a CscMatrix<T>> for CscMatrix<T>

Source§

type Output = CscMatrix<T>

The resulting type after applying the * operator.
Source§

fn mul( self, b: &'a CscMatrix<T>, ) -> <CscMatrix<T> as Mul<&'a CscMatrix<T>>>::Output

Performs the * operation. Read more
Source§

impl<'a, T, R, C, S> Mul<&'a Matrix<T, R, C, S>> for &'a CscMatrix<T>

Source§

type Output = Matrix<T, Dyn, C, <DefaultAllocator as Allocator<Dyn, C>>::Buffer<T>>

The resulting type after applying the * operator.
Source§

fn mul( self, rhs: &'a Matrix<T, R, C, S>, ) -> <&'a CscMatrix<T> as Mul<&'a Matrix<T, R, C, S>>>::Output

Performs the * operation. Read more
Source§

impl<'a, T, R, C, S> Mul<&'a Matrix<T, R, C, S>> for CscMatrix<T>

Source§

type Output = Matrix<T, Dyn, C, <DefaultAllocator as Allocator<Dyn, C>>::Buffer<T>>

The resulting type after applying the * operator.
Source§

fn mul( self, rhs: &'a Matrix<T, R, C, S>, ) -> <CscMatrix<T> as Mul<&'a Matrix<T, R, C, S>>>::Output

Performs the * operation. Read more
Source§

impl<'a, T> Mul<&'a T> for &'a CscMatrix<T>

Source§

type Output = CscMatrix<T>

The resulting type after applying the * operator.
Source§

fn mul(self, b: &'a T) -> <&'a CscMatrix<T> as Mul<&'a T>>::Output

Performs the * operation. Read more
Source§

impl<'a, T> Mul<&'a T> for CscMatrix<T>

Source§

type Output = CscMatrix<T>

The resulting type after applying the * operator.
Source§

fn mul(self, b: &'a T) -> <CscMatrix<T> as Mul<&'a T>>::Output

Performs the * operation. Read more
Source§

impl<'a, T> Mul<CscMatrix<T>> for &'a CscMatrix<T>

Source§

type Output = CscMatrix<T>

The resulting type after applying the * operator.
Source§

fn mul(self, b: CscMatrix<T>) -> <&'a CscMatrix<T> as Mul<CscMatrix<T>>>::Output

Performs the * operation. Read more
Source§

impl<'a, T, R, C, S> Mul<Matrix<T, R, C, S>> for &'a CscMatrix<T>

Source§

type Output = Matrix<T, Dyn, C, <DefaultAllocator as Allocator<Dyn, C>>::Buffer<T>>

The resulting type after applying the * operator.
Source§

fn mul( self, rhs: Matrix<T, R, C, S>, ) -> <&'a CscMatrix<T> as Mul<Matrix<T, R, C, S>>>::Output

Performs the * operation. Read more
Source§

impl<'a, T, R, C, S> Mul<Matrix<T, R, C, S>> for CscMatrix<T>

Source§

type Output = Matrix<T, Dyn, C, <DefaultAllocator as Allocator<Dyn, C>>::Buffer<T>>

The resulting type after applying the * operator.
Source§

fn mul( self, rhs: Matrix<T, R, C, S>, ) -> <CscMatrix<T> as Mul<Matrix<T, R, C, S>>>::Output

Performs the * operation. Read more
Source§

impl<'a, T> Mul<T> for &'a CscMatrix<T>

Source§

type Output = CscMatrix<T>

The resulting type after applying the * operator.
Source§

fn mul(self, b: T) -> <&'a CscMatrix<T> as Mul<T>>::Output

Performs the * operation. Read more
Source§

impl<T> Mul<T> for CscMatrix<T>

Source§

type Output = CscMatrix<T>

The resulting type after applying the * operator.
Source§

fn mul(self, b: T) -> <CscMatrix<T> as Mul<T>>::Output

Performs the * operation. Read more
Source§

impl<'a, T> MulAssign<&'a T> for CscMatrix<T>

Source§

fn mul_assign(&mut self, scalar: &'a T)

Performs the *= operation. Read more
Source§

impl<T> MulAssign<T> for CscMatrix<T>

Source§

fn mul_assign(&mut self, scalar: T)

Performs the *= operation. Read more
Source§

impl<T> Neg for CscMatrix<T>
where T: Scalar + Neg<Output = T>,

Source§

type Output = CscMatrix<T>

The resulting type after applying the - operator.
Source§

fn neg(self) -> <CscMatrix<T> as Neg>::Output

Performs the unary - operation. Read more
Source§

impl<'a, T> Neg for &'a CscMatrix<T>
where T: Scalar + Neg<Output = T>,

Source§

type Output = CscMatrix<T>

The resulting type after applying the - operator.
Source§

fn neg(self) -> <&'a CscMatrix<T> as Neg>::Output

Performs the unary - operation. Read more
Source§

impl<T> PartialEq for CscMatrix<T>
where T: PartialEq,

Source§

fn eq(&self, other: &CscMatrix<T>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl<T> RandomizedAlgs for CscMatrix<T>
where T: RealField + Float + Copy,

Source§

type InMat = CscMatrix<T>

Source§

type OutMat = Matrix<T, Dyn, Dyn, VecStorage<T, Dyn, Dyn>>

Source§

type DVec = Matrix<T, Dyn, Const<1>, VecStorage<T, Dyn, Const<1>>>

Source§

type Scalar = T

Source§

fn rsvd( &self, max_rank: usize, ) -> Result<(<CscMatrix<T> as RandomizedAlgs>::OutMat, <CscMatrix<T> as RandomizedAlgs>::DVec, <CscMatrix<T> as RandomizedAlgs>::OutMat), Error>

randomized singular value decomposition Read more
Source§

impl<T> StructuralPartialEq for CscMatrix<T>
where T: PartialEq,

Source§

impl<'a, T> Sub for &'a CscMatrix<T>

Source§

type Output = CscMatrix<T>

The resulting type after applying the - operator.
Source§

fn sub(self, b: &'a CscMatrix<T>) -> <&'a CscMatrix<T> as Sub>::Output

Performs the - operation. Read more
Source§

impl<T> Sub for CscMatrix<T>

Source§

type Output = CscMatrix<T>

The resulting type after applying the - operator.
Source§

fn sub(self, b: CscMatrix<T>) -> <CscMatrix<T> as Sub>::Output

Performs the - operation. Read more
Source§

impl<'a, T> Sub<&'a CscMatrix<T>> for CscMatrix<T>

Source§

type Output = CscMatrix<T>

The resulting type after applying the - operator.
Source§

fn sub( self, b: &'a CscMatrix<T>, ) -> <CscMatrix<T> as Sub<&'a CscMatrix<T>>>::Output

Performs the - operation. Read more
Source§

impl<'a, T> Sub<CscMatrix<T>> for &'a CscMatrix<T>

Source§

type Output = CscMatrix<T>

The resulting type after applying the - operator.
Source§

fn sub(self, b: CscMatrix<T>) -> <&'a CscMatrix<T> as Sub<CscMatrix<T>>>::Output

Performs the - operation. Read more

Auto Trait Implementations§

§

impl<T> Freeze for CscMatrix<T>
where CsMatrix<T>: Freeze,

§

impl<T> RefUnwindSafe for CscMatrix<T>
where CsMatrix<T>: RefUnwindSafe,

§

impl<T> Send for CscMatrix<T>
where CsMatrix<T>: Send,

§

impl<T> Sync for CscMatrix<T>
where CsMatrix<T>: Sync,

§

impl<T> Unpin for CscMatrix<T>
where CsMatrix<T>: Unpin,

§

impl<T> UnsafeUnpin for CscMatrix<T>
where CsMatrix<T>: UnsafeUnpin,

§

impl<T> UnwindSafe for CscMatrix<T>
where CsMatrix<T>: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T, Right> ClosedDiv<Right> for T
where T: Div<Right, Output = T> + DivAssign<Right>,

Source§

impl<T, Right> ClosedDivAssign<Right> for T
where T: ClosedDiv<Right> + DivAssign<Right>,

Source§

impl<T, Right> ClosedMul<Right> for T
where T: Mul<Right, Output = T> + MulAssign<Right>,

Source§

impl<T, Right> ClosedMulAssign<Right> for T
where T: ClosedMul<Right> + MulAssign<Right>,

Source§

impl<T> ClosedNeg for T
where T: Neg<Output = T>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,

Source§

impl<SS, SP> SupersetOf<SS> for SP
where 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§

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 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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more