Skip to main content

lapack_dgesv

Function lapack_dgesv 

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

Solves the linear system A X = B for a square A and one or more right hand sides (the columns of B), by LU decomposition with partial pivoting (igraph_lapack_dgesv).

Binds igraph_lapack_dgesv.

§Errors

If the dimensions do not match, or A is exactly singular (ErrorKind::Failure).

§Examples

use igraph::{linalg::lapack_dgesv, prelude::*};
// 2x + y = 5, x + 3y = 10  =>  x = 1, y = 3
let a = Matrix::from_rows(&[[2.0, 1.0], [1.0, 3.0]]).unwrap();
let b = Matrix::from_rows(&[[5.0], [10.0]]).unwrap();
let x = lapack_dgesv(&a, &b).unwrap().solution;
assert!((x[(0, 0)] - 1.0).abs() < 1e-12 && (x[(1, 0)] - 3.0).abs() < 1e-12);