Crate nalgebra_lapack [] [src]

linear algebra operations for nalgebra matrices using LAPACK.

Examples

extern crate nalgebra_lapack;
extern crate nalgebra as na;

use nalgebra_lapack::{SVD, Eigensystem, Inverse, Solve};
use na::Eye;

fn main() {
    // SVD -----------------------------------
    let m = na::DMatrix::from_row_vector(3, 5,
        &[-1.01,   0.86,  -4.60,   3.31,  -4.81,
           3.98,   0.53,  -7.04,   5.29,   3.55,
           3.30,   8.26,  -3.89,   8.20,  -1.51]);
    let (u,s,vt) = m.svd().unwrap();
    println!("u {:?}", u);
    println!("s {:?}", s);
    println!("vt {:?}", vt);

    // Eigensystem ---------------------------
    let m = na::DMatrix::from_row_vector(2, 2,
        &[2.0, 1.0,
          1.0, 2.0]);
    let (vals, vecs) = m.eigensystem().unwrap();
    println!("eigenvalues {:?}", vals);
    println!("eigenvectors {:?}", vecs);

    // Invert matrix -------------------------
    let a = na::DMatrix::from_row_vector(2, 2,
        &[1.0, 2.0,
          3.0, 4.0]);
    let a_inv = a.inv().unwrap();
    println!("a_inv {:?}", a_inv);

    // Solve ---------------------------------
    // invert matrix `a` by solving solution to `ax=1`
    let a = na::DMatrix::from_row_vector(2, 2,
        &[1.0, 2.0,
          3.0, 4.0]);
    let n = a.nrows();
    let b = na::DMatrix::new_identity(n);
    let a_inv = a.solve(b);
    println!("a_inv {:?}", a_inv);
}

Structs

NalgebraLapackError

Traits

Cholesky

A type for which the Cholesky decomposition can be computed.

Eigensystem

A type for which eigenvalues and eigenvectors can be computed.

Inverse

A type for which the inverse can be computed.

SVD

A type for which a singular value decomposition can be computed.

Solve

A type for solving a linear matrix equation.

Type Definitions

NalgebraLapackResult