Crates.io | lanczos |
lib.rs | lanczos |
version | 0.2.0 |
source | src |
created_at | 2024-07-31 21:29:31.418833 |
updated_at | 2024-08-09 23:30:00.580429 |
description | lanczos algorithm for eigen decomposition |
homepage | |
repository | https://github.com/tomerdmnt/lanczos |
max_upload_size | |
id | 1321338 |
size | 13,489 |
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
cargo add lanczos
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));