lessthanoptimal / ejml

A fast and easy to use linear algebra library written in Java for dense, sparse, real, and complex matrices.
https://ejml.org
556 stars 116 forks source link

ZDRM: Support for Eigenvalue Decomposition #93

Open rstrauss-logyx opened 3 years ago

rstrauss-logyx commented 3 years ago

How do I get complex eigen values and vectors, like MatLab creates?

I tried using SimpleMatrix, but it assumes the matrix is either double or float. Can this be fixed, quickly? Or can you recommend another library? (jblas also doesn't have this) thx...

getEigen(int n, ZMatrixRMaj hamiltonian) { SimpleMatrix s = new SimpleMatrix(hamiltonian); eigens = s.eig();

java.lang.ClassCastException: org.ejml.data.ZMatrixRMaj cannot be cast to org.ejml.data.FMatrixRMaj org.ejml.dense.row.decomposition.eig.SwitchingEigenDecomposition_FDRM.decompose(SwitchingEigenDecomposition_FDRM.java:36) at org.ejml.simple.SimpleEVD.(SimpleEVD.java:56) at org.ejml.simple.SimpleBase.eig(SimpleBase.java:949)

lessthanoptimal commented 3 years ago

Unfortunately Eigenvalue Decomposition is not fully implemented yet for complex matrices. I did update the code so that it gives a slightly more informative error message.

It's very rare that I need to mess with complex matrices so I'm not sure what others might support it. I believe the C++ library Eigen supports it, so maybe check JEigen?

ztx8511 commented 2 months ago

Does the complex matrix eig operation now support?