Skip to main content

EigGeneralized

Trait EigGeneralized 

Source
pub trait EigGeneralized {
    type EigVal;
    type EigVec;
    type Real;

    // Required method
    fn eig_generalized(
        self,
        thresh_opt: Option<Self::Real>,
    ) -> Result<(Self::EigVal, Self::EigVec)>;
}
Expand description

Eigenvalue decomposition of general matrix reference

Required Associated Types§

Source

type EigVal

EigVec is the right eivenvector

Source

type EigVec

Source

type Real

Required Methods§

Source

fn eig_generalized( self, thresh_opt: Option<Self::Real>, ) -> Result<(Self::EigVal, Self::EigVec)>

Calculate eigenvalues with the right eigenvector

$$ A u_i = \lambda_i B u_i $$

use ndarray::*;
use ndarray_linalg::*;

let a: Array2<f64> = array![
    [-1.01,  0.86, -4.60,  3.31, -4.81],
    [ 3.98,  0.53, -7.04,  5.29,  3.55],
    [ 3.30,  8.26, -3.89,  8.20, -1.51],
    [ 4.43,  4.96, -7.66, -7.33,  6.18],
    [ 7.31, -6.43, -6.16,  2.47,  5.58],
];
let b: Array2<f64> = array![
    [ 1.23, -4.56,  7.89,  0.12, -3.45],
    [ 6.78, -9.01,  2.34, -5.67,  8.90],
    [-1.11,  3.33, -6.66,  9.99, -2.22],
    [ 4.44, -7.77,  0.00,  1.11,  5.55],
    [-8.88,  6.66, -3.33,  2.22, -9.99],
];
let (geneigs, vecs) = (a.clone(), b.clone()).eig_generalized(None).unwrap();

let a = a.map(|v| v.as_c());
let b = b.map(|v| v.as_c());
for (ge, vec) in geneigs.iter().zip(vecs.axis_iter(Axis(1))) {
    if let GeneralizedEigenvalue::Finite(e, _) = ge {
        let ebv = b.dot(&vec).map(|v| v * e);
        let av = a.dot(&vec);
        assert_close_l2!(&av, &ebv, 1e-5);
    }
}
§Arguments
  • thresh_opt - An optional threshold for determining approximate zero |β| values when computing the eigenvalues as α/β. If None, no approximate comparisons to zero will be made.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T1, T2> EigGeneralized for (T1, T2)
where T1: MaybeOwnedMatrix, T1::Elem: Lapack + Scalar, T2: MaybeOwnedMatrix<Elem = T1::Elem>,

Implementors§