Author: luc Date: Sun Feb 15 19:15:51 2009 New Revision: 744724 URL: http://svn.apache.org/viewvc?rev=744724&view=rev Log: improved error messages consistency fixed checkstyle warnings
Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/MessagesResources_fr.java commons/proper/math/trunk/src/java/org/apache/commons/math/linear/EigenDecompositionImpl.java commons/proper/math/trunk/src/java/org/apache/commons/math/linear/SingularValueDecompositionImpl.java commons/proper/math/trunk/src/java/org/apache/commons/math/linear/SparseRealVector.java Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/MessagesResources_fr.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/MessagesResources_fr.java?rev=744724&r1=744723&r2=744724&view=diff ============================================================================== --- commons/proper/math/trunk/src/java/org/apache/commons/math/MessagesResources_fr.java (original) +++ commons/proper/math/trunk/src/java/org/apache/commons/math/MessagesResources_fr.java Sun Feb 15 19:15:51 2009 @@ -189,6 +189,16 @@ { "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}]" }, Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/linear/EigenDecompositionImpl.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/linear/EigenDecompositionImpl.java?rev=744724&r1=744723&r2=744724&view=diff ============================================================================== --- commons/proper/math/trunk/src/java/org/apache/commons/math/linear/EigenDecompositionImpl.java (original) +++ commons/proper/math/trunk/src/java/org/apache/commons/math/linear/EigenDecompositionImpl.java Sun Feb 15 19:15:51 2009 @@ -22,6 +22,7 @@ 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 @@ 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 @@ 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 @@ 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(); Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/linear/SingularValueDecompositionImpl.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/linear/SingularValueDecompositionImpl.java?rev=744724&r1=744723&r2=744724&view=diff ============================================================================== --- commons/proper/math/trunk/src/java/org/apache/commons/math/linear/SingularValueDecompositionImpl.java (original) +++ commons/proper/math/trunk/src/java/org/apache/commons/math/linear/SingularValueDecompositionImpl.java Sun Feb 15 19:15:51 2009 @@ -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 @@ 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 @@ 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 @@ 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); Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/linear/SparseRealVector.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/linear/SparseRealVector.java?rev=744724&r1=744723&r2=744724&view=diff ============================================================================== --- commons/proper/math/trunk/src/java/org/apache/commons/math/linear/SparseRealVector.java (original) +++ commons/proper/math/trunk/src/java/org/apache/commons/math/linear/SparseRealVector.java Sun Feb 15 19:15:51 2009 @@ -1191,8 +1191,8 @@ 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 @@ */ 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 @@ return getData(); } - /* (non-Javadoc) - * @see java.lang.Object#hashCode() - */ + /** {...@inheritdoc} */ @Override public int hashCode() { final int prime = 31; @@ -1230,9 +1229,7 @@ return result; } - /* (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ + /** {...@inheritdoc} */ @Override public boolean equals(Object obj) { if (this == obj)