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/12 20:37:47 UTC

svn commit: r1384082 - /commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/FieldVector.java

Author: celestin
Date: Wed Sep 12 18:37:46 2012
New Revision: 1384082

URL: http://svn.apache.org/viewvc?rev=1384082&view=rev
Log:
MATH-854: in interface FieldVector, replaced throws statements with javadoc comments.

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

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/FieldVector.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/FieldVector.java?rev=1384082&r1=1384081&r2=1384082&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/FieldVector.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/FieldVector.java Wed Sep 12 18:37:46 2012
@@ -18,11 +18,6 @@ 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.MathArithmeticException;
-import org.apache.commons.math3.exception.NotPositiveException;
-import org.apache.commons.math3.exception.NullArgumentException;
-import org.apache.commons.math3.exception.OutOfRangeException;
 
 /**
  * Interface defining a field-valued vector with basic algebraic operations.
@@ -63,22 +58,24 @@ public interface FieldVector<T extends F
     FieldVector<T> copy();
 
     /**
-     * Compute the sum of {@code this} and {@code v}.
+     * Compute the sum of {@code this} and {@code v}. Implementations should throw
+     * {@link org.apache.commons.math3.exception.DimensionMismatchException} if
+     * {@code v} is not the same size as {@code this}.
+     *
      * @param v vector to be added
      * @return {@code this + v}
-     * @throws DimensionMismatchException if {@code v} is not the same size as
-     * {@code this}
      */
-    FieldVector<T> add(FieldVector<T> v) throws DimensionMismatchException;
+    FieldVector<T> add(FieldVector<T> v);
 
     /**
-     * Compute {@code this} minus {@code v}.
+     * Compute {@code this} minus {@code v}. Implementations should throw
+     * {@link org.apache.commons.math3.exception.DimensionMismatchException} if
+     * {@code v} is not the same size as {@code this}
+     *
      * @param v vector to be subtracted
      * @return {@code this + v}
-     * @throws DimensionMismatchException if {@code v} is not the same size as
-     * {@code this}
      */
-    FieldVector<T> subtract(FieldVector<T> v) throws DimensionMismatchException;
+    FieldVector<T> subtract(FieldVector<T> v);
 
     /**
      * Map an addition operation to each entry.
@@ -126,62 +123,78 @@ public interface FieldVector<T extends F
     FieldVector<T> mapMultiplyToSelf(T d);
 
     /**
-     * Map a division operation to each entry.
+     * Map a division operation to each entry. Implementations should throw
+     * <ul>
+     * <li>{@link org.apache.commons.math3.exception.NullArgumentException} if
+     *     {@code d} is {@code null},</li>
+     * <li>{@link org.apache.commons.math3.exception.MathArithmeticException} if
+     *     {@code d} is zero.</li>
+     * </ul>
+     *
      * @param d value to divide all entries by
      * @return {@code this / d}
-     * @throws NullArgumentException if {@code d} is {@code null}.
-     * @throws MathArithmeticException if {@code d} is zero.
      */
-    FieldVector<T> mapDivide(T d)
-        throws NullArgumentException, MathArithmeticException;
+    FieldVector<T> mapDivide(T d);
 
     /**
-     * Map a division operation to each entry.
-     * <p>The instance <strong>is</strong> changed by this method.</p>
+     * Map a division operation to each entry. The instance <strong>is</strong>
+     * changed by this method.
+     * <ul>
+     * <li>{@link org.apache.commons.math3.exception.NullArgumentException} if
+     *     {@code d} is {@code null},</li>
+     * <li>{@link org.apache.commons.math3.exception.MathArithmeticException} if
+     *     {@code d} is zero.</li>
+     * </ul>
+     *
      * @param d value to divide all entries by
      * @return for convenience, return {@code this}
-     * @throws NullArgumentException if {@code d} is {@code null}.
-     * @throws MathArithmeticException if {@code d} is zero.
      */
-    FieldVector<T> mapDivideToSelf(T d)
-        throws NullArgumentException, MathArithmeticException;
+    FieldVector<T> mapDivideToSelf(T d);
 
     /**
-     * Map the 1/x function to each entry.
+     * Map the 1/x function to each entry. Implementations should throw
+     * {@link org.apache.commons.math3.exception.MathArithmeticException} if
+     * one of the entries is zero.
+     *
      * @return a vector containing the result of applying the function to each
      * entry.
-     * @throws MathArithmeticException if one of the entries is zero.
      */
-    FieldVector<T> mapInv() throws MathArithmeticException;
+    FieldVector<T> mapInv();
 
     /**
-     * Map the 1/x function to each entry.
-     * <p>The instance <strong>is</strong> changed by this method.</p>
+     * Map the 1/x function to each entry. The instance <strong>is</strong>
+     * changed by this method. Implementations should throw
+     * {@link org.apache.commons.math3.exception.MathArithmeticException} if
+     * one of the entries is zero.
+     *
      * @return for convenience, return {@code this}
-     * @throws MathArithmeticException if one of the entries is zero.
      */
-    FieldVector<T> mapInvToSelf() throws MathArithmeticException;
+    FieldVector<T> mapInvToSelf();
 
     /**
-     * Element-by-element multiplication.
+     * Element-by-element multiplication. Implementations should throw
+     * {@link org.apache.commons.math3.exception.DimensionMismatchException} if
+     * {@code v} is not the same size as {@code this}.
+     *
      * @param v vector by which instance elements must be multiplied
      * @return a vector containing {@code this[i] * v[i]} for all {@code i}
-     * @throws DimensionMismatchException if {@code v} is not the same size as
-     * {@code this}
      */
