MatrixUtils { public static RealMatrix createRealIdentityMatrix(int dimension) { final RealMatrix m = createRealMatrix(dimension, dimension); for (int i = 0; i < dimension; ++i) { m.setEntry(i, i, 1.0); } return m; } private  MatrixUtils(); static RealMatrix createRealMatrix(final int rows, final int columns); static FieldMatrix<T> createFieldMatrix(final Field<T> field,
                                                                               final int rows,
                                                                               final int columns); static RealMatrix createRealMatrix(double[][] data); static FieldMatrix<T> createFieldMatrix(T[][] data); static RealMatrix createRealIdentityMatrix(int dimension); static FieldMatrix<T> createFieldIdentityMatrix(final Field<T> field, final int dimension); static RealMatrix createRealDiagonalMatrix(final double[] diagonal); static FieldMatrix<T> createFieldDiagonalMatrix(final T[] diagonal); static RealVector createRealVector(double[] data); static FieldVector<T> createFieldVector(final T[] data); static RealMatrix createRowRealMatrix(double[] rowData); static FieldMatrix<T> createRowFieldMatrix(final T[] rowData); static RealMatrix createColumnRealMatrix(double[] columnData); static FieldMatrix<T> createColumnFieldMatrix(final T[] columnData); static void checkSymmetric(RealMatrix matrix,
                                      double eps); static boolean isSymmetric(RealMatrix matrix,
                                      double eps); static void checkMatrixIndex(final AnyMatrix m,
                                        final int row, final int column); static void checkRowIndex(final AnyMatrix m, final int row); static void checkColumnIndex(final AnyMatrix m, final int column); static void checkSubMatrixIndex(final AnyMatrix m,
                                           final int startRow, final int endRow,
                                           final int startColumn, final int endColumn); static void checkSubMatrixIndex(final AnyMatrix m,
                                           final int[] selectedRows,
                                           final int[] selectedColumns); static void checkAdditionCompatible(final AnyMatrix left, final AnyMatrix right); static void checkSubtractionCompatible(final AnyMatrix left, final AnyMatrix right); static void checkMultiplicationCompatible(final AnyMatrix left, final AnyMatrix right); static Array2DRowRealMatrix fractionMatrixToRealMatrix(final FieldMatrix<Fraction> m); static Array2DRowRealMatrix bigFractionMatrixToRealMatrix(final FieldMatrix<BigFraction> m); static void serializeRealVector(final RealVector vector,
                                           final ObjectOutputStream oos); static void deserializeRealVector(final Object instance,
                                             final String fieldName,
                                             final ObjectInputStream ois); static void serializeRealMatrix(final RealMatrix matrix,
                                           final ObjectOutputStream oos); static void deserializeRealMatrix(final Object instance,
                                             final String fieldName,
                                             final ObjectInputStream ois); static void solveLowerTriangularSystem(RealMatrix rm, RealVector b); static void solveUpperTriangularSystem(RealMatrix rm, RealVector b); static RealMatrix blockInverse(RealMatrix m,
                                          int splitIndex); static RealMatrix inverse(RealMatrix matrix); static RealMatrix inverse(RealMatrix matrix, double threshold); static final RealMatrixFormat DEFAULT_FORMAT; static final RealMatrixFormat OCTAVE_FORMAT; }
@Test public void testCreateIdentityMatrix() { checkIdentityMatrix(MatrixUtils.createRealIdentityMatrix(3)); checkIdentityMatrix(MatrixUtils.createRealIdentityMatrix(2)); checkIdentityMatrix(MatrixUtils.createRealIdentityMatrix(1)); try { MatrixUtils.createRealIdentityMatrix(0); Assert.fail("Expecting MathIllegalArgumentException"); } catch (MathIllegalArgumentException ex) { } }