pub fn eigen<T: KernelLinalgScalar, C>(
ctx: &mut C,
tensor: &Tensor<T>,
) -> Result<EigenResult<T, T::Real>>where
C: TensorLinalgContextFor<T>,
C::Backend: 'static,Expand description
Compute the eigendecomposition of a batched square matrix.
Input shape: (n, n, *).
The lower triangle is treated as canonical input, matching the default
UPLO='L' behavior used by PyTorch’s linalg.eigh.
§Examples
use tenferro_device::LogicalMemorySpace;
use tenferro_linalg::eigen;
use tenferro_prims::CpuContext;
use tenferro_tensor::{MemoryOrder, Tensor};
let mut ctx = CpuContext::new(1);
let a = Tensor::<f64>::from_slice(
&[2.0, 1.0, 1.0, 2.0],
&[2, 2],
MemoryOrder::ColumnMajor,
).unwrap();
let result = eigen(&mut ctx, &a).unwrap();
assert_eq!(result.values.dims(), &[2]);