Skip to content

Commit

Permalink
Split eigenvalue test and eigenvector tests
Browse files Browse the repository at this point in the history
  • Loading branch information
termoshtt committed Jul 4, 2020
1 parent 77b6269 commit 0e88d0c
Show file tree
Hide file tree
Showing 2 changed files with 245 additions and 166 deletions.
23 changes: 23 additions & 0 deletions ndarray-linalg/src/eig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,29 @@ pub trait Eig {
type EigVal;
type EigVec;
/// Calculate eigenvalues with the right eigenvector
///
/// $$ A u_i = \lambda_i u_i $$
///
/// ```
/// use ndarray::*;
/// use ndarray_linalg::*;
///
/// let a: Array2<f64> = array![
/// [-1.01, 0.86, -4.60, 3.31, -4.81],
/// [ 3.98, 0.53, -7.04, 5.29, 3.55],
/// [ 3.30, 8.26, -3.89, 8.20, -1.51],
/// [ 4.43, 4.96, -7.66, -7.33, 6.18],
/// [ 7.31, -6.43, -6.16, 2.47, 5.58],
/// ];
/// let (eigs, vecs) = a.eig().unwrap();
///
/// let a: Array2<c64> = a.map(|v| v.into());
/// for (&e, vec) in eigs.iter().zip(vecs.axis_iter(Axis(1))) {
/// let ev = e * vec.into_owned();
/// let av = a.dot(&vec);
/// assert_close_l2!(&av, &ev, 1e-5);
/// }
/// ```
fn eig(&self) -> Result<(Self::EigVal, Self::EigVec)>;
}

Expand Down
Loading

0 comments on commit 0e88d0c

Please sign in to comment.