-    FieldVector<T> ebeMultiply(FieldVector<T> v)
-        throws DimensionMismatchException;
+    FieldVector<T> ebeMultiply(FieldVector<T> v);
 
     /**
-     * Element-by-element division.
+     * Element-by-element division. Implementations should throw
+     * <ul>
+     * <li>{@link org.apache.commons.math3.exception.DimensionMismatchException}
+     *     if {@code v} is not the same size as {@code this},</li>
+     * <li>{@link org.apache.commons.math3.exception.MathArithmeticException}
+     *     if one entry of {@code v} is zero.
+     * </li>
+     * </ul>
+     *
      * @param v vector by which instance elements must be divided
      * @return a vector containing {@code this[i] / v[i]} for all {@code i}
-     * @throws DimensionMismatchException if {@code v} is not the same size as
-     * {@code this}
-     * @throws MathArithmeticException if one entry of {@code v} is zero.
      */
-    FieldVector<T> ebeDivide(FieldVector<T> v)
-        throws DimensionMismatchException, MathArithmeticException;
+    FieldVector<T> ebeDivide(FieldVector<T> v);
 
     /**
      * Returns vector entries as a T array.
@@ -190,23 +203,30 @@ public interface FieldVector<T extends F
      T[] getData();
 
     /**
-     * Compute the dot product.
+     * Compute the dot product. Implementations should throw
+     * {@link org.apache.commons.math3.exception.DimensionMismatchException} if
+     * {@code v} is not the same size as {@code this}.
+     *
      * @param v vector with which dot product should be computed
      * @return the scalar dot product of {@code this} and {@code v}
-     * @throws DimensionMismatchException if {@code v} is not the same size as
-     * {@code this}
      */
-    T dotProduct(FieldVector<T> v) throws DimensionMismatchException;
+    T dotProduct(FieldVector<T> v);
 
-    /** Find the orthogonal projection of this vector onto another vector.
+    /**
+     * Find the orthogonal projection of this vector onto another vector.
+     * Implementations should throw
+     * <ul>
+     * <li>{@link org.apache.commons.math3.exception.DimensionMismatchException}
+     *     if {@code v} is not the same size as {@code this},</li>
+     * <li>{@link org.apache.commons.math3.exception.MathArithmeticException}
+     *     if {@code v} is the null vector.
+     * </li>
+     * </ul>
+     *
      * @param v vector onto which {@code this} must be projected
      * @return projection of {@code this} onto {@code v}
-     * @throws DimensionMismatchException if {@code v} is not the same size as
-     * {@code this}
-     * @throws MathArithmeticException if {@code v} is the null vector.
      */
-    FieldVector<T> projection(FieldVector<T> v)
-        throws DimensionMismatchException, MathArithmeticException;
+    FieldVector<T> projection(FieldVector<T> v);
 
     /**
      * Compute the outer product.
@@ -216,23 +236,30 @@ public interface FieldVector<T extends F
     FieldMatrix<T> outerProduct(FieldVector<T> v);
 
     /**
-     * Returns the entry in the specified index.
+     * Returns the entry in the specified index. Implementations should throw
+     * {@link org.apache.commons.math3.exception.OutOfRangeException} if the
+     * index is not valid.
      *
      * @param index Index location of entry to be fetched.
      * @return the vector entry at {@code index}.
-     * @throws OutOfRangeException if the index is not valid.
      * @see #setEntry(int, FieldElement)
      */
-    T getEntry(int index) throws OutOfRangeException;
+    T getEntry(int index);
 
     /**
-     * Set a single element.
+     * Set a single element. Implementations should throw
+     * <ul>
+     * <li>{@link org.apache.commons.math3.exception.OutOfRangeException} if the
+     *     index is not valid,</li>
+     * <li>{@link org.apache.commons.math3.exception.NullArgumentException} if
+     *     the value is {@code null}.</li>
+     * </ul>
+     *
      * @param index element index.
      * @param value new value for the element.
-     * @throws OutOfRangeException if the index is not valid.
      * @see #getEntry(int)
      */
-    void setEntry(int index, T value) throws OutOfRangeException;
+    void setEntry(int index, T value);
 
     /**
      * Returns the size of the vector.
@@ -255,23 +282,29 @@ public interface FieldVector<T extends F
     FieldVector<T> append(T d);
 
     /**
-     * Get a subvector from consecutive elements.
+     * Get a subvector from consecutive elements. Implementations should throw
+     * <ul>
+     * <li>{@link org.apache.commons.math3.exception.OutOfRangeException} if the
+     *     index is not valid,</li>
+     * <li>{@link org.apache.commons.math3.exception.NotPositiveException} if
+     *     the number of elements is not positive.</li>
+     * </ul>
+     *
      * @param index index of first element.
      * @param n number of elements to be retrieved.
      * @return a vector containing n elements.
-     * @throws OutOfRangeException if the index is not valid.
-     * @throws NotPositiveException if the number of elements if not positive.
      */
-    FieldVector<T> getSubVector(int index, int n)
-        throws OutOfRangeException, NotPositiveException;
+    FieldVector<T> getSubVector(int index, int n);
 
     /**
-     * Set a set of consecutive elements.
+     * Set a set of consecutive elements. Implementations should throw
+     * {@link org.apache.commons.math3.exception.OutOfRangeException} if the
+     * index is not valid.
+     *
      * @param index index of first element to be set.
      * @param v vector containing the values to set.
-     * @throws OutOfRangeException if the index is not valid.
      */
-    void setSubVector(int index, FieldVector<T> v) throws OutOfRangeException;
+    void setSubVector(int index, FieldVector<T> v);
 
     /**
      * Set all elements to a single value.