DiagonalMatrix extends AbstractRealMatrix implements Serializable { @Override public double getEntry(final int row, final int column) throws OutOfRangeException { MatrixUtils.checkMatrixIndex(this, row, column); return row == column ? data[row] : 0; } DiagonalMatrix(final int dimension);  DiagonalMatrix(final double[] d);  DiagonalMatrix(final double[] d, final boolean copyArray); @Override RealMatrix createMatrix(final int rowDimension,
                                   final int columnDimension); @Override RealMatrix copy(); DiagonalMatrix add(final DiagonalMatrix m); DiagonalMatrix subtract(final DiagonalMatrix m); DiagonalMatrix multiply(final DiagonalMatrix m); @Override RealMatrix multiply(final RealMatrix m); @Override double[][] getData(); double[] getDataRef(); @Override double getEntry(final int row, final int column); @Override void setEntry(final int row, final int column, final double value); @Override void addToEntry(final int row,
                           final int column,
                           final double increment); @Override void multiplyEntry(final int row,
                              final int column,
                              final double factor); @Override int getRowDimension(); @Override int getColumnDimension(); @Override double[] operate(final double[] v); @Override double[] preMultiply(final double[] v); @Override RealVector preMultiply(final RealVector v); DiagonalMatrix inverse(); DiagonalMatrix inverse(double threshold); boolean isSingular(double threshold);  }
@Test public void testSetSubMatrix() { final double[] data = { -1.2, 3.4, 5 }; final DiagonalMatrix diag = new DiagonalMatrix(data); diag.setSubMatrix(new double[][] { {0.0, 5.0, 0.0}, {0.0, 0.0, 6.0}}, 1, 0); Assert.assertEquals(-1.2, diag.getEntry(0, 0), 1.0e-20); Assert.assertEquals( 5.0, diag.getEntry(1, 1), 1.0e-20); Assert.assertEquals( 6.0, diag.getEntry(2, 2), 1.0e-20); }