You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ce...@apache.org on 2012/09/03 05:54:24 UTC

svn commit: r1380122 - in /commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear: AbstractFieldMatrix.java ConjugateGradient.java EigenDecomposition.java FieldMatrix.java MatrixUtils.java OpenMapRealVector.java RealVector.java

Author: celestin
Date: Mon Sep  3 03:54:23 2012
New Revision: 1380122

URL: http://svn.apache.org/viewvc?rev=1380122&view=rev
Log:
MATH-854: populate the throws clause in package o.a.c.m.linear.

Modified:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/AbstractFieldMatrix.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/ConjugateGradient.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/EigenDecomposition.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/FieldMatrix.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/MatrixUtils.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/OpenMapRealVector.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/RealVector.java

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/AbstractFieldMatrix.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/AbstractFieldMatrix.java?rev=1380122&r1=1380121&r2=1380122&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/AbstractFieldMatrix.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/AbstractFieldMatrix.java Mon Sep  3 03:54:23 2012
@@ -25,6 +25,7 @@ import org.apache.commons.math3.Field;
 import org.apache.commons.math3.FieldElement;
 import org.apache.commons.math3.exception.DimensionMismatchException;
 import org.apache.commons.math3.exception.NoDataException;
+import org.apache.commons.math3.exception.NotPositiveException;
 import org.apache.commons.math3.exception.OutOfRangeException;
 import org.apache.commons.math3.exception.NumberIsTooSmallException;
 import org.apache.commons.math3.exception.NotStrictlyPositiveException;
