Skip to main content

sparse_kron

Function sparse_kron 

Source
pub fn sparse_kron<T>(
    a: &CsrArray<T>,
    b: &CsrArray<T>,
) -> SparseResult<CsrArray<T>>
where T: Float + SparseElement + Div<Output = T> + Debug + Copy + 'static,
Expand description

Compute the Kronecker product of two sparse matrices.

If A is m x n and B is p x q, the result is (mp) x (nq).

§Arguments

  • a - First sparse matrix
  • b - Second sparse matrix

§Examples

use scirs2_sparse::sparse_functions::{sparse_eye, sparse_kron};
use scirs2_sparse::sparray::SparseArray;

let i2 = sparse_eye::<f64>(2).expect("eye");
let result = sparse_kron(&i2, &i2).expect("kron");
assert_eq!(result.shape(), (4, 4));
assert_eq!(result.nnz(), 4);