pub fn eigen_matrix_symmetric<F>(
n: usize,
matvec: F,
nev: usize,
which: EigenWhich,
) -> IgraphResult<EigenDecomposition>Expand description
Compute selected eigenpairs of a real symmetric matrix.
The matrix is defined implicitly: matvec(x, y) must compute
y = A * x where both slices have length n.
§Arguments
n— matrix dimensionmatvec— closure computing the matrix-vector producty = A xnev— number of eigenvalues to compute (clamped ton)which— which part of the spectrum to target
§Errors
Returns IgraphError::InvalidArgument if n == 0.
§Examples
use rust_igraph::{eigen_matrix_symmetric, EigenWhich};
// diag(5, 3, 1): top-2 eigenvalues are 5.0 and 3.0.
let result = eigen_matrix_symmetric(
3,
|x, y| { y[0] = 5.0*x[0]; y[1] = 3.0*x[1]; y[2] = x[2]; },
2,
EigenWhich::LargestAlgebraic,
).unwrap();
assert!((result.eigenvalues[0] - 5.0).abs() < 1e-6);
assert!((result.eigenvalues[1] - 3.0).abs() < 1e-6);