Java Code Examples for org.apache.commons.math3.exception.util.LocalizedFormats#AT_LEAST_ONE_ROW
The following examples show how to use
org.apache.commons.math3.exception.util.LocalizedFormats#AT_LEAST_ONE_ROW .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Array2DRowFieldMatrix.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Create a new {@code FieldMatrix<T>} using the input array as the underlying * data array. * <p>If an array is built specially in order to be embedded in a * {@code FieldMatrix<T>} and not used directly, the {@code copyArray} may be * set to {@code false}. This will prevent the copying and improve * performance as no new array will be built and no data will be copied.</p> * * @param field Field to which the elements belong. * @param d Data for the new matrix. * @param copyArray Whether to copy or reference the input array. * @throws DimensionMismatchException if {@code d} is not rectangular. * @throws NoDataException if there are not at least one row and one column. * @throws NullArgumentException if {@code d} is {@code null}. * @see #Array2DRowFieldMatrix(FieldElement[][]) */ public Array2DRowFieldMatrix(final Field<T> field, final T[][] d, final boolean copyArray) throws DimensionMismatchException, NoDataException, NullArgumentException { super(field); if (copyArray) { copyIn(d); } else { MathUtils.checkNotNull(d); final int nRows = d.length; if (nRows == 0) { throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_ROW); } final int nCols = d[0].length; if (nCols == 0) { throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_COLUMN); } for (int r = 1; r < nRows; r++) { if (d[r].length != nCols) { throw new DimensionMismatchException(nCols, d[r].length); } } data = d; } }
Example 2
Source File: Array2DRowRealMatrix.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Create a new RealMatrix using the input array as the underlying * data array. * If an array is built specially in order to be embedded in a * RealMatrix and not used directly, the {@code copyArray} may be * set to {@code false}. This will prevent the copying and improve * performance as no new array will be built and no data will be copied. * * @param d Data for new matrix. * @param copyArray if {@code true}, the input array will be copied, * otherwise it will be referenced. * @throws DimensionMismatchException if {@code d} is not rectangular. * @throws NoDataException if {@code d} row or column dimension is zero. * @throws NullArgumentException if {@code d} is {@code null}. * @see #Array2DRowRealMatrix(double[][]) */ public Array2DRowRealMatrix(final double[][] d, final boolean copyArray) throws DimensionMismatchException, NoDataException, NullArgumentException { if (copyArray) { copyIn(d); } else { if (d == null) { throw new NullArgumentException(); } final int nRows = d.length; if (nRows == 0) { throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_ROW); } final int nCols = d[0].length; if (nCols == 0) { throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_COLUMN); } for (int r = 1; r < nRows; r++) { if (d[r].length != nCols) { throw new DimensionMismatchException(d[r].length, nCols); } } data = d; } }
Example 3
Source File: MatrixUtils.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Creates a column {@link FieldMatrix} using the data from the input * array. * * @param <T> the type of the field elements * @param columnData the input column data * @return a columnData x 1 FieldMatrix * @throws NoDataException if {@code data} is empty. * @throws NullArgumentException if {@code columnData} is {@code null}. */ public static <T extends FieldElement<T>> FieldMatrix<T> createColumnFieldMatrix(final T[] columnData) throws NoDataException, NullArgumentException { if (columnData == null) { throw new NullArgumentException(); } final int nRows = columnData.length; if (nRows == 0) { throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_ROW); } final FieldMatrix<T> m = createFieldMatrix(columnData[0].getField(), nRows, 1); for (int i = 0; i < nRows; ++i) { m.setEntry(i, 0, columnData[i]); } return m; }
Example 4
Source File: MatrixUtils.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Creates a column {@link FieldMatrix} using the data from the input * array. * * @param <T> the type of the field elements * @param columnData the input column data * @return a columnData x 1 FieldMatrix * @throws NoDataException if {@code data} is empty. * @throws NullArgumentException if {@code columnData} is {@code null}. */ public static <T extends FieldElement<T>> FieldMatrix<T> createColumnFieldMatrix(final T[] columnData) { if (columnData == null) { throw new NullArgumentException(); } final int nRows = columnData.length; if (nRows == 0) { throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_ROW); } final FieldMatrix<T> m = createFieldMatrix(columnData[0].getField(), nRows, 1); for (int i = 0; i < nRows; ++i) { m.setEntry(i, 0, columnData[i]); } return m; }
Example 5
Source File: Array2DRowFieldMatrix.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Create a new {@code FieldMatrix<T>} using the input array as the underlying * data array. * <p>If an array is built specially in order to be embedded in a * {@code FieldMatrix<T>} and not used directly, the {@code copyArray} may be * set to {@code false}. This will prevent the copying and improve * performance as no new array will be built and no data will be copied.</p> * * @param field Field to which the elements belong. * @param d Data for the new matrix. * @param copyArray Whether to copy or reference the input array. * @throws DimensionMismatchException if {@code d} is not rectangular. * @throws NoDataException if there are not at least one row and one column. * @throws NullArgumentException if {@code d} is {@code null}. * @see #Array2DRowFieldMatrix(FieldElement[][]) */ public Array2DRowFieldMatrix(final Field<T> field, final T[][] d, final boolean copyArray) throws DimensionMismatchException, NoDataException, NullArgumentException { super(field); if (copyArray) { copyIn(d); } else { MathUtils.checkNotNull(d); final int nRows = d.length; if (nRows == 0) { throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_ROW); } final int nCols = d[0].length; if (nCols == 0) { throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_COLUMN); } for (int r = 1; r < nRows; r++) { if (d[r].length != nCols) { throw new DimensionMismatchException(nCols, d[r].length); } } data = d; } }
Example 6
Source File: MatrixUtils.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Creates a column {@link FieldMatrix} using the data from the input * array. * * @param <T> the type of the field elements * @param columnData the input column data * @return a columnData x 1 FieldMatrix * @throws NoDataException if {@code data} is empty. * @throws NullArgumentException if {@code columnData} is {@code null}. */ public static <T extends FieldElement<T>> FieldMatrix<T> createColumnFieldMatrix(final T[] columnData) { if (columnData == null) { throw new NullArgumentException(); } final int nRows = columnData.length; if (nRows == 0) { throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_ROW); } final FieldMatrix<T> m = createFieldMatrix(columnData[0].getField(), nRows, 1); for (int i = 0; i < nRows; ++i) { m.setEntry(i, 0, columnData[i]); } return m; }
Example 7
Source File: Array2DRowRealMatrix.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Create a new RealMatrix using the input array as the underlying * data array. * If an array is built specially in order to be embedded in a * RealMatrix and not used directly, the {@code copyArray} may be * set to {@code false}. This will prevent the copying and improve * performance as no new array will be built and no data will be copied. * * @param d Data for new matrix. * @param copyArray if {@code true}, the input array will be copied, * otherwise it will be referenced. * @throws DimensionMismatchException if {@code d} is not rectangular. * @throws NoDataException if {@code d} row or column dimension is zero. * @throws NullArgumentException if {@code d} is {@code null}. * @see #Array2DRowRealMatrix(double[][]) */ public Array2DRowRealMatrix(final double[][] d, final boolean copyArray) throws DimensionMismatchException, NoDataException, NullArgumentException { if (copyArray) { copyIn(d); } else { if (d == null) { throw new NullArgumentException(); } final int nRows = d.length; if (nRows == 0) { throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_ROW); } final int nCols = d[0].length; if (nCols == 0) { throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_COLUMN); } for (int r = 1; r < nRows; r++) { if (d[r].length != nCols) { throw new DimensionMismatchException(d[r].length, nCols); } } data = d; } }
Example 8
Source File: AbstractFieldMatrix.java From astor with GNU General Public License v2.0 | 5 votes |
/** {@inheritDoc} */ public void setSubMatrix(final T[][] subMatrix, final int row, final int column) throws DimensionMismatchException, OutOfRangeException, NoDataException, NullArgumentException { if (subMatrix == null) { throw new NullArgumentException(); } final int nRows = subMatrix.length; if (nRows == 0) { throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_ROW); } final int nCols = subMatrix[0].length; if (nCols == 0) { throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_COLUMN); } for (int r = 1; r < nRows; ++r) { if (subMatrix[r].length != nCols) { throw new DimensionMismatchException(nCols, subMatrix[r].length); } } checkRowIndex(row); checkColumnIndex(column); checkRowIndex(nRows + row - 1); checkColumnIndex(nCols + column - 1); for (int i = 0; i < nRows; ++i) { for (int j = 0; j < nCols; ++j) { setEntry(row + i, column + j, subMatrix[i][j]); } } }
Example 9
Source File: AbstractFieldMatrix.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Get the elements type from an array. * * @param <T> Type of the field elements. * @param d Data array. * @return the field to which the array elements belong. * @throws NullArgumentException if the array is {@code null}. * @throws NoDataException if the array is empty. */ protected static <T extends FieldElement<T>> Field<T> extractField(final T[][] d) throws NoDataException, NullArgumentException { if (d == null) { throw new NullArgumentException(); } if (d.length == 0) { throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_ROW); } if (d[0].length == 0) { throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_COLUMN); } return d[0][0].getField(); }
Example 10
Source File: AbstractRealMatrix.java From astor with GNU General Public License v2.0 | 5 votes |
/** {@inheritDoc} */ public void setSubMatrix(final double[][] subMatrix, final int row, final int column) throws NoDataException, OutOfRangeException, DimensionMismatchException, NullArgumentException { MathUtils.checkNotNull(subMatrix); final int nRows = subMatrix.length; if (nRows == 0) { throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_ROW); } final int nCols = subMatrix[0].length; if (nCols == 0) { throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_COLUMN); } for (int r = 1; r < nRows; ++r) { if (subMatrix[r].length != nCols) { throw new DimensionMismatchException(nCols, subMatrix[r].length); } } MatrixUtils.checkRowIndex(this, row); MatrixUtils.checkColumnIndex(this, column); MatrixUtils.checkRowIndex(this, nRows + row - 1); MatrixUtils.checkColumnIndex(this, nCols + column - 1); for (int i = 0; i < nRows; ++i) { for (int j = 0; j < nCols; ++j) { setEntry(row + i, column + j, subMatrix[i][j]); } } }
Example 11
Source File: AbstractFieldMatrix.java From astor with GNU General Public License v2.0 | 5 votes |
/** * {@inheritDoc} * */ public void setSubMatrix(final T[][] subMatrix, final int row, final int column) throws DimensionMismatchException, NoDataException, NullArgumentException, OutOfRangeException { if (subMatrix == null) { throw new NullArgumentException(); } final int nRows = subMatrix.length; if (nRows == 0) { throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_ROW); } final int nCols = subMatrix[0].length; if (nCols == 0) { throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_COLUMN); } for (int r = 1; r < nRows; ++r) { if (subMatrix[r].length != nCols) { throw new DimensionMismatchException(nCols, subMatrix[r].length); } } checkRowIndex(row); checkColumnIndex(column); checkRowIndex(nRows + row - 1); checkColumnIndex(nCols + column - 1); for (int i = 0; i < nRows; ++i) { for (int j = 0; j < nCols; ++j) { setEntry(row + i, column + j, subMatrix[i][j]); } } }
Example 12
Source File: Array2DRowRealMatrix.java From astor with GNU General Public License v2.0 | 5 votes |
/** {@inheritDoc} */ @Override public void setSubMatrix(final double[][] subMatrix, final int row, final int column) throws NoDataException, OutOfRangeException, DimensionMismatchException, NullArgumentException { if (data == null) { if (row > 0) { throw new MathIllegalStateException(LocalizedFormats.FIRST_ROWS_NOT_INITIALIZED_YET, row); } if (column > 0) { throw new MathIllegalStateException(LocalizedFormats.FIRST_COLUMNS_NOT_INITIALIZED_YET, column); } MathUtils.checkNotNull(subMatrix); final int nRows = subMatrix.length; if (nRows == 0) { throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_ROW); } final int nCols = subMatrix[0].length; if (nCols == 0) { throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_COLUMN); } data = new double[subMatrix.length][nCols]; for (int i = 0; i < data.length; ++i) { if (subMatrix[i].length != nCols) { throw new DimensionMismatchException(subMatrix[i].length, nCols); } System.arraycopy(subMatrix[i], 0, data[i + row], column, nCols); } } else { super.setSubMatrix(subMatrix, row, column); } }
Example 13
Source File: AbstractRealMatrix.java From astor with GNU General Public License v2.0 | 5 votes |
/** {@inheritDoc} */ public void setSubMatrix(final double[][] subMatrix, final int row, final int column) throws NoDataException, DimensionMismatchException, NullArgumentException { MathUtils.checkNotNull(subMatrix); final int nRows = subMatrix.length; if (nRows == 0) { throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_ROW); } final int nCols = subMatrix[0].length; if (nCols == 0) { throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_COLUMN); } for (int r = 1; r < nRows; ++r) { if (subMatrix[r].length != nCols) { throw new DimensionMismatchException(nCols, subMatrix[r].length); } } MatrixUtils.checkRowIndex(this, row); MatrixUtils.checkColumnIndex(this, column); MatrixUtils.checkRowIndex(this, nRows + row - 1); MatrixUtils.checkColumnIndex(this, nCols + column - 1); for (int i = 0; i < nRows; ++i) { for (int j = 0; j < nCols; ++j) { setEntry(row + i, column + j, subMatrix[i][j]); } } }
Example 14
Source File: Array2DRowFieldMatrix.java From astor with GNU General Public License v2.0 | 5 votes |
/** {@inheritDoc} */ @Override public void setSubMatrix(final T[][] subMatrix, final int row, final int column) { if (data == null) { if (row > 0) { throw new MathIllegalStateException(LocalizedFormats.FIRST_ROWS_NOT_INITIALIZED_YET, row); } if (column > 0) { throw new MathIllegalStateException(LocalizedFormats.FIRST_COLUMNS_NOT_INITIALIZED_YET, column); } final int nRows = subMatrix.length; if (nRows == 0) { throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_ROW); } final int nCols = subMatrix[0].length; if (nCols == 0) { throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_COLUMN); } data = buildArray(getField(), subMatrix.length, nCols); for (int i = 0; i < data.length; ++i) { if (subMatrix[i].length != nCols) { throw new DimensionMismatchException(nCols, subMatrix[i].length); } System.arraycopy(subMatrix[i], 0, data[i + row], column, nCols); } } else { super.setSubMatrix(subMatrix, row, column); } }
Example 15
Source File: AbstractRealMatrix.java From astor with GNU General Public License v2.0 | 5 votes |
/** {@inheritDoc} */ public void setSubMatrix(final double[][] subMatrix, final int row, final int column) throws NoDataException, OutOfRangeException, DimensionMismatchException, NullArgumentException { MathUtils.checkNotNull(subMatrix); final int nRows = subMatrix.length; if (nRows == 0) { throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_ROW); } final int nCols = subMatrix[0].length; if (nCols == 0) { throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_COLUMN); } for (int r = 1; r < nRows; ++r) { if (subMatrix[r].length != nCols) { throw new DimensionMismatchException(nCols, subMatrix[r].length); } } MatrixUtils.checkRowIndex(this, row); MatrixUtils.checkColumnIndex(this, column); MatrixUtils.checkRowIndex(this, nRows + row - 1); MatrixUtils.checkColumnIndex(this, nCols + column - 1); for (int i = 0; i < nRows; ++i) { for (int j = 0; j < nCols; ++j) { setEntry(row + i, column + j, subMatrix[i][j]); } } }
Example 16
Source File: AbstractFieldMatrix.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Get the elements type from an array. * * @param <T> Type of the field elements. * @param d Data array. * @return the field to which the array elements belong. * @throws NullArgumentException if the array is {@code null}. * @throws NoDataException if the array is empty. */ protected static <T extends FieldElement<T>> Field<T> extractField(final T[][] d) throws NoDataException, NullArgumentException { if (d == null) { throw new NullArgumentException(); } if (d.length == 0) { throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_ROW); } if (d[0].length == 0) { throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_COLUMN); } return d[0][0].getField(); }
Example 17
Source File: Array2DRowRealMatrix.java From astor with GNU General Public License v2.0 | 5 votes |
/** {@inheritDoc} */ @Override public void setSubMatrix(final double[][] subMatrix, final int row, final int column) throws NoDataException, OutOfRangeException, DimensionMismatchException, NullArgumentException { if (data == null) { if (row > 0) { throw new MathIllegalStateException(LocalizedFormats.FIRST_ROWS_NOT_INITIALIZED_YET, row); } if (column > 0) { throw new MathIllegalStateException(LocalizedFormats.FIRST_COLUMNS_NOT_INITIALIZED_YET, column); } MathUtils.checkNotNull(subMatrix); final int nRows = subMatrix.length; if (nRows == 0) { throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_ROW); } final int nCols = subMatrix[0].length; if (nCols == 0) { throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_COLUMN); } data = new double[subMatrix.length][nCols]; for (int i = 0; i < data.length; ++i) { if (subMatrix[i].length != nCols) { throw new DimensionMismatchException(subMatrix[i].length, nCols); } System.arraycopy(subMatrix[i], 0, data[i + row], column, nCols); } } else { super.setSubMatrix(subMatrix, row, column); } }
Example 18
Source File: AbstractFieldMatrix.java From astor with GNU General Public License v2.0 | 3 votes |
/** * Get the elements type from an array. * * @param <T> Type of the field elements. * @param d Data array. * @return the field to which the array elements belong. * @throws NoDataException if array is empty. */ protected static <T extends FieldElement<T>> Field<T> extractField(final T[] d) { if (d.length == 0) { throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_ROW); } return d[0].getField(); }
Example 19
Source File: AbstractFieldMatrix.java From astor with GNU General Public License v2.0 | 3 votes |
/** * Get the elements type from an array. * * @param <T> Type of the field elements. * @param d Data array. * @return the field to which the array elements belong. * @throws NoDataException if array is empty. */ protected static <T extends FieldElement<T>> Field<T> extractField(final T[] d) throws NoDataException { if (d.length == 0) { throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_ROW); } return d[0].getField(); }
Example 20
Source File: AbstractFieldMatrix.java From astor with GNU General Public License v2.0 | 3 votes |
/** * Get the elements type from an array. * * @param <T> Type of the field elements. * @param d Data array. * @return the field to which the array elements belong. * @throws NoDataException if array is empty. */ protected static <T extends FieldElement<T>> Field<T> extractField(final T[] d) throws NoDataException { if (d.length == 0) { throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_ROW); } return d[0].getField(); }