Skip to content

Commit 0e88d0c

Browse files
committed
Split eigenvalue test and eigenvector tests
1 parent 77b6269 commit 0e88d0c

File tree

2 files changed

+245
-166
lines changed

2 files changed

+245
-166
lines changed

ndarray-linalg/src/eig.rs

+23
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,29 @@ pub trait Eig {
1111
type EigVal;
1212
type EigVec;
1313
/// Calculate eigenvalues with the right eigenvector
14+
///
15+
/// $$ A u_i = \lambda_i u_i $$
16+
///
17+
/// ```
18+
/// use ndarray::*;
19+
/// use ndarray_linalg::*;
20+
///
21+
/// let a: Array2<f64> = array![
22+
/// [-1.01, 0.86, -4.60, 3.31, -4.81],
23+
/// [ 3.98, 0.53, -7.04, 5.29, 3.55],
24+
/// [ 3.30, 8.26, -3.89, 8.20, -1.51],
25+
/// [ 4.43, 4.96, -7.66, -7.33, 6.18],
26+
/// [ 7.31, -6.43, -6.16, 2.47, 5.58],
27+
/// ];
28+
/// let (eigs, vecs) = a.eig().unwrap();
29+
///
30+
/// let a: Array2<c64> = a.map(|v| v.into());
31+
/// for (&e, vec) in eigs.iter().zip(vecs.axis_iter(Axis(1))) {
32+
/// let ev = e * vec.into_owned();
33+
/// let av = a.dot(&vec);
34+
/// assert_close_l2!(&av, &ev, 1e-5);
35+
/// }
36+
/// ```
1437
fn eig(&self) -> Result<(Self::EigVal, Self::EigVec)>;
1538
}
1639

0 commit comments

Comments
 (0)