Skip to main content

solve_matrix

Function solve_matrix 

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

Solve A X = B for column-major Matrix values.

This routes the operation through the configured tenferro backend and keeps matrix-to-tensor conversion centralized in tensor4all-tensorbackend.

§Errors

Returns an error if the backend rejects the input shapes, scalar dtype, or coefficient matrix.

§Examples

use tensor4all_tensorbackend::{from_vec2d, solve_matrix};

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(&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);