improved error messages

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@723359 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Luc Maisonobe 2008-12-04 15:41:57 +00:00
parent 6d37e391c7
commit f1fa39e47a
2 changed files with 42 additions and 8 deletions

View File

@ -174,8 +174,6 @@ public class MessagesResources_fr
// org.apache.commons.math.linear.EigenDecompositionImpl
{ "cannot solve degree {0} equation",
"impossible de r\u00e9soudre une \u00e9quation de degr\u00e9 {0}" },
{ "negative element on decomposed tridiagonal of {0}x{1} matrix",
"\u00e9l\u00e9ment n\u00e9gatif dans la d\u00e9composition tri-diagonale d''une matrice {0}x{1}" },
// org.apache.commons.math.linear.NonSquareMatrixException
{ "a {0}x{1} matrix was provided instead of a square matrix",
@ -209,6 +207,12 @@ public class MessagesResources_fr
"tableau des indices de lignes s\u00e9lectionn\u00e9es vide" },
{ "empty selected column index array",
"tableau des indices de colonnes s\u00e9lectionn\u00e9es vide" },
{ "{0}x{1} and {2}x{3} matrices are not multiplication compatible",
"les dimensions {0}x{1} et {2}x{3} sont incompatibles pour la multiplication matricielle" },
{ "{0}x{1} and {2}x{3} matrices are not addition compatible",
"les dimensions {0}x{1} et {2}x{3} sont incompatibles pour l'addition matricielle" },
{ "{0}x{1} and {2}x{3} matrices are not subtraction compatible",
"les dimensions {0}x{1} et {2}x{3} sont incompatibles pour la soustraction matricielle" },
// org.apache.commons.math.random.EmpiricalDistributionImpl
// org.apache.commons.math.random.ValueServer

View File

@ -174,7 +174,12 @@ public class RealMatrixImpl implements RealMatrix, Serializable {
final int rowCount = getRowDimension();
final int columnCount = getColumnDimension();
if (columnCount != m.getColumnDimension() || rowCount != m.getRowDimension()) {
throw new IllegalArgumentException("matrix dimension mismatch");
throw MathRuntimeException.createIllegalArgumentException("{0}x{1} and {2}x{3} matrices are not" +
" addition compatible",
new Object[] {
getRowDimension(), getColumnDimension(),
m.getRowDimension(), m.getColumnDimension()
});
}
final double[][] outData = new double[rowCount][columnCount];
for (int row = 0; row < rowCount; row++) {
@ -199,7 +204,12 @@ public class RealMatrixImpl implements RealMatrix, Serializable {
final int rowCount = getRowDimension();
final int columnCount = getColumnDimension();
if (columnCount != m.getColumnDimension() || rowCount != m.getRowDimension()) {
throw new IllegalArgumentException("matrix dimension mismatch");
throw MathRuntimeException.createIllegalArgumentException("{0}x{1} and {2}x{3} matrices are not" +
" addition compatible",
new Object[] {
getRowDimension(), getColumnDimension(),
m.getRowDimension(), m.getColumnDimension()
});
}
final double[][] outData = new double[rowCount][columnCount];
for (int row = 0; row < rowCount; row++) {
@ -221,7 +231,12 @@ public class RealMatrixImpl implements RealMatrix, Serializable {
final int rowCount = getRowDimension();
final int columnCount = getColumnDimension();
if (columnCount != m.getColumnDimension() || rowCount != m.getRowDimension()) {
throw new IllegalArgumentException("matrix dimension mismatch");
throw MathRuntimeException.createIllegalArgumentException("{0}x{1} and {2}x{3} matrices are not" +
" subtraction compatible",
new Object[] {
getRowDimension(), getColumnDimension(),
m.getRowDimension(), m.getColumnDimension()
});
}
final double[][] outData = new double[rowCount][columnCount];
for (int row = 0; row < rowCount; row++) {
@ -246,7 +261,12 @@ public class RealMatrixImpl implements RealMatrix, Serializable {
final int rowCount = getRowDimension();
final int columnCount = getColumnDimension();
if (columnCount != m.getColumnDimension() || rowCount != m.getRowDimension()) {
throw new IllegalArgumentException("matrix dimension mismatch");
throw MathRuntimeException.createIllegalArgumentException("{0}x{1} and {2}x{3} matrices are not" +
" subtraction compatible",
new Object[] {
getRowDimension(), getColumnDimension(),
m.getRowDimension(), m.getColumnDimension()
});
}
final double[][] outData = new double[rowCount][columnCount];
for (int row = 0; row < rowCount; row++) {
@ -296,7 +316,12 @@ public class RealMatrixImpl implements RealMatrix, Serializable {
return multiply((RealMatrixImpl) m);
} catch (ClassCastException cce) {
if (this.getColumnDimension() != m.getRowDimension()) {
throw new IllegalArgumentException("Matrices are not multiplication compatible.");
throw MathRuntimeException.createIllegalArgumentException("{0}x{1} and {2}x{3} matrices are not" +
" multiplication compatible",
new Object[] {
getRowDimension(), getColumnDimension(),
m.getRowDimension(), m.getColumnDimension()
});
}
final int nRows = this.getRowDimension();
final int nCols = m.getColumnDimension();
@ -326,7 +351,12 @@ public class RealMatrixImpl implements RealMatrix, Serializable {
*/
public RealMatrixImpl multiply(RealMatrixImpl m) throws IllegalArgumentException {
if (this.getColumnDimension() != m.getRowDimension()) {
throw new IllegalArgumentException("Matrices are not multiplication compatible.");
throw MathRuntimeException.createIllegalArgumentException("{0}x{1} and {2}x{3} matrices are not" +
" multiplication compatible",
new Object[] {
getRowDimension(), getColumnDimension(),
m.getRowDimension(), m.getColumnDimension()
});
}
final int nRows = this.getRowDimension();
final int nCols = m.getColumnDimension();