Function solve_triangular
pub fn solve_triangular<T, C>(
ctx: &mut C,
a: &Tensor<T>,
b: &Tensor<T>,
upper: bool,
) -> Result<Tensor<T>, Error>where
T: KernelLinalgScalar,
C: TensorLinalgContextFor<T>,
<C as TensorLinalgContextFor<T>>::Backend: 'static,Expand description
Solve a triangular linear system A x = b.
ยงExamples
use tenferro_device::LogicalMemorySpace;
use tenferro_linalg::solve_triangular;
use tenferro_prims::CpuContext;
use tenferro_tensor::{MemoryOrder, Tensor};
let mut ctx = CpuContext::new(1);
let a = Tensor::<f64>::from_slice(
&[1.0, 0.0, 0.0, 2.0],
&[2, 2],
MemoryOrder::ColumnMajor,
).unwrap();
let b = Tensor::<f64>::from_slice(&[1.0, 4.0], &[2], MemoryOrder::ColumnMajor).unwrap();
let x = solve_triangular(&mut ctx, &a, &b, true).unwrap();
assert_eq!(x.logical_memory_space(), LogicalMemorySpace::MainMemory);