EigenDecomposition { public double getRealEigenvalue(final int i) { return realEigenvalues[i]; } 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 testDimension1() { RealMatrix matrix = MatrixUtils.createRealMatrix(new double[][] { { 1.5 } }); EigenDecomposition ed; ed = new EigenDecomposition(matrix); Assert.assertEquals(1.5, ed.getRealEigenvalue(0), 1.0e-15); }
@Test public void testDimension2() { RealMatrix matrix = MatrixUtils.createRealMatrix(new double[][] { { 59.0, 12.0 }, { 12.0, 66.0 } }); EigenDecomposition ed; ed = new EigenDecomposition(matrix); Assert.assertEquals(75.0, ed.getRealEigenvalue(0), 1.0e-15); Assert.assertEquals(50.0, ed.getRealEigenvalue(1), 1.0e-15); }
@Test public void testDimension3() { RealMatrix matrix = MatrixUtils.createRealMatrix(new double[][] { { 39632.0, -4824.0, -16560.0 }, { -4824.0, 8693.0, 7920.0 }, { -16560.0, 7920.0, 17300.0 } }); EigenDecomposition ed; ed = new EigenDecomposition(matrix); Assert.assertEquals(50000.0, ed.getRealEigenvalue(0), 3.0e-11); Assert.assertEquals(12500.0, ed.getRealEigenvalue(1), 3.0e-11); Assert.assertEquals( 3125.0, ed.getRealEigenvalue(2), 3.0e-11); }
@Test public void testDimension3MultipleRoot() { RealMatrix matrix = MatrixUtils.createRealMatrix(new double[][] { { 5, 10, 15 }, { 10, 20, 30 }, { 15, 30, 45 } }); EigenDecomposition ed; ed = new EigenDecomposition(matrix); Assert.assertEquals(70.0, ed.getRealEigenvalue(0), 3.0e-11); Assert.assertEquals(0.0, ed.getRealEigenvalue(1), 3.0e-11); Assert.assertEquals(0.0, ed.getRealEigenvalue(2), 3.0e-11); }
@Test public void testDimension4WithSplit() { RealMatrix matrix = MatrixUtils.createRealMatrix(new double[][] { { 0.784, -0.288, 0.000, 0.000 }, { -0.288, 0.616, 0.000, 0.000 }, { 0.000, 0.000, 0.164, -0.048 }, { 0.000, 0.000, -0.048, 0.136 } }); EigenDecomposition ed; ed = new EigenDecomposition(matrix); Assert.assertEquals(1.0, ed.getRealEigenvalue(0), 1.0e-15); Assert.assertEquals(0.4, ed.getRealEigenvalue(1), 1.0e-15); Assert.assertEquals(0.2, ed.getRealEigenvalue(2), 1.0e-15); Assert.assertEquals(0.1, ed.getRealEigenvalue(3), 1.0e-15); }
@Test public void testDimension4WithoutSplit() { RealMatrix matrix = MatrixUtils.createRealMatrix(new double[][] { { 0.5608, -0.2016, 0.1152, -0.2976 }, { -0.2016, 0.4432, -0.2304, 0.1152 }, { 0.1152, -0.2304, 0.3088, -0.1344 }, { -0.2976, 0.1152, -0.1344, 0.3872 } }); EigenDecomposition ed; ed = new EigenDecomposition(matrix); Assert.assertEquals(1.0, ed.getRealEigenvalue(0), 1.0e-15); Assert.assertEquals(0.4, ed.getRealEigenvalue(1), 1.0e-15); Assert.assertEquals(0.2, ed.getRealEigenvalue(2), 1.0e-15); Assert.assertEquals(0.1, ed.getRealEigenvalue(3), 1.0e-15); }
@Test public void testDiagonal() { double[] diagonal = new double[] { -3.0, -2.0, 2.0, 5.0 }; RealMatrix m = MatrixUtils.createRealDiagonalMatrix(diagonal); EigenDecomposition ed; ed = new EigenDecomposition(m); Assert.assertEquals(diagonal[0], ed.getRealEigenvalue(3), 2.0e-15); Assert.assertEquals(diagonal[1], ed.getRealEigenvalue(2), 2.0e-15); Assert.assertEquals(diagonal[2], ed.getRealEigenvalue(1), 2.0e-15); Assert.assertEquals(diagonal[3], ed.getRealEigenvalue(0), 2.0e-15); }