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/27 07:04:10 UTC

svn commit: r1390842 - in /commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear: AbstractRealMatrix.java OpenMapRealMatrix.java

Author: celestin
Date: Thu Sep 27 05:04:10 2012
New Revision: 1390842

URL: http://svn.apache.org/viewvc?rev=1390842&view=rev
Log:
Populated throws clause of OpenMapRealMatrix (MATH-854).

Modified:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/AbstractRealMatrix.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/OpenMapRealMatrix.java

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/AbstractRealMatrix.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/AbstractRealMatrix.java?rev=1390842&r1=1390841&r2=1390842&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/AbstractRealMatrix.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/AbstractRealMatrix.java Thu Sep 27 05:04:10 2012
@@ -976,5 +976,6 @@ public abstract class AbstractRealMatrix
         throws OutOfRangeException;
 
     /** {@inheritDoc} */
-    public abstract void setEntry(int row, int column, double value);
+    public abstract void setEntry(int row, int column, double value)
+        throws OutOfRangeException;
 }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/OpenMapRealMatrix.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/OpenMapRealMatrix.java?rev=1390842&r1=1390841&r2=1390842&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/OpenMapRealMatrix.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/OpenMapRealMatrix.java Thu Sep 27 05:04:10 2012
@@ -19,7 +19,10 @@ package org.apache.commons.math3.linear;
 
 import java.io.Serializable;
 
+import org.apache.commons.math3.exception.DimensionMismatchException;
+import org.apache.commons.math3.exception.NotStrictlyPositiveException;
 import org.apache.commons.math3.exception.NumberIsTooLargeException;
+import org.apache.commons.math3.exception.OutOfRangeException;
 import org.apache.commons.math3.util.OpenIntToDoubleHashMap;
 
 /**
@@ -50,8 +53,13 @@ public class OpenMapRealMatrix extends A
      *
      * @param rowDimension Number of rows of the matrix.
      * @param columnDimension Number of columns of the matrix.
+     * @throws NotStrictlyPositiveException if row or column dimension is not
+     * positive.
+     * @throws NumberIsTooLargeException if the total number of entries of the
+     * matrix is larger than {@code Integer.MAX_VALUE}.
      */
