EigenDecomposition { public double[] getRealEigenvalues() { return realEigenvalues.clone(); } EigenDecomposition(final RealMatrix matrix); @Deprecated  EigenDecomposition(final RealMatrix matrix,
                              final double splitTolerance);  EigenDecomposition(final double[] main, final double[] secondary); @Deprecated  EigenDecomposition(final double[] main, final double[] secondary,
                              final double splitTolerance); RealMatrix getV(); RealMatrix getD(); RealMatrix getVT(); boolean hasComplexEigenvalues(); double[] getRealEigenvalues(); double getRealEigenvalue(final int i); double[] getImagEigenvalues(); double getImagEigenvalue(final int i); RealVector getEigenvector(final int i); double getDeterminant(); RealMatrix getSquareRoot(); DecompositionSolver getSolver();  }
@Test public void testTridiagonal() { Random r = new Random(4366663527842l); double[] ref = new double[30]; for (int i = 0; i < ref.length; ++i) { if (i < 5) { ref[i] = 2 * r.nextDouble() - 1; } else { ref[i] = 0.0001 * r.nextDouble() + 6; } } Arrays.sort(ref); TriDiagonalTransformer t = new TriDiagonalTransformer(createTestMatrix(r, ref)); EigenDecomposition ed; ed = new EigenDecomposition(t.getMainDiagonalRef(), t.getSecondaryDiagonalRef()); double[] eigenValues = ed.getRealEigenvalues(); Assert.assertEquals(ref.length, eigenValues.length); for (int i = 0; i < ref.length; ++i) { Assert.assertEquals(ref[ref.length - i - 1], eigenValues[i], 2.0e-14); } }
@Test public void testEigenvalues() { EigenDecomposition ed; ed = new EigenDecomposition(matrix); double[] eigenValues = ed.getRealEigenvalues(); Assert.assertEquals(refValues.length, eigenValues.length); for (int i = 0; i < refValues.length; ++i) { Assert.assertEquals(refValues[i], eigenValues[i], 3.0e-15); } }
@Test public void testBigMatrix() { Random r = new Random(17748333525117l); double[] bigValues = new double[200]; for (int i = 0; i < bigValues.length; ++i) { bigValues[i] = 2 * r.nextDouble() - 1; } Arrays.sort(bigValues); EigenDecomposition ed; ed = new EigenDecomposition(createTestMatrix(r, bigValues)); double[] eigenValues = ed.getRealEigenvalues(); Assert.assertEquals(bigValues.length, eigenValues.length); for (int i = 0; i < bigValues.length; ++i) { Assert.assertEquals(bigValues[bigValues.length - i - 1], eigenValues[i], 2.0e-14); } }