eig_frule

Function eig_frule 

Source
pub fn eig_frule<T, C>(
    ctx: &mut C,
    tensor: &Tensor<T>,
    tangent: &Tensor<T>,
) -> AdResult<(EigResult<T>, EigResult<T>)>
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();