-    public OpenMapRealMatrix(int rowDimension, int columnDimension) {
+    public OpenMapRealMatrix(int rowDimension, int columnDimension)
+        throws NotStrictlyPositiveException, NumberIsTooLargeException {
         super(rowDimension, columnDimension);
         long lRow = rowDimension;
         long lCol = columnDimension;
@@ -80,9 +88,15 @@ public class OpenMapRealMatrix extends A
         return new OpenMapRealMatrix(this);
     }
 
-    /** {@inheritDoc} */
+    /**
+     * {@inheritDoc}
+     *
+     * @throws NumberIsTooLargeException if the total number of entries of the
+     * matrix is larger than {@code Integer.MAX_VALUE}.
+     */
     @Override
-    public OpenMapRealMatrix createMatrix(int rowDimension, int columnDimension) {
+    public OpenMapRealMatrix createMatrix(int rowDimension, int columnDimension)
+        throws NotStrictlyPositiveException, NumberIsTooLargeException {
         return new OpenMapRealMatrix(rowDimension, columnDimension);
     }
 
@@ -97,12 +111,12 @@ public class OpenMapRealMatrix extends A
      *
      * @param m Matrix to be added.
      * @return {@code this} + {@code m}.
-     * @throws org.apache.commons.math3.exception.DimensionMismatchException
-     * if {@code m} is not the same size as this matrix.
+     * @throws MatrixDimensionMismatchException if {@code m} is not the same
+     * size as {@code this}.
      */
-    public OpenMapRealMatrix add(OpenMapRealMatrix m) {
+    public OpenMapRealMatrix add(OpenMapRealMatrix m)
+        throws MatrixDimensionMismatchException {
 
-        // safety check
         MatrixUtils.checkAdditionCompatible(this, m);
 
         final OpenMapRealMatrix out = new OpenMapRealMatrix(this);
@@ -119,7 +133,8 @@ public class OpenMapRealMatrix extends A
 
     /** {@inheritDoc} */
     @Override
-    public OpenMapRealMatrix subtract(final RealMatrix m) {
+    public OpenMapRealMatrix subtract(final RealMatrix m)
+        throws MatrixDimensionMismatchException {
         try {
             return subtract((OpenMapRealMatrix) m);
         } catch (ClassCastException cce) {
@@ -132,11 +147,11 @@ public class OpenMapRealMatrix extends A
      *
      * @param m Matrix to be subtracted.
      * @return {@code this} - {@code m}.
-     * @throws org.apache.commons.math3.exception.DimensionMismatchException
-     * if {@code m} is not the same size as this matrix.
+     * @throws MatrixDimensionMismatchException if {@code m} is not the same
+     * size as {@code this}.
      */
-    public OpenMapRealMatrix subtract(OpenMapRealMatrix m) {
-        // Safety check.
+    public OpenMapRealMatrix subtract(OpenMapRealMatrix m)
+        throws MatrixDimensionMismatchException {
         MatrixUtils.checkAdditionCompatible(this, m);
 
         final OpenMapRealMatrix out = new OpenMapRealMatrix(this);
@@ -150,14 +165,20 @@ public class OpenMapRealMatrix extends A
         return out;
     }
 
-    /** {@inheritDoc} */
+    /**
+     * {@inheritDoc}
+     *
+     * @throws NumberIsTooLargeException if {@code m} is an
+     * {@code OpenMapRealMatrix}, and the total number of entries of the product
+     * is larger than {@code Integer.MAX_VALUE}.
+     */
     @Override
-    public RealMatrix multiply(final RealMatrix m) {
+    public RealMatrix multiply(final RealMatrix m)
+        throws DimensionMismatchException, NumberIsTooLargeException {
         try {
             return multiply((OpenMapRealMatrix) m);
         } catch (ClassCastException cce) {
 
-            // safety check
             MatrixUtils.checkMultiplicationCompatible(this, m);
 
             final int outCols = m.getColumnDimension();
@@ -182,11 +203,13 @@ public class OpenMapRealMatrix extends A
      *
      * @param m Matrix to postmultiply by.
      * @return {@code this} * {@code m}.
-     * @throws MatrixDimensionMismatchException
-     * if the number of rows of {@code m} differ from the number of columns
-     * of this matrix.
+     * @throws DimensionMismatchException if the number of rows of {@code m}
+     * differ from the number of columns of {@code this} matrix.
+     * @throws NumberIsTooLargeException if the total number of entries of the
+     * product is larger than {@code Integer.MAX_VALUE}.
      */
-    public OpenMapRealMatrix multiply(OpenMapRealMatrix m) {
+    public OpenMapRealMatrix multiply(OpenMapRealMatrix m)
+        throws DimensionMismatchException, NumberIsTooLargeException {
         // Safety check.
         MatrixUtils.checkMultiplicationCompatible(this, m);
 
@@ -218,7 +241,7 @@ public class OpenMapRealMatrix extends A
 
     /** {@inheritDoc} */
     @Override
-    public double getEntry(int row, int column) {
+    public double getEntry(int row, int column) throws OutOfRangeException {
         MatrixUtils.checkRowIndex(this, row);
         MatrixUtils.checkColumnIndex(this, column);
         return entries.get(computeKey(row, column));
@@ -232,7 +255,8 @@ public class OpenMapRealMatrix extends A
 
     /** {@inheritDoc} */
     @Override
-    public void setEntry(int row, int column, double value) {
+    public void setEntry(int row, int column, double value)
+        throws OutOfRangeException {
         MatrixUtils.checkRowIndex(this, row);
         MatrixUtils.checkColumnIndex(this, column);
         if (value == 0.0) {
@@ -244,7 +268,8 @@ public class OpenMapRealMatrix extends A
 
     /** {@inheritDoc} */
     @Override
-    public void addToEntry(int row, int column, double increment) {
+    public void addToEntry(int row, int column, double increment)
+        throws OutOfRangeException {
         MatrixUtils.checkRowIndex(this, row);
         MatrixUtils.checkColumnIndex(this, column);
         final int key = computeKey(row, column);
@@ -258,7 +283,8 @@ public class OpenMapRealMatrix extends A
 
     /** {@inheritDoc} */
     @Override
-    public void multiplyEntry(int row, int column, double factor) {
+    public void multiplyEntry(int row, int column, double factor)
+        throws OutOfRangeException {
         MatrixUtils.checkRowIndex(this, row);
         MatrixUtils.checkColumnIndex(this, column);
         final int key = computeKey(row, column);