extern crate nalgebra as na; extern crate nalgebra_lapack; #[macro_use] extern crate approx; // for assert_relative_eq use na::Matrix3; use nalgebra_lapack::Eigen; use num_complex::Complex; fn main() { let m = Matrix3::::new(4.0/5.0, -3.0/5.0, 0.0, 3.0/5.0, 4.0/5.0, 0.0, 1.0, 2.0, 2.0); let eigen = Eigen::new(m,true,true).expect("Eigen Creation Failed!"); let (some_eigenvalues, some_left_vec, some_right_vec) = eigen.get_complex_elements(); let eigenvalues = some_eigenvalues.expect("Eigenvalues Failed"); let left_eigenvectors = some_left_vec.expect("Left Eigenvectors Failed"); let eigenvectors = some_right_vec.expect("Right Eigenvectors Failed"); assert_relative_eq!(eigenvalues[0].re, Complex::::new(4.0/5.0,3.0/5.0).re); assert_relative_eq!(eigenvalues[0].im, Complex::::new(4.0/5.0,3.0/5.0).im); assert_relative_eq!(eigenvalues[1].re, Complex::::new(4.0/5.0,-3.0/5.0).re); assert_relative_eq!(eigenvalues[1].im, Complex::::new(4.0/5.0,-3.0/5.0).im); }