improved error messages consistency

fixed checkstyle warnings

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@744724 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Luc Maisonobe 2009-02-15 19:15:51 +00:00
parent 59e6743960
commit 0992284ca5
4 changed files with 43 additions and 16 deletions

View File

@ -189,6 +189,16 @@ public class MessagesResources_fr
{ "matrix is singular",
"matrice singuli\u00e8re" },
// org.apache.commons.math.linear.CholeskyDecompositionImpl
// org.apache.commons.math.linear.EigenDecompositionImpl
// org.apache.commons.math.linear.LUDecompositionImpl
// org.apache.commons.math.linear.QRDecompositionImpl
// org.apache.commons.math.linear.SingularValueDecompositionImpl
{ "vector length mismatch: got {0} but expected {1}",
"dimension de vecteur erronn\u00e9e : {0} \u00e0 la place de {1}" },
{ "dimensions mismatch: got {0}x{1} but expected {2}x{3}",
"dimensions erronn\u00e9es : {0}x{1} \u00e0 la place de {2}x{3}" },
// org.apache.commons.math.linear.RealVectorImpl
{ "index {0} out of allowed range [{1}, {2}]",
"index {0} hors de la plage autoris\u00e9e [{1}, {2}]" },

View File

@ -22,6 +22,7 @@ import java.util.Arrays;
import java.util.List;
import org.apache.commons.math.ConvergenceException;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.MaxIterationsExceededException;
import org.apache.commons.math.util.MathUtils;
@ -404,7 +405,9 @@ public class EigenDecompositionImpl implements EigenDecomposition {
final int m = realEigenvalues.length;
if (b.length != m) {
throw new IllegalArgumentException("constant vector has wrong length");
throw MathRuntimeException.createIllegalArgumentException(
"vector length mismatch: got {0} but expected {1}",
new Object[] { b.length, m });
}
final double[] bp = new double[m];
@ -438,7 +441,9 @@ public class EigenDecompositionImpl implements EigenDecomposition {
final int m = realEigenvalues.length;
if (b.getDimension() != m) {
throw new IllegalArgumentException("constant vector has wrong length");
throw MathRuntimeException.createIllegalArgumentException(
"vector length mismatch: got {0} but expected {1}",
new Object[] { b.getDimension(), m });
}
final double[] bp = new double[m];
@ -472,7 +477,12 @@ public class EigenDecompositionImpl implements EigenDecomposition {
final int m = realEigenvalues.length;
if (b.getRowDimension() != m) {
throw new IllegalArgumentException("Incorrect row dimension");
throw MathRuntimeException.createIllegalArgumentException(
"dimensions mismatch: got {0}x{1} but expected {2}x{3}",
new Object[] {
b.getRowDimension(), b.getColumnDimension(),
m, "n"
});
}
final int nColB = b.getColumnDimension();

View File

@ -18,6 +18,7 @@
package org.apache.commons.math.linear;
import org.apache.commons.math.ConvergenceException;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.util.MathUtils;
/**
@ -336,7 +337,9 @@ public class SingularValueDecompositionImpl implements SingularValueDecompositio
throws IllegalArgumentException, InvalidMatrixException {
if (b.length != singularValues.length) {
throw new IllegalArgumentException("constant vector has wrong length");
throw MathRuntimeException.createIllegalArgumentException(
"vector length mismatch: got {0} but expected {1}",
new Object[] { b.length, singularValues.length });
}
final double[] w = uT.operate(b);
@ -363,7 +366,9 @@ public class SingularValueDecompositionImpl implements SingularValueDecompositio
throws IllegalArgumentException, InvalidMatrixException {
if (b.getDimension() != singularValues.length) {
throw new IllegalArgumentException("constant vector has wrong length");
throw MathRuntimeException.createIllegalArgumentException(
"vector length mismatch: got {0} but expected {1}",
new Object[] { b.getDimension(), singularValues.length });
}
final RealVector w = uT.operate(b);
@ -390,7 +395,12 @@ public class SingularValueDecompositionImpl implements SingularValueDecompositio
throws IllegalArgumentException, InvalidMatrixException {
if (b.getRowDimension() != singularValues.length) {
throw new IllegalArgumentException("Incorrect row dimension");
throw MathRuntimeException.createIllegalArgumentException(
"dimensions mismatch: got {0}x{1} but expected {2}x{3}",
new Object[] {
b.getRowDimension(), b.getColumnDimension(),
singularValues.length, "n"
});
}
final RealMatrix w = uT.multiply(b);

View File

@ -1191,8 +1191,8 @@ public class SparseRealVector implements RealVector {
private void checkIndex(final int index) throws MatrixIndexException {
if (index < 0 || index >= getDimension()) {
throw new MatrixIndexException(
"index {0} out of allowed range [{1}, {2}]", new Object[] {
index, 0, getDimension() - 1 });
"index {0} out of allowed range [{1}, {2}]",
new Object[] { index, 0, getDimension() - 1 });
}
}
@ -1206,8 +1206,9 @@ public class SparseRealVector implements RealVector {
*/
protected void checkVectorDimensions(int n) throws IllegalArgumentException {
if (getDimension() != n) {
throw new IllegalArgumentException("vector dimension is "
+ getDimension() + ", not " + n + " as expected");
throw MathRuntimeException.createIllegalArgumentException(
"vector length mismatch: got {0} but expected {1}",
new Object[] { getDimension(), n });
}
}
@ -1216,9 +1217,7 @@ public class SparseRealVector implements RealVector {
return getData();
}
/* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
/** {@inheritDoc} */
@Override
public int hashCode() {
final int prime = 31;
@ -1230,9 +1229,7 @@ public class SparseRealVector implements RealVector {
return result;
}
/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
/** {@inheritDoc} */
@Override
public boolean equals(Object obj) {
if (this == obj)