Skip to main content

eig

Function eig 

Source
pub fn eig<B: Backend, T: LinalgScalar>(
    x: &Array<B, T>,
    compute_left_eigenvectors: bool,
    compute_right_eigenvectors: bool,
    enable_eigvec_derivs: bool,
) -> (Array<B, T::Complex>, Option<Array<B, T::Complex>>, Option<Array<B, T::Complex>>)
Expand description

The eigendecomposition of each general (nonsymmetric) square matrix, as lax.linalg.eig: the complex eigenvalues w, and, if requested, the left eigenvectors (u^H x = w u^H) and the right eigenvectors (x v = w v), one per column, with unit norm and the component of largest magnitude real, as LAPACK’s geev gives them (the eigenvalues in the order of LAPACK’s Schur form; see ruxla_kernels::linalg::eig).

The eigenvalues are differentiable; the eigenvectors only with enable_eigvec_derivs (valid for distinct eigenvalues), as in JAX.

§Examples

use ruxla_core::{Array, Native, lax};

// A rotation by 90 degrees: the eigenvalues are i and -i.
let a = Array::<Native, f64>::from_vec(vec![0.0, -1.0, 1.0, 0.0], [2, 2]);
let (w, _, _) = lax::linalg::eig(&a, false, false, false);
let w = w.to_vec();
assert_eq!((w[0].re, w[0].im, w[1].im), (0.0, 1.0, -1.0));

§Panics

Panics if x is not a batch of square matrices.