wrong eigh eigenvectors for complex valued matrix

Open
#307 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
rust
Domain
hpc

Research direction

Start by reproducing the provided complex-valued matrix example and trace the implementation behind eigh with UPLO::Lower. Compare the eigenvector result for the matrix and its Hermitian conjugate, then add a regression test based on the shown assertions; done means the original matrix's eigenvectors satisfy the eigenvalue equation.

Written by the indexing model from the issue text.

Description

The resulting eigenvectors for eigh of complex valued matrix is wrong.

If eigh is called with the hermitian conjugate of the matrix,
the resulting eigenvectors are the eigenvectors of the original matrix.

   let values = vec![
        c64::new(1.0, 0.0), c64::new(0.0, -2.0),
        c64::new(0.0, 2.0), c64::new(5.0, 0.0),
    ];
    let matrix = Array2::<c64>::from_shape_vec([2; 2], values).unwrap();
    // assertion passed
    let (eigvalues, eigvecs) = matrix.t().mapv(|v| v.conj()).eigh(UPLO::Lower).unwrap();
    for i in 0 .. 2 {
        let dot = matrix.dot(&eigvecs.column(i));
        let mul = &eigvecs.column(i).mapv(|c| c*eigvalues[i]);
        assert_close_l2!(&dot, &mul, 1.0e-10);
    }
    // assertion failed.
    let (eigvalues, eigvecs) = matrix.eigh(UPLO::Lower).unwrap();
    for i in 0 .. 2 {
        let dot = matrix.dot(&eigvecs.column(i));
        let mul = &eigvecs.column(i).mapv(|c| c*eigvalues[i]);
        assert_close_l2!(&dot, &mul, 1.0e-10);
    }
Dominant language
Rust
Stars
452
Forks
95
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rust-ndarray/ndarray-linalg

All issues in rust-ndarray/ndarray-linalg

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.