MatrixUtils { public static <T extends FieldElement<T>> FieldMatrix<T> createFieldMatrix(final Field<T> field, final int rows, final int columns) { return (rows * columns <= 4096) ? new Array2DRowFieldMatrix<T>(field, rows, columns) : new BlockFieldMatrix<T>(field, rows, columns); } 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 testcreateFieldMatrix() { Assert.assertEquals(new Array2DRowFieldMatrix<Fraction>(asFraction(testData)), MatrixUtils.createFieldMatrix(asFraction(testData))); Assert.assertEquals(new Array2DRowFieldMatrix<Fraction>(FractionField.getInstance(), fractionColMatrix), MatrixUtils.createFieldMatrix(fractionColMatrix)); try { MatrixUtils.createFieldMatrix(asFraction(new double[][] {{1}, {1,2}})); Assert.fail("Expecting MathIllegalArgumentException"); } catch (MathIllegalArgumentException ex) { } try { MatrixUtils.createFieldMatrix(asFraction(new double[][] {{}, {}})); Assert.fail("Expecting MathIllegalArgumentException"); } catch (MathIllegalArgumentException ex) { } try { MatrixUtils.createFieldMatrix((Fraction[][])null); Assert.fail("Expecting NullArgumentException"); } catch (NullArgumentException ex) { } }