pub fn sparse_matrix_power(
row_offsets: &[usize],
col_indices: &[usize],
values: &[f64],
rows: usize,
cols: usize,
power: usize,
config: &MatrixPowerConfig,
) -> Result<MatrixPowerResult, SparseError>Expand description
Compute A^power for a sparse CSR matrix using binary exponentiation.
Binary exponentiation decomposes the exponent into powers of two so that
A^8 = ((A^2)^2)^2 requires only 3 multiplications instead of 7.
§Arguments
row_offsets– CSR row pointer array (lengthrows + 1).col_indices– CSR column indices (lengthnnz).values– CSR values (lengthnnz).rows,cols– Matrix dimensions (must be square for power > 1).power– The exponentk.config–MatrixPowerConfigcontrolling nnz limits and structure reuse.
§Errors
Returns SparseError::DimensionMismatch if the matrix is not square
(when power > 1), SparseError::InvalidFormat if CSR arrays are
inconsistent, or SparseError::InvalidArgument if nnz exceeds max_nnz.