EigenvalueDecomposition { public Matrix getD() { final Matrix X = new Matrix(this.n, this.n); final double[][] D = X.getData(); for (int i = 0; i < this.n; i++) { Arrays.fill(D[i], 0.0); D[i][i] = this.d[i]; if (this.e[i] > 0) { D[i][i + 1] = this.e[i]; } else if (this.e[i] < 0) { D[i][i - 1] = this.e[i]; } } return X; } EigenvalueDecomposition(final Matrix matrix); Matrix getD(); double[] getImagEigenvalues(); double[] getRealEigenvalues(); Matrix getV();  }
@Test public void testGetD_asymentric() { EigenvalueDecomposition decomposition = new EigenvalueDecomposition(matrix1); Matrix d = decomposition.getD(); assertEquals(2, d.getCols()); assertEquals(2, d.getRows()); assertEquals(1.45, d.get(0, 0), 1e-10); assertEquals(1.4991664351, d.get(0, 1), 1e-10); assertEquals(-1.4991664351, d.get(1, 0), 1e-10); assertEquals(1.45, d.get(1, 1), 1e-10); }
@Test public void testGetD_symentric() { EigenvalueDecomposition decomposition = new EigenvalueDecomposition(matrix2); Matrix d = decomposition.getD(); assertEquals(2, d.getCols()); assertEquals(2, d.getRows()); assertEquals(-5.2008771255, d.get(0, 0), 1e-10); assertEquals(0.0, d.get(0, 1), 1e-10); assertEquals(0.0, d.get(1, 0), 1e-10); assertEquals(6.2008771255, d.get(1, 1), 1e-10); }