@@ -72,7 +73,8 @@ public abstract class AbstractFieldMatri
      */
     protected AbstractFieldMatrix(final Field<T> field,
                                   final int rowDimension,
-                                  final int columnDimension) {
+                                  final int columnDimension)
+        throws NotStrictlyPositiveException {
         if (rowDimension <= 0) {
             throw new NotStrictlyPositiveException(LocalizedFormats.DIMENSION,
                                                    rowDimension);
@@ -93,7 +95,8 @@ public abstract class AbstractFieldMatri
      * @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) {
+    protected static <T extends FieldElement<T>> Field<T> extractField(final T[][] d)
+        throws NoDataException, NullArgumentException {
         if (d == null) {
             throw new NullArgumentException();
         }
@@ -114,7 +117,8 @@ public abstract class AbstractFieldMatri
      * @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) {
+    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);
         }
@@ -177,7 +181,8 @@ public abstract class AbstractFieldMatri
     public abstract FieldMatrix<T> copy();
 
     /** {@inheritDoc} */
-    public FieldMatrix<T> add(FieldMatrix<T> m) {
+    public FieldMatrix<T> add(FieldMatrix<T> m)
+        throws MatrixDimensionMismatchException {
         // safety check
         checkAdditionCompatible(m);
 
@@ -194,7 +199,8 @@ public abstract class AbstractFieldMatri
     }
 
     /** {@inheritDoc} */
-    public FieldMatrix<T> subtract(final FieldMatrix<T> m) {
+    public FieldMatrix<T> subtract(final FieldMatrix<T> m)
+        throws MatrixDimensionMismatchException {
         // safety check
         checkSubtractionCompatible(m);
 
@@ -240,7 +246,8 @@ public abstract class AbstractFieldMatri
     }
 
     /** {@inheritDoc} */
-    public FieldMatrix<T> multiply(final FieldMatrix<T> m) {
+    public FieldMatrix<T> multiply(final FieldMatrix<T> m)
+        throws DimensionMismatchException {
         // safety check
         checkMultiplicationCompatible(m);
 
@@ -262,14 +269,16 @@ public abstract class AbstractFieldMatri
     }
 
     /** {@inheritDoc} */
-    public FieldMatrix<T> preMultiply(final FieldMatrix<T> m) {
+    public FieldMatrix<T> preMultiply(final FieldMatrix<T> m)
+        throws DimensionMismatchException {
         return m.multiply(this);
     }
 
     /** {@inheritDoc} */
-    public FieldMatrix<T> power(final int p) {
+    public FieldMatrix<T> power(final int p) throws NonSquareMatrixException,
+    NotPositiveException {
         if (p < 0) {
-            throw new IllegalArgumentException("p must be >= 0");
+            throw new NotPositiveException(p);
         }
 
         if (!isSquare()) {
@@ -340,7 +349,8 @@ public abstract class AbstractFieldMatri
 
     /** {@inheritDoc} */
     public FieldMatrix<T> getSubMatrix(final int startRow, final int endRow,
-                                       final int startColumn, final int endColumn) {
+                                       final int startColumn, final int endColumn)
+        throws NumberIsTooSmallException, OutOfRangeException {
         checkSubMatrixIndex(startRow, endRow, startColumn, endColumn);
 
         final FieldMatrix<T> subMatrix =
@@ -357,7 +367,8 @@ public abstract class AbstractFieldMatri
 
     /** {@inheritDoc} */
     public FieldMatrix<T> getSubMatrix(final int[] selectedRows,
-                                       final int[] selectedColumns) {
+                                       final int[] selectedColumns)
+    throws NoDataException, NullArgumentException, OutOfRangeException {
 
         // safety checks
         checkSubMatrixIndex(selectedRows, selectedColumns);
@@ -382,7 +393,9 @@ public abstract class AbstractFieldMatri
     /** {@inheritDoc} */
     public void copySubMatrix(final int startRow, final int endRow,
                               final int startColumn, final int endColumn,
-                              final T[][] destination) {
+                              final T[][] destination)
+    throws MatrixDimensionMismatchException, NumberIsTooSmallException,
+    OutOfRangeException{
         // safety checks
         checkSubMatrixIndex(startRow, endRow, startColumn, endColumn);
         final int rowsCount    = endRow + 1 - startRow;
@@ -423,7 +436,9 @@ public abstract class AbstractFieldMatri
     }
 
     /** {@inheritDoc} */
-    public void copySubMatrix(int[] selectedRows, int[] selectedColumns, T[][] destination) {
+    public void copySubMatrix(int[] selectedRows, int[] selectedColumns, T[][] destination)
+        throws MatrixDimensionMismatchException, NoDataException,
+        NullArgumentException, OutOfRangeException {
         // safety checks
         checkSubMatrixIndex(selectedRows, selectedColumns);
         if ((destination.length < selectedRows.length) ||
@@ -444,8 +459,13 @@ public abstract class AbstractFieldMatri
 
     }
 
-    /** {@inheritDoc} */
-    public void setSubMatrix(final T[][] subMatrix, final int row, final int column) {
+    /**
+     * {@inheritDoc}
+     *
+     */
+    public void setSubMatrix(final T[][] subMatrix, final int row, final int column)
+        throws DimensionMismatchException, NoDataException, NullArgumentException,
+        OutOfRangeException {
         if (subMatrix == null) {
             throw new NullArgumentException();
         }
@@ -478,7 +498,7 @@ public abstract class AbstractFieldMatri
     }
 
     /** {@inheritDoc} */
-    public FieldMatrix<T> getRowMatrix(final int row) {
+    public FieldMatrix<T> getRowMatrix(final int row) throws OutOfRangeException {
         checkRowIndex(row);
         final int nCols = getColumnDimension();
         final FieldMatrix<T> out = createMatrix(1, nCols);
@@ -491,7 +511,8 @@ public abstract class AbstractFieldMatri
     }
 
     /** {@inheritDoc} */
-    public void setRowMatrix(final int row, final FieldMatrix<T> matrix) {
+    public void setRowMatrix(final int row, final FieldMatrix<T> matrix)
+        throws OutOfRangeException {
         checkRowIndex(row);
         final int nCols = getColumnDimension();
         if ((matrix.getRowDimension() != 1) ||
@@ -507,7 +528,8 @@ public abstract class AbstractFieldMatri
     }
 
     /** {@inheritDoc} */
-    public FieldMatrix<T> getColumnMatrix(final int column) {
+    public FieldMatrix<T> getColumnMatrix(final int column)
+    throws OutOfRangeException {
 
         checkColumnIndex(column);
         final int nRows = getRowDimension();
@@ -521,7 +543,8 @@ public abstract class AbstractFieldMatri
     }
 
     /** {@inheritDoc} */
-    public void setColumnMatrix(final int column, final FieldMatrix<T> matrix) {
+    public void setColumnMatrix(final int column, final FieldMatrix<T> matrix)
+        throws OutOfRangeException {
         checkColumnIndex(column);
         final int nRows = getRowDimension();
         if ((matrix.getRowDimension() != nRows) ||
@@ -542,7 +565,8 @@ public abstract class AbstractFieldMatri
     }
 
     /** {@inheritDoc} */
-    public void setRowVector(final int row, final FieldVector<T> vector) {
+    public void setRowVector(final int row, final FieldVector<T> vector)
+        throws OutOfRangeException {
         checkRowIndex(row);
         final int nCols = getColumnDimension();
         if (vector.getDimension() != nCols) {
@@ -561,7 +585,9 @@ public abstract class AbstractFieldMatri
     }
 
     /** {@inheritDoc} */
-    public void setColumnVector(final int column, final FieldVector<T> vector) {
+    public void setColumnVector(final int column, final FieldVector<T> vector)
+        throws OutOfRangeException {
+
         checkColumnIndex(column);
         final int nRows = getRowDimension();
         if (vector.getDimension() != nRows) {
@@ -575,7 +601,7 @@ public abstract class AbstractFieldMatri
     }
 
     /** {@inheritDoc} */
-    public T[] getRow(final int row) {
+    public T[] getRow(final int row) throws OutOfRangeException {
         checkRowIndex(row);
         final int nCols = getColumnDimension();
         final T[] out = buildArray(field, nCols);
@@ -588,7 +614,7 @@ public abstract class AbstractFieldMatri
     }
 
     /** {@inheritDoc} */
-    public void setRow(final int row, final T[] array) {
+    public void setRow(final int row, final T[] array) throws OutOfRangeException {
         checkRowIndex(row);
         final int nCols = getColumnDimension();
         if (array.length != nCols) {
@@ -601,7 +627,7 @@ public abstract class AbstractFieldMatri
     }
 
     /** {@inheritDoc} */
-    public T[] getColumn(final int column) {
+    public T[] getColumn(final int column) throws OutOfRangeException {
         checkColumnIndex(column);
         final int nRows = getRowDimension();
         final T[] out = buildArray(field, nRows);
@@ -614,7 +640,8 @@ public abstract class AbstractFieldMatri
     }
 
     /** {@inheritDoc} */
-    public void setColumn(final int column, final T[] array) {
+    public void setColumn(final int column, final T[] array)
+        throws OutOfRangeException {
         checkColumnIndex(column);
         final int nRows = getRowDimension();
         if (array.length != nRows) {
@@ -665,7 +692,7 @@ public abstract class AbstractFieldMatri
     public abstract int getColumnDimension();
 
     /** {@inheritDoc} */
-    public T getTrace() {
+    public T getTrace() throws NonSquareMatrixException {
         final int nRows = getRowDimension();
         final int nCols = getColumnDimension();
         if (nRows != nCols) {
@@ -679,7 +706,7 @@ public abstract class AbstractFieldMatri
     }
 
     /** {@inheritDoc} */
-    public T[] operate(final T[] v) {
+    public T[] operate(final T[] v) throws DimensionMismatchException {
 
         final int nRows = getRowDimension();
         final int nCols = getColumnDimension();
@@ -700,7 +727,8 @@ public abstract class AbstractFieldMatri
     }
 
     /** {@inheritDoc} */
-    public FieldVector<T> operate(final FieldVector<T> v) {
+    public FieldVector<T> operate(final FieldVector<T> v)
+        throws DimensionMismatchException {
         try {
             return new ArrayFieldVector<T>(field, operate(((ArrayFieldVector<T>) v).getDataRef()), false);
         } catch (ClassCastException cce) {
@@ -724,7 +752,7 @@ public abstract class AbstractFieldMatri
     }
 
     /** {@inheritDoc} */
-    public T[] preMultiply(final T[] v) {
+    public T[] preMultiply(final T[] v) throws DimensionMismatchException {
 
         final int nRows = getRowDimension();
         final int nCols = getColumnDimension();
@@ -745,7 +773,8 @@ public abstract class AbstractFieldMatri
     }
 
     /** {@inheritDoc} */
-    public FieldVector<T> preMultiply(final FieldVector<T> v) {
+    public FieldVector<T> preMultiply(final FieldVector<T> v)
+        throws DimensionMismatchException {
         try {
             return new ArrayFieldVector<T>(field, preMultiply(((ArrayFieldVector<T>) v).getDataRef()), false);
         } catch (ClassCastException cce) {
@@ -859,7 +888,8 @@ public abstract class AbstractFieldMatri
     /** {@inheritDoc} */
     public T walkInColumnOrder(final FieldMatrixChangingVisitor<T> visitor,
                                final int startRow, final int endRow,
-                               final int startColumn, final int endColumn) {
+                               final int startColumn, final int endColumn)
+    throws NumberIsTooSmallException, OutOfRangeException {
         checkSubMatrixIndex(startRow, endRow, startColumn, endColumn);
         visitor.start(getRowDimension(), getColumnDimension(),
                       startRow, endRow, startColumn, endColumn);
@@ -876,7 +906,8 @@ public abstract class AbstractFieldMatri
     /** {@inheritDoc} */
     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 NumberIsTooSmallException, OutOfRangeException{
         checkSubMatrixIndex(startRow, endRow, startColumn, endColumn);
         visitor.start(getRowDimension(), getColumnDimension(),
                       startRow, endRow, startColumn, endColumn);
@@ -1001,7 +1032,7 @@ public abstract class AbstractFieldMatri
      * @param row Row index to check.
      * @throws OutOfRangeException if {@code index} is not valid.
      */
-    protected void checkRowIndex(final int row) {
+    protected void checkRowIndex(final int row) throws OutOfRangeException {
         if (row < 0 || row >= getRowDimension()) {
             throw new OutOfRangeException(LocalizedFormats.ROW_INDEX,
                                           row, 0, getRowDimension() - 1);
@@ -1014,7 +1045,8 @@ public abstract class AbstractFieldMatri
      * @param column Column index to check.
      * @throws OutOfRangeException if {@code index} is not valid.
      */
-    protected void checkColumnIndex(final int column) {
+    protected void checkColumnIndex(final int column)
+        throws OutOfRangeException {
         if (column < 0 || column >= getColumnDimension()) {
             throw new OutOfRangeException(LocalizedFormats.COLUMN_INDEX,
                                           column, 0, getColumnDimension() - 1);
@@ -1034,7 +1066,8 @@ public abstract class AbstractFieldMatri
      * {@code endColumn < startColumn}.
      */
     protected void checkSubMatrixIndex(final int startRow, final int endRow,
-                                       final int startColumn, final int endColumn) {
+                                       final int startColumn, final int endColumn)
+        throws NumberIsTooSmallException, OutOfRangeException {
         checkRowIndex(startRow);
         checkRowIndex(endRow);
         if (endRow < startRow) {
@@ -1060,7 +1093,8 @@ public abstract class AbstractFieldMatri
      * @throws NoDataException if the arrays have zero length.
      * @throws OutOfRangeException if row or column selections are not valid.
      */
-    protected void checkSubMatrixIndex(final int[] selectedRows, final int[] selectedColumns) {
+    protected void checkSubMatrixIndex(final int[] selectedRows, final int[] selectedColumns)
+        throws NoDataException, NullArgumentException, OutOfRangeException {
         if (selectedRows == null ||
             selectedColumns == null) {
             throw new NullArgumentException();
@@ -1085,7 +1119,8 @@ public abstract class AbstractFieldMatri
      * @throws MatrixDimensionMismatchException if the matrix is not
      * addition-compatible with instance.
      */
-    protected void checkAdditionCompatible(final FieldMatrix<T> m) {
+    protected void checkAdditionCompatible(final FieldMatrix<T> m)
+        throws MatrixDimensionMismatchException {
         if ((getRowDimension() != m.getRowDimension()) ||
             (getColumnDimension() != m.getColumnDimension())) {
             throw new MatrixDimensionMismatchException(m.getRowDimension(), m.getColumnDimension(),
@@ -1100,7 +1135,8 @@ public abstract class AbstractFieldMatri
      * @throws MatrixDimensionMismatchException if the matrix is not
      * subtraction-compatible with instance.
      */
-    protected void checkSubtractionCompatible(final FieldMatrix<T> m) {
+    protected void checkSubtractionCompatible(final FieldMatrix<T> m)
+        throws MatrixDimensionMismatchException {
         if ((getRowDimension() != m.getRowDimension()) ||
             (getColumnDimension() != m.getColumnDimension())) {
             throw new MatrixDimensionMismatchException(m.getRowDimension(), m.getColumnDimension(),
@@ -1115,7 +1151,8 @@ public abstract class AbstractFieldMatri
      * @throws DimensionMismatchException if the matrix is not
      * multiplication-compatible with instance.
      */
-    protected void checkMultiplicationCompatible(final FieldMatrix<T> m) {
+    protected void checkMultiplicationCompatible(final FieldMatrix<T> m)
+        throws DimensionMismatchException {
         if (getColumnDimension() != m.getRowDimension()) {
             throw new DimensionMismatchException(m.getRowDimension(), getColumnDimension());
         }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/ConjugateGradient.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/ConjugateGradient.java?rev=1380122&r1=1380121&r2=1380122&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/ConjugateGradient.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/ConjugateGradient.java Mon Sep  3 03:54:23 2012
@@ -118,9 +118,11 @@ public class ConjugateGradient
      * @param delta the &delta; parameter for the default stopping criterion
      * @param check {@code true} if positive definiteness of both matrix and
      * preconditioner should be checked
+     * @throws NullArgumentException if {@code manager} is {@code null}
      */
     public ConjugateGradient(final IterationManager manager,
-                             final double delta, final boolean check) {
+                             final double delta, final boolean check)
+        throws NullArgumentException {
         super(manager);
         this.delta = delta;
         this.check = check;
@@ -136,12 +138,20 @@ public class ConjugateGradient
         return check;
     }
 
-    /** {@inheritDoc} */
+    /**
+     * {@inheritDoc}
+     *
+     * @throws NonPositiveDefiniteOperatorException if {@code a} or {@code m} is
+     * not positive definite
+     */
     @Override
     public RealVector solveInPlace(final RealLinearOperator a,
-        final RealLinearOperator m, final RealVector b, final RealVector x0)
-        throws NullArgumentException, NonSquareOperatorException,
-        DimensionMismatchException, MaxCountExceededException {
+                                   final RealLinearOperator m,
+                                   final RealVector b,
+                                   final RealVector x0)
+        throws NullArgumentException, NonPositiveDefiniteOperatorException,
+        NonSquareOperatorException, DimensionMismatchException,
+        MaxCountExceededException, NonPositiveDefiniteOperatorException {
         checkParameters(a, m, b, x0);
         final IterationManager manager = getIterationManager();
         // Initialization of default stopping criterion

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/EigenDecomposition.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/EigenDecomposition.java?rev=1380122&r1=1380121&r2=1380122&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/EigenDecomposition.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/EigenDecomposition.java Mon Sep  3 03:54:23 2012
@@ -111,7 +111,8 @@ public class EigenDecomposition {
      * @throws MathArithmeticException if the decomposition of a general matrix
      * results in a matrix with zero norm
      */
-    public EigenDecomposition(final RealMatrix matrix)  {
+    public EigenDecomposition(final RealMatrix matrix)
+        throws MathArithmeticException {
         if (isSymmetric(matrix, false)) {
             transformToTridiagonal(matrix);
             findEigenVectors(transformer.getQ().getData());
@@ -127,12 +128,15 @@ public class EigenDecomposition {
      * @param matrix Matrix to decompose.
      * @param splitTolerance Dummy parameter (present for backward
      * compatibility only).
+     * @throws MathArithmeticException  if the decomposition of a general matrix
+     * results in a matrix with zero norm
      * @throws MaxCountExceededException if the algorithm fails to converge.
      * @deprecated in 3.1 (to be removed in 4.0) due to unused parameter
      */
     @Deprecated
     public EigenDecomposition(final RealMatrix matrix,
-                              final double splitTolerance)  {
+                              final double splitTolerance)
+        throws MathArithmeticException {
         this(matrix);
     }
 
@@ -761,7 +765,8 @@ public class EigenDecomposition {
      * @param schur the schur transformation of the matrix
      * @throws MathArithmeticException if the Schur form has a norm of zero
      */
-    private void findEigenVectorsFromSchur(final SchurTransformer schur) {
+    private void findEigenVectorsFromSchur(final SchurTransformer schur)
+        throws MathArithmeticException {
         final double[][] matrixT = schur.getT().getData();
         final double[][] matrixP = schur.getP().getData();
 

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/FieldMatrix.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/FieldMatrix.java?rev=1380122&r1=1380121&r2=1380122&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/FieldMatrix.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/FieldMatrix.java Mon Sep  3 03:54:23 2012
@@ -20,6 +20,14 @@ package org.apache.commons.math3.linear;
 
 import org.apache.commons.math3.Field;
 import org.apache.commons.math3.FieldElement;
+import org.apache.commons.math3.exception.DimensionMismatchException;
+import org.apache.commons.math3.exception.NoDataException;
+import org.apache.commons.math3.exception.NotPositiveException;
+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.ZeroException;
 
 /**
  * Interface defining field-valued matrix with basic algebraic operations.
@@ -45,11 +53,12 @@ public interface FieldMatrix<T extends F
      * @param rowDimension  the number of rows in the new matrix
      * @param columnDimension  the number of columns in the new matrix
      * @return a new matrix of the same type as the instance
-     * @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.
      * @since 2.0
      */
-    FieldMatrix<T> createMatrix(final int rowDimension, final int columnDimension);
+    FieldMatrix<T> createMatrix(final int rowDimension, final int columnDimension)
+    throws NotStrictlyPositiveException;
 
     /**
      * Make a (deep) copy of this.
@@ -63,20 +72,20 @@ public interface FieldMatrix<T extends F
      *
      * @param m Matrix to be added.
      * @return {@code this} + {@code 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 {@code this} matrix.
      */
-    FieldMatrix<T> add(FieldMatrix<T> m);
+    FieldMatrix<T> add(FieldMatrix<T> m) throws MatrixDimensionMismatchException;
 
     /**
      * Subtract {@code m} from this matrix.
      *
      * @param m Matrix to be subtracted.
      * @return {@code this} - {@code 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 {@code this} matrix.
      */
-    FieldMatrix<T> subtract(FieldMatrix<T> m);
+    FieldMatrix<T> subtract(FieldMatrix<T> m) throws MatrixDimensionMismatchException;
 
      /**
      * Increment each entry of this matrix.
@@ -99,32 +108,34 @@ public interface FieldMatrix<T extends F
      *
      * @param m  Matrix to postmultiply by.
      * @return {@code this} * {@code m}.
-     * @throws IllegalArgumentException
-     *             if columnDimension(this) != rowDimension(m)
+     * @throws DimensionMismatchException if the number of columns of
+     * {@code this} matrix is not equal to the number of rows of matrix
+     * {@code m}.
      */
-    FieldMatrix<T> multiply(FieldMatrix<T> m);
+    FieldMatrix<T> multiply(FieldMatrix<T> m) throws DimensionMismatchException;
 
     /**
      * Premultiply this matrix by {@code m}.
      *
      * @param m Matrix to premultiply by.
      * @return {@code m} * {@code this}.
-     * @throws org.apache.commons.math3.exception.DimensionMismatchException
-     * if the number of columns of {@code m} differ from the number of rows
-     * of this matrix.
+     * @throws DimensionMismatchException if the number of columns of {@code m}
+     * differs from the number of rows of {@code this} matrix.
      */
-    FieldMatrix<T> preMultiply(FieldMatrix<T> m);
+    FieldMatrix<T> preMultiply(FieldMatrix<T> m) throws DimensionMismatchException;
 
     /**
      * Returns the result multiplying this with itself <code>p</code> times.
-     * Depending on the type of the field elements, T,
-     * instability for high powers might occur.
-     * @param      p raise this to power p
-     * @return     this^p
-     * @throws     IllegalArgumentException if p < 0
-     *             NonSquareMatrixException if the matrix is not square
+     * Depending on the type of the field elements, T, instability for high
+     * powers might occur.
+     *
+     * @param p raise this to power p
+     * @return this^p
+     * @throws NotPositiveException if {@code p < 0}
+     * @throws NonSquareMatrixException if {@code this matrix} is not square
      */
-    FieldMatrix<T> power(final int p);
+    FieldMatrix<T> power(final int p) throws NonSquareMatrixException,
+    NotPositiveException;
 
     /**
      * Returns matrix entries as a two-dimensional array.
@@ -141,12 +152,13 @@ public interface FieldMatrix<T extends F
      * @param endRow Final row index (inclusive)
      * @param startColumn Initial column index
      * @param endColumn Final column index (inclusive)
-     * @return the matrix containing the data of the
-     * specified rows and columns.
-     * @throws org.apache.commons.math3.exception.OutOfRangeException
-     * if the indices are not valid.
+     * @return the matrix containing the data of the specified rows and columns.
+     * @throws NumberIsTooSmallException is {@code endRow < startRow} of
+     * {@code endColumn < startColumn}.
+     * @throws OutOfRangeException if the indices are not valid.
      */
-   FieldMatrix<T> getSubMatrix(int startRow, int endRow, int startColumn, int endColumn);
+   FieldMatrix<T> getSubMatrix(int startRow, int endRow, int startColumn, int endColumn)
+   throws NumberIsTooSmallException, OutOfRangeException;
 
    /**
     * Get a submatrix. Rows and columns are indicated
@@ -156,10 +168,14 @@ public interface FieldMatrix<T extends F
     * @param selectedColumns Array of column indices.
     * @return the matrix containing the data in the
     * specified rows and columns.
-    * @throws org.apache.commons.math3.exception.OutOfRangeException
-    * if row or column selections are not valid.
+    * @throws NoDataException if {@code selectedRows} or
+    * {@code selectedColumns} is empty
+    * @throws NullArgumentException if {@code selectedRows} or
+    * {@code selectedColumns} is {@code null}.
+    * @throws OutOfRangeException if row or column selections are not valid.
     */
-   FieldMatrix<T> getSubMatrix(int[] selectedRows, int[] selectedColumns);
+   FieldMatrix<T> getSubMatrix(int[] selectedRows, int[] selectedColumns)
+   throws NoDataException, NullArgumentException, OutOfRangeException;
 
    /**
     * Copy a submatrix. Rows and columns are indicated
@@ -171,12 +187,17 @@ public interface FieldMatrix<T extends F
     * @param endColumn Final column index (inclusive).
     * @param destination The arrays where the submatrix data should be copied
     * (if larger than rows/columns counts, only the upper-left part will be used).
-    * @throws org.apache.commons.math3.exception.OutOfRangeException
-    * if the indices are not valid.
+    * @throws MatrixDimensionMismatchException if the dimensions of
+    * {@code destination} do not match those of {@code this}.
+    * @throws NumberIsTooSmallException is {@code endRow < startRow} of
+    * {@code endColumn < startColumn}.
+    * @throws OutOfRangeException if the indices are not valid.
     * @exception IllegalArgumentException if the destination array is too small.
     */
-  void copySubMatrix(int startRow, int endRow, int startColumn, int endColumn,
-                     T[][] destination);
+    void copySubMatrix(int startRow, int endRow, int startColumn, int endColumn,
+                       T[][] destination)
+    throws MatrixDimensionMismatchException, NumberIsTooSmallException,
+    OutOfRangeException;
 
   /**
    * Copy a submatrix. Rows and columns are indicated
@@ -186,11 +207,17 @@ public interface FieldMatrix<T extends F
    * @param selectedColumns Array of column indices.
    * @param destination Arrays where the submatrix data should be copied
    * (if larger than rows/columns counts, only the upper-left part will be used)
-   * @throws org.apache.commons.math3.exception.OutOfRangeException
-   * if the indices are not valid.
-   * @exception IllegalArgumentException if the destination array is too small
+   * @throws MatrixDimensionMismatchException if the dimensions of
+   * {@code destination} do not match those of {@code this}.
+   * @throws NoDataException if {@code selectedRows} or
+   * {@code selectedColumns} is empty
+   * @throws NullArgumentException if {@code selectedRows} or
+   * {@code selectedColumns} is {@code null}.
+   * @throws OutOfRangeException if the indices are not valid.
    */
-  void copySubMatrix(int[] selectedRows, int[] selectedColumns, T[][] destination);
+  void copySubMatrix(int[] selectedRows, int[] selectedColumns, T[][] destination)
+  throws MatrixDimensionMismatchException, NoDataException, NullArgumentException,
+  OutOfRangeException;
 
    /**
     * Replace the submatrix starting at {@code (row, column)} using data in
@@ -224,7 +251,9 @@ public interface FieldMatrix<T extends F
     * if {@code subMatrix} is {@code null}.
     * @since 2.0
     */
-  void setSubMatrix(T[][] subMatrix, int row, int column);
+    void setSubMatrix(T[][] subMatrix, int row, int column)
+    throws DimensionMismatchException, MatrixDimensionMismatchException,
+           NullArgumentException, ZeroException;
 
    /**
     * Get the entries in row number {@code row}
@@ -232,10 +261,9 @@ public interface FieldMatrix<T extends F
     *
     * @param row Row to be fetched.
     * @return a row matrix.
-    * @throws org.apache.commons.math3.exception.OutOfRangeException
-    * if the specified row index is invalid.
+    * @throws OutOfRangeException if the specified row index is invalid.
     */
-   FieldMatrix<T> getRowMatrix(int row);
+   FieldMatrix<T> getRowMatrix(int row) throws OutOfRangeException;
 
    /**
     * Set the entries in row number {@code row}
@@ -244,12 +272,12 @@ public interface FieldMatrix<T extends F
     * @param row Row to be set.
     * @param matrix Row matrix (must have one row and the same number
     * of columns as the instance).
-    * @throws org.apache.commons.math3.exception.OutOfRangeException
-    * if the specified row index is invalid.
+    * @throws OutOfRangeException if the specified row index is invalid.
     * @throws MatrixDimensionMismatchException
     * if the matrix dimensions do not match one instance row.
     */
-   void setRowMatrix(int row, FieldMatrix<T> matrix);
+   void setRowMatrix(int row, FieldMatrix<T> matrix)
+   throws MatrixDimensionMismatchException, OutOfRangeException;
 
    /**
     * Get the entries in column number {@code column}
@@ -257,10 +285,9 @@ public interface FieldMatrix<T extends F
     *
     * @param column Column to be fetched.
     * @return a column matrix.
-    * @throws org.apache.commons.math3.exception.OutOfRangeException
-    * if the specified column index is invalid.
+    * @throws OutOfRangeException if the specified column index is invalid.
     */
-   FieldMatrix<T> getColumnMatrix(int column);
+   FieldMatrix<T> getColumnMatrix(int column) throws OutOfRangeException;
 
    /**
     * Set the entries in column number {@code column}
@@ -269,12 +296,12 @@ public interface FieldMatrix<T extends F
     * @param column Column to be set.
     * @param matrix column matrix (must have one column and the same
     * number of rows as the instance).
-    * @throws org.apache.commons.math3.exception.OutOfRangeException
-    * if the specified column index is invalid.
-    * @throws MatrixDimensionMismatchException
-    * if the matrix dimensions do not match one instance column.
+    * @throws OutOfRangeException if the specified column index is invalid.
+    * @throws MatrixDimensionMismatchException if the matrix dimensions do
+    * not match one instance column.
     */
-   void setColumnMatrix(int column, FieldMatrix<T> matrix);
+   void setColumnMatrix(int column, FieldMatrix<T> matrix)
+   throws MatrixDimensionMismatchException, OutOfRangeException;
 
    /**
     * Get the entries in row number {@code row}
@@ -282,10 +309,9 @@ public interface FieldMatrix<T extends F
     *
     * @param row Row to be fetched
     * @return a row vector.
-    * @throws org.apache.commons.math3.exception.OutOfRangeException
-    * if the specified row index is invalid.
+    * @throws OutOfRangeException if the specified row index is invalid.
     */
-   FieldVector<T> getRowVector(int row);
+   FieldVector<T> getRowVector(int row) throws OutOfRangeException;
 
    /**
     * Set the entries in row number {@code row}
@@ -294,12 +320,12 @@ public interface FieldMatrix<T extends F
     * @param row Row to be set.
     * @param vector row vector (must have the same number of columns
     * as the instance).
-    * @throws org.apache.commons.math3.exception.OutOfRangeException
-    * if the specified row index is invalid.
-    * @throws MatrixDimensionMismatchException
-    * if the vector dimension does not match one instance row.
+    * @throws OutOfRangeException if the specified row index is invalid.
+    * @throws MatrixDimensionMismatchException if the vector dimension does not
+    * match one instance row.
     */
-   void setRowVector(int row, FieldVector<T> vector);
+   void setRowVector(int row, FieldVector<T> vector)
+   throws MatrixDimensionMismatchException, OutOfRangeException;
 
    /**
     * Returns the entries in column number {@code column}
@@ -307,10 +333,9 @@ public interface FieldMatrix<T extends F
     *
     * @param column Column to be fetched.
     * @return a column vector.
-    * @throws org.apache.commons.math3.exception.OutOfRangeException
-    * if the specified column index is invalid.
+    * @throws OutOfRangeException if the specified column index is invalid.
     */
-   FieldVector<T> getColumnVector(int column);
+   FieldVector<T> getColumnVector(int column) throws OutOfRangeException;
 
    /**
     * Set the entries in column number {@code column}
@@ -319,22 +344,21 @@ public interface FieldMatrix<T extends F
     * @param column Column to be set.
     * @param vector Column vector (must have the same number of rows
     * as the instance).
-    * @throws org.apache.commons.math3.exception.OutOfRangeException
-    * if the specified column index is invalid.
-    * @throws MatrixDimensionMismatchException
-    * if the vector dimension does not match one instance column.
+    * @throws OutOfRangeException if the specified column index is invalid.
+    * @throws MatrixDimensionMismatchException if the vector dimension does not
+    * match one instance column.
     */
-   void setColumnVector(int column, FieldVector<T> vector);
+   void setColumnVector(int column, FieldVector<T> vector)
+   throws MatrixDimensionMismatchException, OutOfRangeException;
 
     /**
      * Get the entries in row number {@code row} as an array.
      *
      * @param row Row to be fetched.
      * @return array of entries in the row.
-     * @throws org.apache.commons.math3.exception.OutOfRangeException
-     * if the specified row index is not valid.
+     * @throws OutOfRangeException if the specified row index is not valid.
      */
-    T[] getRow(int row);
+    T[] getRow(int row) throws OutOfRangeException;
 
     /**
      * Set the entries in row number {@code row}
@@ -343,22 +367,21 @@ public interface FieldMatrix<T extends F
      * @param row Row to be set.
      * @param array Row matrix (must have the same number of columns as
      * the instance).
-     * @throws org.apache.commons.math3.exception.OutOfRangeException
-     * if the specified row index is invalid.
-     * @throws MatrixDimensionMismatchException
-     * if the array size does not match one instance row.
+     * @throws OutOfRangeException if the specified row index is invalid.
+     * @throws MatrixDimensionMismatchException if the array size does not match
+     * one instance row.
      */
-    void setRow(int row, T[] array);
+    void setRow(int row, T[] array) throws MatrixDimensionMismatchException,
+    OutOfRangeException;
 
     /**
      * Get the entries in column number {@code col} as an array.
      *
      * @param column the column to be fetched
      * @return array of entries in the column
-     * @throws org.apache.commons.math3.exception.OutOfRangeException
-     * if the specified column index is not valid.
+     * @throws OutOfRangeException if the specified column index is not valid.
      */
-    T[] getColumn(int column);
+    T[] getColumn(int column) throws OutOfRangeException;
 
     /**
      * Set the entries in column number {@code column}
@@ -366,12 +389,12 @@ public interface FieldMatrix<T extends F
      *
      * @param column the column to be set
      * @param array column array (must have the same number of rows as the instance)
-     * @throws org.apache.commons.math3.exception.OutOfRangeException
-     * if the specified column index is invalid.
-     * @throws MatrixDimensionMismatchException
-     * if the array size does not match one instance column.
+     * @throws OutOfRangeException if the specified column index is invalid.
+     * @throws MatrixDimensionMismatchException if the array size does not match
+     * one instance column.
      */
-    void setColumn(int column, T[] array);
+    void setColumn(int column, T[] array) throws MatrixDimensionMismatchException,
+    OutOfRangeException;
 
     /**
      * Returns the entry in the specified row and column.
@@ -379,10 +402,9 @@ public interface FieldMatrix<T extends F
      * @param row  row location of entry to be fetched
      * @param column  column location of entry to be fetched
      * @return matrix entry in row,column
-     * @throws org.apache.commons.math3.exception.OutOfRangeException
-     * if the row or column index is not valid.
+     * @throws OutOfRangeException if the row or column index is not valid.
      */
-    T getEntry(int row, int column);
+    T getEntry(int row, int column) throws OutOfRangeException;
 
     /**
      * Set the entry in the specified row and column.
@@ -390,11 +412,10 @@ public interface FieldMatrix<T extends F
      * @param row  row location of entry to be set
      * @param column  column location of entry to be set
      * @param value matrix entry to be set in row,column
-     * @throws org.apache.commons.math3.exception.OutOfRangeException
-     * if the row or column index is not valid.
+     * @throws OutOfRangeException if the row or column index is not valid.
      * @since 2.0
      */
-    void setEntry(int row, int column, T value);
+    void setEntry(int row, int column, T value) throws OutOfRangeException;
 
     /**
      * Change an entry in the specified row and column.
@@ -403,11 +424,10 @@ public interface FieldMatrix<T extends F
      * @param column Column location of entry to be set.
      * @param increment Value to add to the current matrix entry in
      * {@code (row, column)}.
-     * @throws org.apache.commons.math3.exception.OutOfRangeException
-     * if the row or column index is not valid.
+     * @throws OutOfRangeException if the row or column index is not valid.
      * @since 2.0
      */
-    void addToEntry(int row, int column, T increment);
+    void addToEntry(int row, int column, T increment) throws OutOfRangeException;
 
     /**
      * Change an entry in the specified row and column.
@@ -416,11 +436,10 @@ public interface FieldMatrix<T extends F
      * @param column Column location of entry to be set.
      * @param factor Multiplication factor for the current matrix entry
      * in {@code (row,column)}
-     * @throws org.apache.commons.math3.exception.OutOfRangeException
-     * if the row or column index is not valid.
+     * @throws OutOfRangeException if the row or column index is not valid.
      * @since 2.0
      */
-    void multiplyEntry(int row, int column, T factor);
+    void multiplyEntry(int row, int column, T factor) throws OutOfRangeException;
 
     /**
      * Returns the transpose of this matrix.
@@ -434,46 +453,51 @@ public interface FieldMatrix<T extends F
      * trace</a> of the matrix (the sum of the elements on the main diagonal).
      *
      * @return trace
-     * @throws NonSquareMatrixException
-     * if the matrix is not square.
+     * @throws NonSquareMatrixException if the matrix is not square.
      */
-    T getTrace();
+    T getTrace() throws NonSquareMatrixException;
 
     /**
-     * Returns the result of multiplying this by the vector <code>v</code>.
+     * Returns the result of multiplying this by the vector {@code v}.
      *
      * @param v the vector to operate on
-     * @return this*v
-     * @throws IllegalArgumentException if columnDimension != v.size()
+     * @return {@code this * v}
+     * @throws DimensionMismatchException if the number of columns of
+     * {@code this} matrix is not equal to the size of the vector {@code v}.
      */
-    T[] operate(T[] v);
+    T[] operate(T[] v) throws DimensionMismatchException;
 
     /**
-     * Returns the result of multiplying this by the vector <code>v</code>.
+     * Returns the result of multiplying this by the vector {@code v}.
      *
      * @param v the vector to operate on
-     * @return this*v
-     * @throws IllegalArgumentException if columnDimension != v.size()
+     * @return {@code this * v}
+     * @throws DimensionMismatchException if the number of columns of
+     * {@code this} matrix is not equal to the size of the vector {@code v}.
      */
-    FieldVector<T> operate(FieldVector<T> v);
+    FieldVector<T> operate(FieldVector<T> v) throws DimensionMismatchException;
 
     /**
-     * Returns the (row) vector result of premultiplying this by the vector <code>v</code>.
+     * Returns the (row) vector result of premultiplying this by the vector
+     * {@code v}.
      *
      * @param v the row vector to premultiply by
-     * @return v*this
-     * @throws IllegalArgumentException if rowDimension != v.size()
+     * @return {@code v * this}
+     * @throws DimensionMismatchException if the number of rows of {@code this}
+     * matrix is not equal to the size of the vector {@code v}
      */
-    T[] preMultiply(T[] v);
+    T[] preMultiply(T[] v) throws DimensionMismatchException;
 
     /**
-     * Returns the (row) vector result of premultiplying this by the vector <code>v</code>.
+     * Returns the (row) vector result of premultiplying this by the vector
+     * {@code v}.
      *
      * @param v the row vector to premultiply by
-     * @return v*this
-     * @throws IllegalArgumentException if rowDimension != v.size()
+     * @return {@code v * this}
+     * @throws DimensionMismatchException if the number of rows of {@code this}
+     * matrix is not equal to the size of the vector {@code v}
      */
-    FieldVector<T> preMultiply(FieldVector<T> v);
+    FieldVector<T> preMultiply(FieldVector<T> v) throws DimensionMismatchException;
 
     /**
      * Visit (and possibly change) all matrix entries in row order.
@@ -529,8 +553,7 @@ public interface FieldMatrix<T extends F
      * @param endRow Final row index (inclusive)
      * @param startColumn Initial column index
      * @param endColumn Final column index
-     * @throws org.apache.commons.math3.exception.OutOfRangeException
-     * if the indices are not valid.
+     * @throws OutOfRangeException if the indices are not valid.
      * @see #walkInRowOrder(FieldMatrixChangingVisitor)
      * @see #walkInRowOrder(FieldMatrixPreservingVisitor)
      * @see #walkInRowOrder(FieldMatrixPreservingVisitor, int, int, int, int)
@@ -546,7 +569,8 @@ public interface FieldMatrix<T extends F
      * of the walk
      */
     T walkInRowOrder(FieldMatrixChangingVisitor<T> visitor,
-                     int startRow, int endRow, int startColumn, int endColumn);
+                     int startRow, int endRow, int startColumn, int endColumn)
+    throws OutOfRangeException;
 
     /**
      * Visit (but don't change) some matrix entries in row order.
@@ -558,8 +582,7 @@ public interface FieldMatrix<T extends F
      * @param endRow Final row index (inclusive)
      * @param startColumn Initial column index
      * @param endColumn Final column index
-     * @throws org.apache.commons.math3.exception.OutOfRangeException
-     * if the indices are not valid.
+     * @throws OutOfRangeException if the indices are not valid.
      * @see #walkInRowOrder(FieldMatrixChangingVisitor)
      * @see #walkInRowOrder(FieldMatrixPreservingVisitor)
      * @see #walkInRowOrder(FieldMatrixChangingVisitor, int, int, int, int)
@@ -575,7 +598,8 @@ public interface FieldMatrix<T extends F
      * of the walk
      */
     T walkInRowOrder(FieldMatrixPreservingVisitor<T> visitor,
-                     int startRow, int endRow, int startColumn, int endColumn);
+                     int startRow, int endRow, int startColumn, int endColumn)
+    throws OutOfRangeException;
 
     /**
      * Visit (and possibly change) all matrix entries in column order.
@@ -631,8 +655,9 @@ public interface FieldMatrix<T extends F
      * @param endRow Final row index (inclusive)
      * @param startColumn Initial column index
      * @param endColumn Final column index
-     * @throws org.apache.commons.math3.exception.OutOfRangeException
-     * if the indices are not valid.
+     * @throws NumberIsTooSmallException if {@code endRow < startRow} or
+     * {@code endColumn < startColumn}.
+     * @throws OutOfRangeException if the indices are not valid.
      * @see #walkInRowOrder(FieldMatrixChangingVisitor)
      * @see #walkInRowOrder(FieldMatrixPreservingVisitor)
      * @see #walkInRowOrder(FieldMatrixChangingVisitor, int, int, int, int)
@@ -648,7 +673,8 @@ public interface FieldMatrix<T extends F
      * of the walk
      */
     T walkInColumnOrder(FieldMatrixChangingVisitor<T> visitor,
-                        int startRow, int endRow, int startColumn, int endColumn);
+                        int startRow, int endRow, int startColumn, int endColumn)
+    throws NumberIsTooSmallException, OutOfRangeException;
 
     /**
      * Visit (but don't change) some matrix entries in column order.
@@ -660,8 +686,9 @@ public interface FieldMatrix<T extends F
      * @param endRow Final row index (inclusive)
      * @param startColumn Initial column index
      * @param endColumn Final column index
-     * @throws org.apache.commons.math3.exception.OutOfRangeException
-     * if the indices are not valid.
+     * @throws NumberIsTooSmallException if {@code endRow < startRow} or
+     * {@code endColumn < startColumn}.
+     * @throws OutOfRangeException if the indices are not valid.
      * @see #walkInRowOrder(FieldMatrixChangingVisitor)
      * @see #walkInRowOrder(FieldMatrixPreservingVisitor)
      * @see #walkInRowOrder(FieldMatrixChangingVisitor, int, int, int, int)
@@ -677,7 +704,8 @@ public interface FieldMatrix<T extends F
      * of the walk
      */
     T walkInColumnOrder(FieldMatrixPreservingVisitor<T> visitor,
-                        int startRow, int endRow, int startColumn, int endColumn);
+                        int startRow, int endRow, int startColumn, int endColumn)
+    throws NumberIsTooSmallException, OutOfRangeException;
 
     /**
      * Visit (and possibly change) all matrix entries using the fastest possible order.
@@ -730,8 +758,9 @@ public interface FieldMatrix<T extends F
      * @param endRow Final row index (inclusive)
      * @param startColumn Initial column index
      * @param endColumn Final column index (inclusive)
-     * @throws org.apache.commons.math3.exception.OutOfRangeException
-     * if the indices are not valid.
+     * @throws NumberIsTooSmallException if {@code endRow < startRow} or
+     * {@code endColumn < startColumn}.
+     * @throws OutOfRangeException if the indices are not valid.
      * @see #walkInRowOrder(FieldMatrixChangingVisitor)
      * @see #walkInRowOrder(FieldMatrixPreservingVisitor)
      * @see #walkInRowOrder(FieldMatrixChangingVisitor, int, int, int, int)
@@ -747,7 +776,8 @@ public interface FieldMatrix<T extends F
      * of the walk
      */
     T walkInOptimizedOrder(FieldMatrixChangingVisitor<T> visitor,
-                           int startRow, int endRow, int startColumn, int endColumn);
+                           int startRow, int endRow, int startColumn, int endColumn)
+    throws NumberIsTooSmallException, OutOfRangeException;
 
     /**
      * Visit (but don't change) some matrix entries using the fastest possible order.
@@ -758,8 +788,9 @@ public interface FieldMatrix<T extends F
      * @param endRow Final row index (inclusive)
      * @param startColumn Initial column index
      * @param endColumn Final column index (inclusive)
-     * @throws org.apache.commons.math3.exception.OutOfRangeException
-     * if the indices are not valid.
+     * @throws NumberIsTooSmallException if {@code endRow < startRow} or
+     * {@code endColumn < startColumn}.
+     * @throws OutOfRangeException if the indices are not valid.
      * @see #walkInRowOrder(FieldMatrixChangingVisitor)
      * @see #walkInRowOrder(FieldMatrixPreservingVisitor)
      * @see #walkInRowOrder(FieldMatrixChangingVisitor, int, int, int, int)
@@ -775,5 +806,6 @@ public interface FieldMatrix<T extends F
      * of the walk
      */
     T walkInOptimizedOrder(FieldMatrixPreservingVisitor<T> visitor,
-                           int startRow, int endRow, int startColumn, int endColumn);
+                           int startRow, int endRow, int startColumn, int endColumn)
+    throws NumberIsTooSmallException, OutOfRangeException;
 }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/MatrixUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/MatrixUtils.java?rev=1380122&r1=1380121&r2=1380122&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/MatrixUtils.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/MatrixUtils.java Mon Sep  3 03:54:23 2012
@@ -26,7 +26,6 @@ import java.util.Arrays;
 import org.apache.commons.math3.Field;
 import org.apache.commons.math3.FieldElement;
 import org.apache.commons.math3.exception.MathArithmeticException;
-import org.apache.commons.math3.exception.MathIllegalArgumentException;
 import org.apache.commons.math3.exception.OutOfRangeException;
 import org.apache.commons.math3.exception.NoDataException;
 import org.apache.commons.math3.exception.NumberIsTooSmallException;
@@ -122,9 +121,12 @@ public class MatrixUtils {
      * @throws NoDataException if a row or column is empty.
      * @throws NullArgumentException if either {@code data} or {@code data[0]}
      * is {@code null}.
+     * @throws DimensionMismatchException if {@code data} is not rectangular.
      * @see #createRealMatrix(int, int)
      */
-    public static RealMatrix createRealMatrix(double[][] data) {
+    public static RealMatrix createRealMatrix(double[][] data)
+        throws NullArgumentException, DimensionMismatchException,
+        NoDataException {
         if (data == null ||
             data[0] == null) {
             throw new NullArgumentException();
@@ -152,7 +154,8 @@ public class MatrixUtils {
      * @see #createFieldMatrix(Field, int, int)
      * @since 2.0
      */
-    public static <T extends FieldElement<T>> FieldMatrix<T> createFieldMatrix(T[][] data) {
+    public static <T extends FieldElement<T>> FieldMatrix<T> createFieldMatrix(T[][] data)
+        throws DimensionMismatchException, NoDataException, NullArgumentException {
         if (data == null ||
             data[0] == null) {
             throw new NullArgumentException();
@@ -244,7 +247,8 @@ public class MatrixUtils {
      * @throws NoDataException if {@code data} is empty.
      * @throws NullArgumentException if {@code data} is {@code null}.
      */
-    public static RealVector createRealVector(double[] data) {
+    public static RealVector createRealVector(double[] data)
+        throws NoDataException, NullArgumentException {
         if (data == null) {
             throw new NullArgumentException();
         }
@@ -261,7 +265,8 @@ public class MatrixUtils {
      * @throws NullArgumentException if {@code data} is {@code null}.
      * @throws ZeroException if {@code data} has 0 elements
      */
-    public static <T extends FieldElement<T>> FieldVector<T> createFieldVector(final T[] data) {
+    public static <T extends FieldElement<T>> FieldVector<T> createFieldVector(final T[] data)
+        throws NoDataException, NullArgumentException, ZeroException {
         if (data == null) {
             throw new NullArgumentException();
         }
@@ -280,7 +285,8 @@ public class MatrixUtils {
      * @throws NoDataException if {@code rowData} is empty.
      * @throws NullArgumentException if {@code rowData} is {@code null}.
      */
-    public static RealMatrix createRowRealMatrix(double[] rowData) {
+    public static RealMatrix createRowRealMatrix(double[] rowData)
+        throws NoDataException, NullArgumentException {
         if (rowData == null) {
             throw new NullArgumentException();
         }
@@ -303,7 +309,8 @@ public class MatrixUtils {
      * @throws NullArgumentException if {@code rowData} is {@code null}.
      */
     public static <T extends FieldElement<T>> FieldMatrix<T>
-        createRowFieldMatrix(final T[] rowData) {
+        createRowFieldMatrix(final T[] rowData)
+        throws NoDataException, NullArgumentException {
         if (rowData == null) {
             throw new NullArgumentException();
         }
@@ -327,7 +334,8 @@ public class MatrixUtils {
      * @throws NoDataException if {@code columnData} is empty.
      * @throws NullArgumentException if {@code columnData} is {@code null}.
      */
-    public static RealMatrix createColumnRealMatrix(double[] columnData) {
+    public static RealMatrix createColumnRealMatrix(double[] columnData)
+        throws NoDataException, NullArgumentException {
         if (columnData == null) {
             throw new NullArgumentException();
         }
@@ -350,7 +358,8 @@ public class MatrixUtils {
      * @throws NullArgumentException if {@code columnData} is {@code null}.
      */
     public static <T extends FieldElement<T>> FieldMatrix<T>
-        createColumnFieldMatrix(final T[] columnData) {
+        createColumnFieldMatrix(final T[] columnData)
+        throws NoDataException, NullArgumentException {
         if (columnData == null) {
             throw new NullArgumentException();
         }
@@ -375,7 +384,8 @@ public class MatrixUtils {
      * a valid index.
      */
     public static void checkMatrixIndex(final AnyMatrix m,
-                                        final int row, final int column) {
+                                        final int row, final int column)
+        throws OutOfRangeException {
         checkRowIndex(m, row);
         checkColumnIndex(m, column);
     }
@@ -387,7 +397,8 @@ public class MatrixUtils {
      * @param row Row index to check.
      * @throws OutOfRangeException if {@code row} is not a valid index.
      */
-    public static void checkRowIndex(final AnyMatrix m, final int row) {
+    public static void checkRowIndex(final AnyMatrix m, final int row)
+        throws OutOfRangeException {
         if (row < 0 ||
             row >= m.getRowDimension()) {
             throw new OutOfRangeException(LocalizedFormats.ROW_INDEX,
@@ -402,7 +413,8 @@ public class MatrixUtils {
      * @param column Column index to check.
      * @throws OutOfRangeException if {@code column} is not a valid index.
      */
-    public static void checkColumnIndex(final AnyMatrix m, final int column) {
+    public static void checkColumnIndex(final AnyMatrix m, final int column)
+        throws OutOfRangeException {
         if (column < 0 || column >= m.getColumnDimension()) {
             throw new OutOfRangeException(LocalizedFormats.COLUMN_INDEX,
                                            column, 0, m.getColumnDimension() - 1);
@@ -424,7 +436,8 @@ public class MatrixUtils {
      */
     public static void checkSubMatrixIndex(final AnyMatrix m,
                                            final int startRow, final int endRow,
-                                           final int startColumn, final int endColumn) {
+                                           final int startColumn, final int endColumn)
+        throws NumberIsTooSmallException, OutOfRangeException {
         checkRowIndex(m, startRow);
         checkRowIndex(m, endRow);
         if (endRow < startRow) {
@@ -457,7 +470,8 @@ public class MatrixUtils {
      */
     public static void checkSubMatrixIndex(final AnyMatrix m,
                                            final int[] selectedRows,
-                                           final int[] selectedColumns) {
+                                           final int[] selectedColumns)
+        throws NoDataException, NullArgumentException, OutOfRangeException {
         if (selectedRows == null) {
             throw new NullArgumentException();
         }
@@ -484,9 +498,11 @@ public class MatrixUtils {
      *
      * @param left Left hand side matrix.
      * @param right Right hand side matrix.
-     * @throws MatrixDimensionMismatchException if the matrices are not addition compatible.
+     * @throws MatrixDimensionMismatchException if the matrices are not addition
+     * compatible.
      */
-    public static void checkAdditionCompatible(final AnyMatrix left, final AnyMatrix right) {
+    public static void checkAdditionCompatible(final AnyMatrix left, final AnyMatrix right)
+        throws MatrixDimensionMismatchException {
         if ((left.getRowDimension()    != right.getRowDimension()) ||
             (left.getColumnDimension() != right.getColumnDimension())) {
             throw new MatrixDimensionMismatchException(left.getRowDimension(), left.getColumnDimension(),
@@ -499,9 +515,11 @@ public class MatrixUtils {
      *
      * @param left Left hand side matrix.
      * @param right Right hand side matrix.
-     * @throws MatrixDimensionMismatchException if the matrices are not addition compatible.
+     * @throws MatrixDimensionMismatchException if the matrices are not addition
+     * compatible.
      */
-    public static void checkSubtractionCompatible(final AnyMatrix left, final AnyMatrix right) {
+    public static void checkSubtractionCompatible(final AnyMatrix left, final AnyMatrix right)
+        throws MatrixDimensionMismatchException {
         if ((left.getRowDimension()    != right.getRowDimension()) ||
             (left.getColumnDimension() != right.getColumnDimension())) {
             throw new MatrixDimensionMismatchException(left.getRowDimension(), left.getColumnDimension(),
@@ -514,9 +532,12 @@ public class MatrixUtils {
      *
      * @param left Left hand side matrix.
      * @param right Right hand side matrix.
-     * @throws DimensionMismatchException if matrices are not multiplication compatible.
+     * @throws DimensionMismatchException if matrices are not multiplication
+     * compatible.
      */
-    public static void checkMultiplicationCompatible(final AnyMatrix left, final AnyMatrix right) {
+    public static void checkMultiplicationCompatible(final AnyMatrix left, final AnyMatrix right)
+        throws DimensionMismatchException {
+
         if (left.getColumnDimension() != right.getRowDimension()) {
             throw new DimensionMismatchException(left.getColumnDimension(),
                                                  right.getRowDimension());
@@ -832,19 +853,23 @@ public class MatrixUtils {
      * </p>
      * @param rm RealMatrix which is lower triangular
      * @param b  RealVector this is overwritten
-     * @exception IllegalArgumentException if the matrix and vector are not conformable
-     * @exception ArithmeticException there is a zero or near zero on the diagonal of rm
-     */
-    public static void solveLowerTriangularSystem( RealMatrix rm, RealVector b){
+     * @throws DimensionMismatchException if the matrix and vector are not
+     * conformable
+     * @throws NonSquareMatrixException if the matrix {@code rm} is not square
+     * @throws MathArithmeticException if the absolute value of one of the diagonal
+     * coefficient of {@code rm} is lower than {@link Precision#SAFE_MIN}
+     */
+    public static void solveLowerTriangularSystem(RealMatrix rm, RealVector b)
+        throws DimensionMismatchException, MathArithmeticException,
+        NonSquareMatrixException {
         if ((rm == null) || (b == null) || ( rm.getRowDimension() != b.getDimension())) {
-            throw new MathIllegalArgumentException(LocalizedFormats.DIMENSIONS_MISMATCH_SIMPLE,
+            throw new DimensionMismatchException(
                     (rm == null) ? 0 : rm.getRowDimension(),
                     (b == null) ? 0 : b.getDimension());
         }
         if( rm.getColumnDimension() != rm.getRowDimension() ){
-            throw new MathIllegalArgumentException(LocalizedFormats.DIMENSIONS_MISMATCH_2x2,
-                    rm.getRowDimension(),rm.getRowDimension(),
-                    rm.getRowDimension(),rm.getColumnDimension());
+            throw new NonSquareMatrixException(rm.getRowDimension(),
+                                               rm.getColumnDimension());
         }
         int rows = rm.getRowDimension();
         for( int i = 0 ; i < rows ; i++ ){
@@ -872,19 +897,24 @@ public class MatrixUtils {
      * </p>
      * @param rm RealMatrix which is upper triangular
      * @param b  RealVector this is overwritten
-     * @exception IllegalArgumentException if the matrix and vector are not conformable
-     * @exception ArithmeticException there is a zero or near zero on the diagonal of rm
-     */
-    public static void solveUpperTriangularSystem( RealMatrix rm, RealVector b){
+     * @throws DimensionMismatchException if the matrix and vector are not
+     * conformable
+     * @throws NonSquareMatrixException if the matrix {@code rm} is not
+     * square
+     * @throws MathArithmeticException if the absolute value of one of the diagonal
+     * coefficient of {@code rm} is lower than {@link Precision#SAFE_MIN}
+     */
+    public static void solveUpperTriangularSystem(RealMatrix rm, RealVector b)
+        throws DimensionMismatchException, MathArithmeticException,
+        NonSquareMatrixException {
         if ((rm == null) || (b == null) || ( rm.getRowDimension() != b.getDimension())) {
-            throw new MathIllegalArgumentException(LocalizedFormats.DIMENSIONS_MISMATCH_SIMPLE,
+            throw new DimensionMismatchException(
                     (rm == null) ? 0 : rm.getRowDimension(),
                     (b == null) ? 0 : b.getDimension());
         }
         if( rm.getColumnDimension() != rm.getRowDimension() ){
-            throw new MathIllegalArgumentException(LocalizedFormats.DIMENSIONS_MISMATCH_2x2,
-                    rm.getRowDimension(),rm.getRowDimension(),
-                    rm.getRowDimension(),rm.getColumnDimension());
+            throw new NonSquareMatrixException(rm.getRowDimension(),
+                                               rm.getColumnDimension());
         }
         int rows = rm.getRowDimension();
         for( int i = rows-1 ; i >-1 ; i-- ){

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/OpenMapRealVector.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/OpenMapRealVector.java?rev=1380122&r1=1380121&r2=1380122&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/OpenMapRealVector.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/OpenMapRealVector.java Mon Sep  3 03:54:23 2012
@@ -640,7 +640,7 @@ public class OpenMapRealVector extends S
 
     /** {@inheritDoc} */
     @Override
-    public OpenMapRealVector unitVector() {
+    public OpenMapRealVector unitVector() throws MathArithmeticException {
         OpenMapRealVector res = copy();
         res.unitize();
         return res;
@@ -648,7 +648,7 @@ public class OpenMapRealVector extends S
 
     /** {@inheritDoc} */
     @Override
-    public void unitize() {
+    public void unitize() throws MathArithmeticException {
         double norm = getNorm();
         if (isDefaultValue(norm)) {
             throw new MathArithmeticException(LocalizedFormats.ZERO_NORM);

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/RealVector.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/RealVector.java?rev=1380122&r1=1380121&r2=1380122&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/RealVector.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/RealVector.java Mon Sep  3 03:54:23 2012
@@ -321,7 +321,7 @@ public abstract class RealVector {
      * @throws DimensionMismatchException if the dimensions of {@code this} and
      * {@code v} do not match
      */
-    public double cosine(RealVector v) {
+    public double cosine(RealVector v) throws MathArithmeticException {
         final double norm = getNorm();
         final double vNorm = v.getNorm();
 
@@ -664,11 +664,11 @@ public abstract class RealVector {
      * @param v vector onto which instance must be projected.
      * @return projection of the instance onto {@code v}.
      * @throws MathArithmeticException if {@code this} or {@code v} is the null
-     * vector
-     * @throws org.apache.commons.math3.exception.DimensionMismatchException
-     * if {@code v} is not the same size as this vector.
+     *         vector
+     * @throws DimensionMismatchException if {@code v} is not the same size as
+     *         this vector.
      */
-    public RealVector projection(final RealVector v) {
+    public RealVector projection(final RealVector v) throws MathArithmeticException {
         final double norm2 = v.dotProduct(v);
         if (norm2 == 0.0) {
             throw new MathArithmeticException(LocalizedFormats.ZERO_NORM);
@@ -710,9 +710,9 @@ public abstract class RealVector {
      * The instance is not changed by this method.
      *
      * @return a unit vector pointing in direction of this vector.
-     * @throws ArithmeticException if the norm is {@code null}.
+     * @throws MathArithmeticException if the norm is zero.
      */
-    public RealVector unitVector() {
+    public RealVector unitVector() throws MathArithmeticException {
         final double norm = getNorm();
         if (norm == 0) {
             throw new MathArithmeticException(LocalizedFormats.ZERO_NORM);
@@ -724,10 +724,9 @@ public abstract class RealVector {
      * Converts this vector into a unit vector.
      * The instance itself is changed by this method.
      *
-     * @throws org.apache.commons.math3.exception.MathArithmeticException
-     * if the norm is zero.
+     * @throws MathArithmeticException if the norm is zero.
      */
-    public void unitize() {
+    public void unitize() throws MathArithmeticException {
         final double norm = getNorm();
         if (norm == 0) {
             throw new MathArithmeticException(LocalizedFormats.ZERO_NORM);
@@ -1351,7 +1350,7 @@ public abstract class RealVector {
 
             /** {@inheritDoc} */
             @Override
-            public double cosine(RealVector w) {
+            public double cosine(RealVector w) throws MathArithmeticException {
                 return v.cosine(w);
             }
 
@@ -1393,7 +1392,7 @@ public abstract class RealVector {
 
             /** {@inheritDoc} */
             @Override
-            public RealVector unitVector() {
+            public RealVector unitVector() throws MathArithmeticException {
                 return v.unitVector();
             }