eig

Function eig 

Source
pub fn eig<T: KernelLinalgScalar<Real = T, Complex = Complex<T>> + Float, C>(
    ctx: &mut C,
    tensor: &Tensor<T>,
) -> Result<EigResult<T>>
where C: TensorLinalgContextFor<T>, C::Backend: 'static,
Expand description

Compute the eigendecomposition of a general (non-symmetric) square matrix.

Returns complex eigenvalues and eigenvectors even for real inputs.

ยงExamples

use tenferro_linalg::eig;
use tenferro_prims::CpuContext;
use tenferro_tensor::{MemoryOrder, Tensor};

let mut ctx = CpuContext::new(1);
let col = MemoryOrder::ColumnMajor;
let a = Tensor::<f64>::from_slice(&[1.0, 0.0, 0.0, 2.0], &[2, 2], col).unwrap();
let result = eig(&mut ctx, &a).unwrap();
assert_eq!(result.values.dims(), &[2]);
assert_eq!(result.vectors.dims(), &[2, 2]);