pub fn qr_frule<T, C>(
ctx: &mut C,
tensor: &Tensor<T>,
tangent: &Tensor<T>,
) -> AdResult<(QrResult<T>, QrResult<T>)>Expand description
Forward-mode AD rule for QR (JVP / pushforward).
ยงExamples
use tenferro_linalg::qr_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::from_slice(
&[1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0],
&[4, 3],
col,
).unwrap();
let da = Tensor::<f64>::ones(&[4, 3], mem, col).unwrap();
let (result, dresult) = qr_frule(&mut ctx, &a, &da).unwrap();