pub fn lu_frule<T, C>(
ctx: &mut C,
tensor: &Tensor<T>,
tangent: &Tensor<T>,
pivot: LuPivot,
) -> AdResult<(LuResult<T>, LuResult<T>)>where
T: KernelLinalgScalar + LiftPermutationMatrixTensor<C>,
C: TensorLinalgContextFor<T> + TensorMetadataContextFor + TensorScalarContextFor<Standard<T::Real>>,
C::MetadataBackend: TensorMetadataPrims<Context = C>,
<C as TensorScalarContextFor<Standard<T::Real>>>::ScalarBackend: TensorMetadataCastPrims<T::Real, Context = C>,
C::Backend: 'static,Expand description
Forward-mode AD rule for LU (JVP / pushforward).
The pivot argument must match the pivoting strategy used in the forward pass.
ยงExamples
use tenferro_linalg::{lu_frule, LuPivot};
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::from_slice(&[1.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 3.0], &[3, 3], col)
.unwrap();
let da = Tensor::<f64>::ones(&[3, 3], mem, col).unwrap();
let (result, dresult) = lu_frule(&mut ctx, &a, &da, LuPivot::Partial).unwrap();