2 unstable releases

0.2.0 Aug 9, 2024
0.1.0 Jul 31, 2024

#715 in Math

MIT/Apache

14KB
277 lines

Eigen decomposition of Hermitian matrices using Lanczos algorithm

Overview

Using Lanczos algorithm to estimate the extremal Eigen values and Eigen vectors of an Symmetrics Hermitian matrix.

Supports both dense and sparse matrices via nalgebra_sparse.

Works well for large sparse matrices

cargo add lanczos

Examples

use nalgebra::DMatrix;
use lanczos::{Hermitian, Order};

// ...
let eigen = matrix.eigsh(50, Order::Smallest);

// Sorted by eigenvalue in ascending order
eprintln!("{}", eigen.eigenvalues);
// Columns sorted according to eigenvalues
eprintln!("{}", eigen.eigenvectors);

// Second smallest eigen value
eprintln!("{}", eigen.eigenvalues[1]);
// Eigen vector corresponding to the second smallest eigen value
eprintln!("{}", eigen.eigenvectors.column(1));

lib.rs:

Eigen decomposition of Hermitian matrices using Lanczos algorithm

Using Lanczos algorithm to estimate the extremal Eigen values and Eigen vectors of an Symmetrics Hermitian matrix.

Supports both dense and sparse matrices via [nalgebra_sparse].

Works well for large sparse matrices

Examples

use lanczos::{Hermitian, Order};

let eigen = matrix.eigsh(50, Order::Smallest);

// Sorted by eigenvalue in ascending order
eprintln!("{}", eigen.eigenvalues);
// Columns sorted according to eigenvalues
eprintln!("{}", eigen.eigenvectors);

// Second smallest eigen value
eprintln!("{}", eigen.eigenvalues[1]);
// Eigen vector corresponding to the second smallest eigen value
eprintln!("{}", eigen.eigenvectors.column(1));

Dependencies

~6MB
~114K SLoC