0

I've found that ND4J is returning incorrect eigenvalues:

 double[][] array = new double[][]{{1, 2, 1}, {6, -1, 0}, {-1, -2, -1}};
 INDArray matrix = Nd4j.create(array);

 INDArray values = Eigen.symmetricGeneralizedEigenvalues(matrix);
 System.out.println(values);

 [-6.2408, -1.3996, 6.6403]

I also tried this with the same result:

INDArray values = Eigen.symmetricGeneralizedEigenvalues(matrix, Nd4j.eye(matrix.rows()));

The actual values are [-4.0, 0.0, 3.0]. I've verified this by hand and with Colt, JAMA and EJML libraries.

I took a closer look at the docs, and saw that the input matrix of symmetricGeneralizedEigenvalues is supposed to be symmetric, which this one is not. However, I cannot find any documentation for a method that accepts non-symmetric square matrices. I feel like I must be doing something wrong here. What am I missing?

rocksNwaves
  • 5,331
  • 4
  • 38
  • 77
  • The documentation I found (http://javadox.com/org.nd4j/nd4j-api/0.9.1/org/nd4j/linalg/eigen/Eigen.html) seems to say that Eigen.eigenvalues computes the eigenvalues of a general (not necessarily symmetric) matrix. – Robert Dodier May 26 '21 at 00:58
  • Hi @RobertDodier, if you take a look at the parameter descriptions, you will see that the input is required to be symmetric. Also "general" refers to a class of eigen decomposition problems, not a type of matrix: https://en.wikipedia.org/wiki/Eigendecomposition_of_a_matrix#Generalized_eigenvalue_problem – rocksNwaves May 26 '21 at 12:52
  • 1
    @rocksNwaves we will expose basic functionality to handle that case. please feel free to open an issue in https://github.com/eclipse/deeplearning4j when you face such. – qwr May 26 '21 at 13:21
  • @rocksNwaves I opened the Pr https://github.com/eclipse/deeplearning4j/pull/9328 . – qwr May 26 '21 at 16:38
  • 1
    @qwr I saw that (actually my boss did). That's very exciting. Your library is awesome, and I am going to try to help out in any small way I can :) – rocksNwaves May 26 '21 at 18:38

0 Answers0