MATH-854: populated throws clause of Array2DRowFieldMatrix.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1392748 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
72051d7f6d
commit
bb0827cc81
|
@ -175,7 +175,9 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>>
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public abstract FieldMatrix<T> createMatrix(final int rowDimension, final int columnDimension);
|
||||
public abstract FieldMatrix<T> createMatrix(final int rowDimension,
|
||||
final int columnDimension)
|
||||
throws NotStrictlyPositiveException;
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public abstract FieldMatrix<T> copy();
|
||||
|
@ -656,16 +658,16 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>>
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public abstract T getEntry(int row, int column);
|
||||
public abstract T getEntry(int row, int column) throws OutOfRangeException;
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public abstract void setEntry(int row, int column, T value);
|
||||
public abstract void setEntry(int row, int column, T value) throws OutOfRangeException;
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public abstract void addToEntry(int row, int column, T increment);
|
||||
public abstract void addToEntry(int row, int column, T increment) throws OutOfRangeException;
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public abstract void multiplyEntry(int row, int column, T factor);
|
||||
public abstract void multiplyEntry(int row, int column, T factor) throws OutOfRangeException;
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public FieldMatrix<T> transpose() {
|
||||
|
|
|
@ -24,7 +24,10 @@ import org.apache.commons.math3.FieldElement;
|
|||
import org.apache.commons.math3.exception.NoDataException;
|
||||
import org.apache.commons.math3.exception.DimensionMismatchException;
|
||||
import org.apache.commons.math3.exception.MathIllegalStateException;
|
||||
import org.apache.commons.math3.exception.NotStrictlyPositiveException;
|
||||
import org.apache.commons.math3.exception.NullArgumentException;
|
||||
import org.apache.commons.math3.exception.NumberIsTooSmallException;
|
||||
import org.apache.commons.math3.exception.OutOfRangeException;
|
||||
import org.apache.commons.math3.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.math3.util.MathUtils;
|
||||
|
||||
|
@ -61,12 +64,11 @@ public class Array2DRowFieldMatrix<T extends FieldElement<T>>
|
|||
* @param field Field to which the elements belong.
|
||||
* @param rowDimension Number of rows in the new matrix.
|
||||
* @param columnDimension Number of columns in the new matrix.
|
||||
* @throws org.apache.commons.math3.exception.NotStrictlyPositiveException
|
||||
* if row or column dimension is not positive.
|
||||
* @throws NotStrictlyPositiveException if row or column dimension is not positive.
|
||||
*/
|
||||
public Array2DRowFieldMatrix(final Field<T> field,
|
||||
final int rowDimension,
|
||||
final int columnDimension) {
|
||||
public Array2DRowFieldMatrix(final Field<T> field, final int rowDimension,
|
||||
final int columnDimension)
|
||||
throws NotStrictlyPositiveException {
|
||||
super(field, rowDimension, columnDimension);
|
||||
data = buildArray(field, rowDimension, columnDimension);
|
||||
}
|
||||
|
@ -80,12 +82,13 @@ public class Array2DRowFieldMatrix<T extends FieldElement<T>>
|
|||
*
|
||||
* @param d Data for the new matrix.
|
||||
* @throws DimensionMismatchException if {@code d} is not rectangular.
|
||||
* @throws org.apache.commons.math3.exception.NullArgumentException if
|
||||
* {@code d} is {@code null}.
|
||||
* @throws NullArgumentException if {@code d} is {@code null}.
|
||||
* @throws NoDataException if there are not at least one row and one column.
|
||||
* @see #Array2DRowFieldMatrix(FieldElement[][], boolean)
|
||||
*/
|
||||
public Array2DRowFieldMatrix(final T[][] d) {
|
||||
public Array2DRowFieldMatrix(final T[][] d)
|
||||
throws DimensionMismatchException, NullArgumentException,
|
||||
NoDataException {
|
||||
this(extractField(d), d);
|
||||
}
|
||||
|
||||
|
@ -99,12 +102,13 @@ public class Array2DRowFieldMatrix<T extends FieldElement<T>>
|
|||
* @param field Field to which the elements belong.
|
||||
* @param d Data for the new matrix.
|
||||
* @throws DimensionMismatchException if {@code d} is not rectangular.
|
||||
* @throws org.apache.commons.math3.exception.NullArgumentException if
|
||||
* {@code d} is {@code null}.
|
||||
* @throws NullArgumentException if {@code d} is {@code null}.
|
||||
* @throws NoDataException if there are not at least one row and one column.
|
||||
* @see #Array2DRowFieldMatrix(FieldElement[][], boolean)
|
||||
*/
|
||||
public Array2DRowFieldMatrix(final Field<T> field, final T[][] d) {
|
||||
public Array2DRowFieldMatrix(final Field<T> field, final T[][] d)
|
||||
throws DimensionMismatchException, NullArgumentException,
|
||||
NoDataException {
|
||||
super(field);
|
||||
copyIn(d);
|
||||
}
|
||||
|
@ -121,11 +125,12 @@ public class Array2DRowFieldMatrix<T extends FieldElement<T>>
|
|||
* @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 org.apache.commons.math3.exception.NullArgumentException
|
||||
* if {@code d} is {@code null}.
|
||||
* @throws NullArgumentException if {@code d} is {@code null}.
|
||||
* @see #Array2DRowFieldMatrix(FieldElement[][])
|
||||
*/
|
||||
public Array2DRowFieldMatrix(final T[][] d, final boolean copyArray) {
|
||||
public Array2DRowFieldMatrix(final T[][] d, final boolean copyArray)
|
||||
throws DimensionMismatchException, NoDataException,
|
||||
NullArgumentException {
|
||||
this(extractField(d), d, copyArray);
|
||||
}
|
||||
|
||||
|
@ -175,8 +180,9 @@ public class Array2DRowFieldMatrix<T extends FieldElement<T>>
|
|||
* The input array is copied.
|
||||
*
|
||||
* @param v Column vector holding data for new matrix.
|
||||
* @throws NoDataException if v is empty
|
||||
*/
|
||||
public Array2DRowFieldMatrix(final T[] v) {
|
||||
public Array2DRowFieldMatrix(final T[] v) throws NoDataException {
|
||||
this(extractField(v), v);
|
||||
}
|
||||
|
||||
|
@ -199,7 +205,9 @@ public class Array2DRowFieldMatrix<T extends FieldElement<T>>
|
|||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldMatrix<T> createMatrix(final int rowDimension, final int columnDimension) {
|
||||
public FieldMatrix<T> createMatrix(final int rowDimension,
|
||||
final int columnDimension)
|
||||
throws NotStrictlyPositiveException {
|
||||
return new Array2DRowFieldMatrix<T>(getField(), rowDimension, columnDimension);
|
||||
}
|
||||
|
||||
|
@ -214,10 +222,11 @@ public class Array2DRowFieldMatrix<T extends FieldElement<T>>
|
|||
*
|
||||
* @param m Matrix to be added.
|
||||
* @return {@code this} + m.
|
||||
* @throws MatrixDimensionMismatchException
|
||||
* if {@code m} is not the same size as this matrix.
|
||||
* @throws MatrixDimensionMismatchException if {@code m} is not the same
|
||||
* size as this matrix.
|
||||
*/
|
||||
public Array2DRowFieldMatrix<T> add(final Array2DRowFieldMatrix<T> m) {
|
||||
public Array2DRowFieldMatrix<T> add(final Array2DRowFieldMatrix<T> m)
|
||||
throws MatrixDimensionMismatchException {
|
||||
// safety check
|
||||
checkAdditionCompatible(m);
|
||||
|
||||
|
@ -241,10 +250,11 @@ public class Array2DRowFieldMatrix<T extends FieldElement<T>>
|
|||
*
|
||||
* @param m Matrix to be subtracted.
|
||||
* @return {@code this} + m.
|
||||
* @throws MatrixDimensionMismatchException
|
||||
* if {@code m} is not the same size as this matrix.
|
||||
* @throws MatrixDimensionMismatchException if {@code m} is not the same
|
||||
* size as this matrix.
|
||||
*/
|
||||
public Array2DRowFieldMatrix<T> subtract(final Array2DRowFieldMatrix<T> m) {
|
||||
public Array2DRowFieldMatrix<T> subtract(final Array2DRowFieldMatrix<T> m)
|
||||
throws MatrixDimensionMismatchException {
|
||||
// safety check
|
||||
checkSubtractionCompatible(m);
|
||||
|
||||
|
@ -272,7 +282,8 @@ public class Array2DRowFieldMatrix<T extends FieldElement<T>>
|
|||
* @throws DimensionMismatchException if the number of columns of this
|
||||
* matrix is not equal to the number of rows of {@code m}.
|
||||
*/
|
||||
public Array2DRowFieldMatrix<T> multiply(final Array2DRowFieldMatrix<T> m) {
|
||||
public Array2DRowFieldMatrix<T> multiply(final Array2DRowFieldMatrix<T> m)
|
||||
throws DimensionMismatchException {
|
||||
// safety check
|
||||
checkMultiplicationCompatible(m);
|
||||
|
||||
|
@ -314,7 +325,10 @@ public class Array2DRowFieldMatrix<T extends FieldElement<T>>
|
|||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void setSubMatrix(final T[][] subMatrix, final int row, final int column) {
|
||||
public void setSubMatrix(final T[][] subMatrix, final int row,
|
||||
final int column)
|
||||
throws OutOfRangeException, NullArgumentException, NoDataException,
|
||||
DimensionMismatchException {
|
||||
if (data == null) {
|
||||
if (row > 0) {
|
||||
throw new MathIllegalStateException(LocalizedFormats.FIRST_ROWS_NOT_INITIALIZED_YET, row);
|
||||
|
@ -346,7 +360,8 @@ public class Array2DRowFieldMatrix<T extends FieldElement<T>>
|
|||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public T getEntry(final int row, final int column) {
|
||||
public T getEntry(final int row, final int column)
|
||||
throws OutOfRangeException {
|
||||
checkRowIndex(row);
|
||||
checkColumnIndex(column);
|
||||
|
||||
|
@ -355,7 +370,8 @@ public class Array2DRowFieldMatrix<T extends FieldElement<T>>
|
|||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void setEntry(final int row, final int column, final T value) {
|
||||
public void setEntry(final int row, final int column, final T value)
|
||||
throws OutOfRangeException {
|
||||
checkRowIndex(row);
|
||||
checkColumnIndex(column);
|
||||
|
||||
|
@ -364,7 +380,8 @@ public class Array2DRowFieldMatrix<T extends FieldElement<T>>
|
|||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void addToEntry(final int row, final int column, final T increment) {
|
||||
public void addToEntry(final int row, final int column, final T increment)
|
||||
throws OutOfRangeException {
|
||||
checkRowIndex(row);
|
||||
checkColumnIndex(column);
|
||||
|
||||
|
@ -373,7 +390,8 @@ public class Array2DRowFieldMatrix<T extends FieldElement<T>>
|
|||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void multiplyEntry(final int row, final int column, final T factor) {
|
||||
public void multiplyEntry(final int row, final int column, final T factor)
|
||||
throws OutOfRangeException {
|
||||
checkRowIndex(row);
|
||||
checkColumnIndex(column);
|
||||
|
||||
|
@ -394,7 +412,7 @@ public class Array2DRowFieldMatrix<T extends FieldElement<T>>
|
|||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public T[] operate(final T[] v) {
|
||||
public T[] operate(final T[] v) throws DimensionMismatchException {
|
||||
final int nRows = this.getRowDimension();
|
||||
final int nCols = this.getColumnDimension();
|
||||
if (v.length != nCols) {
|
||||
|
@ -414,7 +432,7 @@ public class Array2DRowFieldMatrix<T extends FieldElement<T>>
|
|||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public T[] preMultiply(final T[] v) {
|
||||
public T[] preMultiply(final T[] v) throws DimensionMismatchException {
|
||||
final int nRows = getRowDimension();
|
||||
final int nCols = getColumnDimension();
|
||||
if (v.length != nRows) {
|
||||
|
@ -467,7 +485,8 @@ public class Array2DRowFieldMatrix<T extends FieldElement<T>>
|
|||
@Override
|
||||
public T walkInRowOrder(final FieldMatrixChangingVisitor<T> visitor,
|
||||
final int startRow, final int endRow,
|
||||
final int startColumn, final int endColumn) {
|
||||
final int startColumn, final int endColumn)
|
||||
throws OutOfRangeException, NumberIsTooSmallException {
|
||||
checkSubMatrixIndex(startRow, endRow, startColumn, endColumn);
|
||||
visitor.start(getRowDimension(), getColumnDimension(),
|
||||
startRow, endRow, startColumn, endColumn);
|
||||
|
@ -484,7 +503,8 @@ public class Array2DRowFieldMatrix<T extends FieldElement<T>>
|
|||
@Override
|
||||
public T walkInRowOrder(final FieldMatrixPreservingVisitor<T> visitor,
|
||||
final int startRow, final int endRow,
|
||||
final int startColumn, final int endColumn) {
|
||||
final int startColumn, final int endColumn)
|
||||
throws OutOfRangeException, NumberIsTooSmallException {
|
||||
checkSubMatrixIndex(startRow, endRow, startColumn, endColumn);
|
||||
visitor.start(getRowDimension(), getColumnDimension(),
|
||||
startRow, endRow, startColumn, endColumn);
|
||||
|
@ -530,8 +550,9 @@ public class Array2DRowFieldMatrix<T extends FieldElement<T>>
|
|||
@Override
|
||||
public T walkInColumnOrder(final FieldMatrixChangingVisitor<T> visitor,
|
||||
final int startRow, final int endRow,
|
||||
final int startColumn, final int endColumn) {
|
||||
checkSubMatrixIndex(startRow, endRow, startColumn, endColumn);
|
||||
final int startColumn, final int endColumn)
|
||||
throws OutOfRangeException, NumberIsTooSmallException {
|
||||
checkSubMatrixIndex(startRow, endRow, startColumn, endColumn);
|
||||
visitor.start(getRowDimension(), getColumnDimension(),
|
||||
startRow, endRow, startColumn, endColumn);
|
||||
for (int j = startColumn; j <= endColumn; ++j) {
|
||||
|
@ -547,7 +568,8 @@ public class Array2DRowFieldMatrix<T extends FieldElement<T>>
|
|||
@Override
|
||||
public T walkInColumnOrder(final FieldMatrixPreservingVisitor<T> visitor,
|
||||
final int startRow, final int endRow,
|
||||
final int startColumn, final int endColumn) {
|
||||
final int startColumn, final int endColumn)
|
||||
throws OutOfRangeException, NumberIsTooSmallException {
|
||||
checkSubMatrixIndex(startRow, endRow, startColumn, endColumn);
|
||||
visitor.start(getRowDimension(), getColumnDimension(),
|
||||
startRow, endRow, startColumn, endColumn);
|
||||
|
@ -580,10 +602,11 @@ public class Array2DRowFieldMatrix<T extends FieldElement<T>>
|
|||
* @param in Data to copy.
|
||||
* @throws NoDataException if the input array is empty.
|
||||
* @throws DimensionMismatchException if the input array is not rectangular.
|
||||
* @throws org.apache.commons.math3.exception.NullArgumentException if
|
||||
* the input array is {@code null}.
|
||||
* @throws NullArgumentException if the input array is {@code null}.
|
||||
*/
|
||||
private void copyIn(final T[][] in) {
|
||||
private void copyIn(final T[][] in)
|
||||
throws NullArgumentException, NoDataException,
|
||||
DimensionMismatchException {
|
||||
setSubMatrix(in, 0, 0);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue