#![forbid(unsafe_code)]
use approx::assert_abs_diff_eq;
use la_stack::prelude::*;
fn main() -> Result<(), LaError> {
let a = Matrix::<5>::try_from_rows([
[0.0, 1.0, 1.0, 1.0, 1.0],
[1.0, 0.0, 1.0, 1.0, 1.0],
[1.0, 1.0, 0.0, 1.0, 1.0],
[1.0, 1.0, 1.0, 0.0, 1.0],
[1.0, 1.0, 1.0, 1.0, 0.0],
])?;
let b = Vector::<5>::try_new([14.0, 13.0, 12.0, 11.0, 10.0])?;
let lu = a.lu(DEFAULT_SINGULAR_TOL)?;
let x = lu.solve(b)?.into_array();
for (actual, expected) in x.into_iter().zip([1.0, 2.0, 3.0, 4.0, 5.0]) {
assert_abs_diff_eq!(actual, expected, epsilon = 1.0e-12);
}
println!("x = {x:?}");
Ok(())
}