I’ve been trying to figure out why the eigenvalue decomposition provided by ND4J is returning incorrect results in my unit tests. I worked out the matrix decomp by hand and calculated it with several other libraries (EJML, Parallel Colt, and JAMA).
I’ve tried both the standard and the generalized method (setting B to the identity matrix). Both give the same incorrect values:
double[][] array = new double[][]{{1, 2, 1}, {6, -1, 0}, {-1, -2, -1}};
INDArray matrix = Nd4j.create(array);
INDArray values = Eigen.symmetricGeneralizedEigenvalues(matrix);
// INDArray values = Eigen.symmetricGeneralizedEigenvalues(matrix, Nd4j.eye(matrix.row));
System.out.println(values);
With either method I get:
[-6.2408, -1.3996, 6.6403]
However, the actual eigenvalues are
[-4.0, 0.0, 3.0]
I figure this has something to do with the fact that the docs say A should be symmetric… but I see no other class in the library that does eigenvalue decomposition and symmetric matrices are a pretty narrow scope (or so I thought?).
Does anyone have any ideas? Thanks!