solve

Function solve 

Source
pub fn solve<F>(
    a: &ArrayView2<'_, F>,
    b: &ArrayView1<'_, F>,
    workers: Option<usize>,
) -> LinalgResult<Array1<F>>
where F: Float + NumAssign + One + Sum + Send + Sync + ScalarOperand + 'static,
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 matrix
  • b - Ordinate or “dependent variable” values
  • workers - 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);