Skip to main content

eigen_matrix

Function eigen_matrix 

Source
pub fn eigen_matrix(
    a: &Matrix,
    which: &EigenWhich,
    algorithm: EigenAlgorithm,
) -> Result<ComplexEigen>
Expand description

Selected eigenvalues and eigenvectors of a general real dense matrix (igraph_eigen_matrix); only EigenAlgorithm::Lapack is implemented by igraph 1.0.0 and 1.0.1.

The eigenvalues are ordered according to which; EigenWhich::All and EigenWhich::Select use increasing magnitude. Among eigenvalues of equal magnitude (resp. real or imaginary part), real ones come first for the “largest” choices and complex ones come first for the “smallest” choices, All and Select, so that each “smallest” order is the exact reverse of the corresponding “largest” one.

Binds igraph_eigen_matrix (see the linear algebra chapter). The callback form of the C function is not exposed: igraph 1.0.0 and 1.0.1 dereferences a null matrix in that code path.

§Examples

A rotation by 90 degrees has eigenvalues ±i.

use igraph::{linalg::*, prelude::*};
let r = Matrix::from_rows(&[[0.0, -1.0], [1.0, 0.0]]).unwrap();
let e = eigen_matrix(&r, &EigenWhich::All, EigenAlgorithm::Lapack).unwrap();
assert_eq!(e.values.len(), 2);
for v in &e.values {
    assert!(v.re().abs() < 1e-12 && (v.im().abs() - 1.0).abs() < 1e-12);
}