File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change 10
10
//! where `D` is the diagonal matrix of generalized eigenvalues in ascending
11
11
//! order and `V` is the matrix of corresponding generalized eigenvectors. The
12
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
+ //! ```
13
35
14
36
use ndarray:: * ;
15
37
You can’t perform that action at this time.
0 commit comments