Skip to content

Commit 082f01d

Browse files
authored
Merge pull request #283 from jturner314/doc-eigh
Add basic documentation for eigh module
2 parents 6de9acc + ab4cc02 commit 082f01d

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

lax/src/eigh.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub trait Eigh_: Scalar {
1414
a: &mut [Self],
1515
) -> Result<Vec<Self::Real>>;
1616

17-
/// Wraps `*syegv` for real and `*heegv` for complex
17+
/// Wraps `*sygv` for real and `*hegv` for complex
1818
fn eigh_generalized(
1919
calc_eigenvec: bool,
2020
layout: MatrixLayout,

ndarray-linalg/src/eigh.rs

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,37 @@
1-
//! Eigenvalue decomposition for Hermite matrices
1+
//! Eigendecomposition for Hermitian matrices.
2+
//!
3+
//! For a Hermitian matrix `A`, this solves the eigenvalue problem `A V = V D`
4+
//! for `D` and `V`, where `D` is the diagonal matrix of eigenvalues in
5+
//! ascending order and `V` is the orthonormal matrix of corresponding
6+
//! eigenvectors.
7+
//!
8+
//! For a pair of Hermitian matrices `A` and `B` where `B` is also positive
9+
//! definite, this solves the generalized eigenvalue problem `A V = B V D`,
10+
//! where `D` is the diagonal matrix of generalized eigenvalues in ascending
11+
//! order and `V` is the matrix of corresponding generalized eigenvectors. The
12+
//! matrix `V` is normalized such that `V^H B V = I`.
13+
//!
14+
//! # Example
15+
//!
16+
//! Find the eigendecomposition of a Hermitian (or real symmetric) matrix.
17+
//!
18+
//! ```
19+
//! use approx::assert_abs_diff_eq;
20+
//! use ndarray::{array, Array2};
21+
//! use ndarray_linalg::{Eigh, UPLO};
22+
//!
23+
//! let a: Array2<f64> = array![
24+
//! [2., 1.],
25+
//! [1., 2.],
26+
//! ];
27+
//! let (eigvals, eigvecs) = a.eigh(UPLO::Lower)?;
28+
//! assert_abs_diff_eq!(eigvals, array![1., 3.]);
29+
//! assert_abs_diff_eq!(
30+
//! a.dot(&eigvecs),
31+
//! eigvecs.dot(&Array2::from_diag(&eigvals)),
32+
//! );
33+
//! # Ok::<(), Box<dyn std::error::Error>>(())
34+
//! ```
235
336
use ndarray::*;
437

0 commit comments

Comments
 (0)