pub trait EigenValues: VectorSpace {
type EigenValues;
fn eigenvalues(self) -> Self::EigenValues;
}
Expand description
extension for eigen values
Required Associated Types§
type EigenValues
type EigenValues
the type of the array of eigen values
Required Methods§
fn eigenvalues(self) -> Self::EigenValues
fn eigenvalues(self) -> Self::EigenValues
calculate eigen values.
Examples
use cgmath::*;
use matext4cgmath::*;
use num_complex::Complex;
const EPS: f64 = 1.0e-10;
let mat = Matrix2::new(4.0, -2.0, 3.0, -1.0);
let mut eigens = mat.eigenvalues();
// Even in the case of real solutions, the order in the array is not guaranteed.
eigens.sort_by(|x, y| x.re.partial_cmp(&y.re).unwrap());
assert!(Complex::norm(eigens[0] - 1.0) < EPS);
assert!(Complex::norm(eigens[1] - 2.0) < EPS);