pub fn lapack_dgeev(a: &Matrix, left: bool, right: bool) -> Result<DgeevResult>Expand description
Eigenvalues and, optionally, left and/or right eigenvectors of a general
real square matrix (igraph_lapack_dgeev). The eigenvectors are
normalized to unit Euclidean norm with largest component real.
Binds igraph_lapack_dgeev.
§Errors
If the matrix is not square or empty, or the QR algorithm fails.
§Examples
igraph’s igraph_lapack_dgeev.c example: [[1, 1], [-1, 1]] has
eigenvalues 1 ± i.
use igraph::{linalg::lapack_dgeev, prelude::*};
let a = Matrix::from_rows(&[[1.0, 1.0], [-1.0, 1.0]]).unwrap();
let e = lapack_dgeev(&a, true, true).unwrap();
let values = e.values();
assert!((values[0].re() - 1.0).abs() < 1e-12 && (values[0].im() - 1.0).abs() < 1e-12);
assert!((values[1].re() - 1.0).abs() < 1e-12 && (values[1].im() + 1.0).abs() < 1e-12);
// Check A v = (1 + i) v on the first component: (A v)_0 = v_0 + v_1.
let v = &e.right_eigenvectors().unwrap()[0];
let (lhs_re, lhs_im) = (v[0].re() + v[1].re(), v[0].im() + v[1].im());
let (rhs_re, rhs_im) = (v[0].re() - v[0].im(), v[0].re() + v[0].im());
assert!((lhs_re - rhs_re).abs() < 1e-12 && (lhs_im - rhs_im).abs() < 1e-12);