Module ndarray_linalg::solveh[][src]

Solve Hermitian (or real symmetric) linear problems and invert Hermitian (or real symmetric) matrices

Note that only the upper triangular portion of the matrix is used.

Examples

Solve A * x = b, where A is a Hermitian (or real symmetric) matrix:

#[macro_use]
extern crate ndarray;
extern crate ndarray_linalg;

use ndarray::prelude::*;
use ndarray_linalg::SolveH;

let a: Array2<f64> = array![
    [3., 2., -1.],
    [2., -2., 4.],
    [-1., 4., 5.]
];
let b: Array1<f64> = array![11., -12., 1.];
let x = a.solveh_into(b).unwrap();
assert!(x.all_close(&array![1., 3., -2.], 1e-9));

If you are solving multiple systems of linear equations with the same Hermitian or real symmetric coefficient matrix A, it's faster to compute the factorization once at the beginning than solving directly using A:

use ndarray::prelude::*;
use ndarray_linalg::*;

let a: Array2<f64> = random((3, 3));
let f = a.factorizeh_into().unwrap(); // Factorize A (A is consumed)
for _ in 0..10 {
    let b: Array1<f64> = random(3);
    let x = f.solveh_into(b).unwrap(); // Solve A * x = b using the factorization
}

Re-exports

pub use lapack_traits::Pivot;
pub use lapack_traits::UPLO;

Structs

BKFactorized

Represents the Bunch–Kaufman factorization of a Hermitian (or real symmetric) matrix as A = P * U * D * U^H * P^T.

Traits

DeterminantH

An interface for calculating determinants of Hermitian (or real symmetric) matrix refs.

DeterminantHInto

An interface for calculating determinants of Hermitian (or real symmetric) matrices.

FactorizeH

An interface for computing the Bunch–Kaufman factorization of Hermitian (or real symmetric) matrix refs.

FactorizeHInto

An interface for computing the Bunch–Kaufman factorization of Hermitian (or real symmetric) matrices.

InverseH

An interface for inverting Hermitian (or real symmetric) matrix refs.

InverseHInto

An interface for inverting Hermitian (or real symmetric) matrices.

SolveH

An interface for solving systems of Hermitian (or real symmetric) linear equations.