pub fn spdmatrix_function<F, Func>(
a: &ArrayView2<'_, F>,
f: Func,
check_spd: bool,
) -> LinalgResult<Array2<F>>
Expand description
Apply a general function to a symmetric positive definite matrix.
This function applies a scalar function f to a symmetric positive definite matrix A using eigendecomposition: f(A) = V * f(D) * V^T
§Arguments
a
- Input symmetric positive definite matrixf
- Function to apply (as a closure)check_spd
- Whether to check that the matrix is SPD
§Returns
- f(A) where f is applied element-wise to the eigenvalues
§Examples
use scirs2_core::ndarray::array;
use scirs2_linalg::matrix_functions::spdmatrix_function;
let a = array![[4.0_f64, 0.0], [0.0, 9.0]];
let sqrt_a = spdmatrix_function(&a.view(), |x| x.sqrt(), true).unwrap();