Skip to main content

eigen_symmetric_fn

Function eigen_symmetric_fn 

Source
pub fn eigen_symmetric_fn<F: FnMut(&[f64], &mut [f64])>(
    n: usize,
    matvec: F,
    which: &EigenWhich,
    algorithm: EigenAlgorithm,
    options: &ArpackOptions,
) -> Result<SymmetricEigen>
Expand description

Selected eigenvalues and eigenvectors of a real symmetric operator given by a matrix-vector product closure (igraph_eigen_matrix_symmetric with a callback), see arpack_rssolve for the closure contract. With LAPACK the matrix is first formed by applying the closure to the unit vectors.

Binds igraph_eigen_matrix_symmetric (see the linear algebra chapter).

§Errors

As eigen_matrix_symmetric, plus non-finite values produced by the closure.

§Examples

The operator x -> (sum x) 1 (the all-ones matrix J_4) has eigenvalue 4 once and 0 three times.

use igraph::linalg::*;
let ones = |x: &[f64], y: &mut [f64]| {
    let s: f64 = x.iter().sum();
    y.iter_mut().for_each(|yi| *yi = s);
};
let e = eigen_symmetric_fn(4, ones, &EigenWhich::All, EigenAlgorithm::Lapack, &ArpackOptions::default())
    .unwrap();
let mut values = e.values.clone();
values.sort_by(f64::total_cmp);
assert!(values[..3].iter().all(|x| x.abs() < 1e-12) && (values[3] - 4.0).abs() < 1e-12);