pub fn eig_frule<T, C>(
ctx: &mut C,
tensor: &Tensor<T>,
tangent: &Tensor<T>,
) -> AdResult<(EigResult<T>, EigResult<T>)>where
T: KernelLinalgScalar + KernelLinalgScalar<Real = T, Complex = Complex<T>> + Float,
C: TensorLinalgContextFor<T> + TensorLinalgContextFor<Complex<T>> + TensorScalarContextFor<Standard<T::Real>>,
Complex<T>: KernelLinalgScalar,
<C as TensorLinalgContextFor<T>>::Backend: 'static,
<C as TensorLinalgContextFor<Complex<T>>>::Backend: 'static,
T::Real: KeepCountScalar,Expand description
Forward-mode AD rule for general eigendecomposition (JVP / pushforward).
Given eigendecomposition A V = V diag(lambda), computes the tangents
of eigenvalues and eigenvectors from a real tangent dA using the
Mike Giles formulas.
Returns (primal, tangent) where both are EigResult with complex
eigenvalues and eigenvectors.
ยงExamples
use tenferro_linalg::eig_frule;
use tenferro_prims::CpuContext;
use tenferro_tensor::{Tensor, MemoryOrder};
use tenferro_device::LogicalMemorySpace;
let col = MemoryOrder::ColumnMajor;
let mem = LogicalMemorySpace::MainMemory;
let mut ctx = CpuContext::new(1);
let a = Tensor::<f64>::zeros(&[3, 3], mem, col).unwrap();
let da = Tensor::<f64>::ones(&[3, 3], mem, col).unwrap();
let (result, dresult) = eig_frule(&mut ctx, &a, &da).unwrap();