Skip to main content

solve_matrix_owned

Function solve_matrix_owned 

Source
pub fn solve_matrix_owned<T>(
    a: Matrix<T>,
    b: Matrix<T>,
) -> Result<Matrix<T>, BackendLinalgError>
Expand description

Solve A X = B while consuming column-major Matrix values. This routes the operation through the configured tenferro backend and reuses the input buffers when constructing backend tensors for directly supported scalar types.

§Errors

Returns a BackendLinalgError when the context rejects the entry or the solve fails (for example a singular a).

§Examples

use tensor4all_tensorbackend::{from_vec2d, solve_matrix_owned};
let a = from_vec2d(vec![vec![2.0_f64, 1.0], vec![1.0, 2.0]]);
let b = from_vec2d(vec![vec![1.0_f64], vec![0.0]]);
let x = solve_matrix_owned(a, b).unwrap();
assert!((x[[0, 0]] - 2.0 / 3.0).abs() < 1.0e-12);
assert!((x[[1, 0]] + 1.0 / 3.0).abs() < 1.0e-12);