replaced Object[] parameters by variable arguments in exceptions constructors
this allows simpler error declaration and removes the need for the strange null argument with fixed messages git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@746578 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8bf548c5e8
commit
2f335ac471
|
@ -173,11 +173,9 @@ public class RecursiveLayoutRealMatrix extends AbstractRealMatrix implements Ser
|
|||
// create storage array
|
||||
final int expectedLength = tileNumber * tileNumber * tileSizeRows * tileSizeColumns;
|
||||
if (data.length != expectedLength) {
|
||||
throw MathRuntimeException.createIllegalArgumentException("wrong array size (got {0}, expected {1})",
|
||||
new Object[] {
|
||||
data.length,
|
||||
expectedLength
|
||||
});
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"wrong array size (got {0}, expected {1})",
|
||||
data.length, expectedLength);
|
||||
}
|
||||
|
||||
if (copyArray) {
|
||||
|
@ -222,7 +220,7 @@ public class RecursiveLayoutRealMatrix extends AbstractRealMatrix implements Ser
|
|||
if (length != columns) {
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"some rows have length {0} while others have length {1}",
|
||||
new Object[] { columns, length });
|
||||
columns, length);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1028,10 +1026,9 @@ public class RecursiveLayoutRealMatrix extends AbstractRealMatrix implements Ser
|
|||
checkSubMatrixIndex(row, endRow, column, endColumn);
|
||||
for (final double[] subRow : subMatrix) {
|
||||
if (subRow.length != refLength) {
|
||||
throw MathRuntimeException.createIllegalArgumentException("some rows have length {0} while others have length {1}",
|
||||
new Object[] {
|
||||
refLength, subRow.length
|
||||
});
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"some rows have length {0} while others have length {1}",
|
||||
refLength, subRow.length);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1118,12 +1115,10 @@ public class RecursiveLayoutRealMatrix extends AbstractRealMatrix implements Ser
|
|||
final int nCols = getColumnDimension();
|
||||
if ((matrix.getRowDimension() != 1) ||
|
||||
(matrix.getColumnDimension() != nCols)) {
|
||||
throw new InvalidMatrixException("dimensions mismatch: got {0}x{1} but expected {2}x{3}",
|
||||
new Object[] {
|
||||
matrix.getRowDimension(),
|
||||
matrix.getColumnDimension(),
|
||||
1, nCols
|
||||
});
|
||||
throw new InvalidMatrixException(
|
||||
"dimensions mismatch: got {0}x{1} but expected {2}x{3}",
|
||||
matrix.getRowDimension(), matrix.getColumnDimension(),
|
||||
1, nCols);
|
||||
}
|
||||
|
||||
// a row matrix has always only one large tile,
|
||||
|
@ -1196,12 +1191,10 @@ public class RecursiveLayoutRealMatrix extends AbstractRealMatrix implements Ser
|
|||
final int nRows = getRowDimension();
|
||||
if ((matrix.getRowDimension() != nRows) ||
|
||||
(matrix.getColumnDimension() != 1)) {
|
||||
throw new InvalidMatrixException("dimensions mismatch: got {0}x{1} but expected {2}x{3}",
|
||||
new Object[] {
|
||||
matrix.getRowDimension(),
|
||||
matrix.getColumnDimension(),
|
||||
nRows, 1
|
||||
});
|
||||
throw new InvalidMatrixException(
|
||||
"dimensions mismatch: got {0}x{1} but expected {2}x{3}",
|
||||
matrix.getRowDimension(), matrix.getColumnDimension(),
|
||||
nRows, 1);
|
||||
}
|
||||
|
||||
// a column matrix has always only one large tile,
|
||||
|
@ -1229,11 +1222,9 @@ public class RecursiveLayoutRealMatrix extends AbstractRealMatrix implements Ser
|
|||
} catch (ClassCastException cce) {
|
||||
checkRowIndex(row);
|
||||
if (vector.getDimension() != columns) {
|
||||
throw new InvalidMatrixException("dimensions mismatch: got {0}x{1} but expected {2}x{3}",
|
||||
new Object[] {
|
||||
1, vector.getDimension(),
|
||||
1, columns
|
||||
});
|
||||
throw new InvalidMatrixException(
|
||||
"dimensions mismatch: got {0}x{1} but expected {2}x{3}",
|
||||
1, vector.getDimension(), 1, columns);
|
||||
}
|
||||
|
||||
// perform copy tile-wise, to ensure good cache behavior
|
||||
|
@ -1260,11 +1251,9 @@ public class RecursiveLayoutRealMatrix extends AbstractRealMatrix implements Ser
|
|||
} catch (ClassCastException cce) {
|
||||
checkColumnIndex(column);
|
||||
if (vector.getDimension() != rows) {
|
||||
throw new InvalidMatrixException("dimensions mismatch: got {0}x{1} but expected {2}x{3}",
|
||||
new Object[] {
|
||||
vector.getDimension(), 1,
|
||||
rows, 1
|
||||
});
|
||||
throw new InvalidMatrixException(
|
||||
"dimensions mismatch: got {0}x{1} but expected {2}x{3}",
|
||||
vector.getDimension(), 1, rows, 1);
|
||||
}
|
||||
|
||||
// perform copy tile-wise, to ensure good cache behavior
|
||||
|
@ -1311,11 +1300,9 @@ public class RecursiveLayoutRealMatrix extends AbstractRealMatrix implements Ser
|
|||
|
||||
checkRowIndex(row);
|
||||
if (array.length != columns) {
|
||||
throw new InvalidMatrixException("dimensions mismatch: got {0}x{1} but expected {2}x{3}",
|
||||
new Object[] {
|
||||
1, array.length,
|
||||
1, columns
|
||||
});
|
||||
throw new InvalidMatrixException(
|
||||
"dimensions mismatch: got {0}x{1} but expected {2}x{3}",
|
||||
1, array.length, 1, columns);
|
||||
}
|
||||
|
||||
// perform copy tile-wise, to ensure good cache behavior
|
||||
|
@ -1362,11 +1349,9 @@ public class RecursiveLayoutRealMatrix extends AbstractRealMatrix implements Ser
|
|||
|
||||
checkColumnIndex(column);
|
||||
if (array.length != rows) {
|
||||
throw new InvalidMatrixException("dimensions mismatch: got {0}x{1} but expected {2}x{3}",
|
||||
new Object[] {
|
||||
array.length, 1,
|
||||
rows, 1
|
||||
});
|
||||
throw new InvalidMatrixException(
|
||||
"dimensions mismatch: got {0}x{1} but expected {2}x{3}",
|
||||
array.length, 1, rows, 1);
|
||||
}
|
||||
|
||||
// perform copy tile-wise, to ensure good cache behavior
|
||||
|
@ -1388,11 +1373,9 @@ public class RecursiveLayoutRealMatrix extends AbstractRealMatrix implements Ser
|
|||
public double getEntry(final int row, final int column)
|
||||
throws MatrixIndexException {
|
||||
if ((row < 0) || (row >= rows) || (column < 0) || (column >= columns)) {
|
||||
throw new MatrixIndexException("no entry at indices ({0}, {1}) in a {2}x{3} matrix",
|
||||
new Object[] {
|
||||
row, column,
|
||||
getRowDimension(), getColumnDimension()
|
||||
});
|
||||
throw new MatrixIndexException(
|
||||
"no entry at indices ({0}, {1}) in a {2}x{3} matrix",
|
||||
row, column, getRowDimension(), getColumnDimension());
|
||||
}
|
||||
return data[index(row, column)];
|
||||
}
|
||||
|
@ -1401,11 +1384,9 @@ public class RecursiveLayoutRealMatrix extends AbstractRealMatrix implements Ser
|
|||
public void setEntry(final int row, final int column, final double value)
|
||||
throws MatrixIndexException {
|
||||
if ((row < 0) || (row >= rows) || (column < 0) || (column >= columns)) {
|
||||
throw new MatrixIndexException("no entry at indices ({0}, {1}) in a {2}x{3} matrix",
|
||||
new Object[] {
|
||||
row, column,
|
||||
getRowDimension(), getColumnDimension()
|
||||
});
|
||||
throw new MatrixIndexException(
|
||||
"no entry at indices ({0}, {1}) in a {2}x{3} matrix",
|
||||
row, column, getRowDimension(), getColumnDimension());
|
||||
}
|
||||
data[index(row, column)] = value;
|
||||
}
|
||||
|
@ -1414,11 +1395,9 @@ public class RecursiveLayoutRealMatrix extends AbstractRealMatrix implements Ser
|
|||
public void addToEntry(final int row, final int column, final double increment)
|
||||
throws MatrixIndexException {
|
||||
if ((row < 0) || (row >= rows) || (column < 0) || (column >= columns)) {
|
||||
throw new MatrixIndexException("no entry at indices ({0}, {1}) in a {2}x{3} matrix",
|
||||
new Object[] {
|
||||
row, column,
|
||||
getRowDimension(), getColumnDimension()
|
||||
});
|
||||
throw new MatrixIndexException(
|
||||
"no entry at indices ({0}, {1}) in a {2}x{3} matrix",
|
||||
row, column, getRowDimension(), getColumnDimension());
|
||||
}
|
||||
data[index(row, column)] += increment;
|
||||
}
|
||||
|
@ -1427,11 +1406,9 @@ public class RecursiveLayoutRealMatrix extends AbstractRealMatrix implements Ser
|
|||
public void multiplyEntry(final int row, final int column, final double factor)
|
||||
throws MatrixIndexException {
|
||||
if ((row < 0) || (row >= rows) || (column < 0) || (column >= columns)) {
|
||||
throw new MatrixIndexException("no entry at indices ({0}, {1}) in a {2}x{3} matrix",
|
||||
new Object[] {
|
||||
row, column,
|
||||
getRowDimension(), getColumnDimension()
|
||||
});
|
||||
throw new MatrixIndexException(
|
||||
"no entry at indices ({0}, {1}) in a {2}x{3} matrix",
|
||||
row, column, getRowDimension(), getColumnDimension());
|
||||
}
|
||||
data[index(row, column)] *= factor;
|
||||
}
|
||||
|
@ -1486,11 +1463,9 @@ public class RecursiveLayoutRealMatrix extends AbstractRealMatrix implements Ser
|
|||
throws IllegalArgumentException {
|
||||
|
||||
if (v.length != columns) {
|
||||
throw MathRuntimeException.createIllegalArgumentException("vector length mismatch:" +
|
||||
" got {0} but expected {1}",
|
||||
new Object[] {
|
||||
v.length, columns
|
||||
});
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"vector length mismatch: got {0} but expected {1}",
|
||||
v.length, columns);
|
||||
}
|
||||
final double[] out = new double[rows];
|
||||
|
||||
|
@ -1531,11 +1506,9 @@ public class RecursiveLayoutRealMatrix extends AbstractRealMatrix implements Ser
|
|||
throws IllegalArgumentException {
|
||||
|
||||
if (v.length != rows) {
|
||||
throw MathRuntimeException.createIllegalArgumentException("vector length mismatch:" +
|
||||
" got {0} but expected {1}",
|
||||
new Object[] {
|
||||
v.length, rows
|
||||
});
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"vector length mismatch: got {0} but expected {1}",
|
||||
v.length, rows);
|
||||
}
|
||||
final double[] out = new double[columns];
|
||||
|
||||
|
|
|
@ -37,8 +37,7 @@ public class ArgumentOutsideDomainException extends FunctionEvaluationException
|
|||
*/
|
||||
public ArgumentOutsideDomainException(double argument, double lower, double upper) {
|
||||
super(argument,
|
||||
"Argument {0} outside domain [{1} ; {2}]",
|
||||
new Object[] { Double.valueOf(argument), Double.valueOf(lower), Double.valueOf(upper) });
|
||||
"Argument {0} outside domain [{1} ; {2}]", argument, lower, upper);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -25,13 +25,13 @@ package org.apache.commons.math;
|
|||
public class ConvergenceException extends MathException {
|
||||
|
||||
/** Serializable version identifier */
|
||||
private static final long serialVersionUID = 4380655778005469702L;
|
||||
private static final long serialVersionUID = 4883703247677159141L;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
public ConvergenceException() {
|
||||
super("Convergence failed", null);
|
||||
super("Convergence failed");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -41,7 +41,7 @@ public class ConvergenceException extends MathException {
|
|||
* @param arguments format arguments
|
||||
* @since 1.2
|
||||
*/
|
||||
public ConvergenceException(String pattern, Object[] arguments) {
|
||||
public ConvergenceException(String pattern, Object ... arguments) {
|
||||
super(pattern, arguments);
|
||||
}
|
||||
|
||||
|
@ -56,13 +56,13 @@ public class ConvergenceException extends MathException {
|
|||
/**
|
||||
* Constructs an exception with specified formatted detail message and root cause.
|
||||
* Message formatting is delegated to {@link java.text.MessageFormat}.
|
||||
* @param cause the exception or error that caused this exception to be thrown
|
||||
* @param pattern format specifier
|
||||
* @param arguments format arguments
|
||||
* @param cause the exception or error that caused this exception to be thrown
|
||||
* @since 1.2
|
||||
*/
|
||||
public ConvergenceException(String pattern, Object[] arguments, Throwable cause) {
|
||||
super(pattern, arguments, cause);
|
||||
public ConvergenceException(Throwable cause, String pattern, Object ... arguments) {
|
||||
super(cause, pattern, arguments);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -33,10 +33,7 @@ public class DimensionMismatchException extends MathException {
|
|||
* @param dimension2 second dimension
|
||||
*/
|
||||
public DimensionMismatchException(int dimension1, int dimension2) {
|
||||
super("dimension mismatch {0} != {1}",
|
||||
new Object[] {
|
||||
Integer.valueOf(dimension1), Integer.valueOf(dimension2)
|
||||
});
|
||||
super("dimension mismatch {0} != {1}", dimension1, dimension2);
|
||||
this.dimension1 = dimension1;
|
||||
this.dimension2 = dimension2;
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ public class DuplicateSampleAbscissaException extends MathException {
|
|||
*/
|
||||
public DuplicateSampleAbscissaException(double abscissa, int i1, int i2) {
|
||||
super("Abscissa {0} is duplicated at both indices {1} and {2}",
|
||||
new Object[] { Double.valueOf(abscissa), Integer.valueOf(i1), Integer.valueOf(i2) });
|
||||
abscissa, i1, i2);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -27,7 +27,7 @@ package org.apache.commons.math;
|
|||
public class FunctionEvaluationException extends MathException {
|
||||
|
||||
/** Serializable version identifier. */
|
||||
private static final long serialVersionUID = -2193260774031645876L;
|
||||
private static final long serialVersionUID = -7267500407292949362L;
|
||||
|
||||
/** Argument causing function evaluation failure */
|
||||
private double argument = Double.NaN;
|
||||
|
@ -39,8 +39,7 @@ public class FunctionEvaluationException extends MathException {
|
|||
* @param argument the failing function argument
|
||||
*/
|
||||
public FunctionEvaluationException(double argument) {
|
||||
super("Evaluation failed for argument = {0}",
|
||||
new Object[] { Double.valueOf(argument) });
|
||||
super("Evaluation failed for argument = {0}", Double.valueOf(argument));
|
||||
this.argument = argument;
|
||||
}
|
||||
|
||||
|
@ -53,7 +52,7 @@ public class FunctionEvaluationException extends MathException {
|
|||
* @since 1.2
|
||||
*/
|
||||
public FunctionEvaluationException(double argument,
|
||||
String pattern, Object[] arguments) {
|
||||
String pattern, Object ... arguments) {
|
||||
super(pattern, arguments);
|
||||
this.argument = argument;
|
||||
}
|
||||
|
@ -61,11 +60,11 @@ public class FunctionEvaluationException extends MathException {
|
|||
/**
|
||||
* Constructs an exception with specified root cause.
|
||||
* Message formatting is delegated to {@link java.text.MessageFormat}.
|
||||
* @param argument the failing function argument
|
||||
* @param cause the exception or error that caused this exception to be thrown
|
||||
* @param argument the failing function argument
|
||||
* @since 1.2
|
||||
*/
|
||||
public FunctionEvaluationException(double argument, Throwable cause) {
|
||||
public FunctionEvaluationException(Throwable cause, double argument) {
|
||||
super(cause);
|
||||
this.argument = argument;
|
||||
}
|
||||
|
@ -73,16 +72,16 @@ public class FunctionEvaluationException extends MathException {
|
|||
/**
|
||||
* Constructs an exception with specified formatted detail message and root cause.
|
||||
* Message formatting is delegated to {@link java.text.MessageFormat}.
|
||||
* @param cause the exception or error that caused this exception to be thrown
|
||||
* @param argument the failing function argument
|
||||
* @param pattern format specifier
|
||||
* @param arguments format arguments
|
||||
* @param cause the exception or error that caused this exception to be thrown
|
||||
* @since 1.2
|
||||
*/
|
||||
public FunctionEvaluationException(double argument,
|
||||
String pattern, Object[] arguments,
|
||||
Throwable cause) {
|
||||
super(pattern, arguments, cause);
|
||||
public FunctionEvaluationException(Throwable cause,
|
||||
double argument, String pattern,
|
||||
Object ... arguments) {
|
||||
super(cause, pattern, arguments);
|
||||
this.argument = argument;
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ public class MathConfigurationException extends MathException implements Seriali
|
|||
* @param arguments format arguments
|
||||
* @since 1.2
|
||||
*/
|
||||
public MathConfigurationException(String pattern, Object[] arguments) {
|
||||
public MathConfigurationException(String pattern, Object ... arguments) {
|
||||
super(pattern, arguments);
|
||||
}
|
||||
|
||||
|
@ -56,13 +56,13 @@ public class MathConfigurationException extends MathException implements Seriali
|
|||
/**
|
||||
* Constructs an exception with specified formatted detail message and root cause.
|
||||
* Message formatting is delegated to {@link java.text.MessageFormat}.
|
||||
* @param cause the exception or error that caused this exception to be thrown
|
||||
* @param pattern format specifier
|
||||
* @param arguments format arguments
|
||||
* @param cause the exception or error that caused this exception to be thrown
|
||||
* @since 1.2
|
||||
*/
|
||||
public MathConfigurationException(String pattern, Object[] arguments, Throwable cause) {
|
||||
super(pattern, arguments, cause);
|
||||
public MathConfigurationException(Throwable cause, String pattern, Object ... arguments) {
|
||||
super(cause, pattern, arguments);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ import java.util.ResourceBundle;
|
|||
public class MathException extends Exception {
|
||||
|
||||
/** Serializable version identifier. */
|
||||
private static final long serialVersionUID = 5924076008552401454L;
|
||||
private static final long serialVersionUID = -2803873247432645339L;
|
||||
|
||||
/** Cache for resources bundle. */
|
||||
private static ResourceBundle cachedResources = null;
|
||||
|
@ -83,12 +83,12 @@ public class MathException extends Exception {
|
|||
|
||||
/**
|
||||
* Builds a message string by from a pattern and its arguments.
|
||||
* @param locale Locale in which the message should be translated
|
||||
* @param pattern format specifier
|
||||
* @param arguments format arguments
|
||||
* @param locale Locale in which the message should be translated
|
||||
* @return a message string
|
||||
*/
|
||||
private static String buildMessage(String pattern, Object[] arguments, Locale locale) {
|
||||
private static String buildMessage(Locale locale, String pattern, Object ... arguments) {
|
||||
return (pattern == null) ? "" : new MessageFormat(translate(pattern, locale), locale).format(arguments);
|
||||
}
|
||||
|
||||
|
@ -109,8 +109,8 @@ public class MathException extends Exception {
|
|||
* @param pattern format specifier
|
||||
* @param arguments format arguments
|
||||
*/
|
||||
public MathException(String pattern, Object[] arguments) {
|
||||
super(buildMessage(pattern, arguments, Locale.US));
|
||||
public MathException(String pattern, Object ... arguments) {
|
||||
super(buildMessage(Locale.US, pattern, arguments));
|
||||
this.pattern = pattern;
|
||||
this.arguments = (arguments == null) ? new Object[0] : arguments.clone();
|
||||
}
|
||||
|
@ -132,14 +132,14 @@ public class MathException extends Exception {
|
|||
* Constructs a new <code>MathException</code> with specified
|
||||
* formatted detail message and nested <code>Throwable</code> root cause.
|
||||
* Message formatting is delegated to {@link java.text.MessageFormat}.
|
||||
* @param pattern format specifier
|
||||
* @param arguments format arguments
|
||||
* @param rootCause the exception or error that caused this exception
|
||||
* to be thrown.
|
||||
* @param pattern format specifier
|
||||
* @param arguments format arguments
|
||||
* @since 1.2
|
||||
*/
|
||||
public MathException(String pattern, Object[] arguments, Throwable rootCause) {
|
||||
super(buildMessage(pattern, arguments, Locale.US), rootCause);
|
||||
public MathException(Throwable rootCause, String pattern, Object ... arguments) {
|
||||
super(buildMessage(Locale.US, pattern, arguments), rootCause);
|
||||
this.pattern = pattern;
|
||||
this.arguments = (arguments == null) ? new Object[0] : arguments.clone();
|
||||
}
|
||||
|
@ -170,7 +170,7 @@ public class MathException extends Exception {
|
|||
* @since 1.2
|
||||
*/
|
||||
public String getMessage(Locale locale) {
|
||||
return buildMessage(pattern, arguments, locale);
|
||||
return buildMessage(locale, pattern, arguments);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
|
|
@ -37,7 +37,7 @@ import java.util.ResourceBundle;
|
|||
public class MathRuntimeException extends RuntimeException {
|
||||
|
||||
/** Serializable version identifier. */
|
||||
private static final long serialVersionUID = -143052521750625264L;
|
||||
private static final long serialVersionUID = 4184290229453587356L;
|
||||
|
||||
/** Cache for resources bundle. */
|
||||
private static ResourceBundle cachedResources = null;
|
||||
|
@ -84,13 +84,13 @@ public class MathRuntimeException extends RuntimeException {
|
|||
|
||||
/**
|
||||
* Builds a message string by from a pattern and its arguments.
|
||||
* @param locale Locale in which the message should be translated
|
||||
* @param pattern format specifier
|
||||
* @param arguments format arguments
|
||||
* @param locale Locale in which the message should be translated
|
||||
* @return a message string
|
||||
*/
|
||||
private static String buildMessage(final String pattern, final Object[] arguments,
|
||||
final Locale locale) {
|
||||
private static String buildMessage(final Locale locale, final String pattern,
|
||||
final Object ... arguments) {
|
||||
return (pattern == null) ? "" : new MessageFormat(translate(pattern, locale), locale).format(arguments);
|
||||
}
|
||||
|
||||
|
@ -101,8 +101,8 @@ public class MathRuntimeException extends RuntimeException {
|
|||
* @param pattern format specifier
|
||||
* @param arguments format arguments
|
||||
*/
|
||||
public MathRuntimeException(final String pattern, final Object[] arguments) {
|
||||
super(buildMessage(pattern, arguments, Locale.US));
|
||||
public MathRuntimeException(final String pattern, final Object ... arguments) {
|
||||
super(buildMessage(Locale.US, pattern, arguments));
|
||||
this.pattern = pattern;
|
||||
this.arguments = (arguments == null) ? new Object[0] : arguments.clone();
|
||||
}
|
||||
|
@ -124,14 +124,14 @@ public class MathRuntimeException extends RuntimeException {
|
|||
* Constructs a new <code>MathRuntimeException</code> with specified
|
||||
* formatted detail message and nested <code>Throwable</code> root cause.
|
||||
* Message formatting is delegated to {@link java.text.MessageFormat}.
|
||||
* @param pattern format specifier
|
||||
* @param arguments format arguments
|
||||
* @param rootCause the exception or error that caused this exception
|
||||
* to be thrown.
|
||||
* @param pattern format specifier
|
||||
* @param arguments format arguments
|
||||
*/
|
||||
public MathRuntimeException(final String pattern, final Object[] arguments,
|
||||
final Throwable rootCause) {
|
||||
super(buildMessage(pattern, arguments, Locale.US), rootCause);
|
||||
public MathRuntimeException(final Throwable rootCause,
|
||||
final String pattern, final Object ... arguments) {
|
||||
super(buildMessage(Locale.US, pattern, arguments), rootCause);
|
||||
this.pattern = pattern;
|
||||
this.arguments = (arguments == null) ? new Object[0] : arguments.clone();
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ public class MathRuntimeException extends RuntimeException {
|
|||
* @return localized message
|
||||
*/
|
||||
public String getMessage(final Locale locale) {
|
||||
return buildMessage(pattern, arguments, locale);
|
||||
return buildMessage(locale, pattern, arguments);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
@ -196,15 +196,15 @@ public class MathRuntimeException extends RuntimeException {
|
|||
* @return built exception
|
||||
*/
|
||||
public static ArithmeticException createArithmeticException(final String pattern,
|
||||
final Object[] arguments) {
|
||||
return new ArithmeticException(buildMessage(pattern, arguments, Locale.US)) {
|
||||
final Object ... arguments) {
|
||||
return new ArithmeticException(buildMessage(Locale.US, pattern, arguments)) {
|
||||
|
||||
/** Serializable version identifier. */
|
||||
private static final long serialVersionUID = 7705628723242533939L;
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public String getLocalizedMessage() {
|
||||
return buildMessage(pattern, arguments, Locale.getDefault());
|
||||
return buildMessage(Locale.getDefault(), pattern, arguments);
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -218,15 +218,15 @@ public class MathRuntimeException extends RuntimeException {
|
|||
* @return built exception
|
||||
*/
|
||||
public static ArrayIndexOutOfBoundsException createArrayIndexOutOfBoundsException(final String pattern,
|
||||
final Object[] arguments) {
|
||||
return new ArrayIndexOutOfBoundsException(buildMessage(pattern, arguments, Locale.US)) {
|
||||
final Object ... arguments) {
|
||||
return new ArrayIndexOutOfBoundsException(buildMessage(Locale.US, pattern, arguments)) {
|
||||
|
||||
/** Serializable version identifier. */
|
||||
private static final long serialVersionUID = 8077627622976962141L;
|
||||
private static final long serialVersionUID = -3394748305449283486L;
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public String getLocalizedMessage() {
|
||||
return buildMessage(pattern, arguments, Locale.getDefault());
|
||||
return buildMessage(Locale.getDefault(), pattern, arguments);
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -240,15 +240,15 @@ public class MathRuntimeException extends RuntimeException {
|
|||
* @return built exception
|
||||
*/
|
||||
public static EOFException createEOFException(final String pattern,
|
||||
final Object[] arguments) {
|
||||
return new EOFException(buildMessage(pattern, arguments, Locale.US)) {
|
||||
final Object ... arguments) {
|
||||
return new EOFException(buildMessage(Locale.US, pattern, arguments)) {
|
||||
|
||||
/** Serializable version identifier. */
|
||||
private static final long serialVersionUID = 279461544586092584L;
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public String getLocalizedMessage() {
|
||||
return buildMessage(pattern, arguments, Locale.getDefault());
|
||||
return buildMessage(Locale.getDefault(), pattern, arguments);
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -279,15 +279,15 @@ public class MathRuntimeException extends RuntimeException {
|
|||
* @return built exception
|
||||
*/
|
||||
public static IllegalArgumentException createIllegalArgumentException(final String pattern,
|
||||
final Object[] arguments) {
|
||||
return new IllegalArgumentException(buildMessage(pattern, arguments, Locale.US)) {
|
||||
final Object ... arguments) {
|
||||
return new IllegalArgumentException(buildMessage(Locale.US, pattern, arguments)) {
|
||||
|
||||
/** Serializable version identifier. */
|
||||
private static final long serialVersionUID = -7537852425838457684L;
|
||||
private static final long serialVersionUID = -6555453980658317913L;
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public String getLocalizedMessage() {
|
||||
return buildMessage(pattern, arguments, Locale.getDefault());
|
||||
return buildMessage(Locale.getDefault(), pattern, arguments);
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -301,15 +301,15 @@ public class MathRuntimeException extends RuntimeException {
|
|||
* @return built exception
|
||||
*/
|
||||
public static IllegalStateException createIllegalStateException(final String pattern,
|
||||
final Object[] arguments) {
|
||||
return new IllegalStateException(buildMessage(pattern, arguments, Locale.US)) {
|
||||
final Object ... arguments) {
|
||||
return new IllegalStateException(buildMessage(Locale.US, pattern, arguments)) {
|
||||
|
||||
/** Serializable version identifier. */
|
||||
private static final long serialVersionUID = 5173599768297434381L;
|
||||
private static final long serialVersionUID = -95247648156277208L;
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public String getLocalizedMessage() {
|
||||
return buildMessage(pattern, arguments, Locale.getDefault());
|
||||
return buildMessage(Locale.getDefault(), pattern, arguments);
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -323,15 +323,15 @@ public class MathRuntimeException extends RuntimeException {
|
|||
* @return built exception
|
||||
*/
|
||||
public static ConcurrentModificationException createConcurrentModificationException(final String pattern,
|
||||
final Object[] arguments) {
|
||||
return new ConcurrentModificationException(buildMessage(pattern, arguments, Locale.US)) {
|
||||
final Object ... arguments) {
|
||||
return new ConcurrentModificationException(buildMessage(Locale.US, pattern, arguments)) {
|
||||
|
||||
/** Serializable version identifier. */
|
||||
private static final long serialVersionUID = 6134247282754009421L;
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public String getLocalizedMessage() {
|
||||
return buildMessage(pattern, arguments, Locale.getDefault());
|
||||
return buildMessage(Locale.getDefault(), pattern, arguments);
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -345,15 +345,15 @@ public class MathRuntimeException extends RuntimeException {
|
|||
* @return built exception
|
||||
*/
|
||||
public static NoSuchElementException createNoSuchElementException(final String pattern,
|
||||
final Object[] arguments) {
|
||||
return new NoSuchElementException(buildMessage(pattern, arguments, Locale.US)) {
|
||||
final Object ... arguments) {
|
||||
return new NoSuchElementException(buildMessage(Locale.US, pattern, arguments)) {
|
||||
|
||||
/** Serializable version identifier. */
|
||||
private static final long serialVersionUID = 7304273322489425799L;
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public String getLocalizedMessage() {
|
||||
return buildMessage(pattern, arguments, Locale.getDefault());
|
||||
return buildMessage(Locale.getDefault(), pattern, arguments);
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -363,22 +363,22 @@ public class MathRuntimeException extends RuntimeException {
|
|||
* Constructs a new <code>ParseException</code> with specified
|
||||
* formatted detail message.
|
||||
* Message formatting is delegated to {@link java.text.MessageFormat}.
|
||||
* @param offset offset at which error occurred
|
||||
* @param pattern format specifier
|
||||
* @param arguments format arguments
|
||||
* @param offset offset at which error occurred
|
||||
* @return built exception
|
||||
*/
|
||||
public static ParseException createParseException(final String pattern,
|
||||
final Object[] arguments,
|
||||
final int offset) {
|
||||
return new ParseException(buildMessage(pattern, arguments, Locale.US), offset) {
|
||||
public static ParseException createParseException(final int offset,
|
||||
final String pattern,
|
||||
final Object ... arguments) {
|
||||
return new ParseException(buildMessage(Locale.US, pattern, arguments), offset) {
|
||||
|
||||
/** Serializable version identifier. */
|
||||
private static final long serialVersionUID = -1103502177342465975L;
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public String getLocalizedMessage() {
|
||||
return buildMessage(pattern, arguments, Locale.getDefault());
|
||||
return buildMessage(Locale.getDefault(), pattern, arguments);
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
@ -29,19 +29,18 @@ import org.apache.commons.math.ConvergenceException;
|
|||
public class MaxIterationsExceededException extends ConvergenceException {
|
||||
|
||||
/** Serializable version identifier. */
|
||||
private static final long serialVersionUID = -2154780004193976271L;
|
||||
private static final long serialVersionUID = -7821226672760574694L;
|
||||
|
||||
/** Maximal number of iterations allowed. */
|
||||
private int maxIterations;
|
||||
private final int maxIterations;
|
||||
|
||||
/**
|
||||
* Constructs an exception with specified formatted detail message.
|
||||
* Message formatting is delegated to {@link java.text.MessageFormat}.
|
||||
* @param maxIterations maximal number of iterations allowed
|
||||
*/
|
||||
public MaxIterationsExceededException(int maxIterations) {
|
||||
super("Maximal number of iterations ({0}) exceeded",
|
||||
new Object[] { Integer.valueOf(maxIterations) });
|
||||
public MaxIterationsExceededException(final int maxIterations) {
|
||||
super("Maximal number of iterations ({0}) exceeded", maxIterations);
|
||||
this.maxIterations = maxIterations;
|
||||
}
|
||||
|
||||
|
@ -52,8 +51,8 @@ public class MaxIterationsExceededException extends ConvergenceException {
|
|||
* @param pattern format specifier
|
||||
* @param arguments format arguments
|
||||
*/
|
||||
public MaxIterationsExceededException(int maxIterations,
|
||||
String pattern, Object[] arguments) {
|
||||
public MaxIterationsExceededException(final int maxIterations,
|
||||
final String pattern, final Object ... arguments) {
|
||||
super(pattern, arguments);
|
||||
this.maxIterations = maxIterations;
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ public class MessagesResources_fr
|
|||
// org.apache.commons.math.util.MathUtils
|
||||
{ "overflow: gcd({0}, {1}) is 2^31",
|
||||
"d\u00e9passement de capacit\u00e9 : le PGCD de {0} et {1} vaut 2^31" },
|
||||
|
||||
|
||||
// org.apache.commons.math.FunctionEvaluationException
|
||||
{ "Evaluation failed for argument = {0}",
|
||||
"Erreur d''\u00e9valuation pour l''argument {0}" },
|
||||
|
@ -284,6 +284,30 @@ public class MessagesResources_fr
|
|||
"impossible de mettre un \u00e9l\u00e9ment \u00e0 un index n\u00e9gatif ({0})" },
|
||||
{ "cannot substitute an element from an empty array",
|
||||
"impossible de substituer un \u00e9l\u00e9ment dans un tableau vide" },
|
||||
{ "contraction criteria ({0}) smaller than the expansion factor ({1}). This would " +
|
||||
"lead to a never ending loop of expansion and contraction as a newly expanded " +
|
||||
"internal storage array would immediately satisfy the criteria for contraction.",
|
||||
"crit\u00e8re de contraction ({0}) inf\u00e9rieur au facteur d''extension. Ceci " +
|
||||
"induit une boucle infinie d''extensions/contractions car tout tableau de stockage " +
|
||||
"fra\u00eechement \u00e9tendu respecte imm\u00e9diatement le crit\u00e8re de contraction."},
|
||||
{ "contraction criteria smaller than one ({0}). This would lead to a never ending " +
|
||||
"loop of expansion and contraction as an internal storage array length equal " +
|
||||
"to the number of elements would satisfy the contraction criteria.",
|
||||
"crit\u00e8re de contraction inf\u00e9rieur \u00e0 un ({0}). Ceci induit une boucle " +
|
||||
"infinie d''extensions/contractions car tout tableau de stockage de longueur \u00e9gale " +
|
||||
"au nombre d''\u00e9l\u00e9ments respecte le crit\u00e8re de contraction." },
|
||||
{ "expansion factor smaller than one ({0})",
|
||||
"facteur d''extension inf\u00e9rieur \u00e0 un ({0})"},
|
||||
{ "cannot discard {0} elements from a {1} elements array",
|
||||
"impossible d''enlever {0} \u00e9l\u00e9ments d''un tableau en contenant {1}"},
|
||||
{ "cannot discard a negative number of elements ({0})",
|
||||
"impossible d''enlever un nombre d''\u00e9l\u00e9ments{0} n\u00e9gatif"},
|
||||
{ "unsupported expansion mode {0}, supported modes are {1} ({2}) and {3} ({4})",
|
||||
"mode d''extension {0} no support\u00e9, les modes support\u00e9s sont {1} ({2}) et {3} ({4})" },
|
||||
{ "initial capacity ({0}) is not positive",
|
||||
"la capacit\u00e9 initiale ({0}) n''est pas positive" },
|
||||
{ "index ({0}) is not positive",
|
||||
"l''indice ({0}) n''est pas positif" },
|
||||
|
||||
// org.apache.commons.math.analysis.polynomials.PolynomialFunctionLagrangeForm
|
||||
{ "identical abscissas x[{0}] == x[{1}] == {2} cause division by zero",
|
||||
|
@ -365,6 +389,20 @@ public class MessagesResources_fr
|
|||
{ "digest not initialized",
|
||||
"mod\u00e8le empirique non initialis\u00e9" },
|
||||
|
||||
// org.apache.commons.math.stat.correlation.Covariance
|
||||
{ "arrays must have the same length and both must have at " +
|
||||
"least two elements. xArray has size {0}, yArray has {1} elements",
|
||||
"les tableaux doivent avoir la m\u00eame taille et comporter au moins deux \u00e9l\u00e9ments. " +
|
||||
"xArray a une taille de {0}, yArray a {1} \u00e9l\u00e9ments"},
|
||||
{ "insufficient data: only {0} rows and {1} columns.",
|
||||
"donn\u00e9es insuffisantes : seulement {0} lignes et {1} colonnes." },
|
||||
|
||||
// org.apache.commons.math.stat.correlation.PearsonsCorrelation
|
||||
{ "covariance matrix is null",
|
||||
"la matrice de covariance est nulle" },
|
||||
{ "invalid array dimensions. xArray has size {0}; yArray has {1} elements",
|
||||
"dimensions de tableaux invalides. xArray a une taille de {0}, yArray a {1} \u00e9l\u00e9ments" },
|
||||
|
||||
// org.apache.commons.math.stat.descriptive.moment.GeometricMean
|
||||
// org.apache.commons.math.stat.descriptive.MultivariateSummaryStatistics
|
||||
// org.apache.commons.math.stat.descriptive.SummaryStatistics
|
||||
|
|
|
@ -150,7 +150,7 @@ public class LegendreGaussIntegrator extends UnivariateRealIntegratorImpl {
|
|||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"{0} points Legendre-Gauss integrator not supported, " +
|
||||
"number of points must be in the {1}-{2} range",
|
||||
new Object[] { n, 2, 5 });
|
||||
n, 2, 5);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -112,7 +112,7 @@ public class RombergIntegrator extends UnivariateRealIntegratorImpl {
|
|||
if (maximalIterationCount > 32) {
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"invalid iteration limits: min={0}, max={1}",
|
||||
new Object[] { 0, 32 });
|
||||
0, 32);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@ public class SimpsonIntegrator extends UnivariateRealIntegratorImpl {
|
|||
if (maximalIterationCount > 64) {
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"invalid iteration limits: min={0}, max={1}",
|
||||
new Object[] { 0, 64 });
|
||||
0, 64);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -144,7 +144,7 @@ public class TrapezoidIntegrator extends UnivariateRealIntegratorImpl {
|
|||
if (maximalIterationCount > 64) {
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"invalid iteration limits: min={0}, max={1}",
|
||||
new Object[] { 0, 64 });
|
||||
0, 64);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -108,7 +108,7 @@ public abstract class UnivariateRealIntegratorImpl
|
|||
if (resultComputed) {
|
||||
return result;
|
||||
} else {
|
||||
throw MathRuntimeException.createIllegalStateException("no result available", null);
|
||||
throw MathRuntimeException.createIllegalStateException("no result available");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -159,7 +159,7 @@ public abstract class UnivariateRealIntegratorImpl
|
|||
if (lower >= upper) {
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"endpoints do not specify an interval: [{0}, {1}]",
|
||||
new Object[] { lower, upper });
|
||||
lower, upper);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -172,7 +172,7 @@ public abstract class UnivariateRealIntegratorImpl
|
|||
if ((minimalIterationCount <= 0) || (maximalIterationCount <= minimalIterationCount)) {
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"invalid iteration limits: min={0}, max={1}",
|
||||
new Object[] { minimalIterationCount, maximalIterationCount });
|
||||
minimalIterationCount, maximalIterationCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ public abstract class UnivariateRealMinimizerImpl
|
|||
*/
|
||||
protected void checkResultComputed() throws IllegalStateException {
|
||||
if (!resultComputed) {
|
||||
throw MathRuntimeException.createIllegalStateException("no result available", null);
|
||||
throw MathRuntimeException.createIllegalStateException("no result available");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ public class PolynomialFunctionLagrangeForm implements UnivariateRealFunction,
|
|||
try {
|
||||
return evaluate(x, y, z);
|
||||
} catch (DuplicateSampleAbscissaException e) {
|
||||
throw new FunctionEvaluationException(z, e.getPattern(), e.getArguments(), e);
|
||||
throw new FunctionEvaluationException(e, z, e.getPattern(), e.getArguments());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -258,9 +258,7 @@ public class PolynomialFunctionLagrangeForm implements UnivariateRealFunction,
|
|||
for (int k = 0; k < n; ++k) {
|
||||
if ((i != k) && (x[i] == x[k])) {
|
||||
throw MathRuntimeException.createArithmeticException("identical abscissas x[{0}] == x[{1}] == {2} cause division by zero",
|
||||
new Object[] {
|
||||
i, k, x[i]
|
||||
});
|
||||
i, k, x[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -178,7 +178,7 @@ public class BrentSolver extends UnivariateRealSolverImpl {
|
|||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"function values at endpoints do not have different signs. " +
|
||||
"Endpoints: [{0}, {1}], Values: [{2}, {3}]",
|
||||
new Object[] { min, max, yMin, yMax });
|
||||
min, max, yMin, yMax);
|
||||
}
|
||||
} else if (sign < 0){
|
||||
// solve using only the first endpoint as initial guess
|
||||
|
|
|
@ -64,7 +64,7 @@ public class LaguerreSolver extends UnivariateRealSolverImpl {
|
|||
if (f instanceof PolynomialFunction) {
|
||||
p = (PolynomialFunction) f;
|
||||
} else {
|
||||
throw MathRuntimeException.createIllegalArgumentException("function is not polynomial", null);
|
||||
throw MathRuntimeException.createIllegalArgumentException("function is not polynomial");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -160,7 +160,7 @@ public class LaguerreSolver extends UnivariateRealSolverImpl {
|
|||
|
||||
// check function type
|
||||
if (!(f instanceof PolynomialFunction)) {
|
||||
throw MathRuntimeException.createIllegalArgumentException("function is not polynomial", null);
|
||||
throw MathRuntimeException.createIllegalArgumentException("function is not polynomial");
|
||||
}
|
||||
|
||||
// check for zeros before verifying bracketing
|
||||
|
|
|
@ -132,8 +132,7 @@ public class NewtonSolver extends UnivariateRealSolverImpl {
|
|||
|
||||
throw new MaxIterationsExceededException(maximalIterationCount);
|
||||
} catch (ClassCastException cce) {
|
||||
throw MathRuntimeException.createIllegalArgumentException("function is not differentiable",
|
||||
null);
|
||||
throw MathRuntimeException.createIllegalArgumentException("function is not differentiable");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -76,8 +76,7 @@ public abstract class UnivariateRealSolverImpl
|
|||
final double defaultAbsoluteAccuracy) {
|
||||
super(defaultMaximalIterationCount, defaultAbsoluteAccuracy);
|
||||
if (f == null) {
|
||||
throw MathRuntimeException.createIllegalArgumentException("function to solve cannot be null",
|
||||
null);
|
||||
throw MathRuntimeException.createIllegalArgumentException("function to solve cannot be null");
|
||||
}
|
||||
this.f = f;
|
||||
this.defaultFunctionValueAccuracy = 1.0e-15;
|
||||
|
@ -104,7 +103,7 @@ public abstract class UnivariateRealSolverImpl
|
|||
*/
|
||||
protected void checkResultComputed() throws IllegalStateException {
|
||||
if (!resultComputed) {
|
||||
throw MathRuntimeException.createIllegalStateException("no result available", null);
|
||||
throw MathRuntimeException.createIllegalStateException("no result available");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -212,7 +211,7 @@ public abstract class UnivariateRealSolverImpl
|
|||
if (lower >= upper) {
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"endpoints do not specify an interval: [{0}, {1}]",
|
||||
new Object[] { lower, upper });
|
||||
lower, upper);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -229,7 +228,7 @@ public abstract class UnivariateRealSolverImpl
|
|||
if (!isSequence(lower, initial, upper)) {
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"invalid interval, initial value parameters: lower={0}, initial={1}, upper={2}",
|
||||
new Object[] { lower, initial, upper });
|
||||
lower, initial, upper);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -253,7 +252,7 @@ public abstract class UnivariateRealSolverImpl
|
|||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"function values at endpoints do not have different signs. " +
|
||||
"Endpoints: [{0}, {1}], Values: [{2}, {3}]",
|
||||
new Object[] { lower, upper, f.value(lower), f.value(upper) });
|
||||
lower, upper, f.value(lower), f.value(upper));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -200,9 +200,7 @@ public class UnivariateRealSolverUtils {
|
|||
if (fa * fb >= 0.0 ) {
|
||||
throw new ConvergenceException
|
||||
("Number of iterations={0}, maximum iterations={1}, initial={2}, lower bound={3}, upper bound={4}, final a value={5}, final b value={6}, f(a)={7}, f(b)={8}",
|
||||
new Object[] { Integer.valueOf(numIterations), Integer.valueOf(maximumIterations),
|
||||
Double.valueOf(initial), Double.valueOf(lowerBound), Double.valueOf(upperBound),
|
||||
Double.valueOf(a), Double.valueOf(b), Double.valueOf(fa), Double.valueOf(fb) });
|
||||
numIterations, maximumIterations, initial, lowerBound, upperBound, a, b, fa, fb);
|
||||
}
|
||||
|
||||
return new double[]{a, b};
|
||||
|
|
|
@ -905,8 +905,9 @@ public class Complex implements Serializable {
|
|||
public List<Complex> nthRoot(int n) throws IllegalArgumentException {
|
||||
|
||||
if (n <= 0) {
|
||||
throw MathRuntimeException.createIllegalArgumentException("cannot compute nth root for null or negative n: {0}",
|
||||
new Object[] { n });
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"cannot compute nth root for null or negative n: {0}",
|
||||
n);
|
||||
}
|
||||
|
||||
List<Complex> result = new ArrayList<Complex>();
|
||||
|
|
|
@ -251,9 +251,9 @@ public class ComplexFormat extends CompositeFormat {
|
|||
ParsePosition parsePosition = new ParsePosition(0);
|
||||
Complex result = parse(source, parsePosition);
|
||||
if (parsePosition.getIndex() == 0) {
|
||||
throw MathRuntimeException.createParseException("unparseable complex number: \"{0}\"",
|
||||
new Object[] { source },
|
||||
parsePosition.getErrorIndex());
|
||||
throw MathRuntimeException.createParseException(
|
||||
parsePosition.getErrorIndex(),
|
||||
"unparseable complex number: \"{0}\"", source);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ public abstract class AbstractContinuousDistribution
|
|||
try {
|
||||
return cumulativeProbability(x) - p;
|
||||
} catch (MathException ex) {
|
||||
throw new FunctionEvaluationException(x, ex.getPattern(), ex.getArguments(), ex);
|
||||
throw new FunctionEvaluationException(ex, x, ex.getPattern(), ex.getArguments());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -98,12 +98,12 @@ public class BetaDistributionImpl
|
|||
return 0;
|
||||
} else if (x == 0) {
|
||||
if (alpha < 1) {
|
||||
throw new MathException("Cannot compute beta density at 0 when alpha = {0,number}", new Double[]{alpha});
|
||||
throw new MathException("Cannot compute beta density at 0 when alpha = {0,number}", alpha);
|
||||
}
|
||||
return 0;
|
||||
} else if (x == 1) {
|
||||
if (beta < 1) {
|
||||
throw new MathException("Cannot compute beta density at 1 when beta = %.3g", new Double[]{beta});
|
||||
throw new MathException("Cannot compute beta density at 1 when beta = %.3g", beta);
|
||||
}
|
||||
return 0;
|
||||
} else {
|
||||
|
|
|
@ -73,9 +73,9 @@ public class ZipfDistributionImpl extends AbstractIntegerDistribution
|
|||
public void setNumberOfElements(final int n)
|
||||
throws IllegalArgumentException {
|
||||
if (n <= 0) {
|
||||
throw MathRuntimeException.createIllegalArgumentException("invalid number of elements {0}" +
|
||||
" (must be positive)",
|
||||
new Object[] { n });
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"invalid number of elements {0} (must be positive)",
|
||||
n);
|
||||
}
|
||||
this.numberOfElements = n;
|
||||
}
|
||||
|
@ -100,8 +100,9 @@ public class ZipfDistributionImpl extends AbstractIntegerDistribution
|
|||
public void setExponent(final double s)
|
||||
throws IllegalArgumentException {
|
||||
if (s <= 0.0) {
|
||||
throw MathRuntimeException.createIllegalArgumentException("invalid exponent {0} (must be positive)",
|
||||
new Object[] { s });
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"invalid exponent {0} (must be positive)",
|
||||
s);
|
||||
}
|
||||
this.exponent = s;
|
||||
}
|
||||
|
|
|
@ -106,7 +106,7 @@ public abstract class AbstractEstimator implements Estimator {
|
|||
|
||||
if (++costEvaluations > maxCostEval) {
|
||||
throw new EstimationException("maximal number of evaluations exceeded ({0})",
|
||||
new Object[] { Integer.valueOf(maxCostEval) });
|
||||
maxCostEval);
|
||||
}
|
||||
|
||||
cost = 0;
|
||||
|
@ -191,8 +191,7 @@ public abstract class AbstractEstimator implements Estimator {
|
|||
new LUDecompositionImpl(MatrixUtils.createRealMatrix(jTj)).getSolver().getInverse();
|
||||
return inverse.getData();
|
||||
} catch (InvalidMatrixException ime) {
|
||||
throw new EstimationException("unable to compute covariances: singular problem",
|
||||
null);
|
||||
throw new EstimationException("unable to compute covariances: singular problem");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -211,8 +210,9 @@ public abstract class AbstractEstimator implements Estimator {
|
|||
int m = problem.getMeasurements().length;
|
||||
int p = problem.getUnboundParameters().length;
|
||||
if (m <= p) {
|
||||
throw new EstimationException("no degrees of freedom ({0} measurements, {1} parameters)",
|
||||
new Object[] { Integer.valueOf(m), Integer.valueOf(p)});
|
||||
throw new EstimationException(
|
||||
"no degrees of freedom ({0} measurements, {1} parameters)",
|
||||
m, p);
|
||||
}
|
||||
double[] errors = new double[problem.getUnboundParameters().length];
|
||||
final double c = Math.sqrt(getChiSquare(problem) / (m - p));
|
||||
|
|
|
@ -39,7 +39,7 @@ extends MathException {
|
|||
* @param specifier format specifier (to be translated)
|
||||
* @param parts to insert in the format (no translation)
|
||||
*/
|
||||
public EstimationException(String specifier, Object[] parts) {
|
||||
public EstimationException(String specifier, Object ... parts) {
|
||||
super(specifier, parts);
|
||||
}
|
||||
|
||||
|
|
|
@ -210,7 +210,7 @@ public class GaussNewtonEstimator extends AbstractEstimator implements Serializa
|
|||
}
|
||||
|
||||
} catch(InvalidMatrixException e) {
|
||||
throw new EstimationException("unable to solve: singular problem", null);
|
||||
throw new EstimationException("unable to solve: singular problem");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -400,16 +400,16 @@ public class LevenbergMarquardtEstimator extends AbstractEstimator implements Se
|
|||
throw new EstimationException("cost relative tolerance is too small ({0})," +
|
||||
" no further reduction in the" +
|
||||
" sum of squares is possible",
|
||||
new Object[] { Double.valueOf(costRelativeTolerance) });
|
||||
costRelativeTolerance);
|
||||
} else if (delta <= 2.2204e-16 * xNorm) {
|
||||
throw new EstimationException("parameters relative tolerance is too small" +
|
||||
" ({0}), no further improvement in" +
|
||||
" the approximate solution is possible",
|
||||
new Object[] { Double.valueOf(parRelativeTolerance) });
|
||||
parRelativeTolerance);
|
||||
} else if (maxCosine <= 2.2204e-16) {
|
||||
throw new EstimationException("orthogonality tolerance is too small ({0})," +
|
||||
" solution is orthogonal to the jacobian",
|
||||
new Object[] { Double.valueOf(orthoTolerance) });
|
||||
orthoTolerance);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -761,8 +761,9 @@ public class LevenbergMarquardtEstimator extends AbstractEstimator implements Se
|
|||
norm2 += aki * aki;
|
||||
}
|
||||
if (Double.isInfinite(norm2) || Double.isNaN(norm2)) {
|
||||
throw new EstimationException("unable to perform Q.R decomposition on the {0}x{1} jacobian matrix",
|
||||
new Object[] { Integer.valueOf(rows), Integer.valueOf(cols) });
|
||||
throw new EstimationException(
|
||||
"unable to perform Q.R decomposition on the {0}x{1} jacobian matrix",
|
||||
rows, cols);
|
||||
}
|
||||
if (norm2 > ak2) {
|
||||
nextColumn = i;
|
||||
|
|
|
@ -209,12 +209,12 @@ public class Fraction extends Number implements Comparable<Fraction> {
|
|||
super();
|
||||
if (den == 0) {
|
||||
throw MathRuntimeException.createArithmeticException("zero denominator in fraction {0}/{1}",
|
||||
new Object[] { num, den});
|
||||
num, den);
|
||||
}
|
||||
if (den < 0) {
|
||||
if (num == Integer.MIN_VALUE || den == Integer.MIN_VALUE) {
|
||||
throw MathRuntimeException.createArithmeticException("overflow in fraction {0}/{1}, cannot negate",
|
||||
new Object[] { num, den});
|
||||
num, den);
|
||||
}
|
||||
num = -num;
|
||||
den = -den;
|
||||
|
@ -371,7 +371,7 @@ public class Fraction extends Number implements Comparable<Fraction> {
|
|||
public Fraction negate() {
|
||||
if (numerator==Integer.MIN_VALUE) {
|
||||
throw MathRuntimeException.createArithmeticException("overflow in fraction {0}/{1}, cannot negate",
|
||||
new Object[] { numerator, denominator});
|
||||
numerator, denominator);
|
||||
}
|
||||
return new Fraction(-numerator, denominator);
|
||||
}
|
||||
|
@ -462,7 +462,7 @@ public class Fraction extends Number implements Comparable<Fraction> {
|
|||
BigInteger w = t.divide(BigInteger.valueOf(d2));
|
||||
if (w.bitLength() > 31) {
|
||||
throw MathRuntimeException.createArithmeticException("overflow, numerator too large after multiply: {0}",
|
||||
new Object[] { w });
|
||||
w);
|
||||
}
|
||||
return new Fraction (w.intValue(),
|
||||
MathUtils.mulAndCheck(denominator/d1,
|
||||
|
@ -510,8 +510,9 @@ public class Fraction extends Number implements Comparable<Fraction> {
|
|||
throw new IllegalArgumentException("The fraction must not be null");
|
||||
}
|
||||
if (fraction.numerator == 0) {
|
||||
throw MathRuntimeException.createArithmeticException("the fraction to divide by must not be zero: {0}/{1}",
|
||||
new Object[] { fraction.numerator, fraction.denominator });
|
||||
throw MathRuntimeException.createArithmeticException(
|
||||
"the fraction to divide by must not be zero: {0}/{1}",
|
||||
fraction.numerator, fraction.denominator);
|
||||
}
|
||||
return multiply(fraction.reciprocal());
|
||||
}
|
||||
|
@ -529,8 +530,9 @@ public class Fraction extends Number implements Comparable<Fraction> {
|
|||
*/
|
||||
public static Fraction getReducedFraction(int numerator, int denominator) {
|
||||
if (denominator == 0) {
|
||||
throw MathRuntimeException.createArithmeticException("zero denominator in fraction {0}/{1}",
|
||||
new Object[] { numerator, denominator});
|
||||
throw MathRuntimeException.createArithmeticException(
|
||||
"zero denominator in fraction {0}/{1}",
|
||||
numerator, denominator);
|
||||
}
|
||||
if (numerator==0) {
|
||||
return ZERO; // normalize zero.
|
||||
|
@ -542,8 +544,9 @@ public class Fraction extends Number implements Comparable<Fraction> {
|
|||
if (denominator < 0) {
|
||||
if (numerator==Integer.MIN_VALUE ||
|
||||
denominator==Integer.MIN_VALUE) {
|
||||
throw MathRuntimeException.createArithmeticException("overflow in fraction {0}/{1}, cannot negate",
|
||||
new Object[] { numerator, denominator});
|
||||
throw MathRuntimeException.createArithmeticException(
|
||||
"overflow in fraction {0}/{1}, cannot negate",
|
||||
numerator, denominator);
|
||||
}
|
||||
numerator = -numerator;
|
||||
denominator = -denominator;
|
||||
|
|
|
@ -38,8 +38,7 @@ public class FractionConversionException extends ConvergenceException {
|
|||
* @param maxIterations maximal number of iterations allowed
|
||||
*/
|
||||
public FractionConversionException(double value, int maxIterations) {
|
||||
super("Unable to convert {0} to fraction after {1} iterations",
|
||||
new Object[] { Double.valueOf(value), Integer.valueOf(maxIterations) });
|
||||
super("Unable to convert {0} to fraction after {1} iterations", value, maxIterations);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -50,8 +49,7 @@ public class FractionConversionException extends ConvergenceException {
|
|||
* @param q current denominator
|
||||
*/
|
||||
public FractionConversionException(double value, long p, long q) {
|
||||
super("Overflow trying to convert {0} to fraction ({1}/{2})",
|
||||
new Object[] { Double.valueOf(value), Long.valueOf(p), Long.valueOf(q) });
|
||||
super("Overflow trying to convert {0} to fraction ({1}/{2})", value, p, q);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -244,9 +244,9 @@ public class FractionFormat extends NumberFormat implements Serializable {
|
|||
ParsePosition parsePosition = new ParsePosition(0);
|
||||
Fraction result = parse(source, parsePosition);
|
||||
if (parsePosition.getIndex() == 0) {
|
||||
throw MathRuntimeException.createParseException("unparseable fraction number: \"{0}\"",
|
||||
new Object[] { source },
|
||||
parsePosition.getErrorIndex());
|
||||
throw MathRuntimeException.createParseException(
|
||||
parsePosition.getErrorIndex(),
|
||||
"unparseable fraction number: \"{0}\"", source);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ public class CardanEulerSingularityException
|
|||
* if false it is related to EulerAngles
|
||||
*/
|
||||
public CardanEulerSingularityException(boolean isCardan) {
|
||||
super(isCardan ? "Cardan angles singularity" : "Euler angles singularity", null);
|
||||
super(isCardan ? "Cardan angles singularity" : "Euler angles singularity");
|
||||
}
|
||||
|
||||
/** Serializable version identifier */
|
||||
|
|
|
@ -36,7 +36,7 @@ public class NotARotationMatrixException
|
|||
* @param specifier format specifier (to be translated)
|
||||
* @param parts to insert in the format (no translation)
|
||||
*/
|
||||
public NotARotationMatrixException(String specifier, Object[] parts) {
|
||||
public NotARotationMatrixException(String specifier, Object ... parts) {
|
||||
super(specifier, parts);
|
||||
}
|
||||
|
||||
|
|
|
@ -156,8 +156,7 @@ public class Rotation implements Serializable {
|
|||
|
||||
double norm = axis.getNorm();
|
||||
if (norm == 0) {
|
||||
throw MathRuntimeException.createArithmeticException("zero norm for rotation axis",
|
||||
null);
|
||||
throw MathRuntimeException.createArithmeticException("zero norm for rotation axis");
|
||||
}
|
||||
|
||||
double halfAngle = -0.5 * angle;
|
||||
|
@ -206,12 +205,9 @@ public class Rotation implements Serializable {
|
|||
// dimension check
|
||||
if ((m.length != 3) || (m[0].length != 3) ||
|
||||
(m[1].length != 3) || (m[2].length != 3)) {
|
||||
throw new NotARotationMatrixException("a {0}x{1} matrix" +
|
||||
" cannot be a rotation matrix",
|
||||
new Object[] {
|
||||
Integer.toString(m.length),
|
||||
Integer.toString(m[0].length)
|
||||
});
|
||||
throw new NotARotationMatrixException(
|
||||
"a {0}x{1} matrix cannot be a rotation matrix",
|
||||
m.length, m[0].length);
|
||||
}
|
||||
|
||||
// compute a "close" orthogonal matrix
|
||||
|
@ -222,11 +218,9 @@ public class Rotation implements Serializable {
|
|||
ort[1][0] * (ort[0][1] * ort[2][2] - ort[2][1] * ort[0][2]) +
|
||||
ort[2][0] * (ort[0][1] * ort[1][2] - ort[1][1] * ort[0][2]);
|
||||
if (det < 0.0) {
|
||||
throw new NotARotationMatrixException("the closest orthogonal matrix" +
|
||||
" has a negative determinant {0}",
|
||||
new Object[] {
|
||||
Double.toString(det)
|
||||
});
|
||||
throw new NotARotationMatrixException(
|
||||
"the closest orthogonal matrix has a negative determinant {0}",
|
||||
det);
|
||||
}
|
||||
|
||||
// There are different ways to compute the quaternions elements
|
||||
|
@ -1022,11 +1016,9 @@ public class Rotation implements Serializable {
|
|||
}
|
||||
|
||||
// the algorithm did not converge after 10 iterations
|
||||
throw new NotARotationMatrixException("unable to orthogonalize matrix" +
|
||||
" in {0} iterations",
|
||||
new Object[] {
|
||||
Integer.toString(i - 1)
|
||||
});
|
||||
throw new NotARotationMatrixException(
|
||||
"unable to orthogonalize matrix in {0} iterations",
|
||||
i - 1);
|
||||
}
|
||||
|
||||
/** Compute the <i>distance</i> between two rotations.
|
||||
|
|
|
@ -267,8 +267,7 @@ public class Vector3D
|
|||
public Vector3D normalize() {
|
||||
double s = getNorm();
|
||||
if (s == 0) {
|
||||
throw MathRuntimeException.createArithmeticException("cannot normalize a zero norm vector",
|
||||
null);
|
||||
throw MathRuntimeException.createArithmeticException("cannot normalize a zero norm vector");
|
||||
}
|
||||
return scalarMultiply(1 / s);
|
||||
}
|
||||
|
@ -292,7 +291,7 @@ public class Vector3D
|
|||
|
||||
double threshold = 0.6 * getNorm();
|
||||
if (threshold == 0) {
|
||||
throw MathRuntimeException.createArithmeticException("zero norm", null);
|
||||
throw MathRuntimeException.createArithmeticException("zero norm");
|
||||
}
|
||||
|
||||
if ((x >= -threshold) && (x <= threshold)) {
|
||||
|
@ -322,7 +321,7 @@ public class Vector3D
|
|||
|
||||
double normProduct = v1.getNorm() * v2.getNorm();
|
||||
if (normProduct == 0) {
|
||||
throw MathRuntimeException.createArithmeticException("zero norm", null);
|
||||
throw MathRuntimeException.createArithmeticException("zero norm");
|
||||
}
|
||||
|
||||
double dot = dotProduct(v1, v2);
|
||||
|
|
|
@ -255,9 +255,9 @@ public class Vector3DFormat extends CompositeFormat {
|
|||
ParsePosition parsePosition = new ParsePosition(0);
|
||||
Vector3D result = parse(source, parsePosition);
|
||||
if (parsePosition.getIndex() == 0) {
|
||||
throw MathRuntimeException.createParseException("unparseable 3D vector: \"{0}\"",
|
||||
new Object[] { source },
|
||||
parsePosition.getErrorIndex());
|
||||
throw MathRuntimeException.createParseException(
|
||||
parsePosition.getErrorIndex(),
|
||||
"unparseable 3D vector: \"{0}\"", source);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -61,14 +61,14 @@ public abstract class AbstractRealMatrix implements RealMatrix, Serializable {
|
|||
protected AbstractRealMatrix(final int rowDimension, final int columnDimension)
|
||||
throws IllegalArgumentException {
|
||||
if (rowDimension <= 0 ) {
|
||||
throw MathRuntimeException.createIllegalArgumentException("invalid row dimension {0}" +
|
||||
" (must be positive)",
|
||||
new Object[] { rowDimension });
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"invalid row dimension {0} (must be positive)",
|
||||
rowDimension);
|
||||
}
|
||||
if (columnDimension <= 0) {
|
||||
throw MathRuntimeException.createIllegalArgumentException("invalid column dimension {0}" +
|
||||
" (must be positive)",
|
||||
new Object[] { columnDimension });
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"invalid column dimension {0} (must be positive)",
|
||||
columnDimension);
|
||||
}
|
||||
lu = null;
|
||||
}
|
||||
|
@ -327,10 +327,8 @@ public abstract class AbstractRealMatrix implements RealMatrix, Serializable {
|
|||
if ((destination.length < rowsCount) || (destination[0].length < columnsCount)) {
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"dimensions mismatch: got {0}x{1} but expected {2}x{3}",
|
||||
new Object[] {
|
||||
destination.length, destination[0].length,
|
||||
rowsCount, columnsCount
|
||||
});
|
||||
destination.length, destination[0].length,
|
||||
rowsCount, columnsCount);
|
||||
}
|
||||
|
||||
// copy entries
|
||||
|
@ -372,10 +370,8 @@ public abstract class AbstractRealMatrix implements RealMatrix, Serializable {
|
|||
(destination[0].length < selectedColumns.length)) {
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"dimensions mismatch: got {0}x{1} but expected {2}x{3}",
|
||||
new Object[] {
|
||||
destination.length, destination[0].length,
|
||||
selectedRows.length, selectedColumns.length
|
||||
});
|
||||
destination.length, destination[0].length,
|
||||
selectedRows.length, selectedColumns.length);
|
||||
}
|
||||
|
||||
// copy entries
|
||||
|
@ -394,22 +390,19 @@ public abstract class AbstractRealMatrix implements RealMatrix, Serializable {
|
|||
|
||||
final int nRows = subMatrix.length;
|
||||
if (nRows == 0) {
|
||||
throw MathRuntimeException.createIllegalArgumentException("matrix must have at least one row",
|
||||
null);
|
||||
throw MathRuntimeException.createIllegalArgumentException("matrix must have at least one row");
|
||||
}
|
||||
|
||||
final int nCols = subMatrix[0].length;
|
||||
if (nCols == 0) {
|
||||
throw MathRuntimeException.createIllegalArgumentException("matrix must have at least one column",
|
||||
null);
|
||||
throw MathRuntimeException.createIllegalArgumentException("matrix must have at least one column");
|
||||
}
|
||||
|
||||
for (int r = 1; r < nRows; ++r) {
|
||||
if (subMatrix[r].length != nCols) {
|
||||
throw MathRuntimeException.createIllegalArgumentException("some rows have length {0} while others have length {1}",
|
||||
new Object[] {
|
||||
nCols, subMatrix[r].length
|
||||
});
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"some rows have length {0} while others have length {1}",
|
||||
nCols, subMatrix[r].length);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -451,12 +444,9 @@ public abstract class AbstractRealMatrix implements RealMatrix, Serializable {
|
|||
final int nCols = getColumnDimension();
|
||||
if ((matrix.getRowDimension() != 1) ||
|
||||
(matrix.getColumnDimension() != nCols)) {
|
||||
throw new InvalidMatrixException("dimensions mismatch: got {0}x{1} but expected {2}x{3}",
|
||||
new Object[] {
|
||||
matrix.getRowDimension(),
|
||||
matrix.getColumnDimension(),
|
||||
1, nCols
|
||||
});
|
||||
throw new InvalidMatrixException(
|
||||
"dimensions mismatch: got {0}x{1} but expected {2}x{3}",
|
||||
matrix.getRowDimension(), matrix.getColumnDimension(), 1, nCols);
|
||||
}
|
||||
for (int i = 0; i < nCols; ++i) {
|
||||
setEntry(row, i, matrix.getEntry(0, i));
|
||||
|
@ -487,12 +477,9 @@ public abstract class AbstractRealMatrix implements RealMatrix, Serializable {
|
|||
final int nRows = getRowDimension();
|
||||
if ((matrix.getRowDimension() != nRows) ||
|
||||
(matrix.getColumnDimension() != 1)) {
|
||||
throw new InvalidMatrixException("dimensions mismatch: got {0}x{1} but expected {2}x{3}",
|
||||
new Object[] {
|
||||
matrix.getRowDimension(),
|
||||
matrix.getColumnDimension(),
|
||||
nRows, 1
|
||||
});
|
||||
throw new InvalidMatrixException(
|
||||
"dimensions mismatch: got {0}x{1} but expected {2}x{3}",
|
||||
matrix.getRowDimension(), matrix.getColumnDimension(), nRows, 1);
|
||||
}
|
||||
for (int i = 0; i < nRows; ++i) {
|
||||
setEntry(i, column, matrix.getEntry(i, 0));
|
||||
|
@ -513,11 +500,9 @@ public abstract class AbstractRealMatrix implements RealMatrix, Serializable {
|
|||
checkRowIndex(row);
|
||||
final int nCols = getColumnDimension();
|
||||
if (vector.getDimension() != nCols) {
|
||||
throw new InvalidMatrixException("dimensions mismatch: got {0}x{1} but expected {2}x{3}",
|
||||
new Object[] {
|
||||
1, vector.getDimension(),
|
||||
1, nCols
|
||||
});
|
||||
throw new InvalidMatrixException(
|
||||
"dimensions mismatch: got {0}x{1} but expected {2}x{3}",
|
||||
1, vector.getDimension(), 1, nCols);
|
||||
}
|
||||
for (int i = 0; i < nCols; ++i) {
|
||||
setEntry(row, i, vector.getEntry(i));
|
||||
|
@ -538,11 +523,9 @@ public abstract class AbstractRealMatrix implements RealMatrix, Serializable {
|
|||
checkColumnIndex(column);
|
||||
final int nRows = getRowDimension();
|
||||
if (vector.getDimension() != nRows) {
|
||||
throw new InvalidMatrixException("dimensions mismatch: got {0}x{1} but expected {2}x{3}",
|
||||
new Object[] {
|
||||
vector.getDimension(), 1,
|
||||
nRows, 1
|
||||
});
|
||||
throw new InvalidMatrixException(
|
||||
"dimensions mismatch: got {0}x{1} but expected {2}x{3}",
|
||||
vector.getDimension(), 1, nRows, 1);
|
||||
}
|
||||
for (int i = 0; i < nRows; ++i) {
|
||||
setEntry(i, column, vector.getEntry(i));
|
||||
|
@ -572,11 +555,9 @@ public abstract class AbstractRealMatrix implements RealMatrix, Serializable {
|
|||
checkRowIndex(row);
|
||||
final int nCols = getColumnDimension();
|
||||
if (array.length != nCols) {
|
||||
throw new InvalidMatrixException("dimensions mismatch: got {0}x{1} but expected {2}x{3}",
|
||||
new Object[] {
|
||||
1, array.length,
|
||||
1, nCols
|
||||
});
|
||||
throw new InvalidMatrixException(
|
||||
"dimensions mismatch: got {0}x{1} but expected {2}x{3}",
|
||||
1, array.length, 1, nCols);
|
||||
}
|
||||
for (int i = 0; i < nCols; ++i) {
|
||||
setEntry(row, i, array[i]);
|
||||
|
@ -606,11 +587,9 @@ public abstract class AbstractRealMatrix implements RealMatrix, Serializable {
|
|||
checkColumnIndex(column);
|
||||
final int nRows = getRowDimension();
|
||||
if (array.length != nRows) {
|
||||
throw new InvalidMatrixException("dimensions mismatch: got {0}x{1} but expected {2}x{3}",
|
||||
new Object[] {
|
||||
array.length, 1,
|
||||
nRows, 1
|
||||
});
|
||||
throw new InvalidMatrixException(
|
||||
"dimensions mismatch: got {0}x{1} but expected {2}x{3}",
|
||||
array.length, 1, nRows, 1);
|
||||
}
|
||||
for (int i = 0; i < nRows; ++i) {
|
||||
setEntry(i, column, array[i]);
|
||||
|
@ -715,11 +694,9 @@ public abstract class AbstractRealMatrix implements RealMatrix, Serializable {
|
|||
final int nRows = getRowDimension();
|
||||
final int nCols = getColumnDimension();
|
||||
if (v.length != nCols) {
|
||||
throw MathRuntimeException.createIllegalArgumentException("vector length mismatch:" +
|
||||
" got {0} but expected {1}",
|
||||
new Object[] {
|
||||
v.length, nCols
|
||||
});
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"vector length mismatch: got {0} but expected {1}",
|
||||
v.length, nCols);
|
||||
}
|
||||
|
||||
final double[] out = new double[nRows];
|
||||
|
@ -744,11 +721,9 @@ public abstract class AbstractRealMatrix implements RealMatrix, Serializable {
|
|||
final int nRows = getRowDimension();
|
||||
final int nCols = getColumnDimension();
|
||||
if (v.getDimension() != nCols) {
|
||||
throw MathRuntimeException.createIllegalArgumentException("vector length mismatch:" +
|
||||
" got {0} but expected {1}",
|
||||
new Object[] {
|
||||
v.getDimension(), nCols
|
||||
});
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"vector length mismatch: got {0} but expected {1}",
|
||||
v.getDimension(), nCols);
|
||||
}
|
||||
|
||||
final double[] out = new double[nRows];
|
||||
|
@ -771,11 +746,9 @@ public abstract class AbstractRealMatrix implements RealMatrix, Serializable {
|
|||
final int nRows = getRowDimension();
|
||||
final int nCols = getColumnDimension();
|
||||
if (v.length != nRows) {
|
||||
throw MathRuntimeException.createIllegalArgumentException("vector length mismatch:" +
|
||||
" got {0} but expected {1}",
|
||||
new Object[] {
|
||||
v.length, nRows
|
||||
});
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"vector length mismatch: got {0} but expected {1}",
|
||||
v.length, nRows);
|
||||
}
|
||||
|
||||
final double[] out = new double[nCols];
|
||||
|
@ -801,11 +774,9 @@ public abstract class AbstractRealMatrix implements RealMatrix, Serializable {
|
|||
final int nRows = getRowDimension();
|
||||
final int nCols = getColumnDimension();
|
||||
if (v.getDimension() != nRows) {
|
||||
throw MathRuntimeException.createIllegalArgumentException("vector length mismatch:" +
|
||||
" got {0} but expected {1}",
|
||||
new Object[] {
|
||||
v.getDimension(), nRows
|
||||
});
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"vector length mismatch: got {0} but expected {1}",
|
||||
v.getDimension(), nRows);
|
||||
}
|
||||
|
||||
final double[] out = new double[nCols];
|
||||
|
@ -1119,7 +1090,7 @@ public abstract class AbstractRealMatrix implements RealMatrix, Serializable {
|
|||
protected void checkRowIndex(final int row) {
|
||||
if (row < 0 || row >= getRowDimension()) {
|
||||
throw new MatrixIndexException("row index {0} out of allowed range [{1}, {2}]",
|
||||
new Object[] { row, 0, getRowDimension() - 1});
|
||||
row, 0, getRowDimension() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1132,7 +1103,7 @@ public abstract class AbstractRealMatrix implements RealMatrix, Serializable {
|
|||
throws MatrixIndexException {
|
||||
if (column < 0 || column >= getColumnDimension()) {
|
||||
throw new MatrixIndexException("column index {0} out of allowed range [{1}, {2}]",
|
||||
new Object[] { column, 0, getColumnDimension() - 1});
|
||||
column, 0, getColumnDimension() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1152,14 +1123,14 @@ public abstract class AbstractRealMatrix implements RealMatrix, Serializable {
|
|||
checkRowIndex(endRow);
|
||||
if (startRow > endRow) {
|
||||
throw new MatrixIndexException("initial row {0} after final row {1}",
|
||||
new Object[] { startRow, endRow });
|
||||
startRow, endRow);
|
||||
}
|
||||
|
||||
checkColumnIndex(startColumn);
|
||||
checkColumnIndex(endColumn);
|
||||
if (startColumn > endColumn) {
|
||||
throw new MatrixIndexException("initial column {0} after final column {1}",
|
||||
new Object[] { startColumn, endColumn });
|
||||
startColumn, endColumn);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1176,9 +1147,9 @@ public abstract class AbstractRealMatrix implements RealMatrix, Serializable {
|
|||
protected void checkSubMatrixIndex(final int[] selectedRows, final int[] selectedColumns) {
|
||||
if (selectedRows.length * selectedColumns.length == 0) {
|
||||
if (selectedRows.length == 0) {
|
||||
throw new MatrixIndexException("empty selected row index array", null);
|
||||
throw new MatrixIndexException("empty selected row index array");
|
||||
}
|
||||
throw new MatrixIndexException("empty selected column index array", null);
|
||||
throw new MatrixIndexException("empty selected column index array");
|
||||
}
|
||||
|
||||
for (final int row : selectedRows) {
|
||||
|
@ -1197,14 +1168,10 @@ public abstract class AbstractRealMatrix implements RealMatrix, Serializable {
|
|||
protected void checkAdditionCompatible(final RealMatrix m) {
|
||||
if ((getRowDimension() != m.getRowDimension()) ||
|
||||
(getColumnDimension() != m.getColumnDimension())) {
|
||||
throw MathRuntimeException.createIllegalArgumentException("{0}x{1} and {2}x{3} matrices are not" +
|
||||
" addition compatible",
|
||||
new Object[] {
|
||||
getRowDimension(),
|
||||
getColumnDimension(),
|
||||
m.getRowDimension(),
|
||||
m.getColumnDimension()
|
||||
});
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"{0}x{1} and {2}x{3} matrices are not addition compatible",
|
||||
getRowDimension(), getColumnDimension(),
|
||||
m.getRowDimension(), m.getColumnDimension());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1216,14 +1183,10 @@ public abstract class AbstractRealMatrix implements RealMatrix, Serializable {
|
|||
protected void checkSubtractionCompatible(final RealMatrix m) {
|
||||
if ((getRowDimension() != m.getRowDimension()) ||
|
||||
(getColumnDimension() != m.getColumnDimension())) {
|
||||
throw MathRuntimeException.createIllegalArgumentException("{0}x{1} and {2}x{3} matrices are not" +
|
||||
" subtraction compatible",
|
||||
new Object[] {
|
||||
getRowDimension(),
|
||||
getColumnDimension(),
|
||||
m.getRowDimension(),
|
||||
m.getColumnDimension()
|
||||
});
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"{0}x{1} and {2}x{3} matrices are not subtraction compatible",
|
||||
getRowDimension(), getColumnDimension(),
|
||||
m.getRowDimension(), m.getColumnDimension());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1234,14 +1197,10 @@ public abstract class AbstractRealMatrix implements RealMatrix, Serializable {
|
|||
*/
|
||||
protected void checkMultiplicationCompatible(final RealMatrix m) {
|
||||
if (getColumnDimension() != m.getRowDimension()) {
|
||||
throw MathRuntimeException.createIllegalArgumentException("{0}x{1} and {2}x{3} matrices are not" +
|
||||
" multiplication compatible",
|
||||
new Object[] {
|
||||
getRowDimension(),
|
||||
getColumnDimension(),
|
||||
m.getRowDimension(),
|
||||
m.getColumnDimension()
|
||||
});
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"{0}x{1} and {2}x{3} matrices are not multiplication compatible",
|
||||
getRowDimension(), getColumnDimension(),
|
||||
m.getRowDimension(), m.getColumnDimension());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -588,14 +588,14 @@ public class BigMatrixImpl implements BigMatrix, Serializable {
|
|||
checkRowIndex(endRow);
|
||||
if (startRow > endRow) {
|
||||
throw new MatrixIndexException("initial row {0} after final row {1}",
|
||||
new Object[] { startRow, endRow });
|
||||
startRow, endRow);
|
||||
}
|
||||
|
||||
checkColumnIndex(startColumn);
|
||||
checkColumnIndex(endColumn);
|
||||
if (startColumn > endColumn) {
|
||||
throw new MatrixIndexException("initial column {0} after final column {1}",
|
||||
new Object[] { startColumn, endColumn });
|
||||
startColumn, endColumn);
|
||||
}
|
||||
|
||||
final BigDecimal[][] subMatrixData =
|
||||
|
@ -626,9 +626,9 @@ public class BigMatrixImpl implements BigMatrix, Serializable {
|
|||
|
||||
if (selectedRows.length * selectedColumns.length == 0) {
|
||||
if (selectedRows.length == 0) {
|
||||
throw new MatrixIndexException("empty selected row index array", null);
|
||||
throw new MatrixIndexException("empty selected row index array");
|
||||
}
|
||||
throw new MatrixIndexException("empty selected column index array", null);
|
||||
throw new MatrixIndexException("empty selected column index array");
|
||||
}
|
||||
|
||||
final BigDecimal[][] subMatrixData =
|
||||
|
@ -702,12 +702,14 @@ public class BigMatrixImpl implements BigMatrix, Serializable {
|
|||
|
||||
if (data == null) {
|
||||
if (row > 0) {
|
||||
throw MathRuntimeException.createIllegalStateException("first {0} rows are not initialized yet",
|
||||
new Object[] { row });
|
||||
throw MathRuntimeException.createIllegalStateException(
|
||||
"first {0} rows are not initialized yet",
|
||||
row);
|
||||
}
|
||||
if (column > 0) {
|
||||
throw MathRuntimeException.createIllegalStateException("first {0} columns are not initialized yet",
|
||||
new Object[] { column });
|
||||
throw MathRuntimeException.createIllegalStateException(
|
||||
"first {0} columns are not initialized yet",
|
||||
column);
|
||||
}
|
||||
data = new BigDecimal[nRows][nCols];
|
||||
System.arraycopy(subMatrix, 0, data, 0, subMatrix.length);
|
||||
|
@ -859,11 +861,9 @@ public class BigMatrixImpl implements BigMatrix, Serializable {
|
|||
try {
|
||||
return data[row][column];
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
throw new MatrixIndexException("no entry at indices ({0}, {1}) in a {2}x{3} matrix",
|
||||
new Object[] {
|
||||
row, column,
|
||||
getRowDimension(), getColumnDimension()
|
||||
});
|
||||
throw new MatrixIndexException(
|
||||
"no entry at indices ({0}, {1}) in a {2}x{3} matrix",
|
||||
row, column, getRowDimension(), getColumnDimension());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -989,7 +989,7 @@ public class BigMatrixImpl implements BigMatrix, Serializable {
|
|||
*/
|
||||
public BigDecimal getTrace() throws IllegalArgumentException {
|
||||
if (!isSquare()) {
|
||||
throw new IllegalArgumentException("matrix is not square");
|
||||
throw new NonSquareMatrixException(getRowDimension(), getColumnDimension());
|
||||
}
|
||||
BigDecimal trace = data[0][0];
|
||||
for (int i = 1; i < this.getRowDimension(); i++) {
|
||||
|
@ -1006,8 +1006,10 @@ public class BigMatrixImpl implements BigMatrix, Serializable {
|
|||
* @throws IllegalArgumentException if columnDimension != v.size()
|
||||
*/
|
||||
public BigDecimal[] operate(BigDecimal[] v) throws IllegalArgumentException {
|
||||
if (v.length != this.getColumnDimension()) {
|
||||
throw new IllegalArgumentException("vector has wrong length");
|
||||
if (v.length != getColumnDimension()) {
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"vector length mismatch: got {0} but expected {1}",
|
||||
v.length, getColumnDimension() );
|
||||
}
|
||||
final int nRows = this.getRowDimension();
|
||||
final int nCols = this.getColumnDimension();
|
||||
|
@ -1047,7 +1049,9 @@ public class BigMatrixImpl implements BigMatrix, Serializable {
|
|||
public BigDecimal[] preMultiply(BigDecimal[] v) throws IllegalArgumentException {
|
||||
final int nRows = this.getRowDimension();
|
||||
if (v.length != nRows) {
|
||||
throw new IllegalArgumentException("vector has wrong length");
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"vector length mismatch: got {0} but expected {1}",
|
||||
v.length, nRows );
|
||||
}
|
||||
final int nCols = this.getColumnDimension();
|
||||
final BigDecimal[] out = new BigDecimal[nCols];
|
||||
|
@ -1075,7 +1079,9 @@ public class BigMatrixImpl implements BigMatrix, Serializable {
|
|||
public BigDecimal[] solve(BigDecimal[] b) throws IllegalArgumentException, InvalidMatrixException {
|
||||
final int nRows = this.getRowDimension();
|
||||
if (b.length != nRows) {
|
||||
throw new IllegalArgumentException("constant vector has wrong length");
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"vector length mismatch: got {0} but expected {1}",
|
||||
b.length, nRows);
|
||||
}
|
||||
final BigMatrix bMatrix = new BigMatrixImpl(b);
|
||||
final BigDecimal[][] solution = ((BigMatrixImpl) (solve(bMatrix))).getDataRef();
|
||||
|
@ -1117,10 +1123,12 @@ public class BigMatrixImpl implements BigMatrix, Serializable {
|
|||
* @throws InvalidMatrixException if this matrix is not square or is singular
|
||||
*/
|
||||
public BigMatrix solve(BigMatrix b) throws IllegalArgumentException, InvalidMatrixException {
|
||||
if (b.getRowDimension() != this.getRowDimension()) {
|
||||
throw new IllegalArgumentException("Incorrect row dimension");
|
||||
if (b.getRowDimension() != getRowDimension()) {
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"dimensions mismatch: got {0}x{1} but expected {2}x{3}",
|
||||
b.getRowDimension(), b.getColumnDimension(), getRowDimension(), "n");
|
||||
}
|
||||
if (!this.isSquare()) {
|
||||
if (!isSquare()) {
|
||||
throw new NonSquareMatrixException(getRowDimension(), getColumnDimension());
|
||||
}
|
||||
if (this.isSingular()) { // side effect: compute LU decomp
|
||||
|
@ -1480,8 +1488,9 @@ public class BigMatrixImpl implements BigMatrix, Serializable {
|
|||
*/
|
||||
private void checkRowIndex(final int row) {
|
||||
if (row < 0 || row >= getRowDimension()) {
|
||||
throw new MatrixIndexException("row index {0} out of allowed range [{1}, {2}]",
|
||||
new Object[] { row, 0, getRowDimension() - 1});
|
||||
throw new MatrixIndexException(
|
||||
"row index {0} out of allowed range [{1}, {2}]",
|
||||
row, 0, getRowDimension() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1493,8 +1502,9 @@ public class BigMatrixImpl implements BigMatrix, Serializable {
|
|||
private void checkColumnIndex(final int column)
|
||||
throws MatrixIndexException {
|
||||
if (column < 0 || column >= getColumnDimension()) {
|
||||
throw new MatrixIndexException("column index {0} out of allowed range [{1}, {2}]",
|
||||
new Object[] { column, 0, getColumnDimension() - 1});
|
||||
throw new MatrixIndexException(
|
||||
"column index {0} out of allowed range [{1}, {2}]",
|
||||
column, 0, getColumnDimension() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -166,11 +166,9 @@ public class DenseRealMatrix extends AbstractRealMatrix implements Serializable
|
|||
final int iHeight = blockHeight(iBlock);
|
||||
for (int jBlock = 0; jBlock < blockColumns; ++jBlock, ++index) {
|
||||
if (blockData[index].length != iHeight * blockWidth(jBlock)) {
|
||||
throw MathRuntimeException.createIllegalArgumentException("wrong array shape (block length = {0}, expected {1})",
|
||||
new Object[] {
|
||||
blockData[index].length,
|
||||
iHeight * blockWidth(jBlock)
|
||||
});
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"wrong array shape (block length = {0}, expected {1})",
|
||||
blockData[index].length, iHeight * blockWidth(jBlock));
|
||||
}
|
||||
if (copyArray) {
|
||||
blocks[index] = blockData[index].clone();
|
||||
|
@ -216,7 +214,7 @@ public class DenseRealMatrix extends AbstractRealMatrix implements Serializable
|
|||
if (length != columns) {
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"some rows have length {0} while others have length {1}",
|
||||
new Object[] { columns, length });
|
||||
columns, length);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -801,18 +799,16 @@ public class DenseRealMatrix extends AbstractRealMatrix implements Serializable
|
|||
// safety checks
|
||||
final int refLength = subMatrix[0].length;
|
||||
if (refLength < 1) {
|
||||
throw MathRuntimeException.createIllegalArgumentException("matrix must have at least one column",
|
||||
null);
|
||||
throw MathRuntimeException.createIllegalArgumentException("matrix must have at least one column");
|
||||
}
|
||||
final int endRow = row + subMatrix.length - 1;
|
||||
final int endColumn = column + refLength - 1;
|
||||
checkSubMatrixIndex(row, endRow, column, endColumn);
|
||||
for (final double[] subRow : subMatrix) {
|
||||
if (subRow.length != refLength) {
|
||||
throw MathRuntimeException.createIllegalArgumentException("some rows have length {0} while others have length {1}",
|
||||
new Object[] {
|
||||
refLength, subRow.length
|
||||
});
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"some rows have length {0} while others have length {1}",
|
||||
refLength, subRow.length);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -908,12 +904,10 @@ public class DenseRealMatrix extends AbstractRealMatrix implements Serializable
|
|||
final int nCols = getColumnDimension();
|
||||
if ((matrix.getRowDimension() != 1) ||
|
||||
(matrix.getColumnDimension() != nCols)) {
|
||||
throw new InvalidMatrixException("dimensions mismatch: got {0}x{1} but expected {2}x{3}",
|
||||
new Object[] {
|
||||
matrix.getRowDimension(),
|
||||
matrix.getColumnDimension(),
|
||||
1, nCols
|
||||
});
|
||||
throw new InvalidMatrixException(
|
||||
"dimensions mismatch: got {0}x{1} but expected {2}x{3}",
|
||||
matrix.getRowDimension(), matrix.getColumnDimension(),
|
||||
1, nCols);
|
||||
}
|
||||
|
||||
// perform copy block-wise, to ensure good cache behavior
|
||||
|
@ -997,12 +991,10 @@ public class DenseRealMatrix extends AbstractRealMatrix implements Serializable
|
|||
final int nRows = getRowDimension();
|
||||
if ((matrix.getRowDimension() != nRows) ||
|
||||
(matrix.getColumnDimension() != 1)) {
|
||||
throw new InvalidMatrixException("dimensions mismatch: got {0}x{1} but expected {2}x{3}",
|
||||
new Object[] {
|
||||
matrix.getRowDimension(),
|
||||
matrix.getColumnDimension(),
|
||||
nRows, 1
|
||||
});
|
||||
throw new InvalidMatrixException(
|
||||
"dimensions mismatch: got {0}x{1} but expected {2}x{3}",
|
||||
matrix.getRowDimension(), matrix.getColumnDimension(),
|
||||
nRows, 1);
|
||||
}
|
||||
|
||||
// perform copy block-wise, to ensure good cache behavior
|
||||
|
@ -1121,11 +1113,9 @@ public class DenseRealMatrix extends AbstractRealMatrix implements Serializable
|
|||
checkRowIndex(row);
|
||||
final int nCols = getColumnDimension();
|
||||
if (array.length != nCols) {
|
||||
throw new InvalidMatrixException("dimensions mismatch: got {0}x{1} but expected {2}x{3}",
|
||||
new Object[] {
|
||||
1, array.length,
|
||||
1, nCols
|
||||
});
|
||||
throw new InvalidMatrixException(
|
||||
"dimensions mismatch: got {0}x{1} but expected {2}x{3}",
|
||||
1, array.length, 1, nCols);
|
||||
}
|
||||
|
||||
// perform copy block-wise, to ensure good cache behavior
|
||||
|
@ -1172,11 +1162,9 @@ public class DenseRealMatrix extends AbstractRealMatrix implements Serializable
|
|||
checkColumnIndex(column);
|
||||
final int nRows = getRowDimension();
|
||||
if (array.length != nRows) {
|
||||
throw new InvalidMatrixException("dimensions mismatch: got {0}x{1} but expected {2}x{3}",
|
||||
new Object[] {
|
||||
array.length, 1,
|
||||
nRows, 1
|
||||
});
|
||||
throw new InvalidMatrixException(
|
||||
"dimensions mismatch: got {0}x{1} but expected {2}x{3}",
|
||||
array.length, 1, nRows, 1);
|
||||
}
|
||||
|
||||
// perform copy block-wise, to ensure good cache behavior
|
||||
|
@ -1204,11 +1192,9 @@ public class DenseRealMatrix extends AbstractRealMatrix implements Serializable
|
|||
(column - jBlock * BLOCK_SIZE);
|
||||
return blocks[iBlock * blockColumns + jBlock][k];
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
throw new MatrixIndexException("no entry at indices ({0}, {1}) in a {2}x{3} matrix",
|
||||
new Object[] {
|
||||
row, column,
|
||||
getRowDimension(), getColumnDimension()
|
||||
});
|
||||
throw new MatrixIndexException(
|
||||
"no entry at indices ({0}, {1}) in a {2}x{3} matrix",
|
||||
row, column, getRowDimension(), getColumnDimension());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1222,11 +1208,9 @@ public class DenseRealMatrix extends AbstractRealMatrix implements Serializable
|
|||
(column - jBlock * BLOCK_SIZE);
|
||||
blocks[iBlock * blockColumns + jBlock][k] = value;
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
throw new MatrixIndexException("no entry at indices ({0}, {1}) in a {2}x{3} matrix",
|
||||
new Object[] {
|
||||
row, column,
|
||||
getRowDimension(), getColumnDimension()
|
||||
});
|
||||
throw new MatrixIndexException(
|
||||
"no entry at indices ({0}, {1}) in a {2}x{3} matrix",
|
||||
row, column, getRowDimension(), getColumnDimension());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1240,11 +1224,9 @@ public class DenseRealMatrix extends AbstractRealMatrix implements Serializable
|
|||
(column - jBlock * BLOCK_SIZE);
|
||||
blocks[iBlock * blockColumns + jBlock][k] += increment;
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
throw new MatrixIndexException("no entry at indices ({0}, {1}) in a {2}x{3} matrix",
|
||||
new Object[] {
|
||||
row, column,
|
||||
getRowDimension(), getColumnDimension()
|
||||
});
|
||||
throw new MatrixIndexException(
|
||||
"no entry at indices ({0}, {1}) in a {2}x{3} matrix",
|
||||
row, column, getRowDimension(), getColumnDimension());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1258,11 +1240,9 @@ public class DenseRealMatrix extends AbstractRealMatrix implements Serializable
|
|||
(column - jBlock * BLOCK_SIZE);
|
||||
blocks[iBlock * blockColumns + jBlock][k] *= factor;
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
throw new MatrixIndexException("no entry at indices ({0}, {1}) in a {2}x{3} matrix",
|
||||
new Object[] {
|
||||
row, column,
|
||||
getRowDimension(), getColumnDimension()
|
||||
});
|
||||
throw new MatrixIndexException(
|
||||
"no entry at indices ({0}, {1}) in a {2}x{3} matrix",
|
||||
row, column, getRowDimension(), getColumnDimension());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1317,11 +1297,9 @@ public class DenseRealMatrix extends AbstractRealMatrix implements Serializable
|
|||
throws IllegalArgumentException {
|
||||
|
||||
if (v.length != columns) {
|
||||
throw MathRuntimeException.createIllegalArgumentException("vector length mismatch:" +
|
||||
" got {0} but expected {1}",
|
||||
new Object[] {
|
||||
v.length, columns
|
||||
});
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"vector length mismatch: got {0} but expected {1}",
|
||||
v.length, columns);
|
||||
}
|
||||
final double[] out = new double[rows];
|
||||
|
||||
|
@ -1361,11 +1339,9 @@ public class DenseRealMatrix extends AbstractRealMatrix implements Serializable
|
|||
throws IllegalArgumentException {
|
||||
|
||||
if (v.length != rows) {
|
||||
throw MathRuntimeException.createIllegalArgumentException("vector length mismatch:" +
|
||||
" got {0} but expected {1}",
|
||||
new Object[] {
|
||||
v.length, rows
|
||||
});
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"vector length mismatch: got {0} but expected {1}",
|
||||
v.length, rows);
|
||||
}
|
||||
final double[] out = new double[columns];
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ public class InvalidMatrixException extends MathRuntimeException {
|
|||
* @param arguments format arguments
|
||||
* @since 2.0
|
||||
*/
|
||||
public InvalidMatrixException(final String pattern, final Object[] arguments) {
|
||||
public InvalidMatrixException(final String pattern, final Object ... arguments) {
|
||||
super(pattern, arguments);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ public class MatrixIndexException extends MathRuntimeException {
|
|||
* @param pattern format specifier
|
||||
* @param arguments format arguments
|
||||
*/
|
||||
public MatrixIndexException(final String pattern, final Object[] arguments) {
|
||||
public MatrixIndexException(final String pattern, final Object ... arguments) {
|
||||
super(pattern, arguments);
|
||||
}
|
||||
|
||||
|
|
|
@ -120,19 +120,17 @@ public class RealMatrixImpl extends AbstractRealMatrix implements Serializable {
|
|||
}
|
||||
final int nRows = d.length;
|
||||
if (nRows == 0) {
|
||||
throw MathRuntimeException.createIllegalArgumentException("matrix must have at least one row",
|
||||
null);
|
||||
throw MathRuntimeException.createIllegalArgumentException("matrix must have at least one row");
|
||||
}
|
||||
final int nCols = d[0].length;
|
||||
if (nCols == 0) {
|
||||
throw MathRuntimeException.createIllegalArgumentException("matrix must have at least one column",
|
||||
null);
|
||||
throw MathRuntimeException.createIllegalArgumentException("matrix must have at least one column");
|
||||
}
|
||||
for (int r = 1; r < nRows; r++) {
|
||||
if (d[r].length != nCols) {
|
||||
throw MathRuntimeException.createIllegalArgumentException("some rows have length {0} while" +
|
||||
" others have length {1}",
|
||||
new Object[] { nCols, d[r].length });
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"some rows have length {0} while others have length {1}",
|
||||
nCols, d[r].length);
|
||||
}
|
||||
}
|
||||
data = d;
|
||||
|
@ -308,31 +306,30 @@ public class RealMatrixImpl extends AbstractRealMatrix implements Serializable {
|
|||
throws MatrixIndexException {
|
||||
if (data == null) {
|
||||
if (row > 0) {
|
||||
throw MathRuntimeException.createIllegalStateException("first {0} rows are not initialized yet",
|
||||
new Object[] { row });
|
||||
throw MathRuntimeException.createIllegalStateException(
|
||||
"first {0} rows are not initialized yet",
|
||||
row);
|
||||
}
|
||||
if (column > 0) {
|
||||
throw MathRuntimeException.createIllegalStateException("first {0} columns are not initialized yet",
|
||||
new Object[] { column });
|
||||
throw MathRuntimeException.createIllegalStateException(
|
||||
"first {0} columns are not initialized yet",
|
||||
column);
|
||||
}
|
||||
final int nRows = subMatrix.length;
|
||||
if (nRows == 0) {
|
||||
throw MathRuntimeException.createIllegalArgumentException("matrix must have at least one row",
|
||||
null);
|
||||
throw MathRuntimeException.createIllegalArgumentException("matrix must have at least one row");
|
||||
}
|
||||
|
||||
final int nCols = subMatrix[0].length;
|
||||
if (nCols == 0) {
|
||||
throw MathRuntimeException.createIllegalArgumentException("matrix must have at least one column",
|
||||
null);
|
||||
throw MathRuntimeException.createIllegalArgumentException("matrix must have at least one column");
|
||||
}
|
||||
data = new double[subMatrix.length][nCols];
|
||||
for (int i = 0; i < data.length; ++i) {
|
||||
if (subMatrix[i].length != nCols) {
|
||||
throw MathRuntimeException.createIllegalArgumentException("some rows have length {0} while others have length {1}",
|
||||
new Object[] {
|
||||
nCols, subMatrix[i].length
|
||||
});
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"some rows have length {0} while others have length {1}",
|
||||
nCols, subMatrix[i].length);
|
||||
}
|
||||
System.arraycopy(subMatrix[i], 0, data[i + row], column, nCols);
|
||||
}
|
||||
|
@ -348,11 +345,9 @@ public class RealMatrixImpl extends AbstractRealMatrix implements Serializable {
|
|||
try {
|
||||
return data[row][column];
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
throw new MatrixIndexException("no entry at indices ({0}, {1}) in a {2}x{3} matrix",
|
||||
new Object[] {
|
||||
row, column,
|
||||
getRowDimension(), getColumnDimension()
|
||||
});
|
||||
throw new MatrixIndexException(
|
||||
"no entry at indices ({0}, {1}) in a {2}x{3} matrix",
|
||||
row, column, getRowDimension(), getColumnDimension());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -362,11 +357,9 @@ public class RealMatrixImpl extends AbstractRealMatrix implements Serializable {
|
|||
try {
|
||||
data[row][column] = value;
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
throw new MatrixIndexException("no entry at indices ({0}, {1}) in a {2}x{3} matrix",
|
||||
new Object[] {
|
||||
row, column,
|
||||
getRowDimension(), getColumnDimension()
|
||||
});
|
||||
throw new MatrixIndexException(
|
||||
"no entry at indices ({0}, {1}) in a {2}x{3} matrix",
|
||||
row, column, getRowDimension(), getColumnDimension());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -376,11 +369,9 @@ public class RealMatrixImpl extends AbstractRealMatrix implements Serializable {
|
|||
try {
|
||||
data[row][column] += increment;
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
throw new MatrixIndexException("no entry at indices ({0}, {1}) in a {2}x{3} matrix",
|
||||
new Object[] {
|
||||
row, column,
|
||||
getRowDimension(), getColumnDimension()
|
||||
});
|
||||
throw new MatrixIndexException(
|
||||
"no entry at indices ({0}, {1}) in a {2}x{3} matrix",
|
||||
row, column, getRowDimension(), getColumnDimension());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -390,11 +381,9 @@ public class RealMatrixImpl extends AbstractRealMatrix implements Serializable {
|
|||
try {
|
||||
data[row][column] *= factor;
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
throw new MatrixIndexException("no entry at indices ({0}, {1}) in a {2}x{3} matrix",
|
||||
new Object[] {
|
||||
row, column,
|
||||
getRowDimension(), getColumnDimension()
|
||||
});
|
||||
throw new MatrixIndexException(
|
||||
"no entry at indices ({0}, {1}) in a {2}x{3} matrix",
|
||||
row, column, getRowDimension(), getColumnDimension());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -414,11 +403,9 @@ public class RealMatrixImpl extends AbstractRealMatrix implements Serializable {
|
|||
final int nRows = this.getRowDimension();
|
||||
final int nCols = this.getColumnDimension();
|
||||
if (v.length != nCols) {
|
||||
throw MathRuntimeException.createIllegalArgumentException("vector length mismatch:" +
|
||||
" got {0} but expected {1}",
|
||||
new Object[] {
|
||||
v.length, nCols
|
||||
});
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"vector length mismatch: got {0} but expected {1}",
|
||||
v.length, nCols);
|
||||
}
|
||||
final double[] out = new double[nRows];
|
||||
for (int row = 0; row < nRows; row++) {
|
||||
|
@ -439,11 +426,9 @@ public class RealMatrixImpl extends AbstractRealMatrix implements Serializable {
|
|||
final int nRows = getRowDimension();
|
||||
final int nCols = getColumnDimension();
|
||||
if (v.length != nRows) {
|
||||
throw MathRuntimeException.createIllegalArgumentException("vector length mismatch:" +
|
||||
" got {0} but expected {1}",
|
||||
new Object[] {
|
||||
v.length, nRows
|
||||
});
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"vector length mismatch: got {0} but expected {1}",
|
||||
v.length, nRows);
|
||||
}
|
||||
|
||||
final double[] out = new double[nCols];
|
||||
|
|
|
@ -259,9 +259,9 @@ public class RealVectorFormat extends CompositeFormat {
|
|||
ParsePosition parsePosition = new ParsePosition(0);
|
||||
RealVectorImpl result = parse(source, parsePosition);
|
||||
if (parsePosition.getIndex() == 0) {
|
||||
throw MathRuntimeException.createParseException("unparseable real vector: \"{0}\"",
|
||||
new Object[] { source },
|
||||
parsePosition.getErrorIndex());
|
||||
throw MathRuntimeException.createParseException(
|
||||
parsePosition.getErrorIndex(),
|
||||
"unparseable real vector: \"{0}\"", source);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -1069,7 +1069,7 @@ public class RealVectorImpl implements RealVector, Serializable {
|
|||
public RealVector unitVector() throws ArithmeticException {
|
||||
final double norm = getNorm();
|
||||
if (norm == 0) {
|
||||
throw MathRuntimeException.createArithmeticException("zero norm", null);
|
||||
throw MathRuntimeException.createArithmeticException("zero norm");
|
||||
}
|
||||
return mapDivide(getNorm());
|
||||
}
|
||||
|
@ -1078,8 +1078,7 @@ public class RealVectorImpl implements RealVector, Serializable {
|
|||
public void unitize() throws ArithmeticException {
|
||||
final double norm = getNorm();
|
||||
if (norm == 0) {
|
||||
throw MathRuntimeException.createArithmeticException("cannot normalize a zero norm vector",
|
||||
null);
|
||||
throw MathRuntimeException.createArithmeticException("cannot normalize a zero norm vector");
|
||||
}
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
data[i] /= norm;
|
||||
|
@ -1399,8 +1398,9 @@ public class RealVectorImpl implements RealVector, Serializable {
|
|||
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});
|
||||
throw new MatrixIndexException(
|
||||
"index {0} out of allowed range [{1}, {2}]",
|
||||
index, 0, getDimension() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1168,8 +1168,7 @@ public class SparseRealVector implements RealVector {
|
|||
public void unitize() {
|
||||
double norm = getNorm();
|
||||
if(isZero(norm)){
|
||||
throw MathRuntimeException.createArithmeticException("cannot normalize a zero norm vector",
|
||||
null);
|
||||
throw MathRuntimeException.createArithmeticException("cannot normalize a zero norm vector");
|
||||
|
||||
}
|
||||
Iterator iter = entries.iterator();
|
||||
|
@ -1192,7 +1191,7 @@ public class SparseRealVector implements RealVector {
|
|||
if (index < 0 || index >= getDimension()) {
|
||||
throw new MatrixIndexException(
|
||||
"index {0} out of allowed range [{1}, {2}]",
|
||||
new Object[] { index, 0, getDimension() - 1 });
|
||||
index, 0, getDimension() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1208,7 +1207,7 @@ public class SparseRealVector implements RealVector {
|
|||
if (getDimension() != n) {
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"vector length mismatch: got {0} but expected {1}",
|
||||
new Object[] { getDimension(), n });
|
||||
getDimension(), n);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -224,7 +224,7 @@ public class CholeskyDecompositionImpl implements CholeskyDecomposition {
|
|||
if (b.length != m) {
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"vector length mismatch: got {0} but expected {1}",
|
||||
new Object[] { b.length, m });
|
||||
b.length, m);
|
||||
}
|
||||
|
||||
final double[] x = b.clone();
|
||||
|
@ -263,7 +263,7 @@ public class CholeskyDecompositionImpl implements CholeskyDecomposition {
|
|||
if (b.getDimension() != m) {
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"vector length mismatch: got {0} but expected {1}",
|
||||
new Object[] { b.getDimension(), m });
|
||||
b.getDimension(), m);
|
||||
}
|
||||
|
||||
final double[] x = b.getData();
|
||||
|
@ -312,7 +312,7 @@ public class CholeskyDecompositionImpl implements CholeskyDecomposition {
|
|||
if (b.getRowDimension() != m) {
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"dimensions mismatch: got {0}x{1} but expected {2}x{3}",
|
||||
new Object[] { b.getRowDimension(), b.getColumnDimension(), m, "n"});
|
||||
b.getRowDimension(), b.getColumnDimension(), m, "n");
|
||||
}
|
||||
|
||||
final int nColB = b.getColumnDimension();
|
||||
|
|
|
@ -177,8 +177,7 @@ public class EigenDecompositionImpl implements EigenDecomposition {
|
|||
} else {
|
||||
// as of 2.0, non-symmetric matrices (i.e. complex eigenvalues) are NOT supported
|
||||
// see issue https://issues.apache.org/jira/browse/MATH-235
|
||||
throw new InvalidMatrixException("eigen decomposition of assymetric matrices not supported yet",
|
||||
null);
|
||||
throw new InvalidMatrixException("eigen decomposition of assymetric matrices not supported yet");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -412,7 +411,7 @@ public class EigenDecompositionImpl implements EigenDecomposition {
|
|||
if (b.length != m) {
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"vector length mismatch: got {0} but expected {1}",
|
||||
new Object[] { b.length, m });
|
||||
b.length, m);
|
||||
}
|
||||
|
||||
final double[] bp = new double[m];
|
||||
|
@ -448,7 +447,7 @@ public class EigenDecompositionImpl implements EigenDecomposition {
|
|||
if (b.getDimension() != m) {
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"vector length mismatch: got {0} but expected {1}",
|
||||
new Object[] { b.getDimension(), m });
|
||||
b.getDimension(), m);
|
||||
}
|
||||
|
||||
final double[] bp = new double[m];
|
||||
|
@ -484,10 +483,7 @@ public class EigenDecompositionImpl implements EigenDecomposition {
|
|||
if (b.getRowDimension() != m) {
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"dimensions mismatch: got {0}x{1} but expected {2}x{3}",
|
||||
new Object[] {
|
||||
b.getRowDimension(), b.getColumnDimension(),
|
||||
m, "n"
|
||||
});
|
||||
b.getRowDimension(), b.getColumnDimension(), m, "n");
|
||||
}
|
||||
|
||||
final int nColB = b.getColumnDimension();
|
||||
|
@ -744,7 +740,7 @@ public class EigenDecompositionImpl implements EigenDecomposition {
|
|||
final double p = q0 * q1 - e12;
|
||||
final double delta = s * s - 4 * p;
|
||||
if (delta < 0) {
|
||||
throw new InvalidMatrixException("cannot solve degree {0} equation", new Object[] { 2 });
|
||||
throw new InvalidMatrixException("cannot solve degree {0} equation", 2);
|
||||
}
|
||||
|
||||
final double largestRoot = 0.5 * (s + Math.sqrt(delta));
|
||||
|
@ -784,7 +780,7 @@ public class EigenDecompositionImpl implements EigenDecomposition {
|
|||
// in fact, there are solutions to the equation, but in the context
|
||||
// of symmetric realEigenvalues problem, there should be three distinct
|
||||
// real roots, so we throw an error if this condition is not met
|
||||
throw new InvalidMatrixException("cannot solve degree {0} equation", new Object[] { 3 });
|
||||
throw new InvalidMatrixException("cannot solve degree {0} equation", 3);
|
||||
}
|
||||
final double sqrtMq = Math.sqrt(-q);
|
||||
final double theta = Math.acos(r / (-q * sqrtMq));
|
||||
|
|
|
@ -273,7 +273,7 @@ public class LUDecompositionImpl implements LUDecomposition {
|
|||
if (b.length != m) {
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"vector length mismatch: got {0} but expected {1}",
|
||||
new Object[] { b.length, m });
|
||||
b.length, m);
|
||||
}
|
||||
if (singular) {
|
||||
throw new SingularMatrixException();
|
||||
|
@ -316,7 +316,7 @@ public class LUDecompositionImpl implements LUDecomposition {
|
|||
if (b.getDimension() != m) {
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"vector length mismatch: got {0} but expected {1}",
|
||||
new Object[] { b.getDimension(), m });
|
||||
b.getDimension(), m);
|
||||
}
|
||||
if (singular) {
|
||||
throw new SingularMatrixException();
|
||||
|
@ -369,7 +369,7 @@ public class LUDecompositionImpl implements LUDecomposition {
|
|||
if (b.getRowDimension() != m) {
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"dimensions mismatch: got {0}x{1} but expected {2}x{3}",
|
||||
new Object[] { b.getRowDimension(), b.getColumnDimension(), m, "n"});
|
||||
b.getRowDimension(), b.getColumnDimension(), m, "n");
|
||||
}
|
||||
if (singular) {
|
||||
throw new SingularMatrixException();
|
||||
|
|
|
@ -36,7 +36,7 @@ public class NonSquareMatrixException extends InvalidMatrixException {
|
|||
*/
|
||||
public NonSquareMatrixException(final int rows, final int columns) {
|
||||
super("a {0}x{1} matrix was provided instead of a square matrix",
|
||||
new Object[] { rows, columns });
|
||||
rows, columns);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ public class NotPositiveDefiniteMatrixException extends MathException {
|
|||
* build an exception with a default message.
|
||||
*/
|
||||
public NotPositiveDefiniteMatrixException() {
|
||||
super("not positive definite matrix", null);
|
||||
super("not positive definite matrix");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ public class NotSymmetricMatrixException extends MathException {
|
|||
* build an exception with a default message.
|
||||
*/
|
||||
public NotSymmetricMatrixException() {
|
||||
super("not symmetric matrix", null);
|
||||
super("not symmetric matrix");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -303,7 +303,7 @@ public class QRDecompositionImpl implements QRDecomposition {
|
|||
if (b.length != m) {
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"vector length mismatch: got {0} but expected {1}",
|
||||
new Object[] { b.length, m });
|
||||
b.length, m);
|
||||
}
|
||||
if (!isNonSingular()) {
|
||||
throw new SingularMatrixException();
|
||||
|
@ -374,7 +374,7 @@ public class QRDecompositionImpl implements QRDecomposition {
|
|||
if (b.getRowDimension() != m) {
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"dimensions mismatch: got {0}x{1} but expected {2}x{3}",
|
||||
new Object[] { b.getRowDimension(), b.getColumnDimension(), m, "n"});
|
||||
b.getRowDimension(), b.getColumnDimension(), m, "n");
|
||||
}
|
||||
if (!isNonSingular()) {
|
||||
throw new SingularMatrixException();
|
||||
|
|
|
@ -33,7 +33,7 @@ public class SingularMatrixException extends InvalidMatrixException {
|
|||
* Construct an exception with a default message.
|
||||
*/
|
||||
public SingularMatrixException() {
|
||||
super("matrix is singular", null);
|
||||
super("matrix is singular");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -343,7 +343,7 @@ public class SingularValueDecompositionImpl implements SingularValueDecompositio
|
|||
if (b.length != singularValues.length) {
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"vector length mismatch: got {0} but expected {1}",
|
||||
new Object[] { b.length, singularValues.length });
|
||||
b.length, singularValues.length);
|
||||
}
|
||||
|
||||
final double[] w = uT.operate(b);
|
||||
|
@ -372,7 +372,7 @@ public class SingularValueDecompositionImpl implements SingularValueDecompositio
|
|||
if (b.getDimension() != singularValues.length) {
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"vector length mismatch: got {0} but expected {1}",
|
||||
new Object[] { b.getDimension(), singularValues.length });
|
||||
b.getDimension(), singularValues.length);
|
||||
}
|
||||
|
||||
final RealVector w = uT.operate(b);
|
||||
|
@ -401,10 +401,8 @@ public class SingularValueDecompositionImpl implements SingularValueDecompositio
|
|||
if (b.getRowDimension() != singularValues.length) {
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"dimensions mismatch: got {0}x{1} but expected {2}x{3}",
|
||||
new Object[] {
|
||||
b.getRowDimension(), b.getColumnDimension(),
|
||||
singularValues.length, "n"
|
||||
});
|
||||
b.getRowDimension(), b.getColumnDimension(),
|
||||
singularValues.length, "n");
|
||||
}
|
||||
|
||||
final RealMatrix w = uT.multiply(b);
|
||||
|
|
|
@ -137,28 +137,23 @@ public abstract class AbstractIntegrator implements FirstOrderIntegrator {
|
|||
throws IntegratorException {
|
||||
|
||||
if (equations.getDimension() != y0.length) {
|
||||
throw new IntegratorException("dimensions mismatch: ODE problem has dimension {0}," +
|
||||
" initial state vector has dimension {1}",
|
||||
new Object[] {
|
||||
Integer.valueOf(equations.getDimension()),
|
||||
Integer.valueOf(y0.length)
|
||||
});
|
||||
throw new IntegratorException(
|
||||
"dimensions mismatch: ODE problem has dimension {0}," +
|
||||
" initial state vector has dimension {1}",
|
||||
equations.getDimension(), y0.length);
|
||||
}
|
||||
|
||||
if (equations.getDimension() != y.length) {
|
||||
throw new IntegratorException("dimensions mismatch: ODE problem has dimension {0}," +
|
||||
" final state vector has dimension {1}",
|
||||
new Object[] {
|
||||
Integer.valueOf(equations.getDimension()),
|
||||
Integer.valueOf(y.length)
|
||||
});
|
||||
throw new IntegratorException(
|
||||
"dimensions mismatch: ODE problem has dimension {0}," +
|
||||
" final state vector has dimension {1}",
|
||||
equations.getDimension(), y.length);
|
||||
}
|
||||
|
||||
if (Math.abs(t - t0) <= 1.0e-12 * Math.max(Math.abs(t0), Math.abs(t))) {
|
||||
throw new IntegratorException("too small integration interval: length = {0}",
|
||||
new Object[] {
|
||||
Double.valueOf(Math.abs(t - t0))
|
||||
});
|
||||
throw new IntegratorException(
|
||||
"too small integration interval: length = {0}",
|
||||
Math.abs(t - t0));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -315,7 +315,7 @@ public class ContinuousOutputModel
|
|||
steps.get(index).setInterpolatedTime(time);
|
||||
|
||||
} catch (DerivativeException de) {
|
||||
throw new MathRuntimeException("unexpected exception caught", null, de);
|
||||
throw new MathRuntimeException(de, "unexpected exception caught");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -29,12 +29,15 @@ import org.apache.commons.math.MathException;
|
|||
public class DerivativeException
|
||||
extends MathException {
|
||||
|
||||
/** Serializable version identifier */
|
||||
private static final long serialVersionUID = 5666710788967425123L;
|
||||
|
||||
/** Simple constructor.
|
||||
* Build an exception by translating and formating a message
|
||||
* @param specifier format specifier (to be translated)
|
||||
* @param parts to insert in the format (no translation)
|
||||
*/
|
||||
public DerivativeException(final String specifier, final Object[] parts) {
|
||||
public DerivativeException(final String specifier, final Object ... parts) {
|
||||
super(specifier, parts);
|
||||
}
|
||||
|
||||
|
@ -45,7 +48,4 @@ public class DerivativeException
|
|||
super(cause);
|
||||
}
|
||||
|
||||
/** Serializable version identifier */
|
||||
private static final long serialVersionUID = -4100440615830558122L;
|
||||
|
||||
}
|
||||
|
|
|
@ -27,13 +27,16 @@ import org.apache.commons.math.MathException;
|
|||
*/
|
||||
public class IntegratorException
|
||||
extends MathException {
|
||||
|
||||
|
||||
/** Serializable version identifier */
|
||||
private static final long serialVersionUID = -1607588949778036796L;
|
||||
|
||||
/** Simple constructor.
|
||||
* Build an exception by translating and formating a message
|
||||
* @param specifier format specifier (to be translated)
|
||||
* @param parts to insert in the format (no translation)
|
||||
*/
|
||||
public IntegratorException(final String specifier, final Object[] parts) {
|
||||
public IntegratorException(final String specifier, final Object ... parts) {
|
||||
super(specifier, parts);
|
||||
}
|
||||
|
||||
|
@ -45,7 +48,4 @@ public class IntegratorException
|
|||
super(cause);
|
||||
}
|
||||
|
||||
/** Serializable version identifier */
|
||||
private static final long serialVersionUID = -1215318282266670558L;
|
||||
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ public class EventException extends MathException {
|
|||
* @param specifier format specifier (to be translated)
|
||||
* @param parts to insert in the format (no translation)
|
||||
*/
|
||||
public EventException(final String specifier, final Object[] parts) {
|
||||
public EventException(final String specifier, final Object ... parts) {
|
||||
super(specifier, parts);
|
||||
}
|
||||
|
||||
|
|
|
@ -197,9 +197,9 @@ public class EventState implements Serializable {
|
|||
interpolator.setInterpolatedTime(t);
|
||||
return handler.g(t, interpolator.getInterpolatedState());
|
||||
} catch (DerivativeException e) {
|
||||
throw new FunctionEvaluationException(t, e);
|
||||
throw new FunctionEvaluationException(e, t);
|
||||
} catch (EventException e) {
|
||||
throw new FunctionEvaluationException(t, e);
|
||||
throw new FunctionEvaluationException(e, t);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -152,21 +152,17 @@ public abstract class AdaptiveStepsizeIntegrator
|
|||
super.sanityChecks(equations, t0, y0, t, y);
|
||||
|
||||
if ((vecAbsoluteTolerance != null) && (vecAbsoluteTolerance.length != y0.length)) {
|
||||
throw new IntegratorException("dimensions mismatch: state vector has dimension {0}," +
|
||||
" absolute tolerance vector has dimension {1}",
|
||||
new Object[] {
|
||||
Integer.valueOf(y0.length),
|
||||
Integer.valueOf(vecAbsoluteTolerance.length)
|
||||
});
|
||||
throw new IntegratorException(
|
||||
"dimensions mismatch: state vector has dimension {0}," +
|
||||
" absolute tolerance vector has dimension {1}",
|
||||
y0.length, vecAbsoluteTolerance.length);
|
||||
}
|
||||
|
||||
if ((vecRelativeTolerance != null) && (vecRelativeTolerance.length != y0.length)) {
|
||||
throw new IntegratorException("dimensions mismatch: state vector has dimension {0}," +
|
||||
" relative tolerance vector has dimension {1}",
|
||||
new Object[] {
|
||||
Integer.valueOf(y0.length),
|
||||
Integer.valueOf(vecRelativeTolerance.length)
|
||||
});
|
||||
throw new IntegratorException(
|
||||
"dimensions mismatch: state vector has dimension {0}," +
|
||||
" relative tolerance vector has dimension {1}",
|
||||
y0.length, vecRelativeTolerance.length);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -267,12 +263,9 @@ public abstract class AdaptiveStepsizeIntegrator
|
|||
if (acceptSmall) {
|
||||
filteredH = forward ? minStep : -minStep;
|
||||
} else {
|
||||
throw new IntegratorException("minimal step size ({0}) reached," +
|
||||
" integration needs {1}",
|
||||
new Object[] {
|
||||
Double.valueOf(minStep),
|
||||
Double.valueOf(Math.abs(h))
|
||||
});
|
||||
throw new IntegratorException(
|
||||
"minimal step size ({0}) reached, integration needs {1}",
|
||||
minStep, Math.abs(h));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ public class CostException
|
|||
* @param pattern format specifier
|
||||
* @param arguments format arguments
|
||||
*/
|
||||
public CostException(String pattern, Object[] arguments) {
|
||||
public CostException(String pattern, Object ... arguments) {
|
||||
super(pattern, arguments);
|
||||
}
|
||||
|
||||
|
|
|
@ -270,7 +270,7 @@ public abstract class DirectSearchOptimizer {
|
|||
|
||||
} catch (DimensionMismatchException dme) {
|
||||
// this should not happen
|
||||
throw new MathRuntimeException("unexpected exception caught", null, dme);
|
||||
throw new MathRuntimeException(dme, "unexpected exception caught");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -507,11 +507,9 @@ public abstract class DirectSearchOptimizer {
|
|||
|
||||
// return the found point given the lowest cost
|
||||
if (minima[0] == null) {
|
||||
throw new ConvergenceException("none of the {0} start points" +
|
||||
" lead to convergence",
|
||||
new Object[] {
|
||||
Integer.toString(starts)
|
||||
});
|
||||
throw new ConvergenceException(
|
||||
"none of the {0} start points lead to convergence",
|
||||
starts);
|
||||
}
|
||||
return minima[0];
|
||||
|
||||
|
|
|
@ -140,7 +140,7 @@ public class EmpiricalDistributionImpl implements Serializable, EmpiricalDistrib
|
|||
}
|
||||
if (sampleStats.getN() == 0) {
|
||||
throw MathRuntimeException.createEOFException("URL {0} contains no data",
|
||||
new Object[] { url });
|
||||
url);
|
||||
}
|
||||
in = new BufferedReader(new InputStreamReader(url.openStream()));
|
||||
fillBinStats(in);
|
||||
|
@ -413,8 +413,7 @@ public class EmpiricalDistributionImpl implements Serializable, EmpiricalDistrib
|
|||
public double getNextValue() throws IllegalStateException {
|
||||
|
||||
if (!loaded) {
|
||||
throw MathRuntimeException.createIllegalStateException("distribution not loaded",
|
||||
null);
|
||||
throw MathRuntimeException.createIllegalStateException("distribution not loaded");
|
||||
}
|
||||
|
||||
// Start with a uniformly distributed random number in (0,1)
|
||||
|
@ -434,7 +433,7 @@ public class EmpiricalDistributionImpl implements Serializable, EmpiricalDistrib
|
|||
}
|
||||
}
|
||||
}
|
||||
throw new MathRuntimeException("no bin selected", null);
|
||||
throw new MathRuntimeException("no bin selected");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -32,10 +32,11 @@ public class RandomAdaptor extends Random implements RandomGenerator {
|
|||
|
||||
/** Wrapped randomGenerator instance */
|
||||
private RandomGenerator randomGenerator = null;
|
||||
|
||||
|
||||
/**
|
||||
* Prevent instantiation without a generator argument
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
private RandomAdaptor() { }
|
||||
|
||||
/**
|
||||
|
|
|
@ -106,18 +106,13 @@ public class ValueServer {
|
|||
case EXPONENTIAL_MODE: return getNextExponential();
|
||||
case GAUSSIAN_MODE: return getNextGaussian();
|
||||
case CONSTANT_MODE: return mu;
|
||||
default: throw MathRuntimeException.createIllegalStateException("unknown mode {0}, known modes: " +
|
||||
"{1} ({2}), {3} ({4}), {5} ({6}), " +
|
||||
"{7} ({8}), {9} ({10}) and {11} ({12})",
|
||||
new Object[] {
|
||||
mode,
|
||||
"DIGEST_MODE", DIGEST_MODE,
|
||||
"REPLAY_MODE", REPLAY_MODE,
|
||||
"UNIFORM_MODE", UNIFORM_MODE,
|
||||
"EXPONENTIAL_MODE", EXPONENTIAL_MODE,
|
||||
"GAUSSIAN_MODE", GAUSSIAN_MODE,
|
||||
"CONSTANT_MODE", CONSTANT_MODE
|
||||
});
|
||||
default: throw MathRuntimeException.createIllegalStateException(
|
||||
"unknown mode {0}, known modes: " +
|
||||
"{1} ({2}), {3} ({4}), {5} ({6}), {7} ({8}), {9} ({10}) and {11} ({12})",
|
||||
mode,
|
||||
"DIGEST_MODE", DIGEST_MODE, "REPLAY_MODE", REPLAY_MODE,
|
||||
"UNIFORM_MODE", UNIFORM_MODE, "EXPONENTIAL_MODE", EXPONENTIAL_MODE,
|
||||
"GAUSSIAN_MODE", GAUSSIAN_MODE, "CONSTANT_MODE", CONSTANT_MODE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -306,7 +301,7 @@ public class ValueServer {
|
|||
private double getNextDigest() {
|
||||
if ((empiricalDistribution == null) ||
|
||||
(empiricalDistribution.getBinStats().size() == 0)) {
|
||||
throw MathRuntimeException.createIllegalStateException("digest not initialized", null);
|
||||
throw MathRuntimeException.createIllegalStateException("digest not initialized");
|
||||
}
|
||||
return empiricalDistribution.getNextValue();
|
||||
}
|
||||
|
@ -340,7 +335,7 @@ public class ValueServer {
|
|||
resetReplayFile();
|
||||
if ((str = filePointer.readLine()) == null) {
|
||||
throw MathRuntimeException.createEOFException("URL {0} contains no data",
|
||||
new Object[] { valuesFileURL });
|
||||
valuesFileURL);
|
||||
}
|
||||
}
|
||||
return Double.valueOf(str).doubleValue();
|
||||
|
|
|
@ -199,9 +199,9 @@ public class Covariance {
|
|||
}
|
||||
else {
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"Arrays must have the same length and both must have at " +
|
||||
"arrays must have the same length and both must have at " +
|
||||
"least two elements. xArray has size {0}, yArray has {1} elements",
|
||||
new Object[] {xArray.length, yArray.length});
|
||||
xArray.length, yArray.length);
|
||||
}
|
||||
return biasCorrected ? result * ((double) length / (double)(length - 1)) : result;
|
||||
}
|
||||
|
@ -216,8 +216,8 @@ public class Covariance {
|
|||
int nCols = matrix.getColumnDimension();
|
||||
if (nRows < 2 || nCols < 2) {
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"Insufficient data: only {0} rows and {1} columns.",
|
||||
new Object[]{nRows, nCols});
|
||||
"insufficient data: only {0} rows and {1} columns.",
|
||||
nRows, nCols);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -91,8 +91,7 @@ public class PearsonsCorrelation {
|
|||
public PearsonsCorrelation(Covariance covariance) {
|
||||
RealMatrix covarianceMatrix = covariance.getCovarianceMatrix();
|
||||
if (covarianceMatrix == null) {
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"Covariance matrix is null", null);
|
||||
throw MathRuntimeException.createIllegalArgumentException("covariance matrix is null");
|
||||
}
|
||||
nObs = covariance.getN();
|
||||
correlationMatrix = covarianceToCorrelation(covarianceMatrix);
|
||||
|
@ -220,8 +219,8 @@ public class PearsonsCorrelation {
|
|||
}
|
||||
else {
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"Invalid array dimensions. xArray has size {0}; yArray has {1} elements",
|
||||
new Object[] {xArray.length, yArray.length});
|
||||
"invalid array dimensions. xArray has size {0}; yArray has {1} elements",
|
||||
xArray.length, yArray.length);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -263,8 +262,8 @@ public class PearsonsCorrelation {
|
|||
int nCols = matrix.getColumnDimension();
|
||||
if (nRows < 2 || nCols < 2) {
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"Insufficient data: only {0} rows and {1} columns.",
|
||||
new Object[]{nRows, nCols});
|
||||
"insufficient data: only {0} rows and {1} columns.",
|
||||
nRows, nCols);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -610,8 +610,9 @@ public class MultivariateSummaryStatistics
|
|||
*/
|
||||
private void checkEmpty() {
|
||||
if (n > 0) {
|
||||
throw MathRuntimeException.createIllegalStateException("{0} values have been added before statistic is configured",
|
||||
new Object[] { n });
|
||||
throw MathRuntimeException.createIllegalStateException(
|
||||
"{0} values have been added before statistic is configured",
|
||||
n);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -610,8 +610,9 @@ public class SummaryStatistics implements StatisticalSummary, Serializable {
|
|||
*/
|
||||
private void checkEmpty() {
|
||||
if (n > 0) {
|
||||
throw MathRuntimeException.createIllegalStateException("{0} values have been added before statistic is configured",
|
||||
new Object[] { n });
|
||||
throw MathRuntimeException.createIllegalStateException(
|
||||
"{0} values have been added before statistic is configured",
|
||||
n);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -186,8 +186,9 @@ public class GeometricMean extends AbstractStorelessUnivariateStatistic {
|
|||
*/
|
||||
private void checkEmpty() {
|
||||
if (getN() > 0) {
|
||||
throw MathRuntimeException.createIllegalStateException("{0} values have been added before statistic is configured",
|
||||
new Object[] { getN() });
|
||||
throw MathRuntimeException.createIllegalStateException(
|
||||
"{0} values have been added before statistic is configured",
|
||||
getN());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -91,9 +91,8 @@ public class Kurtosis extends AbstractStorelessUnivariateStatistic {
|
|||
if (incMoment) {
|
||||
moment.increment(d);
|
||||
} else {
|
||||
throw MathRuntimeException.createIllegalStateException("statistics constructed from external " +
|
||||
"moments cannot be incremented",
|
||||
null);
|
||||
throw MathRuntimeException.createIllegalStateException(
|
||||
"statistics constructed from external moments cannot be incremented");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -124,9 +123,8 @@ public class Kurtosis extends AbstractStorelessUnivariateStatistic {
|
|||
if (incMoment) {
|
||||
moment.clear();
|
||||
} else {
|
||||
throw MathRuntimeException.createIllegalStateException("statistics constructed from external " +
|
||||
"moments cannot be cleared",
|
||||
null);
|
||||
throw MathRuntimeException.createIllegalStateException(
|
||||
"statistics constructed from external moments cannot be cleared");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -224,8 +224,9 @@ public class FastCosineTransformer implements RealTransformer {
|
|||
|
||||
int N = f.length - 1;
|
||||
if (!FastFourierTransformer.isPowerOf2(N)) {
|
||||
throw MathRuntimeException.createIllegalArgumentException("{0} is not a power of 2 plus one",
|
||||
new Object[] { f.length });
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"{0} is not a power of 2 plus one",
|
||||
f.length);
|
||||
}
|
||||
if (N == 1) { // trivial case
|
||||
F[0] = 0.5 * (f[0] + f[1]);
|
||||
|
|
|
@ -431,8 +431,9 @@ public class FastFourierTransformer implements Serializable {
|
|||
throws FunctionEvaluationException, IllegalArgumentException {
|
||||
|
||||
if (n <= 0) {
|
||||
throw MathRuntimeException.createIllegalArgumentException("number of sample is not positive: {0}",
|
||||
new Object[] { n });
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"number of sample is not positive: {0}",
|
||||
n);
|
||||
}
|
||||
verifyInterval(min, max);
|
||||
|
||||
|
@ -492,8 +493,9 @@ public class FastFourierTransformer implements Serializable {
|
|||
*/
|
||||
public static void verifyDataSet(double d[]) throws IllegalArgumentException {
|
||||
if (!isPowerOf2(d.length)) {
|
||||
throw MathRuntimeException.createIllegalArgumentException("{0} is not a power of 2, consider padding for fix",
|
||||
new Object[] { d.length });
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"{0} is not a power of 2, consider padding for fix",
|
||||
d.length);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -505,8 +507,9 @@ public class FastFourierTransformer implements Serializable {
|
|||
*/
|
||||
public static void verifyDataSet(Object o[]) throws IllegalArgumentException {
|
||||
if (!isPowerOf2(o.length)) {
|
||||
throw MathRuntimeException.createIllegalArgumentException("{0} is not a power of 2, consider padding for fix",
|
||||
new Object[] { o.length });
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"{0} is not a power of 2, consider padding for fix",
|
||||
o.length);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -521,8 +524,9 @@ public class FastFourierTransformer implements Serializable {
|
|||
throws IllegalArgumentException {
|
||||
|
||||
if (lower >= upper) {
|
||||
throw MathRuntimeException.createIllegalArgumentException("endpoints do not specify an interval: [{0}, {1}]",
|
||||
new Object[] { lower, upper });
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"endpoints do not specify an interval: [{0}, {1}]",
|
||||
lower, upper);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -661,15 +665,14 @@ public class FastFourierTransformer implements Serializable {
|
|||
public Complex get(int... vector)
|
||||
throws IllegalArgumentException {
|
||||
if (vector == null && dimensionSize.length > 1) {
|
||||
throw MathRuntimeException.createIllegalArgumentException("some dimensions don't math: {0} != {1}",
|
||||
new Object[] { 0, dimensionSize.length });
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"some dimensions don't math: {0} != {1}",
|
||||
0, dimensionSize.length);
|
||||
}
|
||||
if (vector != null && vector.length != dimensionSize.length) {
|
||||
throw MathRuntimeException.createIllegalArgumentException("some dimensions don't math: {0} != {1}",
|
||||
new Object[] {
|
||||
vector.length,
|
||||
dimensionSize.length
|
||||
});
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"some dimensions don't math: {0} != {1}",
|
||||
vector.length, dimensionSize.length);
|
||||
}
|
||||
|
||||
Object lastDimension = multiDimensionalComplexArray;
|
||||
|
@ -691,17 +694,16 @@ public class FastFourierTransformer implements Serializable {
|
|||
throws IllegalArgumentException {
|
||||
if (vector == null) {
|
||||
if (dimensionSize.length > 1) {
|
||||
throw MathRuntimeException.createIllegalArgumentException("some dimensions don't math: {0} != {1}",
|
||||
new Object[] { 0, dimensionSize.length });
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"some dimensions don't math: {0} != {1}",
|
||||
0, dimensionSize.length);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
if (vector != null && vector.length != dimensionSize.length) {
|
||||
throw MathRuntimeException.createIllegalArgumentException("some dimensions don't math: {0} != {1}",
|
||||
new Object[] {
|
||||
vector.length,
|
||||
dimensionSize.length
|
||||
});
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"some dimensions don't math: {0} != {1}",
|
||||
vector.length,dimensionSize.length);
|
||||
}
|
||||
|
||||
Object[] lastDimension = (Object[]) multiDimensionalComplexArray;
|
||||
|
@ -817,8 +819,7 @@ public class FastFourierTransformer implements Serializable {
|
|||
|
||||
if (omegaCount == 0) {
|
||||
throw MathRuntimeException.createIllegalStateException(
|
||||
"roots of unity have not been computed yet",
|
||||
null);
|
||||
"roots of unity have not been computed yet");
|
||||
}
|
||||
return isForward;
|
||||
|
||||
|
@ -837,8 +838,7 @@ public class FastFourierTransformer implements Serializable {
|
|||
|
||||
if (n == 0) {
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"cannot compute 0-th root of unity, indefinite result",
|
||||
null);
|
||||
"cannot compute 0-th root of unity, indefinite result");
|
||||
}
|
||||
|
||||
isForward = (n > 0);
|
||||
|
@ -883,13 +883,12 @@ public class FastFourierTransformer implements Serializable {
|
|||
|
||||
if (omegaCount == 0) {
|
||||
throw MathRuntimeException.createIllegalStateException(
|
||||
"roots of unity have not been computed yet",
|
||||
null);
|
||||
"roots of unity have not been computed yet");
|
||||
}
|
||||
if ((k < 0) || (k >= omegaCount)) {
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"out of range root of unity index {0} (must be in [{1};{2}])",
|
||||
new Object[] { k, 0, omegaCount - 1 });
|
||||
k, 0, omegaCount - 1);
|
||||
}
|
||||
|
||||
return omegaReal[k];
|
||||
|
@ -908,13 +907,12 @@ public class FastFourierTransformer implements Serializable {
|
|||
|
||||
if (omegaCount == 0) {
|
||||
throw MathRuntimeException.createIllegalStateException(
|
||||
"roots of unity have not been computed yet",
|
||||
null);
|
||||
"roots of unity have not been computed yet");
|
||||
}
|
||||
if ((k < 0) || (k >= omegaCount)) {
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"out of range root of unity index {0} (must be in [{1};{2}])",
|
||||
new Object[] { k, 0, omegaCount - 1 });
|
||||
k, 0, omegaCount - 1);
|
||||
}
|
||||
|
||||
return (isForward) ?
|
||||
|
|
|
@ -162,8 +162,9 @@ public class FastHadamardTransformer implements RealTransformer {
|
|||
|
||||
// n has to be of the form n = 2^p !!
|
||||
if (!FastFourierTransformer.isPowerOf2(n)) {
|
||||
throw MathRuntimeException.createIllegalArgumentException("{0} is not a power of 2",
|
||||
new Object[] { n });
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"{0} is not a power of 2",
|
||||
n);
|
||||
}
|
||||
|
||||
// Instead of creating a matrix with p+1 columns and n rows
|
||||
|
@ -212,8 +213,9 @@ public class FastHadamardTransformer implements RealTransformer {
|
|||
|
||||
// n has to be of the form n = 2^p !!
|
||||
if (!FastFourierTransformer.isPowerOf2(n)) {
|
||||
throw MathRuntimeException.createIllegalArgumentException("{0} is not a power of 2",
|
||||
new Object[] { n });
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"{0} is not a power of 2",
|
||||
n);
|
||||
}
|
||||
|
||||
// Instead of creating a matrix with p+1 columns and n rows
|
||||
|
|
|
@ -218,8 +218,9 @@ public class FastSineTransformer implements RealTransformer {
|
|||
|
||||
FastFourierTransformer.verifyDataSet(f);
|
||||
if (f[0] != 0.0) {
|
||||
throw MathRuntimeException.createIllegalArgumentException("first element is not 0: {0}",
|
||||
new Object[] { f[0] });
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"first element is not 0: {0}",
|
||||
f[0]);
|
||||
}
|
||||
int N = f.length;
|
||||
if (N == 1) { // trivial case
|
||||
|
|
|
@ -155,7 +155,7 @@ public abstract class ContinuedFraction implements Serializable {
|
|||
// can not scale an convergent is unbounded.
|
||||
throw new ConvergenceException(
|
||||
"Continued fraction convergents diverged to +/- infinity for value {0}",
|
||||
new Object[] { Double.valueOf(x) });
|
||||
x);
|
||||
}
|
||||
}
|
||||
double r = p2 / q2;
|
||||
|
@ -172,7 +172,7 @@ public abstract class ContinuedFraction implements Serializable {
|
|||
if (n >= maxIterations) {
|
||||
throw new MaxIterationsExceededException(maxIterations,
|
||||
"Continued fraction convergents failed to converge for value {0}",
|
||||
new Object[] { Double.valueOf(x) });
|
||||
x);
|
||||
}
|
||||
|
||||
return c;
|
||||
|
|
|
@ -44,7 +44,7 @@ public class DefaultTransformer implements NumberTransformer, Serializable {
|
|||
public double transform(Object o) throws MathException{
|
||||
|
||||
if (o == null) {
|
||||
throw new MathException("Conversion Exception in Transformation, Object is null", null);
|
||||
throw new MathException("Conversion Exception in Transformation, Object is null");
|
||||
}
|
||||
|
||||
if (o instanceof Number) {
|
||||
|
@ -54,8 +54,8 @@ public class DefaultTransformer implements NumberTransformer, Serializable {
|
|||
try {
|
||||
return Double.valueOf(o.toString()).doubleValue();
|
||||
} catch (Exception e) {
|
||||
throw new MathException("Conversion Exception in Transformation: {0}",
|
||||
new Object[] { e.getMessage() }, e);
|
||||
throw new MathException(e,
|
||||
"Conversion Exception in Transformation: {0}", e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ package org.apache.commons.math.util;
|
|||
import java.math.BigDecimal;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.apache.commons.math.MathException;
|
||||
import org.apache.commons.math.MathRuntimeException;
|
||||
|
||||
/**
|
||||
|
@ -543,7 +542,7 @@ public final class MathUtils {
|
|||
if ((u == Integer.MIN_VALUE) || (v == Integer.MIN_VALUE)) {
|
||||
throw MathRuntimeException.createArithmeticException(
|
||||
"overflow: gcd({0}, {1}) is 2^31",
|
||||
new Object[] { p, q });
|
||||
p, q);
|
||||
}
|
||||
return (Math.abs(u) + Math.abs(v));
|
||||
}
|
||||
|
@ -569,7 +568,7 @@ public final class MathUtils {
|
|||
if (k == 31) {
|
||||
throw MathRuntimeException.createArithmeticException(
|
||||
"overflow: gcd({0}, {1}) is 2^31",
|
||||
new Object[] { p, q });
|
||||
p, q);
|
||||
}
|
||||
// B2. Initialize: u and v have been divided by 2^k and at least
|
||||
// one is odd.
|
||||
|
|
|
@ -523,11 +523,10 @@ public class OpenIntToDoubleHashMap implements Serializable {
|
|||
public int key()
|
||||
throws ConcurrentModificationException, NoSuchElementException {
|
||||
if (referenceCount != count) {
|
||||
throw MathRuntimeException.createConcurrentModificationException("map has been modified while iterating",
|
||||
null);
|
||||
throw MathRuntimeException.createConcurrentModificationException("map has been modified while iterating");
|
||||
}
|
||||
if (current < 0) {
|
||||
throw MathRuntimeException.createNoSuchElementException("iterator exhausted", null);
|
||||
throw MathRuntimeException.createNoSuchElementException("iterator exhausted");
|
||||
}
|
||||
return keys[current];
|
||||
}
|
||||
|
@ -541,11 +540,10 @@ public class OpenIntToDoubleHashMap implements Serializable {
|
|||
public double value()
|
||||
throws ConcurrentModificationException, NoSuchElementException {
|
||||
if (referenceCount != count) {
|
||||
throw MathRuntimeException.createConcurrentModificationException("map has been modified while iterating",
|
||||
null);
|
||||
throw MathRuntimeException.createConcurrentModificationException("map has been modified while iterating");
|
||||
}
|
||||
if (current < 0) {
|
||||
throw MathRuntimeException.createNoSuchElementException("iterator exhausted", null);
|
||||
throw MathRuntimeException.createNoSuchElementException("iterator exhausted");
|
||||
}
|
||||
return values[current];
|
||||
}
|
||||
|
@ -559,8 +557,7 @@ public class OpenIntToDoubleHashMap implements Serializable {
|
|||
throws ConcurrentModificationException, NoSuchElementException {
|
||||
|
||||
if (referenceCount != count) {
|
||||
throw MathRuntimeException.createConcurrentModificationException("map has been modified while iterating",
|
||||
null);
|
||||
throw MathRuntimeException.createConcurrentModificationException("map has been modified while iterating");
|
||||
}
|
||||
|
||||
// advance on step
|
||||
|
@ -574,7 +571,7 @@ public class OpenIntToDoubleHashMap implements Serializable {
|
|||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
next = -2;
|
||||
if (current < 0) {
|
||||
throw MathRuntimeException.createNoSuchElementException("iterator exhausted", null);
|
||||
throw MathRuntimeException.createNoSuchElementException("iterator exhausted");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -321,7 +321,7 @@ public class ResizableDoubleArray implements DoubleArray, Serializable {
|
|||
public synchronized double substituteMostRecentElement(double value) {
|
||||
if (numElements < 1) {
|
||||
throw MathRuntimeException.createArrayIndexOutOfBoundsException(
|
||||
"cannot substitute an element from an empty array", null);
|
||||
"cannot substitute an element from an empty array");
|
||||
}
|
||||
|
||||
double discarded = internalArray[startIndex + (numElements - 1)];
|
||||
|
@ -347,29 +347,25 @@ public class ResizableDoubleArray implements DoubleArray, Serializable {
|
|||
float expansionFactor) {
|
||||
|
||||
if (contractionCritera < expansionFactor) {
|
||||
String msg =
|
||||
"Contraction criteria can never be smaller than " +
|
||||
"the expansion factor. This would lead to a never " +
|
||||
"ending loop of expansion and contraction as a newly " +
|
||||
"expanded internal storage array would immediately " +
|
||||
"satisfy the criteria for contraction";
|
||||
throw new IllegalArgumentException(msg);
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"contraction criteria ({0}) smaller than the expansion factor ({1}). This would " +
|
||||
"lead to a never ending loop of expansion and contraction as a newly expanded " +
|
||||
"internal storage array would immediately satisfy the criteria for contraction",
|
||||
contractionCritera, expansionFactor);
|
||||
}
|
||||
|
||||
if (contractionCriteria <= 1.0) {
|
||||
String msg =
|
||||
"The contraction criteria must be a number larger " +
|
||||
"than one. If the contractionCriteria is less than or " +
|
||||
"equal to one an endless loop of contraction and " +
|
||||
"expansion would ensue as an internalArray.length " +
|
||||
"== numElements would satisfy the contraction criteria";
|
||||
throw new IllegalArgumentException(msg);
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"contraction criteria smaller than one ({0}). This would lead to a never ending " +
|
||||
"loop of expansion and contraction as an internal storage array length equal " +
|
||||
"to the number of elements would satisfy the contraction criteria.",
|
||||
contractionCriteria);
|
||||
}
|
||||
|
||||
if (expansionFactor <= 1.0) {
|
||||
String msg =
|
||||
"The expansion factor must be a number greater than 1.0";
|
||||
throw new IllegalArgumentException(msg);
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"expansion factor smaller than one ({0})",
|
||||
contractionCriteria);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -453,12 +449,13 @@ public class ResizableDoubleArray implements DoubleArray, Serializable {
|
|||
*/
|
||||
private synchronized void discardExtremeElements(int i,boolean front) {
|
||||
if (i > numElements) {
|
||||
String msg = "Cannot discard more elements than are" +
|
||||
"contained in this array.";
|
||||
throw new IllegalArgumentException(msg);
|
||||
} else if (i < 0) {
|
||||
String msg = "Cannot discard a negative number of elements.";
|
||||
throw new IllegalArgumentException(msg);
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"cannot discard {0} elements from a {1} elements array",
|
||||
i, numElements);
|
||||
} else if (i < 0) {
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"cannot discard a negative number of elements ({0})",
|
||||
i);
|
||||
} else {
|
||||
// "Subtract" this number of discarded from numElements
|
||||
numElements -= i;
|
||||
|
@ -536,13 +533,15 @@ public class ResizableDoubleArray implements DoubleArray, Serializable {
|
|||
*/
|
||||
public synchronized double getElement(int index) {
|
||||
if (index >= numElements) {
|
||||
throw MathRuntimeException.createArrayIndexOutOfBoundsException("the index specified: {0} is larger than the current maximal index {1}",
|
||||
new Object[] { index, numElements - 1 });
|
||||
throw MathRuntimeException.createArrayIndexOutOfBoundsException(
|
||||
"the index specified: {0} is larger than the current maximal index {1}",
|
||||
index, numElements - 1);
|
||||
} else if (index >= 0) {
|
||||
return internalArray[startIndex + index];
|
||||
} else {
|
||||
throw MathRuntimeException.createArrayIndexOutOfBoundsException("elements cannot be retrieved from a negative array index {0}",
|
||||
new Object[] { index });
|
||||
throw MathRuntimeException.createArrayIndexOutOfBoundsException(
|
||||
"elements cannot be retrieved from a negative array index {0}",
|
||||
index);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -666,8 +665,9 @@ public class ResizableDoubleArray implements DoubleArray, Serializable {
|
|||
*/
|
||||
public synchronized void setElement(int index, double value) {
|
||||
if (index < 0) {
|
||||
throw MathRuntimeException.createArrayIndexOutOfBoundsException("cannot set an element at a negative index {0}",
|
||||
new Object[] { index });
|
||||
throw MathRuntimeException.createArrayIndexOutOfBoundsException(
|
||||
"cannot set an element at a negative index {0}",
|
||||
index);
|
||||
}
|
||||
if (index + 1 > numElements) {
|
||||
numElements = index + 1;
|
||||
|
@ -705,7 +705,10 @@ public class ResizableDoubleArray implements DoubleArray, Serializable {
|
|||
public void setExpansionMode(int expansionMode) {
|
||||
if (expansionMode != MULTIPLICATIVE_MODE &&
|
||||
expansionMode != ADDITIVE_MODE) {
|
||||
throw new IllegalArgumentException("Illegal expansionMode setting.");
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"unsupported expansion mode {0}, supported modes are {1} ({2}) and {3} ({4})",
|
||||
expansionMode, MULTIPLICATIVE_MODE, "MULTIPLICATIVE_MODE",
|
||||
ADDITIVE_MODE, "ADDITIVE_MODE");
|
||||
}
|
||||
this.expansionMode = expansionMode;
|
||||
}
|
||||
|
@ -722,11 +725,10 @@ public class ResizableDoubleArray implements DoubleArray, Serializable {
|
|||
synchronized(this) {
|
||||
this.initialCapacity = initialCapacity;
|
||||
}
|
||||
} else {
|
||||
String msg =
|
||||
"The initial capacity supplied: " + initialCapacity +
|
||||
"must be a positive integer";
|
||||
throw new IllegalArgumentException(msg);
|
||||
} else {
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"initial capacity ({0}) is not positive",
|
||||
initialCapacity);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -742,9 +744,9 @@ public class ResizableDoubleArray implements DoubleArray, Serializable {
|
|||
|
||||
// If index is negative thrown an error
|
||||
if (i < 0) {
|
||||
String msg =
|
||||
"Number of elements must be zero or a positive " + "integer";
|
||||
throw new IllegalArgumentException(msg);
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
"index ({0}) is not positive",
|
||||
i);
|
||||
}
|
||||
|
||||
// Test the new num elements, check to see if the array needs to be
|
||||
|
|
|
@ -60,7 +60,7 @@ public class ConvergenceExceptionTest extends TestCase {
|
|||
Object[] arguments = { Integer.valueOf(6), Integer.valueOf(4) };
|
||||
String inMsg = "inner message";
|
||||
Exception cause = new Exception(inMsg);
|
||||
ConvergenceException ex = new ConvergenceException(pattern, arguments, cause);
|
||||
ConvergenceException ex = new ConvergenceException(cause, pattern, arguments);
|
||||
assertEquals(cause, ex.getCause());
|
||||
assertEquals(pattern, ex.getPattern());
|
||||
assertEquals(arguments.length, ex.getArguments().length);
|
||||
|
|
|
@ -53,7 +53,7 @@ public class FunctionEvaluationExceptionTest extends TestCase {
|
|||
Object[] arguments = { Double.valueOf(0.0) };
|
||||
String inMsg = "inner message";
|
||||
Exception cause = new Exception(inMsg);
|
||||
FunctionEvaluationException ex = new FunctionEvaluationException(0.0, pattern, arguments, cause);
|
||||
FunctionEvaluationException ex = new FunctionEvaluationException(cause, 0.0, pattern, arguments);
|
||||
assertEquals(cause, ex.getCause());
|
||||
assertEquals(pattern, ex.getPattern());
|
||||
assertEquals(arguments.length, ex.getArguments().length);
|
||||
|
@ -67,7 +67,7 @@ public class FunctionEvaluationExceptionTest extends TestCase {
|
|||
public void testConstructorArgumentCause(){
|
||||
String inMsg = "inner message";
|
||||
Exception cause = new Exception(inMsg);
|
||||
FunctionEvaluationException ex = new FunctionEvaluationException(0.0, cause);
|
||||
FunctionEvaluationException ex = new FunctionEvaluationException(cause, 0.0);
|
||||
assertEquals(cause, ex.getCause());
|
||||
assertTrue(ex.getMessage().equals(ex.getMessage(Locale.FRENCH)));
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ public class MathConfigurationExceptionTest extends TestCase {
|
|||
Object[] arguments = { Integer.valueOf(6), Integer.valueOf(4) };
|
||||
String inMsg = "inner message";
|
||||
Exception cause = new Exception(inMsg);
|
||||
MathConfigurationException ex = new MathConfigurationException(pattern, arguments, cause);
|
||||
MathConfigurationException ex = new MathConfigurationException(cause, pattern, arguments);
|
||||
assertEquals(cause, ex.getCause());
|
||||
assertEquals(pattern, ex.getPattern());
|
||||
assertEquals(arguments.length, ex.getArguments().length);
|
||||
|
|
|
@ -62,7 +62,7 @@ public class MathExceptionTest extends TestCase {
|
|||
Object[] arguments = { Integer.valueOf(6), Integer.valueOf(4) };
|
||||
String inMsg = "inner message";
|
||||
Exception cause = new Exception(inMsg);
|
||||
MathException ex = new MathException(pattern, arguments, cause);
|
||||
MathException ex = new MathException(cause, pattern, arguments);
|
||||
assertEquals(cause, ex.getCause());
|
||||
assertEquals(pattern, ex.getPattern());
|
||||
assertEquals(arguments.length, ex.getArguments().length);
|
||||
|
@ -79,8 +79,8 @@ public class MathExceptionTest extends TestCase {
|
|||
public void testPrintStackTrace() {
|
||||
String outMsg = "outer message";
|
||||
String inMsg = "inner message";
|
||||
MathException cause = new MathConfigurationException(inMsg, null);
|
||||
MathException ex = new MathException(outMsg, null, cause);
|
||||
MathException cause = new MathConfigurationException(inMsg);
|
||||
MathException ex = new MathException(cause, outMsg);
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
PrintStream ps = new PrintStream(baos);
|
||||
ex.printStackTrace(ps);
|
||||
|
@ -104,8 +104,8 @@ public class MathExceptionTest extends TestCase {
|
|||
public void testSerialization() {
|
||||
String outMsg = "outer message";
|
||||
String inMsg = "inner message";
|
||||
MathException cause = new MathConfigurationException(inMsg, null);
|
||||
MathException ex = new MathException(outMsg, null, cause);
|
||||
MathException cause = new MathConfigurationException(inMsg);
|
||||
MathException ex = new MathException(cause, outMsg);
|
||||
MathException image = (MathException) TestUtils.serializeAndRecover(ex);
|
||||
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
|
|
|
@ -39,7 +39,7 @@ public class MaxIterationsExceededExceptionTest extends TestCase {
|
|||
MaxIterationsExceededException ex =
|
||||
new MaxIterationsExceededException(1000000,
|
||||
"Continued fraction convergents failed to converge for value {0}",
|
||||
new Object[] { Double.valueOf(1234567) });
|
||||
1234567);
|
||||
assertNull(ex.getCause());
|
||||
assertNotNull(ex.getMessage());
|
||||
assertTrue(ex.getMessage().indexOf("1,000,000") < 0);
|
||||
|
|
|
@ -783,7 +783,7 @@ public final class BigMatrixImplTest extends TestCase {
|
|||
if (!lu.isSquare() || lowerData.length != lowerData[0].length || upperData.length != upperData[0].length ||
|
||||
lowerData.length != upperData.length
|
||||
|| lowerData.length != lu.getRowDimension()) {
|
||||
throw new InvalidMatrixException("incorrect dimensions", null);
|
||||
throw new InvalidMatrixException("incorrect dimensions");
|
||||
}
|
||||
int n = lu.getRowDimension();
|
||||
for (int i = 0; i < n; i++) {
|
||||
|
|
|
@ -24,12 +24,9 @@ import junit.framework.TestCase;
|
|||
*/
|
||||
public class InvalidMatrixExceptionTest extends TestCase {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void testConstructorMessage(){
|
||||
String msg = "message";
|
||||
InvalidMatrixException ex = new InvalidMatrixException(msg, null);
|
||||
InvalidMatrixException ex = new InvalidMatrixException(msg);
|
||||
assertEquals(msg, ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ public class MatrixIndexExceptionTest extends TestCase {
|
|||
*/
|
||||
public void testConstructorMessage(){
|
||||
String msg = "message";
|
||||
MatrixIndexException ex = new MatrixIndexException(msg, null);
|
||||
MatrixIndexException ex = new MatrixIndexException(msg);
|
||||
assertEquals(msg, ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -964,7 +964,7 @@ public final class RealMatrixImplTest extends TestCase {
|
|||
if (!lu.isSquare() || lowerData.length != lowerData[0].length || upperData.length != upperData[0].length ||
|
||||
lowerData.length != upperData.length
|
||||
|| lowerData.length != lu.getRowDimension()) {
|
||||
throw new InvalidMatrixException("incorrect dimensions", null);
|
||||
throw new InvalidMatrixException("incorrect dimensions");
|
||||
}
|
||||
int n = lu.getRowDimension();
|
||||
for (int i = 0; i < n; i++) {
|
||||
|
|
|
@ -26,9 +26,6 @@ import org.apache.commons.math.linear.MatrixUtils;
|
|||
import org.apache.commons.math.linear.RealMatrix;
|
||||
import org.apache.commons.math.linear.RealVectorImpl;
|
||||
import org.apache.commons.math.linear.RealVectorImplTest;
|
||||
import org.apache.commons.math.linear.RealVectorImplTest.RealVectorTestImpl;
|
||||
import org.apache.commons.math.linear.decomposition.CholeskyDecompositionImpl;
|
||||
import org.apache.commons.math.linear.decomposition.DecompositionSolver;
|
||||
|
||||
public class CholeskySolverTest extends TestCase {
|
||||
|
||||
|
|
|
@ -28,9 +28,6 @@ import org.apache.commons.math.linear.MatrixUtils;
|
|||
import org.apache.commons.math.linear.RealMatrix;
|
||||
import org.apache.commons.math.linear.RealVectorImpl;
|
||||
import org.apache.commons.math.linear.RealVectorImplTest;
|
||||
import org.apache.commons.math.linear.RealVectorImplTest.RealVectorTestImpl;
|
||||
import org.apache.commons.math.linear.decomposition.DecompositionSolver;
|
||||
import org.apache.commons.math.linear.decomposition.EigenDecompositionImpl;
|
||||
import org.apache.commons.math.util.MathUtils;
|
||||
|
||||
public class EigenSolverTest extends TestCase {
|
||||
|
|
|
@ -17,18 +17,15 @@
|
|||
|
||||
package org.apache.commons.math.linear.decomposition;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.apache.commons.math.linear.InvalidMatrixException;
|
||||
import org.apache.commons.math.linear.MatrixUtils;
|
||||
import org.apache.commons.math.linear.RealMatrix;
|
||||
import org.apache.commons.math.linear.RealVectorImpl;
|
||||
import org.apache.commons.math.linear.RealVectorImplTest;
|
||||
import org.apache.commons.math.linear.RealVectorImplTest.RealVectorTestImpl;
|
||||
import org.apache.commons.math.linear.decomposition.DecompositionSolver;
|
||||
import org.apache.commons.math.linear.decomposition.LUDecompositionImpl;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
public class LUSolverTest extends TestCase {
|
||||
private double[][] testData = {
|
||||
|
|
|
@ -19,6 +19,10 @@ package org.apache.commons.math.linear.decomposition;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.apache.commons.math.linear.DefaultRealMatrixChangingVisitor;
|
||||
import org.apache.commons.math.linear.DenseRealMatrix;
|
||||
import org.apache.commons.math.linear.InvalidMatrixException;
|
||||
|
@ -28,14 +32,6 @@ import org.apache.commons.math.linear.RealMatrix;
|
|||
import org.apache.commons.math.linear.RealVector;
|
||||
import org.apache.commons.math.linear.RealVectorImpl;
|
||||
import org.apache.commons.math.linear.RealVectorImplTest;
|
||||
import org.apache.commons.math.linear.RealVectorImplTest.RealVectorTestImpl;
|
||||
import org.apache.commons.math.linear.decomposition.DecompositionSolver;
|
||||
import org.apache.commons.math.linear.decomposition.QRDecomposition;
|
||||
import org.apache.commons.math.linear.decomposition.QRDecompositionImpl;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
public class QRSolverTest extends TestCase {
|
||||
double[][] testData3x3NonSingular = {
|
||||
|
|
|
@ -17,18 +17,15 @@
|
|||
|
||||
package org.apache.commons.math.linear.decomposition;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.apache.commons.math.linear.InvalidMatrixException;
|
||||
import org.apache.commons.math.linear.MatrixUtils;
|
||||
import org.apache.commons.math.linear.RealMatrix;
|
||||
import org.apache.commons.math.linear.RealVectorImpl;
|
||||
import org.apache.commons.math.linear.RealVectorImplTest;
|
||||
import org.apache.commons.math.linear.RealVectorImplTest.RealVectorTestImpl;
|
||||
import org.apache.commons.math.linear.decomposition.DecompositionSolver;
|
||||
import org.apache.commons.math.linear.decomposition.SingularValueDecompositionImpl;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
public class SingularValueSolverTest extends TestCase {
|
||||
|
||||
|
|
|
@ -78,7 +78,9 @@ public class FirstOrderConverterTest
|
|||
private static class Equations
|
||||
implements SecondOrderDifferentialEquations {
|
||||
|
||||
private int n;
|
||||
private static final long serialVersionUID = -7926271579508637558L;
|
||||
|
||||
private int n;
|
||||
|
||||
private double omega2;
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue