pub fn sparse_matrix_polynomial(
row_offsets: &[usize],
col_indices: &[usize],
values: &[f64],
rows: usize,
cols: usize,
coefficients: &[f64],
) -> Result<MatrixPowerResult, SparseError>Expand description
Evaluate a polynomial p(A) = c0*I + c1*A + c2*A^2 + ... + ck*A^k using
Horner’s method.
Horner’s form: p(A) = ((...((ck*A + c_{k-1})*A + c_{k-2})*A + ...) + c1)*A + c0*I
This requires only k multiplications rather than computing each A^i
separately.
§Arguments
- CSR arrays and dimensions for
A(must be square). coefficients– Polynomial coefficients[c0, c1, ..., ck].
§Errors
Returns SparseError::DimensionMismatch if the matrix is not square,
or SparseError::InvalidArgument if coefficients is empty.