MATH-854: document all exceptions in ArrayFieldVector.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1384212 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Sebastien Brisard 2012-09-13 06:11:05 +00:00
parent 10af7e2b2f
commit 8469bc496c
1 changed files with 122 additions and 40 deletions

View File

@ -97,7 +97,7 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
* @see #ArrayFieldVector(Field, FieldElement[])
*/
public ArrayFieldVector(T[] d)
throws NullArgumentException, ZeroException {
throws NullArgumentException, ZeroException {
if (d == null) {
throw new NullArgumentException();
}
@ -118,7 +118,7 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
* @see #ArrayFieldVector(FieldElement[])
*/
public ArrayFieldVector(Field<T> field, T[] d)
throws NullArgumentException {
throws NullArgumentException {
if (d == null) {
throw new NullArgumentException();
}
@ -148,7 +148,7 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
* @see #ArrayFieldVector(Field, FieldElement[], boolean)
*/
public ArrayFieldVector(T[] d, boolean copyArray)
throws NullArgumentException, ZeroException {
throws NullArgumentException, ZeroException {
if (d == null) {
throw new NullArgumentException();
}
@ -175,7 +175,7 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
* @see #ArrayFieldVector(FieldElement[], boolean)
*/
public ArrayFieldVector(Field<T> field, T[] d, boolean copyArray)
throws NullArgumentException {
throws NullArgumentException {
if (d == null) {
throw new NullArgumentException();
}
@ -194,7 +194,7 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
* than {@code pos + size}.
*/
public ArrayFieldVector(T[] d, int pos, int size)
throws NullArgumentException, NumberIsTooLargeException {
throws NullArgumentException, NumberIsTooLargeException {
if (d == null) {
throw new NullArgumentException();
}
@ -218,7 +218,7 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
* than {@code pos + size}.
*/
public ArrayFieldVector(Field<T> field, T[] d, int pos, int size)
throws NullArgumentException, NumberIsTooLargeException {
throws NullArgumentException, NumberIsTooLargeException {
if (d == null) {
throw new NullArgumentException();
}
@ -237,7 +237,7 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
* @throws NullArgumentException if {@code v} is {@code null}.
*/
public ArrayFieldVector(FieldVector<T> v)
throws NullArgumentException {
throws NullArgumentException {
if (v == null) {
throw new NullArgumentException();
}
@ -255,7 +255,7 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
* @throws NullArgumentException if {@code v} is {@code null}.
*/
public ArrayFieldVector(ArrayFieldVector<T> v)
throws NullArgumentException {
throws NullArgumentException {
if (v == null) {
throw new NullArgumentException();
}
@ -272,7 +272,7 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
* @throws NullArgumentException if {@code v} is {@code null}.
*/
public ArrayFieldVector(ArrayFieldVector<T> v, boolean deep)
throws NullArgumentException {
throws NullArgumentException {
if (v == null) {
throw new NullArgumentException();
}
@ -289,7 +289,7 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
* {@code null}.
*/
public ArrayFieldVector(ArrayFieldVector<T> v1, ArrayFieldVector<T> v2)
throws NullArgumentException {
throws NullArgumentException {
if (v1 == null || v2 == null) {
throw new NullArgumentException();
}
@ -308,7 +308,7 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
* {@code null}.
*/
public ArrayFieldVector(ArrayFieldVector<T> v1, T[] v2)
throws NullArgumentException {
throws NullArgumentException {
if (v1 == null || v2 == null) {
throw new NullArgumentException();
}
@ -327,7 +327,7 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
* {@code null}.
*/
public ArrayFieldVector(T[] v1, ArrayFieldVector<T> v2)
throws NullArgumentException {
throws NullArgumentException {
if (v1 == null || v2 == null) {
throw new NullArgumentException();
}
@ -353,7 +353,7 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
* @see #ArrayFieldVector(Field, FieldElement[], FieldElement[])
*/
public ArrayFieldVector(T[] v1, T[] v2)
throws NullArgumentException, ZeroException {
throws NullArgumentException, ZeroException {
if (v1 == null || v2 == null) {
throw new NullArgumentException();
}
@ -378,7 +378,7 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
* @see #ArrayFieldVector(FieldElement[], FieldElement[])
*/
public ArrayFieldVector(Field<T> field, T[] v1, T[] v2)
throws NullArgumentException, ZeroException {
throws NullArgumentException, ZeroException {
if (v1 == null || v2 == null) {
throw new NullArgumentException();
}
@ -412,7 +412,12 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
return new ArrayFieldVector<T>(this, true);
}
/** {@inheritDoc} */
/**
* {@inheritDoc}
*
* @throws DimensionMismatchException if {@code v} is not the same size as
* {@code this}.
*/
public FieldVector<T> add(FieldVector<T> v)
throws DimensionMismatchException {
try {
@ -444,7 +449,12 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
return new ArrayFieldVector<T>(field, out, false);
}
/** {@inheritDoc} */
/**
* {@inheritDoc}
*
* @throws DimensionMismatchException if {@code v} is not the same size as
* {@code this}.
*/
public FieldVector<T> subtract(FieldVector<T> v)
throws DimensionMismatchException {
try {
@ -476,8 +486,12 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
return new ArrayFieldVector<T>(field, out, false);
}
/** {@inheritDoc} */
public FieldVector<T> mapAdd(T d) {
/**
* {@inheritDoc}
*
* @throws NullArgumentException if {@code d} is {@code null}.
*/
public FieldVector<T> mapAdd(T d) throws NullArgumentException {
T[] out = buildArray(data.length);
for (int i = 0; i < data.length; i++) {
out[i] = data[i].add(d);
@ -485,16 +499,24 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
return new ArrayFieldVector<T>(field, out, false);
}
/** {@inheritDoc} */
public FieldVector<T> mapAddToSelf(T d) {
/**
* {@inheritDoc}
*
* @throws NullArgumentException if {@code d} is {@code null}.
*/
public FieldVector<T> mapAddToSelf(T d) throws NullArgumentException {
for (int i = 0; i < data.length; i++) {
data[i] = data[i].add(d);
}
return this;
}
/** {@inheritDoc} */
public FieldVector<T> mapSubtract(T d) {
/**
* {@inheritDoc}
*
* @throws NullArgumentException if {@code d} is {@code null}.
*/
public FieldVector<T> mapSubtract(T d) throws NullArgumentException {
T[] out = buildArray(data.length);
for (int i = 0; i < data.length; i++) {
out[i] = data[i].subtract(d);
@ -502,16 +524,24 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
return new ArrayFieldVector<T>(field, out, false);
}
/** {@inheritDoc} */
public FieldVector<T> mapSubtractToSelf(T d) {
/**
* {@inheritDoc}
*
* @throws NullArgumentException if {@code d} is {@code null}.
*/
public FieldVector<T> mapSubtractToSelf(T d) throws NullArgumentException {
for (int i = 0; i < data.length; i++) {
data[i] = data[i].subtract(d);
}
return this;
}
/** {@inheritDoc} */
public FieldVector<T> mapMultiply(T d) {
/**
* {@inheritDoc}
*
* @throws NullArgumentException if {@code d} is {@code null}.
*/
public FieldVector<T> mapMultiply(T d) throws NullArgumentException {
T[] out = buildArray(data.length);
for (int i = 0; i < data.length; i++) {
out[i] = data[i].multiply(d);
@ -519,15 +549,24 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
return new ArrayFieldVector<T>(field, out, false);
}
/** {@inheritDoc} */
public FieldVector<T> mapMultiplyToSelf(T d) {
/**
* {@inheritDoc}
*
* @throws NullArgumentException if {@code d} is {@code null}.
*/
public FieldVector<T> mapMultiplyToSelf(T d) throws NullArgumentException {
for (int i = 0; i < data.length; i++) {
data[i] = data[i].multiply(d);
}
return this;
}
/** {@inheritDoc} */
/**
* {@inheritDoc}
*
* @throws NullArgumentException if {@code d} is {@code null}.
* @throws MathArithmeticException if {@code d} is zero.
*/
public FieldVector<T> mapDivide(T d)
throws NullArgumentException, MathArithmeticException {
if (d == null) {
@ -540,7 +579,12 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
return new ArrayFieldVector<T>(field, out, false);
}
/** {@inheritDoc} */
/**
* {@inheritDoc}
*
* @throws NullArgumentException if {@code d} is {@code null}.
* @throws MathArithmeticException if {@code d} is zero.
*/
public FieldVector<T> mapDivideToSelf(T d)
throws NullArgumentException, MathArithmeticException {
if (d == null) {
@ -552,7 +596,11 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
return this;
}
/** {@inheritDoc} */
/**
* {@inheritDoc}
*
* @throws MathArithmeticException if {@code d} is zero.
*/
public FieldVector<T> mapInv() throws MathArithmeticException {
T[] out = buildArray(data.length);
final T one = field.getOne();
@ -566,7 +614,11 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
return new ArrayFieldVector<T>(field, out, false);
}
/** {@inheritDoc} */
/**
* {@inheritDoc}
*
* @throws MathArithmeticException if {@code d} is zero.
*/
public FieldVector<T> mapInvToSelf() throws MathArithmeticException {
final T one = field.getOne();
for (int i = 0; i < data.length; i++) {
@ -579,7 +631,12 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
return this;
}
/** {@inheritDoc} */
/**
* {@inheritDoc}
*
* @throws DimensionMismatchException if {@code v} is not the same size as
* {@code this}.
*/
public FieldVector<T> ebeMultiply(FieldVector<T> v)
throws DimensionMismatchException {
try {
@ -611,7 +668,13 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
return new ArrayFieldVector<T>(field, out, false);
}
/** {@inheritDoc} */
/**
* {@inheritDoc}
*
* @throws DimensionMismatchException if {@code v} is not the same size as
* {@code this}.
* @throws MathArithmeticException if one entry of {@code v} is zero.
*/
public FieldVector<T> ebeDivide(FieldVector<T> v)
throws DimensionMismatchException, MathArithmeticException {
try {
@ -666,9 +729,13 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
return data;
}
/** {@inheritDoc} */
public T dotProduct(FieldVector<T> v)
throws DimensionMismatchException {
/**
* {@inheritDoc}
*
* @throws DimensionMismatchException if {@code v} is not the same size as
* {@code this}.
*/
public T dotProduct(FieldVector<T> v) throws DimensionMismatchException {
try {
return dotProduct((ArrayFieldVector<T>) v);
} catch (ClassCastException cce) {
@ -698,7 +765,13 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
return dot;
}
/** {@inheritDoc} */
/**
* {@inheritDoc}
*
* @throws DimensionMismatchException if {@code v} is not the same size as
* {@code this}.
* @throws MathArithmeticException if {@code v} is the null vector.
*/
public FieldVector<T> projection(FieldVector<T> v)
throws DimensionMismatchException, MathArithmeticException {
return v.mapMultiply(dotProduct(v).divide(v.dotProduct(v)));
@ -786,7 +859,12 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
return new ArrayFieldVector<T>(field, out, false);
}
/** {@inheritDoc} */
/**
* {@inheritDoc}
*
* @throws OutOfRangeException if the index is not valid.
* @throws NotPositiveException if the number of elements is not positive.
*/
public FieldVector<T> getSubVector(int index, int n)
throws OutOfRangeException, NotPositiveException {
if (n < 0) {
@ -811,7 +889,11 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
}
}
/** {@inheritDoc} */
/**
* {@inheritDoc}
*
* @throws OutOfRangeException if the index is not valid.
*/
public void setSubVector(int index, FieldVector<T> v) throws OutOfRangeException {
try {
try {