pub fn lu_solve<T, C>(
ctx: &mut C,
factors: &Tensor<T>,
pivots: &Tensor<i32>,
b: &Tensor<T>,
) -> Result<Tensor<T>>Expand description
Solve A x = b from a packed LU factorization.
ยงExamples
use tenferro_linalg::{lu_factor, lu_solve};
use tenferro_prims::CpuContext;
use tenferro_tensor::{MemoryOrder, Tensor};
let mut ctx = CpuContext::new(1);
let col = MemoryOrder::ColumnMajor;
let a = Tensor::<f64>::from_slice(&[2.0, 1.0, 1.0, 3.0], &[2, 2], col).unwrap();
let lu = lu_factor(&mut ctx, &a).unwrap();
let b = Tensor::<f64>::from_slice(&[5.0, 7.0], &[2], col).unwrap();
let x = lu_solve(&mut ctx, &lu.factors, &lu.pivots, &b).unwrap();
assert_eq!(x.dims(), &[2]);