MatrixUtils { public static <T extends FieldElement<T>> FieldMatrix<T> createRowFieldMatrix(final T[] rowData) throws NoDataException, NullArgumentException { if (rowData == null) { throw new NullArgumentException(); } final int nCols = rowData.length; if (nCols == 0) { throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_COLUMN); } final FieldMatrix<T> m = createFieldMatrix(rowData[0].getField(), 1, nCols); for (int i = 0; i < nCols; ++i) { m.setEntry(0, i, rowData[i]); } 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 testCreateRowFieldMatrix() { Assert.assertEquals(MatrixUtils.createRowFieldMatrix(asFraction(row)), new Array2DRowFieldMatrix<Fraction>(asFraction(rowMatrix))); Assert.assertEquals(MatrixUtils.createRowFieldMatrix(fractionRow), new Array2DRowFieldMatrix<Fraction>(fractionRowMatrix)); try { MatrixUtils.createRowFieldMatrix(new Fraction[] {}); Assert.fail("Expecting MathIllegalArgumentException"); } catch (MathIllegalArgumentException ex) { } try { MatrixUtils.createRowFieldMatrix((Fraction[]) null); Assert.fail("Expecting NullArgumentException"); } catch (NullArgumentException ex) { } }