pub fn solve<F>(
a: &ArrayView2<'_, F>,
b: &ArrayView1<'_, F>,
workers: Option<usize>,
) -> LinalgResult<Array1<F>>
Expand description
Solve a linear system of equations.
Solves the equation a x = b for x, assuming a is a square matrix.
§Arguments
a
- Coefficient matrixb
- Ordinate or “dependent variable” valuesworkers
- Number of worker threads (None = use default)
§Returns
- Solution vector x
§Examples
use scirs2_core::ndarray::{array, ScalarOperand};
use scirs2_linalg::solve;
let a = array![[1.0_f64, 0.0], [0.0, 1.0]];
let b = array![2.0_f64, 3.0];
let x = solve(&a.view(), &b.view(), None).unwrap();
assert!((x[0] - 2.0).abs() < 1e-10);
assert!((x[1] - 3.0).abs() < 1e-10);