changed the localization mechanism for error messages. The new system is based on an enum rather than on duplicated string literals.

JIRA: MATH-361

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@955423 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Luc Maisonobe 2010-06-16 23:03:38 +00:00
parent abfacd6d14
commit 92a9c20dc5
169 changed files with 1938 additions and 1787 deletions

View File

@ -16,6 +16,10 @@
*/
package org.apache.commons.math;
import org.apache.commons.math.util.DummyLocalizable;
import org.apache.commons.math.util.Localizable;
import org.apache.commons.math.util.LocalizedFormats;
/**
* Error thrown when a numerical computation can not be performed because the
* numerical result failed to converge to a finite value.
@ -25,13 +29,13 @@ package org.apache.commons.math;
public class ConvergenceException extends MathException {
/** Serializable version identifier */
private static final long serialVersionUID = 4883703247677159141L;
private static final long serialVersionUID = -1111352570797662604L;
/**
* Default constructor.
*/
public ConvergenceException() {
super("Convergence failed");
super(LocalizedFormats.CONVERGENCE_FAILED);
}
/**
@ -40,8 +44,21 @@ public class ConvergenceException extends MathException {
* @param pattern format specifier
* @param arguments format arguments
* @since 1.2
* @deprecated as of 2.2 replaced by {@link #ConvergenceException(Localizable, Object...)}
*/
@Deprecated
public ConvergenceException(String pattern, Object ... arguments) {
this(new DummyLocalizable(pattern), arguments);
}
/**
* Constructs an exception with specified formatted detail message.
* Message formatting is delegated to {@link java.text.MessageFormat}.
* @param pattern format specifier
* @param arguments format arguments
* @since 2.2
*/
public ConvergenceException(Localizable pattern, Object ... arguments) {
super(pattern, arguments);
}
@ -60,8 +77,22 @@ public class ConvergenceException extends MathException {
* @param pattern format specifier
* @param arguments format arguments
* @since 1.2
* @deprecated as of 2.2 replaced by {@link #ConvergenceException(Throwable, Localizable, Object...)}
*/
@Deprecated
public ConvergenceException(Throwable cause, String pattern, Object ... arguments) {
this(cause, new DummyLocalizable(pattern), arguments);
}
/**
* 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
* @since 2.2
*/
public ConvergenceException(Throwable cause, Localizable pattern, Object ... arguments) {
super(cause, pattern, arguments);
}

View File

@ -16,6 +16,8 @@
*/
package org.apache.commons.math;
import org.apache.commons.math.util.LocalizedFormats;
/**
* Error thrown when two dimensions differ.
*
@ -39,7 +41,7 @@ public class DimensionMismatchException extends MathException {
* @param dimension2 second dimension
*/
public DimensionMismatchException(final int dimension1, final int dimension2) {
super("dimension mismatch {0} != {1}", dimension1, dimension2);
super(LocalizedFormats.DIMENSIONS_MISMATCH_SIMPLE, dimension1, dimension2);
this.dimension1 = dimension1;
this.dimension2 = dimension2;
}

View File

@ -16,6 +16,8 @@
*/
package org.apache.commons.math;
import org.apache.commons.math.util.LocalizedFormats;
/**
* Exception thrown when a sample contains several entries at the same abscissa.
*
@ -34,7 +36,7 @@ public class DuplicateSampleAbscissaException extends MathException {
* @param i2 index of another entry having the duplicate abscissa
*/
public DuplicateSampleAbscissaException(double abscissa, int i1, int i2) {
super("Abscissa {0} is duplicated at both indices {1} and {2}",
super(LocalizedFormats.DUPLICATED_ABSCISSA,
abscissa, i1, i2);
}

View File

@ -17,6 +17,9 @@
package org.apache.commons.math;
import org.apache.commons.math.linear.ArrayRealVector;
import org.apache.commons.math.util.DummyLocalizable;
import org.apache.commons.math.util.Localizable;
import org.apache.commons.math.util.LocalizedFormats;
/**
* Exception thrown when an error occurs evaluating a function.
@ -29,11 +32,7 @@ import org.apache.commons.math.linear.ArrayRealVector;
public class FunctionEvaluationException extends MathException {
/** Serializable version identifier. */
private static final long serialVersionUID = -4305020489115478365L;
/** Message for failed evaluation. */
private static final String FAILED_EVALUATION_MESSAGE =
"evaluation failed for argument = {0}";
private static final long serialVersionUID = 1384427981840836868L;
/** Argument causing function evaluation failure */
private double[] argument;
@ -45,7 +44,7 @@ public class FunctionEvaluationException extends MathException {
* @param argument the failing function argument
*/
public FunctionEvaluationException(double argument) {
super(FAILED_EVALUATION_MESSAGE, argument);
super(LocalizedFormats.EVALUATION_FAILED, argument);
this.argument = new double[] { argument };
}
@ -57,7 +56,7 @@ public class FunctionEvaluationException extends MathException {
* @since 2.0
*/
public FunctionEvaluationException(double[] argument) {
super(FAILED_EVALUATION_MESSAGE, new ArrayRealVector(argument));
super(LocalizedFormats.EVALUATION_FAILED, new ArrayRealVector(argument));
this.argument = argument.clone();
}
@ -71,6 +70,19 @@ public class FunctionEvaluationException extends MathException {
*/
public FunctionEvaluationException(double argument,
String pattern, Object ... arguments) {
this(argument, new DummyLocalizable(pattern), argument);
}
/**
* Constructs an exception with specified formatted detail message.
* Message formatting is delegated to {@link java.text.MessageFormat}.
* @param argument the failing function argument
* @param pattern format specifier
* @param arguments format arguments
* @since 2.2
*/
public FunctionEvaluationException(double argument,
Localizable pattern, Object ... arguments) {
super(pattern, arguments);
this.argument = new double[] { argument };
}
@ -85,6 +97,19 @@ public class FunctionEvaluationException extends MathException {
*/
public FunctionEvaluationException(double[] argument,
String pattern, Object ... arguments) {
this(argument, new DummyLocalizable(pattern), argument);
}
/**
* Constructs an exception with specified formatted detail message.
* Message formatting is delegated to {@link java.text.MessageFormat}.
* @param argument the failing function argument
* @param pattern format specifier
* @param arguments format arguments
* @since 2.2
*/
public FunctionEvaluationException(double[] argument,
Localizable pattern, Object ... arguments) {
super(pattern, arguments);
this.argument = argument.clone();
}
@ -125,6 +150,21 @@ public class FunctionEvaluationException extends MathException {
public FunctionEvaluationException(Throwable cause,
double argument, String pattern,
Object ... arguments) {
this(cause, argument, new DummyLocalizable(pattern), argument);
}
/**
* 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
* @since 2.2
*/
public FunctionEvaluationException(Throwable cause,
double argument, Localizable pattern,
Object ... arguments) {
super(cause, pattern, arguments);
this.argument = new double[] { argument };
}
@ -141,6 +181,21 @@ public class FunctionEvaluationException extends MathException {
public FunctionEvaluationException(Throwable cause,
double[] argument, String pattern,
Object ... arguments) {
this(cause, argument, new DummyLocalizable(pattern), argument);
}
/**
* 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
* @since 2.2
*/
public FunctionEvaluationException(Throwable cause,
double[] argument, Localizable pattern,
Object ... arguments) {
super(cause, pattern, arguments);
this.argument = argument.clone();
}

View File

@ -18,6 +18,9 @@ package org.apache.commons.math;
import java.io.Serializable;
import org.apache.commons.math.util.DummyLocalizable;
import org.apache.commons.math.util.Localizable;
/**
* Signals a configuration problem with any of the factory methods.
* @version $Revision$ $Date$
@ -42,6 +45,17 @@ public class MathConfigurationException extends MathException implements Seriali
* @since 1.2
*/
public MathConfigurationException(String pattern, Object ... arguments) {
this(new DummyLocalizable(pattern), arguments);
}
/**
* Constructs an exception with specified formatted detail message.
* Message formatting is delegated to {@link java.text.MessageFormat}.
* @param pattern format specifier
* @param arguments format arguments
* @since 2.2
*/
public MathConfigurationException(Localizable pattern, Object ... arguments) {
super(pattern, arguments);
}
@ -62,6 +76,18 @@ public class MathConfigurationException extends MathException implements Seriali
* @since 1.2
*/
public MathConfigurationException(Throwable cause, String pattern, Object ... arguments) {
this(cause, new DummyLocalizable(pattern), arguments);
}
/**
* 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
* @since 2.2
*/
public MathConfigurationException(Throwable cause, Localizable pattern, Object ... arguments) {
super(cause, pattern, arguments);
}

View File

@ -20,8 +20,10 @@ import java.io.PrintStream;
import java.io.PrintWriter;
import java.text.MessageFormat;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import org.apache.commons.math.util.DummyLocalizable;
import org.apache.commons.math.util.Localizable;
import org.apache.commons.math.util.LocalizedFormats;
/**
@ -36,12 +38,12 @@ import java.util.ResourceBundle;
public class MathException extends Exception {
/** Serializable version identifier. */
private static final long serialVersionUID = -9004610152740737812L;
private static final long serialVersionUID = 7428019509644517071L;
/**
* Pattern used to build the message.
*/
private final String pattern;
private final Localizable pattern;
/**
* Arguments used to build the message.
@ -53,8 +55,21 @@ public class MathException extends Exception {
* detail message.
*/
public MathException() {
this.pattern = null;
this.arguments = new Object[0];
this.pattern = LocalizedFormats.SIMPLE_MESSAGE;
this.arguments = new Object[] { "" };
}
/**
* Constructs a new <code>MathException</code> with specified
* formatted detail message.
* Message formatting is delegated to {@link java.text.MessageFormat}.
* @param pattern format specifier
* @param arguments format arguments
* @deprecated as of 2.2 replaced by {@link #MathException(Localizable, Object...)}
*/
@Deprecated
public MathException(String pattern, Object ... arguments) {
this(new DummyLocalizable(pattern), arguments);
}
/**
@ -64,7 +79,7 @@ public class MathException extends Exception {
* @param pattern format specifier
* @param arguments format arguments
*/
public MathException(String pattern, Object ... arguments) {
public MathException(Localizable pattern, Object ... arguments) {
this.pattern = pattern;
this.arguments = (arguments == null) ? new Object[0] : arguments.clone();
}
@ -78,8 +93,24 @@ public class MathException extends Exception {
*/
public MathException(Throwable rootCause) {
super(rootCause);
this.pattern = getMessage();
this.arguments = new Object[0];
this.pattern = LocalizedFormats.SIMPLE_MESSAGE;
this.arguments = new Object[] { (rootCause == null) ? "" : rootCause.getMessage() };
}
/**
* 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 rootCause the exception or error that caused this exception
* to be thrown.
* @param pattern format specifier
* @param arguments format arguments
* @since 1.2
* @deprecated as of 2.2 replaced by {@link #MathException(Throwable, Localizable, Object...)}
*/
@Deprecated
public MathException(Throwable rootCause, String pattern, Object ... arguments) {
this(rootCause, new DummyLocalizable(pattern), arguments);
}
/**
@ -92,44 +123,29 @@ public class MathException extends Exception {
* @param arguments format arguments
* @since 1.2
*/
public MathException(Throwable rootCause, String pattern, Object ... arguments) {
public MathException(Throwable rootCause, Localizable pattern, Object ... arguments) {
super(rootCause);
this.pattern = pattern;
this.arguments = (arguments == null) ? new Object[0] : arguments.clone();
}
/**
* Translate a string to a given locale.
* @param s string to translate
* @param locale locale into which to translate the string
* @return translated string or original string
* for unsupported locales or unknown strings
*/
private static String translate(String s, Locale locale) {
try {
ResourceBundle bundle =
ResourceBundle.getBundle("org.apache.commons.math.MessagesResources", locale);
if (bundle.getLocale().getLanguage().equals(locale.getLanguage())) {
// the value of the resource is the translated string
return bundle.getString(s);
}
} catch (MissingResourceException mre) {
// do nothing here
}
// the locale is not supported or the resource is unknown
// don't translate and fall back to using the string as is
return s;
}
/** Gets the pattern used to build the message of this throwable.
*
* @return the pattern used to build the message of this throwable
* @since 1.2
* @deprecated as of 2.2 replaced by {@link #getLocalizablePattern()}
*/
@Deprecated
public String getPattern() {
return pattern.getSourceString();
}
/** Gets the localizable pattern used to build the message of this throwable.
*
* @return the localizable pattern used to build the message of this throwable
* @since 2.2
*/
public Localizable getLocalizablePattern() {
return pattern;
}
@ -150,7 +166,10 @@ public class MathException extends Exception {
* @since 1.2
*/
public String getMessage(final Locale locale) {
return (pattern == null) ? "" : new MessageFormat(translate(pattern, locale), locale).format(arguments);
if (pattern != null) {
return new MessageFormat(pattern.getLocalizedString(locale), locale).format(arguments);
}
return "";
}
/** {@inheritDoc} */

View File

@ -24,9 +24,11 @@ import java.text.MessageFormat;
import java.text.ParseException;
import java.util.ConcurrentModificationException;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.NoSuchElementException;
import java.util.ResourceBundle;
import org.apache.commons.math.util.DummyLocalizable;
import org.apache.commons.math.util.Localizable;
import org.apache.commons.math.util.LocalizedFormats;
/**
* Base class for commons-math unchecked exceptions.
@ -37,12 +39,12 @@ import java.util.ResourceBundle;
public class MathRuntimeException extends RuntimeException {
/** Serializable version identifier. */
private static final long serialVersionUID = -5128983364075381060L;
private static final long serialVersionUID = 9058794795027570002L;
/**
* Pattern used to build the message.
*/
private final String pattern;
private final Localizable pattern;
/**
* Arguments used to build the message.
@ -55,8 +57,22 @@ public class MathRuntimeException extends RuntimeException {
* Message formatting is delegated to {@link java.text.MessageFormat}.
* @param pattern format specifier
* @param arguments format arguments
* @deprecated as of 2.2 replaced by {@link #MathRuntimeException(Localizable, Object...)}
*/
@Deprecated
public MathRuntimeException(final String pattern, final Object ... arguments) {
this(new DummyLocalizable(pattern), arguments);
}
/**
* Constructs a new <code>MathRuntimeException</code> with specified
* formatted detail message.
* Message formatting is delegated to {@link java.text.MessageFormat}.
* @param pattern format specifier
* @param arguments format arguments
* @since 2.2
*/
public MathRuntimeException(final Localizable pattern, final Object ... arguments) {
this.pattern = pattern;
this.arguments = (arguments == null) ? new Object[0] : arguments.clone();
}
@ -70,8 +86,8 @@ public class MathRuntimeException extends RuntimeException {
*/
public MathRuntimeException(final Throwable rootCause) {
super(rootCause);
this.pattern = getMessage();
this.arguments = new Object[0];
this.pattern = LocalizedFormats.SIMPLE_MESSAGE;
this.arguments = new Object[] { (rootCause == null) ? "" : rootCause.getMessage() };
}
/**
@ -82,38 +98,29 @@ public class MathRuntimeException extends RuntimeException {
* to be thrown.
* @param pattern format specifier
* @param arguments format arguments
* @deprecated as of 2.2 replaced by {@link #MathRuntimeException(Throwable, Localizable, Object...)}
*/
@Deprecated
public MathRuntimeException(final Throwable rootCause,
final String pattern, final Object ... arguments) {
super(rootCause);
this.pattern = pattern;
this.arguments = (arguments == null) ? new Object[0] : arguments.clone();
this(rootCause, new DummyLocalizable(pattern), arguments);
}
/**
* Translate a string to a given locale.
* @param s string to translate
* @param locale locale into which to translate the string
* @return translated string or original string
* for unsupported locales or unknown strings
* 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 rootCause the exception or error that caused this exception
* to be thrown.
* @param pattern format specifier
* @param arguments format arguments
* @since 2.2
*/
private static String translate(final String s, final Locale locale) {
try {
ResourceBundle bundle =
ResourceBundle.getBundle("org.apache.commons.math.MessagesResources", locale);
if (bundle.getLocale().getLanguage().equals(locale.getLanguage())) {
// the value of the resource is the translated string
return bundle.getString(s);
}
} catch (MissingResourceException mre) {
// do nothing here
}
// the locale is not supported or the resource is unknown
// don't translate and fall back to using the string as is
return s;
public MathRuntimeException(final Throwable rootCause,
final Localizable pattern, final Object ... arguments) {
super(rootCause);
this.pattern = pattern;
this.arguments = (arguments == null) ? new Object[0] : arguments.clone();
}
/**
@ -122,17 +129,29 @@ public class MathRuntimeException extends RuntimeException {
* @param pattern format specifier
* @param arguments format arguments
* @return a message string
* @since 2.2
*/
private static String buildMessage(final Locale locale, final String pattern,
private static String buildMessage(final Locale locale, final Localizable pattern,
final Object ... arguments) {
return (pattern == null) ? "" : new MessageFormat(translate(pattern, locale), locale).format(arguments);
return new MessageFormat(pattern.getLocalizedString(locale), locale).format(arguments);
}
/** Gets the pattern used to build the message of this throwable.
*
* @return the pattern used to build the message of this throwable
*/
*
* @return the pattern used to build the message of this throwable
* @deprecated as of 2.2 replaced by {@link #getLocalizablePattern()}
*/
@Deprecated
public String getPattern() {
return pattern.getSourceString();
}
/** Gets the localizable pattern used to build the message of this throwable.
*
* @return the localizable pattern used to build the message of this throwable
* @since 2.2
*/
public Localizable getLocalizablePattern() {
return pattern;
}
@ -151,7 +170,10 @@ public class MathRuntimeException extends RuntimeException {
* @return localized message
*/
public String getMessage(final Locale locale) {
return buildMessage(locale, pattern, arguments);
if (pattern != null) {
return buildMessage(locale, pattern, arguments);
}
return "";
}
/** {@inheritDoc} */
@ -198,10 +220,23 @@ public class MathRuntimeException extends RuntimeException {
*/
public static ArithmeticException createArithmeticException(final String pattern,
final Object ... arguments) {
return createArithmeticException(new DummyLocalizable(pattern), arguments);
}
/**
* Constructs a new <code>ArithmeticException</code> with specified formatted detail message.
* Message formatting is delegated to {@link java.text.MessageFormat}.
* @param pattern format specifier
* @param arguments format arguments
* @return built exception
* @since 2.2
*/
public static ArithmeticException createArithmeticException(final Localizable pattern,
final Object ... arguments) {
return new ArithmeticException() {
/** Serializable version identifier. */
private static final long serialVersionUID = 7705628723242533939L;
private static final long serialVersionUID = 5305498554076846637L;
/** {@inheritDoc} */
@Override
@ -227,10 +262,23 @@ public class MathRuntimeException extends RuntimeException {
*/
public static ArrayIndexOutOfBoundsException createArrayIndexOutOfBoundsException(final String pattern,
final Object ... arguments) {
return createArrayIndexOutOfBoundsException(new DummyLocalizable(pattern), arguments);
}
/**
* Constructs a new <code>ArrayIndexOutOfBoundsException</code> with specified formatted detail message.
* Message formatting is delegated to {@link java.text.MessageFormat}.
* @param pattern format specifier
* @param arguments format arguments
* @return built exception
* @since 2.2
*/
public static ArrayIndexOutOfBoundsException createArrayIndexOutOfBoundsException(final Localizable pattern,
final Object ... arguments) {
return new ArrayIndexOutOfBoundsException() {
/** Serializable version identifier. */
private static final long serialVersionUID = -3394748305449283486L;
private static final long serialVersionUID = 6718518191249632175L;
/** {@inheritDoc} */
@Override
@ -256,10 +304,22 @@ public class MathRuntimeException extends RuntimeException {
*/
public static EOFException createEOFException(final String pattern,
final Object ... arguments) {
return createEOFException(new DummyLocalizable(pattern), arguments);
}
/**
* Constructs a new <code>EOFException</code> with specified formatted detail message.
* Message formatting is delegated to {@link java.text.MessageFormat}.
* @param pattern format specifier
* @param arguments format arguments
* @return built exception
*/
public static EOFException createEOFException(final Localizable pattern,
final Object ... arguments) {
return new EOFException() {
/** Serializable version identifier. */
private static final long serialVersionUID = 279461544586092584L;
private static final long serialVersionUID = 6067985859347601503L;
/** {@inheritDoc} */
@Override
@ -302,10 +362,23 @@ public class MathRuntimeException extends RuntimeException {
*/
public static IllegalArgumentException createIllegalArgumentException(final String pattern,
final Object ... arguments) {
return createIllegalArgumentException(new DummyLocalizable(pattern), arguments);
}
/**
* Constructs a new <code>IllegalArgumentException</code> with specified formatted detail message.
* Message formatting is delegated to {@link java.text.MessageFormat}.
* @param pattern format specifier
* @param arguments format arguments
* @return built exception
* @since 2.2
*/
public static IllegalArgumentException createIllegalArgumentException(final Localizable pattern,
final Object ... arguments) {
return new IllegalArgumentException() {
/** Serializable version identifier. */
private static final long serialVersionUID = -6555453980658317913L;
private static final long serialVersionUID = -4284649691002411505L;
/** {@inheritDoc} */
@Override
@ -344,10 +417,23 @@ public class MathRuntimeException extends RuntimeException {
*/
public static IllegalStateException createIllegalStateException(final String pattern,
final Object ... arguments) {
return createIllegalStateException(new DummyLocalizable(pattern), arguments);
}
/**
* Constructs a new <code>IllegalStateException</code> with specified formatted detail message.
* Message formatting is delegated to {@link java.text.MessageFormat}.
* @param pattern format specifier
* @param arguments format arguments
* @return built exception
* @since 2.2
*/
public static IllegalStateException createIllegalStateException(final Localizable pattern,
final Object ... arguments) {
return new IllegalStateException() {
/** Serializable version identifier. */
private static final long serialVersionUID = -95247648156277208L;
private static final long serialVersionUID = 6880901520234515725L;
/** {@inheritDoc} */
@Override
@ -373,10 +459,23 @@ public class MathRuntimeException extends RuntimeException {
*/
public static ConcurrentModificationException createConcurrentModificationException(final String pattern,
final Object ... arguments) {
return createConcurrentModificationException(new DummyLocalizable(pattern), arguments);
}
/**
* Constructs a new <code>ConcurrentModificationException</code> with specified formatted detail message.
* Message formatting is delegated to {@link java.text.MessageFormat}.
* @param pattern format specifier
* @param arguments format arguments
* @return built exception
* @since 2.2
*/
public static ConcurrentModificationException createConcurrentModificationException(final Localizable pattern,
final Object ... arguments) {
return new ConcurrentModificationException() {
/** Serializable version identifier. */
private static final long serialVersionUID = 6134247282754009421L;
private static final long serialVersionUID = -1878427236170442052L;
/** {@inheritDoc} */
@Override
@ -402,10 +501,23 @@ public class MathRuntimeException extends RuntimeException {
*/
public static NoSuchElementException createNoSuchElementException(final String pattern,
final Object ... arguments) {
return createNoSuchElementException(new DummyLocalizable(pattern), arguments);
}
/**
* Constructs a new <code>NoSuchElementException</code> with specified formatted detail message.
* Message formatting is delegated to {@link java.text.MessageFormat}.
* @param pattern format specifier
* @param arguments format arguments
* @return built exception
* @since 2.2
*/
public static NoSuchElementException createNoSuchElementException(final Localizable pattern,
final Object ... arguments) {
return new NoSuchElementException() {
/** Serializable version identifier. */
private static final long serialVersionUID = 7304273322489425799L;
private static final long serialVersionUID = 1632410088350355086L;
/** {@inheritDoc} */
@Override
@ -431,10 +543,23 @@ public class MathRuntimeException extends RuntimeException {
*/
public static NullPointerException createNullPointerException(final String pattern,
final Object ... arguments) {
return createNullPointerException(new DummyLocalizable(pattern), arguments);
}
/**
* Constructs a new <code>NullPointerException</code> with specified formatted detail message.
* Message formatting is delegated to {@link java.text.MessageFormat}.
* @param pattern format specifier
* @param arguments format arguments
* @return built exception
* @since 2.2
*/
public static NullPointerException createNullPointerException(final Localizable pattern,
final Object ... arguments) {
return new NullPointerException() {
/** Serializable version identifier. */
private static final long serialVersionUID = -3075660477939965216L;
private static final long serialVersionUID = 451965530686593945L;
/** {@inheritDoc} */
@Override
@ -463,10 +588,26 @@ public class MathRuntimeException extends RuntimeException {
public static ParseException createParseException(final int offset,
final String pattern,
final Object ... arguments) {
return createParseException(offset, new DummyLocalizable(pattern), arguments);
}
/**
* 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
* @return built exception
* @since 2.2
*/
public static ParseException createParseException(final int offset,
final Localizable pattern,
final Object ... arguments) {
return new ParseException(null, offset) {
/** Serializable version identifier. */
private static final long serialVersionUID = -1103502177342465975L;
private static final long serialVersionUID = 8153587599409010120L;
/** {@inheritDoc} */
@Override
@ -489,7 +630,6 @@ public class MathRuntimeException extends RuntimeException {
*/
public static RuntimeException createInternalError(final Throwable cause) {
final String pattern = "internal error, please fill a bug report at {0}";
final String argument = "https://issues.apache.org/jira/browse/MATH";
return new RuntimeException() {
@ -500,13 +640,13 @@ public class MathRuntimeException extends RuntimeException {
/** {@inheritDoc} */
@Override
public String getMessage() {
return buildMessage(Locale.US, pattern, argument);
return buildMessage(Locale.US, LocalizedFormats.INTERNAL_ERROR, argument);
}
/** {@inheritDoc} */
@Override
public String getLocalizedMessage() {
return buildMessage(Locale.getDefault(), pattern, argument);
return buildMessage(Locale.getDefault(), LocalizedFormats.INTERNAL_ERROR, argument);
}
};

View File

@ -18,6 +18,9 @@
package org.apache.commons.math;
import org.apache.commons.math.ConvergenceException;
import org.apache.commons.math.util.DummyLocalizable;
import org.apache.commons.math.util.Localizable;
import org.apache.commons.math.util.LocalizedFormats;
/**
* Error thrown when a numerical computation exceeds its allowed
@ -35,12 +38,11 @@ public class MaxEvaluationsExceededException extends ConvergenceException {
private final int maxEvaluations;
/**
* Constructs an exception with specified formatted detail message.
* Message formatting is delegated to {@link java.text.MessageFormat}.
* Constructs an exception with a default detail message.
* @param maxEvaluations maximal number of evaluations allowed
*/
public MaxEvaluationsExceededException(final int maxEvaluations) {
super("Maximal number of evaluations ({0}) exceeded", maxEvaluations);
super(LocalizedFormats.MAX_EVALUATIONS_EXCEEDED, maxEvaluations);
this.maxEvaluations = maxEvaluations;
}
@ -50,9 +52,24 @@ public class MaxEvaluationsExceededException extends ConvergenceException {
* @param maxEvaluations the exceeded maximal number of evaluations
* @param pattern format specifier
* @param arguments format arguments
* @deprecated as of 2.2 replaced by {@link #MaxEvaluationsExceededException(int, Localizable, Object...)}
*/
@Deprecated
public MaxEvaluationsExceededException(final int maxEvaluations,
final String pattern, final Object ... arguments) {
this(maxEvaluations, new DummyLocalizable(pattern), arguments);
}
/**
* Constructs an exception with specified formatted detail message.
* Message formatting is delegated to {@link java.text.MessageFormat}.
* @param maxEvaluations the exceeded maximal number of evaluations
* @param pattern format specifier
* @param arguments format arguments
* @since 2.2
*/
public MaxEvaluationsExceededException(final int maxEvaluations,
final Localizable pattern, final Object ... arguments) {
super(pattern, arguments);
this.maxEvaluations = maxEvaluations;
}

View File

@ -18,6 +18,9 @@
package org.apache.commons.math;
import org.apache.commons.math.ConvergenceException;
import org.apache.commons.math.util.DummyLocalizable;
import org.apache.commons.math.util.Localizable;
import org.apache.commons.math.util.LocalizedFormats;
/**
* Error thrown when a numerical computation exceeds its allowed
@ -35,12 +38,11 @@ public class MaxIterationsExceededException extends ConvergenceException {
private final int maxIterations;
/**
* Constructs an exception with specified formatted detail message.
* Message formatting is delegated to {@link java.text.MessageFormat}.
* Constructs an exception with a default detail message.
* @param maxIterations maximal number of iterations allowed
*/
public MaxIterationsExceededException(final int maxIterations) {
super("Maximal number of iterations ({0}) exceeded", maxIterations);
super(LocalizedFormats.MAX_ITERATIONS_EXCEEDED, maxIterations);
this.maxIterations = maxIterations;
}
@ -50,9 +52,24 @@ public class MaxIterationsExceededException extends ConvergenceException {
* @param maxIterations the exceeded maximal number of iterations
* @param pattern format specifier
* @param arguments format arguments
* @deprecated as of 2.2 replaced by {@link #MaxIterationsExceededException(int, Localizable, Object...)}
*/
@Deprecated
public MaxIterationsExceededException(final int maxIterations,
final String pattern, final Object ... arguments) {
this(maxIterations, new DummyLocalizable(pattern), arguments);
}
/**
* Constructs an exception with specified formatted detail message.
* Message formatting is delegated to {@link java.text.MessageFormat}.
* @param maxIterations the exceeded maximal number of iterations
* @param pattern format specifier
* @param arguments format arguments
* @since 2.2
*/
public MaxIterationsExceededException(final int maxIterations,
final Localizable pattern, final Object ... arguments) {
super(pattern, arguments);
this.maxIterations = maxIterations;
}

View File

@ -1,880 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.math;
import java.util.ListResourceBundle;
/**
* French localization message resources for the commons-math library.
* @version $Revision$ $Date$
* @since 1.2
*/
public class MessagesResources_fr
extends ListResourceBundle {
/** Non-translated/translated messages arrays. */
private static final Object[][] CONTENTS = {
// org.apache.commons.math.util.MathUtils
{ "must have n >= k for binomial coefficient (n,k), got n = {0}, k = {1}",
"n doit \u00eatre sup\u00e9rieur ou \u00e9gal \u00e0 k " +
"pour le coefficient du bin\u00f4me (n,k), or n = {0}, k = {1}" },
{ "must have n >= 0 for binomial coefficient (n,k), got n = {0}",
"n doit \u00eatre positif pour le coefficient du bin\u00f4me (n,k), or n = {0}" },
{ "must have n >= 0 for n!, got n = {0}",
"n doit \u00eatre positif pour le calcul de n!, or n = {0}" },
{ "overflow: gcd({0}, {1}) is 2^31",
"d\u00e9passement de capacit\u00e9 : le PGCD de {0} et {1} vaut 2^31" },
{ "overflow: gcd({0}, {1}) is 2^63",
"d\u00e9passement de capacit\u00e9 : le PGCD de {0} et {1} vaut 2^63" },
{ "overflow: lcm({0}, {1}) is 2^31",
"d\u00e9passement de capacit\u00e9 : le MCM de {0} et {1} vaut 2^31" },
{ "overflow: lcm({0}, {1}) is 2^63",
"d\u00e9passement de capacit\u00e9 : le MCM de {0} et {1} vaut 2^63" },
{ "cannot raise an integral value to a negative power ({0}^{1})",
"impossible d''\u00e9lever une valeur enti\u00e8re " +
"\u00e0 une puissance n\u00e9gative ({0}^{1})" },
{ "invalid rounding method {0}, valid methods: {1} ({2}), {3} ({4}), {5} ({6}), {7} ({8}), {9} ({10}), {11} ({12}), {13} ({14}), {15} ({16})",
"m\u00e9thode d''arondi {0} invalide, m\u00e9thodes valides : {1} ({2}), {3} ({4}), {5} ({6}), {7} ({8}), {9} ({10}), {11} ({12}), {13} ({14}), {15} ({16})" },
{ "Cannot normalize to an infinite value",
"impossible de normaliser vers une valeur infinie" },
{ "Cannot normalize to NaN",
"impossible de normaliser vers NaN" },
{ "Array contains an infinite element, {0} at index {1}",
"le tableau contient l''\u00e9l\u00e9ment infini {0} \u00e0 l''index {1}" },
// org.apache.commons.math.FunctionEvaluationException
{ "evaluation failed for argument = {0}",
"erreur d''\u00e9valuation pour l''argument {0}" },
// org.apache.commons.math.DuplicateSampleAbscissaException
{ "Abscissa {0} is duplicated at both indices {1} and {2}",
"Abscisse {0} dupliqu\u00e9e aux indices {1} et {2}" },
// org.apache.commons.math.ConvergenceException
{ "Convergence failed",
"\u00c9chec de convergence" },
// org.apache.commons.math.ArgumentOutsideDomainException
{ "Argument {0} outside domain [{1} ; {2}]",
"Argument {0} hors du domaine [{1} ; {2}]" },
// org.apache.commons.math.MaxIterationsExceededException
{ "Maximal number of iterations ({0}) exceeded",
"Nombre maximal d''it\u00e9rations ({0}) d\u00e9pass\u00e9" },
// org.apache.commons.math.MaxEvaluationsExceededException
{ "Maximal number of evaluations ({0}) exceeded",
"Nombre maximal d''\u00e9valuations ({0}) d\u00e9pass\u00e9" },
// org.apache.commons.math.analysis.interpolation.SplineInterpolator
// org.apache.commons.math.analysis.polynomials.PolynomialFunctionLagrangeForm
// org.apache.commons.math.DimensionMismatchException
// org.apache.commons.math.optimization.LeastSquaresConverter
// org.apache.commons.math.optimization.direct.DirectSearchOptimizer
// org.apache.commons.math.optimization.general.AbstractLeastSquaresOptimizer
// org.apache.commons.math.ode.ContinuousOutputModel
// org.apache.commons.math.random.UncorrelatedRandomVectorGenerator
// org.apache.commons.math.stat.regression.AbstractMultipleLinearRegression
// org.apache.commons.math.stat.inference.ChiSquareTestImpl
// org.apache.commons.math.analysis.interpolation.MicrosphereInterpolatingFunction
{ "dimension mismatch {0} != {1}",
"dimensions incompatibles {0} != {1}" },
// org.apache.commons.math.analysis.interpolation.MicrosphereInterpolatingFunction
{ "no data",
"aucune donn\u00e9e" },
// org.apache.commons.math.analysis.interpolation.MicrosphereInterpolator
{ "brightness exponent should be positive or null, but got {0}",
"l''exposant de brillance devrait \u00eatre positif ou null, or e = {0}" },
{ "number of microsphere elements must be positive, but got {0}",
"le nombre d''\u00e9l\u00e9ments de la microsph\u00e8re devrait \u00eatre positif, or n = {0}" },
// org.apache.commons.math.linear.decomposition.NotPositiveDefiniteMatrixException
{ "not positive definite matrix",
"matrice non d\u00e9finie positive" },
// org.apache.commons.math.linear.decomposition.NotSymmetricMatrixException
{ "not symmetric matrix",
"matrice non symm\u00e9trique" },
// org.apache.commons.math.fraction.FractionConversionException
{ "Unable to convert {0} to fraction after {1} iterations",
"Impossible de convertir {0} en fraction apr\u00e8s {1} it\u00e9rations" },
{ "Overflow trying to convert {0} to fraction ({1}/{2})",
"D\u00e9passement de capacit\u00e9 lors de la conversion de {0} en fraction ({1}/{2})" },
// org.apache.commons.math.fraction.BigFraction
{ "numerator is null",
"le num\u00e9rateur est null" },
{ "denimonator is null",
"le d\u00e9nominateur est null" },
{ "denominator must be different from 0",
"le d\u00e9nominateur doit \u00eatre diff\u00e9rent de 0" },
{ "cannot convert NaN value",
"les valeurs NaN ne peuvent \u00eatre converties" },
{ "cannot convert infinite value",
"les valeurs infinies ne peuvent \u00eatre converties" },
// org.apache.commons.math.fraction.AbstractFormat
{ "denominator format can not be null",
"le format du d\u00e9nominateur ne doit pas \u00eatre nul" },
{ "numerator format can not be null",
"le format du num\u00e9rateur ne doit pas \u00eatre nul" },
// org.apache.commons.math.fraction.FractionFormat
{ "cannot convert given object to a fraction number: {0}",
"impossible de convertir l''objet sous forme d''un nombre rationnel : {0}" },
// org.apache.commons.math.fraction.FractionFormat
// org.apache.commons.math.fraction.BigFractionFormat
{ "unparseable fraction number: \"{0}\"",
"\u00e9chec d''analyse du nombre rationnel \"{0}\"" },
{ "cannot format given object as a fraction number",
"impossible de formater l''objet sous forme d''un nombre rationnel" },
// org.apache.commons.math.fraction.ProperFractionFormat
// org.apache.commons.math.fraction.ProperBigFractionFormat
{ "whole format can not be null",
"le format complet ne doit pas \u00eatre nul" },
// org.apache.commons.math.analysis.solvers.UnivariateRealSolverUtils
{ "function is null",
"la fonction est nulle" },
{ "bad value for maximum iterations number: {0}",
"valeur invalide pour le nombre maximal d''it\u00e9rations : {0}" },
{ "invalid bracketing parameters: lower bound={0}, initial={1}, upper bound={2}",
"param\u00e8tres d''encadrement invalides : borne inf\u00e9rieure = {0}, valeur initiale = {1}, borne sup\u00e9rieure = {2}" },
{ "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}",
"nombre d''it\u00e9rations = {0}, it\u00e9rations maximum = {1}, valeur initiale = {2}," +
" borne inf\u00e9rieure = {3}, borne sup\u00e9rieure = {4}," +
" valeur a finale = {5}, valeur b finale = {6}, f(a) = {7}, f(b) = {8}" },
// org.apache.commons.math.analysis.solvers.LaguerreSolver
{ "polynomial degree must be positive: degree={0}",
"le polyn\u00f4me doit \u00eatre de degr\u00e9 positif : degr\u00e9 = {0}" },
// org.apache.commons.math.analysis.solvers.SecantSolver
{ "function values at endpoints do not have different signs, endpoints: [{0}, {1}], values: [{2}, {3}]",
"les valeurs de la fonctions aux bornes sont de m\u00eame signe, bornes : [{0}, {1}], valeurs : [{2}, {3}]" },
// org.apache.commons.math.analysis.interpolation.SplineInterpolator
// org.apache.commons.math.analysis.polynomials.PolynomialFunctionLagrangeForm
{ "{0} points are required, got only {1}",
"{0} sont n\u00e9cessaires, seuls {1} ont \u00e9t\u00e9 fournis" },
// org.apache.commons.math.analysis.interpolation.SplineInterpolator
{ "points {0} and {1} are not strictly increasing ({2} >= {3})",
"les points {0} et {1} ne sont pas strictement croissants ({2} >= {3})" },
{ "points {0} and {1} are not strictly decreasing ({2} <= {3})",
"les points {0} et {1} ne sont pas strictement d\u00e9croissants ({2} <= {3})" },
{ "points {0} and {1} are not increasing ({2} > {3})",
"les points {0} et {1} ne sont pas croissants ({2} > {3})" },
{ "points {0} and {1} are not decreasing ({2} < {3})",
"les points {0} et {1} ne sont pas d\u00e9croissants ({2} < {3})" },
// org.apache.commons.math.analysis.interpolation.LoessInterpolator
{ "bandwidth must be in the interval [0,1], but got {0}",
"la largeur de bande doit \u00eatre dans l''intervalle [0, 1], alors qu'elle vaut {0}" },
{ "the number of robustness iterations must be non-negative, but got {0}",
"le nombre d''it\u00e9rations robuste ne peut \u00eatre n\u00e9gatif, alors qu''il est de {0}" },
{ "Loess expects the abscissa and ordinate arrays to be of the same size, " +
"but got {0} abscissae and {1} ordinatae",
"la r\u00e9gression Loess n\u00e9cessite autant d''abscisses que d''ordonn\u00e9es, " +
"mais {0} abscisses et {1} ordonn\u00e9es ont \u00e9t\u00e9 fournies" },
{ "Loess expects at least 1 point",
"la r\u00e9gression Loess n\u00e9cessite au moins un point" },
{ "the bandwidth must be large enough to accomodate at least 2 points. There are {0} " +
" data points, and bandwidth must be at least {1} but it is only {2}",
"la largeur de bande doit \u00eatre assez grande pour supporter au moins 2 points. Il y a {0}" +
"donn\u00e9es et la largeur de bande doit \u00eatre au moins de {1}, or elle est seulement de {2}" },
{ "all abscissae must be finite real numbers, but {0}-th is {1}",
"toutes les abscisses doivent \u00eatre des nombres r\u00e9els finis, mais l''abscisse {0} vaut {1}" },
{ "all ordinatae must be finite real numbers, but {0}-th is {1}",
"toutes les ordonn\u00e9es doivent \u00eatre des nombres r\u00e9els finis, mais l''ordonn\u00e9e {0} vaut {1}" },
{ "all weights must be finite real numbers, but {0}-th is {1}",
"tous les poids doivent \u00eatre des nombres r\u00e9els finis, mais le poids {0} vaut {1}" },
{ "the abscissae array must be sorted in a strictly increasing order, " +
"but the {0}-th element is {1} whereas {2}-th is {3}",
"les abscisses doivent \u00eatre en ordre strictement croissant, " +
"mais l''\u00e9l\u00e9ment {0} vaut {1} alors que l''\u00e9l\u00e9ment {2} vaut {3}" },
// org.apache.commons.math.util.ContinuedFraction
{ "Continued fraction convergents diverged to +/- infinity for value {0}",
"Divergence de fraction continue \u00e0 l''infini pour la valeur {0}" },
{ "Continued fraction convergents failed to converge for value {0}",
"\u00c9chec de convergence de fraction continue pour la valeur {0}" },
{ "Continued fraction diverged to NaN for value {0}",
"Divergence de fraction continue \u00e0 NaN pour la valeur {0}"},
// org.apache.commons.math.util.DefaultTransformer
{ "Conversion Exception in Transformation, Object is null",
"Exception de conversion dans une transformation, l''objet est nul" },
{ "Conversion Exception in Transformation: {0}",
"Exception de conversion dans une transformation : {0}" },
// org.apache.commons.math.optimization.MultiStartOptimizer
{ "no optimum computed yet",
"aucun optimum n''a encore \u00e9t\u00e9 calcul\u00e9" },
// org.apache.commons.math.optimization.direct.DirectSearchOptimizer
{ "simplex must contain at least one point",
"le simplex doit contenir au moins un point" },
{ "equal vertices {0} and {1} in simplex configuration",
"sommets {0} et {1} \u00e9gaux dans la configuration du simplex" },
// org.apache.commons.math.estimation.AbstractEstimation
{ "maximal number of evaluations exceeded ({0})",
"nombre maximal d''\u00e9valuations d\u00e9pass\u00e9 ({0})" },
// org.apache.commons.math.optimization.general.AbstractLeastSquaresOptimizer
{ "unable to compute covariances: singular problem",
"impossible de calculer les covariances : probl\u00e8me singulier"},
{ "no degrees of freedom ({0} measurements, {1} parameters)",
"aucun degr\u00e9 de libert\u00e9 ({0} mesures, {1} param\u00e8tres)" },
// org.apache.commons.math.optimization.general.GaussNewtonOptimizer
{ "unable to solve: singular problem",
"r\u00e9solution impossible : probl\u00e8me singulier" },
// org.apache.commons.math.optimization.general.LevenbergMarquardtEstimator
{ "cost relative tolerance is too small ({0}), no further reduction in the sum of squares is possible",
"trop petite tol\u00e9rance relative sur le co\u00fbt ({0}), aucune r\u00e9duction de la somme des carr\u00e9s n''est possible" },
{ "parameters relative tolerance is too small ({0}), no further improvement in the approximate solution is possible",
"trop petite tol\u00e9rance relative sur les param\u00e8tres ({0}), aucune am\u00e9lioration de la solution approximative n''est possible" },
{ "orthogonality tolerance is too small ({0}), solution is orthogonal to the jacobian",
"trop petite tol\u00e9rance sur l''orthogonalit\u00e9 ({0}), la solution est orthogonale \u00e0 la jacobienne" },
{ "unable to perform Q.R decomposition on the {0}x{1} jacobian matrix",
"impossible de calculer la factorisation Q.R de la matrice jacobienne {0}x{1}" },
// org.apache.commons.math.optimization.general.NonLinearConjugateGradientOptimizer
{ "unable to bracket optimum in line search",
"impossible d''encadrer l''optimum lors de la recherche lin\u00e9aire" },
// org.apache.commons.math.optimization.fitting.HarmonicCoefficientsGuesser
{ "unable to first guess the harmonic coefficients",
"impossible de faire une premi\u00e8re estimation des coefficients harmoniques" },
// org.apache.commons.math.optimization.fitting.HarmonicCoefficientsGuesser
{ "sample contains {0} observed points, at least {1} are required",
"l''\u00e9chantillon ne contient que {0} points alors qu''au moins {1} sont n\u00e9cessaires" },
// org.apache.commons.math.optimization.linear.NoFeasibleSolutionException
{ "no feasible solution",
"aucune solution r\u00e9alisable" },
// org.apache.commons.math.optimization.linear.UnboundedSolutionException
{ "unbounded solution",
"solution non born\u00e9e" },
// org.apache.commons.math.geometry.CardanEulerSingularityException
{ "Cardan angles singularity",
"singularit\u00e9 d''angles de Cardan" },
{ "Euler angles singularity",
"singularit\u00e9 d''angles d''Euler" },
// org.apache.commons.math.geometry.Rotation
{ "a {0}x{1} matrix cannot be a rotation matrix",
"une matrice {0}x{1} ne peut pas \u00eatre une matrice de rotation" },
{ "the closest orthogonal matrix has a negative determinant {0}",
"la matrice orthogonale la plus proche a un d\u00e9terminant n\u00e9gatif {0}" },
{ "unable to orthogonalize matrix in {0} iterations",
"impossible de rendre la matrice orthogonale en {0} it\u00e9rations" },
// org.apache.commons.math.ode.nonstiff.AdaptiveStepsizeIntegrator
{ "minimal step size ({0,number,0.00E00}) reached, integration needs {1,number,0.00E00}",
"pas minimal ({0,number,0.00E00}) atteint, l''int\u00e9gration n\u00e9cessite {1,number,0.00E00}" },
{ "dimensions mismatch: state vector has dimension {0}, absolute tolerance vector has dimension {1}",
"incompatibilit\u00e9 de dimensions entre le vecteur d''\u00e9tat ({0}), et le vecteur de tol\u00e9rance absolue ({1})" },
{ "dimensions mismatch: state vector has dimension {0}, relative tolerance vector has dimension {1}",
"incompatibilit\u00e9 de dimensions entre le vecteur d''\u00e9tat ({0}), et le vecteur de tol\u00e9rance relative ({1})" },
// org.apache.commons.math.ode.nonstiff.AdaptiveStepsizeIntegrator,
// org.apache.commons.math.ode.nonstiff.RungeKuttaIntegrator
{ "dimensions mismatch: ODE problem has dimension {0}, initial state vector has dimension {1}",
"incompatibilit\u00e9 de dimensions entre le probl\u00e8me ODE ({0}), et le vecteur d''\u00e9tat initial ({1})" },
{ "dimensions mismatch: ODE problem has dimension {0}, final state vector has dimension {1}",
"incompatibilit\u00e9 de dimensions entre le probl\u00e8me ODE ({0}), et le vecteur d''\u00e9tat final ({1})" },
{ "too small integration interval: length = {0}",
"intervalle d''int\u00e9gration trop petit : {0}" },
// org.apache.commons.math.ode.MultistepIntegrator
{ "{0} method needs at least one previous point",
"la m\u00e9thode {0} n\u00e9cessite au moins un point pr\u00e9c\u00e9dent" },
// org.apache.commons.math.ode.ContinuousOutputModel
// org.apache.commons.math.optimization.direct.DirectSearchOptimizer
{ "unexpected exception caught",
"exception inattendue lev\u00e9e" },
{ "propagation direction mismatch",
"directions de propagation incoh\u00e9rentes" },
{ "{0} wide hole between models time ranges",
"trou de longueur {0} entre les domaines temporels des mod\u00e8les" },
// org.apache.commons.math.optimization.direct.DirectSearchOptimizer
{ "none of the {0} start points lead to convergence",
"aucun des {0} points de d\u00e9part n''aboutit \u00e0 une convergence" },
// org.apache.commons.math.random.ValueServer
{ "unknown mode {0}, known modes: {1} ({2}), {3} ({4}), {5} ({6}), {7} ({8}), {9} ({10}) and {11} ({12})",
"mode {0} inconnu, modes connus : {1} ({2}), {3} ({4}), {5} ({6}), {7} ({8}), {9} ({10}) et {11} ({12})" },
{ "digest not initialized",
"mod\u00e8le empirique non initialis\u00e9" },
// org.apache.commons.math.random.EmpiricalDistributionImpl
{ "distribution not loaded",
"aucune distribution n''a \u00e9t\u00e9 charg\u00e9e" },
{ "no bin selected",
"aucun compartiment s\u00e9lectionn\u00e9" },
{ "input data comes from unsupported datasource: {0}, supported sources: {1}, {2}",
"les donn\u00e9es d''entr\u00e9e proviennent " +
"d''une source non support\u00e9e : {0}, sources support\u00e9es : {1}, {2}" },
// org.apache.commons.math.random.EmpiricalDistributionImpl
// org.apache.commons.math.random.ValueServer
{ "URL {0} contains no data",
"l''adresse {0} ne contient aucune donn\u00e9e" },
// org.apache.commons.math.random.AbstractRandomGenerator
// org.apache.commons.math.random.BitsStreamGenerator
{ "upper bound must be positive ({0})",
"la borne sup\u00e9rieure doit \u00eatre positive ({0})" },
// org.apache.commons.math.random.RandomDataImpl
{ "length must be positive ({0})",
"la longueur doit \u00eatre positive ({0})" },
{ "upper bound ({0}) must be greater than lower bound ({1})",
"la borne sup\u00e9rieure ({0}) doit \u00eatre sup\u00e9rieure" +
" \u00e0 la borne inf\u00e9rieure ({1})" },
{ "permutation k ({0}) exceeds n ({1})",
"la permutation k ({0}) d\u00e9passe n ({1})" },
{ "permutation k ({0}) must be positive",
"la permutation k ({0}) doit \u00eatre positive" },
{ "sample size ({0}) exceeds collection size ({1})",
"la taille de l''\u00e9chantillon ({0}) d\u00e9passe la taille de la collection ({1})" },
// org.apache.commons.math.linear.decomposition.EigenDecompositionImpl
{ "cannot solve degree {0} equation",
"impossible de r\u00e9soudre une \u00e9quation de degr\u00e9 {0}" },
{ "eigen decomposition of assymetric matrices not supported yet",
"la d\u00e9composition en valeurs/vecteurs propres de matrices " +
"non sym\u00e9triques n''est pas encore disponible" },
// org.apache.commons.math.linear.decomposition.NonSquareMatrixException
// org.apache.commons.math.stat.regression.AbstractMultipleLinearRegression
{ "a {0}x{1} matrix was provided instead of a square matrix",
"une matrice {0}x{1} a \u00e9t\u00e9 fournie \u00e0 la place d''une matrice carr\u00e9e" },
// org.apache.commons.math.linear.decomposition.SingularMatrixException
{ "matrix is singular",
"matrice singuli\u00e8re" },
// org.apache.commons.math.linear.decomposition.SingularValueDecompositionImpl
{ "cutoff singular value is {0}, should be at most {1}",
"la valeur singuli\u00e8re de coupure vaut {0}, elle ne devrait pas d\u00e9passer {1}" },
// org.apache.commons.math.linear.decomposition.CholeskyDecompositionImpl
// org.apache.commons.math.linear.decomposition.EigenDecompositionImpl
// org.apache.commons.math.linear.decomposition.LUDecompositionImpl
// org.apache.commons.math.linear.decomposition.QRDecompositionImpl
// org.apache.commons.math.linear.decomposition.SingularValueDecompositionImpl
{ "dimensions mismatch: got {0}x{1} but expected {2}x{3}",
"dimensions incoh\u00e9rentes : {0}x{1} \u00e0 la place de {2}x{3}" },
// org.apache.commons.math.linear.decomposition.CholeskyDecompositionImpl
// org.apache.commons.math.linear.decomposition.EigenDecompositionImpl
// org.apache.commons.math.linear.decomposition.LUDecompositionImpl
// org.apache.commons.math.linear.decomposition.QRDecompositionImpl
// org.apache.commons.math.linear.decomposition.SingularValueDecompositionImpl
// org.apache.commons.math.linear.ArrayRealVector
// org.apache.commons.math.linear.SparseRealVector
{ "vector length mismatch: got {0} but expected {1}",
"taille de vecteur invalide : {0} au lieu de {1} attendue" },
// org.apache.commons.math.linear.ArrayRealVector
// org.apache.commons.math.linear.ArrayFieldVector
// org.apache.commons.math.linear.SparseRealVector
{ "index {0} out of allowed range [{1}, {2}]",
"index {0} hors de la plage autoris\u00e9e [{1}, {2}]" },
{ "vector must have at least one element",
"un vecteur doit comporter au moins un \u00e9l\u00e9ment" },
{ "position {0} and size {1} don't fit to the size of the input array {2}",
"la position {0} et la taille {1} sont incompatibles avec la taille du tableau d''entr\u00e9e {2}"},
// org.apache.commons.math.linear.AbstractRealMatrix
// org.apache.commons.math.linear.AbstractFieldMatrix
{ "invalid row dimension: {0} (must be positive)",
"nombre de lignes invalide : {0} (doit \u00eatre positif)" },
{ "invalid column dimension: {0} (must be positive)",
"nombre de colonnes invalide : {0} (doit \u00eatre positif)" },
{ "matrix must have at least one row",
"une matrice doit comporter au moins une ligne" },
{ "matrix must have at least one column",
"une matrice doit comporter au moins une colonne" },
// org.apache.commons.math.linear.AbstractRealMatrix
// org.apache.commons.math.linear.AbstractFieldMatrix
// org.apache.commons.math.stat.inference.ChiSquareTestImpl
{ "some rows have length {0} while others have length {1}",
"certaines lignes ont une longueur de {0} alors que d''autres ont une longueur de {1}" },
// org.apache.commons.math.linear.MatrixUtils
{ "row index {0} out of allowed range [{1}, {2}]",
"index de ligne {0} hors de la plage autoris\u00e9e [{1}, {2}]" },
{ "column index {0} out of allowed range [{1}, {2}]",
"index de colonne {0} hors de la plage autoris\u00e9e [{1}, {2}]" },
{ "initial row {0} after final row {1}",
"ligne initiale {0} apr\u00e8s la ligne finale {1}" },
{ "initial column {0} after final column {1}",
"colonne initiale {0} apr\u00e8s la colonne finale {1}" },
{ "empty selected row index array",
"tableau des indices de lignes s\u00e9lectionn\u00e9es vide" },
{ "empty selected column index array",
"tableau des indices de colonnes s\u00e9lectionn\u00e9es vide" },
{ "{0}x{1} and {2}x{3} matrices are not addition compatible",
"les dimensions {0}x{1} et {2}x{3} sont incompatibles pour l'addition matricielle" },
{ "{0}x{1} and {2}x{3} matrices are not subtraction compatible",
"les dimensions {0}x{1} et {2}x{3} sont incompatibles pour la soustraction matricielle" },
{ "{0}x{1} and {2}x{3} matrices are not multiplication compatible",
"les dimensions {0}x{1} et {2}x{3} sont incompatibles pour la multiplication matricielle" },
// org.apache.commons.math.linear.BlockRealMatrix
{ "wrong array shape (block length = {0}, expected {1})",
"forme de tableau erron\u00e9e (bloc de longueur {0} au lieu des {1} attendus)" },
// org.apache.commons.math.complex.Complex
{ "cannot compute nth root for null or negative n: {0}",
"impossible de calculer la racine ni\u00e8me pour n n\u00e9gatif ou nul : {0}" },
// org.apache.commons.math.complex.ComplexFormat
{ "unparseable complex number: \"{0}\"",
"\u00e9chec d''analyse du nombre complexe \"{0}\"" },
{ "cannot format a {0} instance as a complex number",
"impossible de formater une instance de {0} comme un nombre complexe" },
{ "empty string for imaginary character",
"cha\u00eene vide pour le caract\u00e8 imaginaire" },
{ "null imaginary format",
"format imaginaire nul" },
{ "null real format",
"format r\u00e9el nul" },
// org.apache.commons.math.complex.ComplexUtils
{ "negative complex module {0}",
"module n\u00e9gatif ({0}) pour un nombre complexe" },
// org.apache.commons.math.geometry.Vector3DFormat
{ "unparseable 3D vector: \"{0}\"",
"\u00e9chec d''analyse du vecteur de dimension 3 \"{0}\"" },
{ "cannot format a {0} instance as a 3D vector",
"impossible de formater une instance de {0} comme un vecteur de dimension 3" },
// org.apache.commons.math.linear.RealVectorFormat
{ "unparseable real vector: \"{0}\"",
"\u00e9chec d''analyse du vecteur r\u00e9el \"{0}\"" },
{ "cannot format a {0} instance as a real vector",
"impossible de formater une instance de {0} comme un vecteur r\u00e9el" },
// org.apache.commons.math.util.ResizableDoubleArray
{ "the index specified: {0} is larger than the current maximal index {1}",
"l''index sp\u00e9cifi\u00e9 ({0}) d\u00e9passe l''index maximal courant ({1})" },
{ "elements cannot be retrieved from a negative array index {0}",
"impossible d''extraire un \u00e9l\u00e9ment \u00e0 un index n\u00e9gatif ({0})" },
{ "cannot set an element at a negative index {0}",
"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.PolynomialFunction
// org.apache.commons.math.analysis.polynomials.PolynomialFunctionNewtonForm
{ "empty polynomials coefficients array",
"tableau de coefficients polyn\u00f4miaux vide" },
// org.apache.commons.math.analysis.polynomials.PolynomialFunctionNewtonForm
{ "array sizes should have difference 1 ({0} != {1} + 1)",
"les tableaux devraient avoir une diff\u00e9rence de taille de 1 ({0} != {1} + 1)" },
// org.apache.commons.math.analysis.polynomials.PolynomialFunctionLagrangeForm
{ "identical abscissas x[{0}] == x[{1}] == {2} cause division by zero",
"division par z\u00e9ro caus\u00e9e par les abscisses identiques x[{0}] == x[{1}] == {2}" },
// org.apache.commons.math.analysis.polynomials.PolynomialSplineFunction
{ "spline partition must have at least {0} points, got {1}",
"une partiction spline n\u00e9cessite au moins {0} points, seuls {1} ont \u00e9t\u00e9 fournis" },
{ "knot values must be strictly increasing",
"les n\u0153uds d''interpolation doivent \u00eatre strictement croissants" },
{ "number of polynomial interpolants must match the number of segments ({0} != {1} - 1)",
"le nombre d''interpolants polyn\u00f4miaux doit correspondre au nombre de segments ({0} != {1} - 1)" },
// org.apache.commons.math.analysis.solvers.UnivariateRealSolverImpl
{ "function to solve cannot be null",
"la fonction \u00e0 r\u00e9soudre ne peux pas \u00eatre nulle" },
{ "invalid interval, initial value parameters: lower={0}, initial={1}, upper={2}",
"param\u00e8tres de l''intervalle initial invalides : borne inf = {0}, valeur initiale = {1}, borne sup = {2}" },
// org.apache.commons.math.analysis.solvers.UnivariateRealSolverImpl
// org.apache.commons.math.analysis.solvers.BrentSolver
{ "function values at endpoints do not have different signs. Endpoints: [{0}, {1}], Values: [{2}, {3}]",
"les valeurs de la fonction aux bornes n''ont pas des signes diff\u00e9rents. Bornes : [{0}, {1}], valeurs : [{2}, {3}]" },
// org.apache.commons.math.analysis.solvers.UnivariateRealSolverImpl
// org.apache.commons.math.analysis.integration.UnivariateRealIntegratorImpl
// org.apache.commons.math.transform.FastFourierTransformer
{ "endpoints do not specify an interval: [{0}, {1}]",
"les extr\u00e9mit\u00e9s ne constituent pas un intervalle : [{0}, {1}]" },
// org.apache.commons.math.analysis.solvers.LaguerreSolver
{ "function is not polynomial",
"la fonction n''est pas p\u00f4lynomiale" },
// org.apache.commons.math.analysis.solvers.NewtonSolver
{ "function is not differentiable",
"la fonction n''est pas diff\u00e9rentiable" },
// org.apache.commons.math.analysis.integration.UnivariateRealIntegratorImpl
{ "invalid iteration limits: min={0}, max={1}",
"limites d''it\u00e9rations invalides : min = {0}, max = {1}" },
// org.apache.commons.math.analysis.integration.LegendreGaussIntegrator
{ "{0} points Legendre-Gauss integrator not supported," +
" number of points must be in the {1}-{2} range",
"int\u00e9grateur de Legendre-Gauss non support\u00e9 en {0} points, " +
"le nombre de points doit \u00eatre entre {1} et {2}" },
// org.apache.commons.math.fraction.Fraction
{ "zero denominator in fraction {0}/{1}",
"d\u00e9nominateur null dans le nombre rationnel {0}/{1}" },
{ "overflow in fraction {0}/{1}, cannot negate",
"d\u00e9passement de capacit\u00e9 pour la fraction {0}/{1}, son signe ne peut \u00eatre chang\u00e9" },
{ "overflow, numerator too large after multiply: {0}",
"d\u00e9passement de capacit\u00e9 pour le num\u00e9rateur apr\u00e8s multiplication : {0}" },
{ "the fraction to divide by must not be zero: {0}/{1}",
"division par un nombre rationnel nul : {0}/{1}" },
{ "null fraction",
"fraction nulle" },
// org.apache.commons.math.geometry.Rotation
{ "zero norm for rotation axis",
"norme nulle pour un axe de rotation" },
{ "zero norm for rotation defining vector",
"norme nulle pour un axe de d\u00e9finition de rotation" },
// org.apache.commons.math.geometry.Vector3D
// org.apache.commons.math.linear.ArrayRealVector
{ "cannot normalize a zero norm vector",
"impossible de normer un vecteur de norme nulle" },
{ "zero norm",
"norme nulle" },
// org.apache.commons.math.ConvergingAlgorithmImpl
{ "no result available",
"aucun r\u00e9sultat n''est disponible" },
// org.apache.commons.math.linear.BigMatrixImpl
{ "first {0} rows are not initialized yet",
"les {0} premi\u00e8res lignes ne sont pas encore initialis\u00e9es" },
{ "first {0} columns are not initialized yet",
"les {0} premi\u00e8res colonnes ne sont pas encore initialis\u00e9es" },
// org.apache.commons.math.stat.Frequency
{ "class ({0}) does not implement Comparable",
"la classe ({0}) n''implante pas l''interface Comparable" },
{ "instance of class {0} not comparable to existing values",
"l''instance de la classe {0} n''est pas comparable aux valeurs existantes" },
// org.apache.commons.math.stat.StatUtils
{ "input arrays must have the same positive length ({0} and {1})",
"les tableaux d''entr\u00e9e doivent avoir la m\u00eame taille positive ({0} et {1})" },
{ "input arrays must have the same length and at least two elements ({0} and {1})",
"les tableaux d''entr\u00e9e doivent avoir la m\u00eame taille" +
" et au moins deux \u00e9l\u00e9ments ({0} et {1})" },
// 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.DescriptiveStatistics
{ "window size must be positive ({0})",
"la taille de la fen\u00eatre doit \u00eatre positive ({0})" },
{ "percentile implementation {0} does not support {1}",
"l''implantation de pourcentage {0} ne dispose pas de la m\u00e9thode {1}" },
{ "cannot access {0} method in percentile implementation {1}",
"acc\u00e8s impossible \u00e0 la m\u00e9thode {0}" +
" dans l''implantation de pourcentage {1}" },
{ "out of bounds quantile value: {0}, must be in (0, 100]",
"valeur de quantile {0} hors bornes, doit \u00eatre dans l''intervalle ]0, 100]" },
// org.apache.commons.math.stat.descriptive.moment.Variance
// org.apache.commons.math.stat.descriptive.moment.SemiVariance
// org.apache.commons.math.stat.descriptive.AbstractStorelessUnivariateStatistic
// org.apache.commons.math.stat.descriptive.AbstractUnivariateStatistic
{ "input values array is null",
"le tableau des valeurs d''entr\u00e9es est nul" },
// org.apache.commons.math.stat.descriptive.AbstractUnivariateStatistic
{ "start position cannot be negative ({0})",
"la position de d\u00e9part ne peut pas \u00eatre n\u00e9gative" },
{ "length cannot be negative ({0})",
"la longueur ne peut pas \u00eatre n\u00e9gative" },
{ "subarray ends after array end",
"le sous-tableau se termine apr\u00e8s la fin du tableau" },
// org.apache.commons.math.stat.descriptive.moment.GeometricMean
// org.apache.commons.math.stat.descriptive.MultivariateSummaryStatistics
// org.apache.commons.math.stat.descriptive.SummaryStatistics
{ "{0} values have been added before statistic is configured",
"{0} valeurs ont \u00e9t\u00e9 ajout\u00e9es " +
"avant que la statistique ne soit configur\u00e9e" },
// org.apache.commons.math.stat.descriptive.moment.Kurtosis
{ "statistics constructed from external moments cannot be incremented",
"les statistiques bas\u00e9es sur des moments externes ne peuvent pas \u00eatre incr\u00e9ment\u00e9es" },
{ "statistics constructed from external moments cannot be cleared",
"les statistiques bas\u00e9es sur des moments externes ne peuvent pas \u00eatre remises \u00e0 z\u00e9ro" },
// org.apache.commons.math.stat.inference.ChiSquareTestImpl
{ "expected array length = {0}, must be at least 2",
"le tableau des valeurs attendues a une longueur de {0}, elle devrait \u00eatre au moins de 2" },
{ "observed array length = {0}, must be at least 2",
"le tableau des valeurs observ\u00e9es a une longueur de {0}, elle devrait \u00eatre au moins de 2" },
{ "observed counts are all 0 in first observed array",
"aucune occurrence dans le premier tableau des observations" },
{ "observed counts are all 0 in second observed array",
"aucune occurrence dans le second tableau des observations" },
{ "observed counts are both zero for entry {0}",
"les occurrences observ\u00e9es sont toutes deux nulles pour l'entr\u00e9e {0}" },
{ "invalid row dimension: {0} (must be at least 2)",
"nombre de lignes invalide : {0} (doit \u00eatre au moins de 2)" },
{ "invalid column dimension: {0} (must be at least 2)",
"nombre de colonnes invalide : {0} (doit \u00eatre au moins de 2)" },
{ "element {0} is not positive: {1}",
"l''\u00e9l\u00e9ment {0} n''est pas positif : {1}" },
{ "element {0} is negative: {1}",
"l''\u00e9l\u00e9ment {0} est n\u00e9gatif : {1}" },
{ "element ({0}, {1}) is negative: {2}",
"l''\u00e9l\u00e9ment ({0}, {1}) est n\u00e9gatif : {2}" },
// org.apache.commons.math.stat.inference.OneWayAnovaImpl
{ "two or more categories required, got {0}",
"deux cat\u00e9gories ou plus sont n\u00e9cessaires, il y en a {0}" },
{ "two or more values required in each category, one has {0}",
"deux valeurs ou plus sont n\u00e9cessaires pour chaque cat\u00e9gorie, une cat\u00e9gorie en a {0}" },
// org.apache.commons.math.stat.inference.TTestImpl
{ "insufficient data for t statistic, needs at least 2, got {0}",
"deux valeurs ou plus sont n\u00e9cessaires pour la statistique t, il y en a {0}" },
// org.apache.commons.math.stat.inference.ChiSquareTestImpl
// org.apache.commons.math.stat.inference.TTestImpl
// org.apache.commons.math.stat.inference.OneWayAnovaImpl
// org.apache.commons.math.stat.Regression
{ "out of bounds significance level {0}, must be between {1} and {2}",
"niveau de signification {0} hors domaine, doit \u00eatre entre {1} et {2}" },
// org.apache.commons.math.stat.regression.AbstractMultipleLinearRegression
{ "not enough data ({0} rows) for this many predictors ({1} predictors)",
"pas assez de donn\u00e9es ({0} lignes) pour {1} pr\u00e9dicteurs" },
// org.apache.commons.math.distribution.AbstractContinuousDistribution
// org.apache.commons.math.distribution.AbstractIntegerDistribution
// org.apache.commons.math.distribution.ExponentialDistributionImpl
// org.apache.commons.math.distribution.BinomialDistributionImpl
// org.apache.commons.math.distribution.CauchyDistributionImpl
// org.apache.commons.math.distribution.PascalDistributionImpl
// org.apache.commons.math.distribution.WeibullDistributionImpl
{ "{0} out of [{1}, {2}] range",
"{0} hors du domaine [{1}, {2}]" },
// org.apache.commons.math.distribution.AbstractDistribution
// org.apache.commons.math.distribution.AbstractIntegerDistribution
{ "lower endpoint ({0}) must be less than or equal to upper endpoint ({1})",
"la borne inf\u00e9rieure ({0}) devrait \u00eatre inf\u00e9rieure " +
"ou \u00e9gale \u00e0 la borne sup\u00e9rieure ({1})" },
// org.apache.commons.math.distribution.AbstractContinuousDistribution
{ "Cumulative probability function returned NaN for argument {0} p = {1}",
"Fonction de probabilit\u00e9 cumulative retourn\u00e9 NaN \u00e0 l''argument de {0} p = {1}" },
{ "This distribution does not have a density function implemented",
"La fonction de densit\u00e9 pour cette distribution n'a pas \u00e9t\u00e9 mis en oeuvre" },
// org.apache.commons.math.distribution.AbstractIntegerDistribution
{ "Discrete cumulative probability function returned NaN for argument {0}",
"Discr\u00e8tes fonction de probabilit\u00e9 cumulative retourn\u00e9 NaN \u00e0 l''argument de {0}" },
// org.apache.commons.math.distribution.AbstractIntegerDistribution
// org.apache.commons.math.distribution.AbstractContinuousDistribution
{ "Sample size must be positive",
"La taille de l'\u00e9chantillon doit \u00eatre positive" },
// org.apache.commons.math.distribution.BinomialDistributionImpl
{ "number of trials must be non-negative ({0})",
"le nombre d''essais ne doit pas \u00eatre n\u00e9gatif ({0})" },
// org.apache.commons.math.distribution.ExponentialDistributionImpl
// org.apache.commons.math.random.RandomDataImpl
{ "mean must be positive ({0})",
"la moyenne doit \u00eatre positive ({0})" },
// org.apache.commons.math.distribution.FDistributionImpl
// org.apache.commons.math.distribution.TDistributionImpl
{ "degrees of freedom must be positive ({0})",
"les degr\u00e9s de libert\u00e9 doivent \u00eatre positifs ({0})" },
// org.apache.commons.math.distribution.GammaDistributionImpl
{ "alpha must be positive ({0})",
"alpha doit \u00eatre positif ({0})" },
{ "beta must be positive ({0})",
"beta doit \u00eatre positif ({0})" },
// org.apache.commons.math.distribution.HypergeometricDistributionImpl
{ "number of successes ({0}) must be less than or equal to population size ({1})",
"le nombre de succ\u00e8s doit \u00eatre inf\u00e9rieur " +
"ou \u00e9gal \u00e0 la taille de la population ({1})" },
{ "sample size ({0}) must be less than or equal to population size ({1})",
"la taille de l''\u00e9chantillon doit \u00eatre inf\u00e9rieure " +
"ou \u00e9gale \u00e0 la taille de la population ({1})" },
{ "population size must be positive ({0})",
"la taille de la population doit \u00eatre positive ({0})" },
// org.apache.commons.math.distribution.HypergeometricDistributionImpl
// org.apache.commons.math.random.RandomDataImpl
{ "sample size must be positive ({0})",
"la taille de l''\u00e9chantillon doit \u00eatre positive ({0})" },
// org.apache.commons.math.distribution.HypergeometricDistributionImpl
// org.apache.commons.math.distribution.PascalDistributionImpl
{ "number of successes must be non-negative ({0})",
"le nombre de succ\u00e8s ne doit pas \u00eatre n\u00e9gatif ({0})" },
// org.apache.commons.math.distribution.NormalDistributionImpl
// org.apache.commons.math.random.RandomDataImpl
{ "standard deviation must be positive ({0})",
"l''\u00e9cart type doit \u00eatre positif ({0})" },
// org.apache.commons.math.distribution.PoissonDistributionImpl
// org.apache.commons.math.random.RandomDataImpl
{ "the Poisson mean must be positive ({0})",
"la moyenne de Poisson doit \u00eatre positive ({0})" },
// org.apache.commons.math.distribution.WeibullDistributionImpl
{ "shape must be positive ({0})",
"le facteur de forme doit \u00eatre positif ({0})" },
// org.apache.commons.math.distribution.WeibullDistributionImpl
// org.apache.commons.math.distribution.CauchyDistributionImpl
{ "scale must be positive ({0})",
"l''\u00e9chelle doit \u00eatre positive ({0})" },
// org.apache.commons.math.distribution.ZipfDistributionImpl
{ "invalid number of elements {0} (must be positive)",
"nombre d''\u00e9l\u00e9ments {0} invalide (doit \u00eatre positif)" },
{ "invalid exponent {0} (must be positive)",
"exposant {0} invalide (doit \u00eatre positif)" },
// org.apache.commons.math.transform.FastHadamardTransformer
{ "{0} is not a power of 2",
"{0} n''est pas une puissance de 2" },
// org.apache.commons.math.transform.FastFourierTransformer
{ "cannot compute 0-th root of unity, indefinite result",
"impossible de calculer la racine z\u00e9roi\u00e8me de l''unit\u00e9, " +
"r\u00e9sultat ind\u00e9fini" },
{ "roots of unity have not been computed yet",
"les racines de l''unit\u00e9 n''ont pas encore \u00e9t\u00e9 calcul\u00e9es" },
{ "out of range root of unity index {0} (must be in [{1};{2}])",
"index de racine de l''unit\u00e9 hors domaine (devrait \u00eatre dans [{1}; {2}])" },
{ "number of sample is not positive: {0}",
"le nombre d''\u00e9chantillons n''est pas positif : {0}" },
{ "{0} is not a power of 2, consider padding for fix",
"{0} n''est pas une puissance de 2, ajoutez des \u00e9l\u00e9ments pour corriger" },
{ "some dimensions don't match: {0} != {1}",
"certaines dimensions sont incoh\u00e9rentes : {0} != {1}" },
// org.apache.commons.math.transform.FastCosineTransformer
{ "{0} is not a power of 2 plus one",
"{0} n''est pas une puissance de 2 plus un" },
// org.apache.commons.math.transform.FastSineTransformer
{ "first element is not 0: {0}",
"le premier \u00e9l\u00e9ment n''est pas nul : {0}" },
// org.apache.commons.math.util.OpenIntToDoubleHashMap
{ "map has been modified while iterating",
"la table d''adressage a \u00e9t\u00e9 modifi\u00e9e pendant l''it\u00e9ration" },
{ "iterator exhausted",
"it\u00e9ration achev\u00e9e" },
// org.apache.commons.math.MathRuntimeException
{ "internal error, please fill a bug report at {0}",
"erreur interne, veuillez signaler l''erreur \u00e0 {0}" }
};
/**
* Simple constructor.
*/
public MessagesResources_fr() {
}
/**
* Get the non-translated/translated messages arrays from this resource bundle.
* @return non-translated/translated messages arrays
*/
@Override
public Object[][] getContents() {
return CONTENTS.clone();
}
}

View File

@ -20,6 +20,7 @@ import org.apache.commons.math.FunctionEvaluationException;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.MaxIterationsExceededException;
import org.apache.commons.math.analysis.UnivariateRealFunction;
import org.apache.commons.math.util.LocalizedFormats;
/**
* Implements the <a href="http://mathworld.wolfram.com/RombergIntegration.html">
@ -113,7 +114,7 @@ public class RombergIntegrator extends UnivariateRealIntegratorImpl {
// at most 32 bisection refinements due to higher order divider
if (maximalIterationCount > 32) {
throw MathRuntimeException.createIllegalArgumentException(
"invalid iteration limits: min={0}, max={1}",
LocalizedFormats.INVALID_ITERATIONS_LIMITS,
0, 32);
}
}

View File

@ -20,6 +20,7 @@ import org.apache.commons.math.FunctionEvaluationException;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.MaxIterationsExceededException;
import org.apache.commons.math.analysis.UnivariateRealFunction;
import org.apache.commons.math.util.LocalizedFormats;
/**
* Implements the <a href="http://mathworld.wolfram.com/SimpsonsRule.html">
@ -104,7 +105,7 @@ public class SimpsonIntegrator extends UnivariateRealIntegratorImpl {
// at most 64 bisection refinements
if (maximalIterationCount > 64) {
throw MathRuntimeException.createIllegalArgumentException(
"invalid iteration limits: min={0}, max={1}",
LocalizedFormats.INVALID_ITERATIONS_LIMITS,
0, 64);
}
}

View File

@ -20,6 +20,7 @@ import org.apache.commons.math.FunctionEvaluationException;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.MaxIterationsExceededException;
import org.apache.commons.math.analysis.UnivariateRealFunction;
import org.apache.commons.math.util.LocalizedFormats;
/**
* Implements the <a href="http://mathworld.wolfram.com/TrapezoidalRule.html">
@ -135,7 +136,7 @@ public class TrapezoidIntegrator extends UnivariateRealIntegratorImpl {
// at most 64 bisection refinements
if (maximalIterationCount > 64) {
throw MathRuntimeException.createIllegalArgumentException(
"invalid iteration limits: min={0}, max={1}",
LocalizedFormats.INVALID_ITERATIONS_LIMITS,
0, 64);
}
}

View File

@ -19,6 +19,7 @@ package org.apache.commons.math.analysis.integration;
import org.apache.commons.math.ConvergingAlgorithmImpl;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.analysis.UnivariateRealFunction;
import org.apache.commons.math.util.LocalizedFormats;
/**
* Provide a default implementation for several generic functions.
@ -66,7 +67,7 @@ public abstract class UnivariateRealIntegratorImpl
throws IllegalArgumentException {
super(defaultMaximalIterationCount, 1.0e-15);
if (f == null) {
throw MathRuntimeException.createIllegalArgumentException("function is null");
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.NULL_FUNCTION);
}
this.f = f;
@ -108,7 +109,7 @@ public abstract class UnivariateRealIntegratorImpl
if (resultComputed) {
return result;
} else {
throw MathRuntimeException.createIllegalStateException("no result available");
throw MathRuntimeException.createIllegalStateException(LocalizedFormats.NO_RESULT_AVAILABLE);
}
}
@ -171,7 +172,7 @@ public abstract class UnivariateRealIntegratorImpl
protected void verifyIterationCount() throws IllegalArgumentException {
if ((minimalIterationCount <= 0) || (maximalIterationCount <= minimalIterationCount)) {
throw MathRuntimeException.createIllegalArgumentException(
"invalid iteration limits: min={0}, max={1}",
LocalizedFormats.INVALID_ITERATIONS_LIMITS,
minimalIterationCount, maximalIterationCount);
}
}

View File

@ -16,6 +16,7 @@
*/
package org.apache.commons.math.analysis.interpolation;
import org.apache.commons.math.util.LocalizedFormats;
import org.apache.commons.math.util.MathUtils;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.FunctionEvaluationException;
@ -98,7 +99,7 @@ public class BicubicSplineInterpolatingFunction
final int yLen = y.length;
if (xLen == 0 || yLen == 0 || f.length == 0 || f[0].length == 0) {
throw MathRuntimeException.createIllegalArgumentException("no data");
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.NO_DATA);
}
if (xLen != f.length) {
throw new DimensionMismatchException(xLen, f.length);
@ -157,13 +158,15 @@ public class BicubicSplineInterpolatingFunction
public double value(double x, double y) {
final int i = searchIndex(x, xval);
if (i == -1) {
throw MathRuntimeException.createIllegalArgumentException("{0} out of [{1}, {2}] range",
x, xval[0], xval[xval.length - 1]);
throw MathRuntimeException.createIllegalArgumentException(
LocalizedFormats.OUT_OF_RANGE_SIMPLE,
x, xval[0], xval[xval.length - 1]);
}
final int j = searchIndex(y, yval);
if (j == -1) {
throw MathRuntimeException.createIllegalArgumentException("{0} out of [{1}, {2}] range",
y, yval[0], yval[yval.length - 1]);
throw MathRuntimeException.createIllegalArgumentException(
LocalizedFormats.OUT_OF_RANGE_SIMPLE,
y, yval[0], yval[yval.length - 1]);
}
final double xN = (x - xval[i]) / (xval[i + 1] - xval[i]);
@ -230,12 +233,12 @@ public class BicubicSplineInterpolatingFunction
final int i = searchIndex(x, xval);
if (i == -1) {
throw MathRuntimeException.createIllegalArgumentException("{0} out of [{1}, {2}] range",
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.OUT_OF_RANGE_SIMPLE,
x, xval[0], xval[xval.length - 1]);
}
final int j = searchIndex(y, yval);
if (j == -1) {
throw MathRuntimeException.createIllegalArgumentException("{0} out of [{1}, {2}] range",
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.OUT_OF_RANGE_SIMPLE,
y, yval[0], yval[yval.length - 1]);
}
@ -373,11 +376,11 @@ class BicubicSplineFunction
*/
public double value(double x, double y) {
if (x < 0 || x > 1) {
throw MathRuntimeException.createIllegalArgumentException("{0} out of [{1}, {2}] range",
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.OUT_OF_RANGE_SIMPLE,
x, 0, 1);
}
if (y < 0 || y > 1) {
throw MathRuntimeException.createIllegalArgumentException("{0} out of [{1}, {2}] range",
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.OUT_OF_RANGE_SIMPLE,
y, 0, 1);
}

View File

@ -19,6 +19,7 @@ package org.apache.commons.math.analysis.interpolation;
import org.apache.commons.math.DimensionMismatchException;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.MathException;
import org.apache.commons.math.util.LocalizedFormats;
import org.apache.commons.math.util.MathUtils;
import org.apache.commons.math.analysis.UnivariateRealFunction;
import org.apache.commons.math.analysis.polynomials.PolynomialSplineFunction;
@ -39,7 +40,7 @@ public class BicubicSplineInterpolator
final double[][] fval)
throws MathException, IllegalArgumentException {
if (xval.length == 0 || yval.length == 0 || fval.length == 0) {
throw MathRuntimeException.createIllegalArgumentException("no data");
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.NO_DATA);
}
if (xval.length != fval.length) {
throw new DimensionMismatchException(xval.length, fval.length);

View File

@ -21,6 +21,8 @@ import java.util.Arrays;
import org.apache.commons.math.MathException;
import org.apache.commons.math.analysis.polynomials.PolynomialSplineFunction;
import org.apache.commons.math.util.Localizable;
import org.apache.commons.math.util.LocalizedFormats;
/**
* Implements the <a href="http://en.wikipedia.org/wiki/Local_regression">
@ -145,14 +147,12 @@ public class LoessInterpolator
*/
public LoessInterpolator(double bandwidth, int robustnessIters, double accuracy) throws MathException {
if (bandwidth < 0 || bandwidth > 1) {
throw new MathException("bandwidth must be in the interval [0,1], but got {0}",
throw new MathException(LocalizedFormats.BANDWIDTH_OUT_OF_INTERVAL,
bandwidth);
}
this.bandwidth = bandwidth;
if (robustnessIters < 0) {
throw new MathException("the number of robustness iterations must " +
"be non-negative, but got {0}",
robustnessIters);
throw new MathException(LocalizedFormats.NEGATIVE_ROBUSTNESS_ITERATIONS, robustnessIters);
}
this.robustnessIters = robustnessIters;
this.accuracy = accuracy;
@ -198,22 +198,19 @@ public class LoessInterpolator
public final double[] smooth(final double[] xval, final double[] yval, final double[] weights)
throws MathException {
if (xval.length != yval.length) {
throw new MathException(
"Loess expects the abscissa and ordinate arrays " +
"to be of the same size, " +
"but got {0} abscissae and {1} ordinatae",
xval.length, yval.length);
throw new MathException(LocalizedFormats.MISMATCHED_LOESS_ABSCISSA_ORDINATE_ARRAYS,
xval.length, yval.length);
}
final int n = xval.length;
if (n == 0) {
throw new MathException("Loess expects at least 1 point");
throw new MathException(LocalizedFormats.LOESS_EXPECTS_AT_LEAST_ONE_POINT);
}
checkAllFiniteReal(xval, "all abscissae must be finite real numbers, but {0}-th is {1}");
checkAllFiniteReal(yval, "all ordinatae must be finite real numbers, but {0}-th is {1}");
checkAllFiniteReal(weights, "all weights must be finite real numbers, but {0}-th is {1}");
checkAllFiniteReal(xval, LocalizedFormats.NON_REAL_FINITE_ABSCISSA);
checkAllFiniteReal(yval, LocalizedFormats.NON_REAL_FINITE_ORDINATE);
checkAllFiniteReal(weights, LocalizedFormats.NON_REAL_FINITE_WEIGHT);
checkStrictlyIncreasing(xval);
@ -228,12 +225,8 @@ public class LoessInterpolator
int bandwidthInPoints = (int) (bandwidth * n);
if (bandwidthInPoints < 2) {
throw new MathException(
"the bandwidth must be large enough to " +
"accomodate at least 2 points. There are {0} " +
" data points, and bandwidth must be at least {1} " +
" but it is only {2}",
n, 2.0 / n, bandwidth);
throw new MathException(LocalizedFormats.TOO_SMALL_BANDWIDTH,
n, 2.0 / n, bandwidth);
}
final double[] res = new double[n];
@ -365,11 +358,8 @@ public class LoessInterpolator
public final double[] smooth(final double[] xval, final double[] yval)
throws MathException {
if (xval.length != yval.length) {
throw new MathException(
"Loess expects the abscissa and ordinate arrays " +
"to be of the same size, " +
"but got {0} abscissae and {1} ordinatae",
xval.length, yval.length);
throw new MathException(LocalizedFormats.MISMATCHED_LOESS_ABSCISSA_ORDINATE_ARRAYS,
xval.length, yval.length);
}
final double[] unitWeights = new double[xval.length];
@ -442,7 +432,7 @@ public class LoessInterpolator
* @param pattern pattern of the error message
* @throws MathException if one of the values is not a finite real number
*/
private static void checkAllFiniteReal(final double[] values, final String pattern)
private static void checkAllFiniteReal(final double[] values, final Localizable pattern)
throws MathException {
for (int i = 0; i < values.length; i++) {
final double x = values[i];
@ -464,11 +454,8 @@ public class LoessInterpolator
throws MathException {
for (int i = 0; i < xval.length; ++i) {
if (i >= 1 && xval[i - 1] >= xval[i]) {
throw new MathException(
"the abscissae array must be sorted in a strictly " +
"increasing order, but the {0}-th element is {1} " +
"whereas {2}-th is {3}",
i - 1, xval[i - 1], i, xval[i]);
throw new MathException(LocalizedFormats.OUT_OF_ORDER_ABSCISSA_ARRAY,
i - 1, xval[i - 1], i, xval[i]);
}
}
}

View File

@ -27,6 +27,7 @@ import org.apache.commons.math.analysis.MultivariateRealFunction;
import org.apache.commons.math.linear.ArrayRealVector;
import org.apache.commons.math.linear.RealVector;
import org.apache.commons.math.random.UnitSphereRandomVectorGenerator;
import org.apache.commons.math.util.LocalizedFormats;
/**
* Interpolating function that implements the
@ -150,7 +151,7 @@ public class MicrosphereInterpolatingFunction
UnitSphereRandomVectorGenerator rand)
throws DimensionMismatchException, IllegalArgumentException {
if (xval.length == 0 || xval[0] == null) {
throw MathRuntimeException.createIllegalArgumentException("no data");
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.NO_DATA);
}
if (xval.length != yval.length) {

View File

@ -20,6 +20,7 @@ import org.apache.commons.math.MathException;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.analysis.MultivariateRealFunction;
import org.apache.commons.math.random.UnitSphereRandomVectorGenerator;
import org.apache.commons.math.util.LocalizedFormats;
/**
* Interpolator that implements the algorithm described in
@ -100,7 +101,7 @@ public class MicrosphereInterpolator
public void setBrightnessExponent(final int brightnessExponent) {
if (brightnessExponent < 0) {
throw MathRuntimeException.createIllegalArgumentException(
"brightness exponent should be positive or null, but got {0}",
LocalizedFormats.NEGATIVE_BRIGHTNESS_EXPONENT,
brightnessExponent);
}
this.brightnessExponent = brightnessExponent;
@ -114,7 +115,7 @@ public class MicrosphereInterpolator
public void setMicropshereElements(final int elements) {
if (microsphereElements < 0) {
throw MathRuntimeException.createIllegalArgumentException(
"number of microsphere elements must be positive, but got {0}",
LocalizedFormats.NON_POSITIVE_MICROSPHERE_ELEMENTS,
microsphereElements);
}
this.microsphereElements = elements;

View File

@ -19,6 +19,7 @@ package org.apache.commons.math.analysis.interpolation;
import org.apache.commons.math.DimensionMismatchException;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.MathException;
import org.apache.commons.math.util.LocalizedFormats;
import org.apache.commons.math.util.MathUtils;
import org.apache.commons.math.analysis.UnivariateRealFunction;
import org.apache.commons.math.analysis.polynomials.PolynomialSplineFunction;
@ -48,7 +49,7 @@ public class SmoothingBicubicSplineInterpolator
final double[][] zval)
throws MathException, IllegalArgumentException {
if (xval.length == 0 || yval.length == 0 || zval.length == 0) {
throw MathRuntimeException.createIllegalArgumentException("no data");
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.NO_DATA);
}
if (xval.length != zval.length) {
throw new DimensionMismatchException(xval.length, zval.length);

View File

@ -19,6 +19,7 @@ package org.apache.commons.math.analysis.interpolation;
import org.apache.commons.math.DimensionMismatchException;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.MathException;
import org.apache.commons.math.util.LocalizedFormats;
import org.apache.commons.math.util.MathUtils;
import org.apache.commons.math.optimization.general.GaussNewtonOptimizer;
import org.apache.commons.math.optimization.fitting.PolynomialFitter;
@ -71,7 +72,7 @@ public class SmoothingPolynomialBicubicSplineInterpolator
final double[][] fval)
throws MathException, IllegalArgumentException {
if (xval.length == 0 || yval.length == 0 || fval.length == 0) {
throw MathRuntimeException.createIllegalArgumentException("no data");
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.NO_DATA);
}
if (xval.length != fval.length) {
throw new DimensionMismatchException(xval.length, fval.length);

View File

@ -19,6 +19,7 @@ package org.apache.commons.math.analysis.interpolation;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.analysis.polynomials.PolynomialFunction;
import org.apache.commons.math.analysis.polynomials.PolynomialSplineFunction;
import org.apache.commons.math.util.LocalizedFormats;
/**
* Computes a natural (also known as "free", "unclamped") cubic spline interpolation for the data set.
@ -58,12 +59,12 @@ public class SplineInterpolator implements UnivariateRealInterpolator {
public PolynomialSplineFunction interpolate(double x[], double y[]) {
if (x.length != y.length) {
throw MathRuntimeException.createIllegalArgumentException(
"dimension mismatch {0} != {1}", x.length, y.length);
LocalizedFormats.DIMENSIONS_MISMATCH_SIMPLE, x.length, y.length);
}
if (x.length < 3) {
throw MathRuntimeException.createIllegalArgumentException(
"{0} points are required, got only {1}", 3, x.length);
LocalizedFormats.WRONG_NUMBER_OF_POINTS, 3, x.length);
}
// Number of intervals. The number of data points is n + 1.
@ -72,7 +73,7 @@ public class SplineInterpolator implements UnivariateRealInterpolator {
for (int i = 0; i < n; i++) {
if (x[i] >= x[i + 1]) {
throw MathRuntimeException.createIllegalArgumentException(
"points {0} and {1} are not strictly increasing ({2} >= {3})",
LocalizedFormats.NOT_STRICTLY_INCREASING_NUMBER_OF_POINTS,
i, i+1, x[i], x[i+1]);
}
}

View File

@ -16,6 +16,7 @@
*/
package org.apache.commons.math.analysis.interpolation;
import org.apache.commons.math.util.LocalizedFormats;
import org.apache.commons.math.util.MathUtils;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.DimensionMismatchException;
@ -156,7 +157,7 @@ public class TricubicSplineInterpolatingFunction
if (xLen == 0 || yLen == 0 || z.length == 0
|| f.length == 0 || f[0].length == 0) {
throw MathRuntimeException.createIllegalArgumentException("no data");
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.NO_DATA);
}
if (xLen != f.length) {
throw new DimensionMismatchException(xLen, f.length);
@ -307,18 +308,21 @@ public class TricubicSplineInterpolatingFunction
public double value(double x, double y, double z) {
final int i = searchIndex(x, xval);
if (i == -1) {
throw MathRuntimeException.createIllegalArgumentException("{0} out of [{1}, {2}] range",
x, xval[0], xval[xval.length - 1]);
throw MathRuntimeException.createIllegalArgumentException(
LocalizedFormats.OUT_OF_RANGE_SIMPLE,
x, xval[0], xval[xval.length - 1]);
}
final int j = searchIndex(y, yval);
if (j == -1) {
throw MathRuntimeException.createIllegalArgumentException("{0} out of [{1}, {2}] range",
y, yval[0], yval[yval.length - 1]);
throw MathRuntimeException.createIllegalArgumentException(
LocalizedFormats.OUT_OF_RANGE_SIMPLE,
y, yval[0], yval[yval.length - 1]);
}
final int k = searchIndex(z, zval);
if (k == -1) {
throw MathRuntimeException.createIllegalArgumentException("{0} out of [{1}, {2}] range",
z, zval[0], zval[zval.length - 1]);
throw MathRuntimeException.createIllegalArgumentException(
LocalizedFormats.OUT_OF_RANGE_SIMPLE,
z, zval[0], zval[zval.length - 1]);
}
final double xN = (x - xval[i]) / (xval[i + 1] - xval[i]);
@ -449,15 +453,15 @@ class TricubicSplineFunction
*/
public double value(double x, double y, double z) {
if (x < 0 || x > 1) {
throw MathRuntimeException.createIllegalArgumentException("{0} out of [{1}, {2}] range",
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.OUT_OF_RANGE_SIMPLE,
x, 0, 1);
}
if (y < 0 || y > 1) {
throw MathRuntimeException.createIllegalArgumentException("{0} out of [{1}, {2}] range",
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.OUT_OF_RANGE_SIMPLE,
y, 0, 1);
}
if (z < 0 || z > 1) {
throw MathRuntimeException.createIllegalArgumentException("{0} out of [{1}, {2}] range",
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.OUT_OF_RANGE_SIMPLE,
z, 0, 1);
}

View File

@ -19,6 +19,7 @@ package org.apache.commons.math.analysis.interpolation;
import org.apache.commons.math.DimensionMismatchException;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.MathException;
import org.apache.commons.math.util.LocalizedFormats;
import org.apache.commons.math.util.MathUtils;
/**
@ -38,7 +39,7 @@ public class TricubicSplineInterpolator
final double[][][] fval)
throws MathException, IllegalArgumentException {
if (xval.length == 0 || yval.length == 0 || zval.length == 0 || fval.length == 0) {
throw MathRuntimeException.createIllegalArgumentException("no data");
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.NO_DATA);
}
if (xval.length != fval.length) {
throw new DimensionMismatchException(xval.length, fval.length);

View File

@ -22,6 +22,7 @@ import java.util.Arrays;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.analysis.DifferentiableUnivariateRealFunction;
import org.apache.commons.math.analysis.UnivariateRealFunction;
import org.apache.commons.math.util.LocalizedFormats;
/**
* Immutable representation of a real polynomial function with real coefficients.
@ -33,10 +34,6 @@ import org.apache.commons.math.analysis.UnivariateRealFunction;
*/
public class PolynomialFunction implements DifferentiableUnivariateRealFunction, Serializable {
/** Message for empty coefficients array. */
private static final String EMPTY_ARRAY_MESSAGE =
"empty polynomials coefficients array";
/**
* Serialization identifier
*/
@ -66,7 +63,7 @@ public class PolynomialFunction implements DifferentiableUnivariateRealFunction,
public PolynomialFunction(double c[]) {
super();
if (c.length < 1) {
throw MathRuntimeException.createIllegalArgumentException(EMPTY_ARRAY_MESSAGE);
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.EMPTY_POLYNOMIALS_COEFFICIENTS_ARRAY);
}
int l = c.length;
while ((l > 1) && (c[l - 1] == 0)) {
@ -126,7 +123,7 @@ public class PolynomialFunction implements DifferentiableUnivariateRealFunction,
protected static double evaluate(double[] coefficients, double argument) {
int n = coefficients.length;
if (n < 1) {
throw MathRuntimeException.createIllegalArgumentException(EMPTY_ARRAY_MESSAGE);
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.EMPTY_POLYNOMIALS_COEFFICIENTS_ARRAY);
}
double result = coefficients[n - 1];
for (int j = n -2; j >=0; j--) {
@ -235,7 +232,7 @@ public class PolynomialFunction implements DifferentiableUnivariateRealFunction,
protected static double[] differentiate(double[] coefficients) {
int n = coefficients.length;
if (n < 1) {
throw MathRuntimeException.createIllegalArgumentException(EMPTY_ARRAY_MESSAGE);
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.EMPTY_POLYNOMIALS_COEFFICIENTS_ARRAY);
}
if (n == 1) {
return new double[]{0};

View File

@ -20,6 +20,7 @@ import org.apache.commons.math.DuplicateSampleAbscissaException;
import org.apache.commons.math.FunctionEvaluationException;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.analysis.UnivariateRealFunction;
import org.apache.commons.math.util.LocalizedFormats;
/**
* Implements the representation of a real polynomial function in
@ -90,7 +91,7 @@ public class PolynomialFunctionLagrangeForm implements UnivariateRealFunction {
try {
return evaluate(x, y, z);
} catch (DuplicateSampleAbscissaException e) {
throw new FunctionEvaluationException(e, z, e.getPattern(), e.getArguments());
throw new FunctionEvaluationException(e, z, e.getLocalizablePattern(), e.getArguments());
}
}
@ -297,12 +298,12 @@ public class PolynomialFunctionLagrangeForm implements UnivariateRealFunction {
if (x.length != y.length) {
throw MathRuntimeException.createIllegalArgumentException(
"dimension mismatch {0} != {1}", x.length, y.length);
LocalizedFormats.DIMENSIONS_MISMATCH_SIMPLE, x.length, y.length);
}
if (x.length < 2) {
throw MathRuntimeException.createIllegalArgumentException(
"{0} points are required, got only {1}", 2, x.length);
LocalizedFormats.WRONG_NUMBER_OF_POINTS, 2, x.length);
}
}

View File

@ -19,6 +19,7 @@ package org.apache.commons.math.analysis.polynomials;
import org.apache.commons.math.FunctionEvaluationException;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.analysis.UnivariateRealFunction;
import org.apache.commons.math.util.LocalizedFormats;
/**
* Implements the representation of a real polynomial function in
@ -209,11 +210,11 @@ public class PolynomialFunctionNewtonForm implements UnivariateRealFunction {
if (a.length < 1 || c.length < 1) {
throw MathRuntimeException.createIllegalArgumentException(
"empty polynomials coefficients array");
LocalizedFormats.EMPTY_POLYNOMIALS_COEFFICIENTS_ARRAY);
}
if (a.length != c.length + 1) {
throw MathRuntimeException.createIllegalArgumentException(
"array sizes should have difference 1 ({0} != {1} + 1)",
LocalizedFormats.ARRAY_SIZES_SHOULD_HAVE_DIFFERENCE_1,
a.length, c.length);
}
}

View File

@ -22,6 +22,7 @@ import org.apache.commons.math.ArgumentOutsideDomainException;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.analysis.DifferentiableUnivariateRealFunction;
import org.apache.commons.math.analysis.UnivariateRealFunction;
import org.apache.commons.math.util.LocalizedFormats;
/**
* Represents a polynomial spline function.
@ -97,17 +98,17 @@ public class PolynomialSplineFunction
public PolynomialSplineFunction(double knots[], PolynomialFunction polynomials[]) {
if (knots.length < 2) {
throw MathRuntimeException.createIllegalArgumentException(
"spline partition must have at least {0} points, got {1}",
LocalizedFormats.NOT_ENOUGH_POINTS_IN_SPLINE_PARTITION,
2, knots.length);
}
if (knots.length - 1 != polynomials.length) {
throw MathRuntimeException.createIllegalArgumentException(
"number of polynomial interpolants must match the number of segments ({0} != {1} - 1)",
LocalizedFormats.POLYNOMIAL_INTERPOLANTS_MISMATCH_SEGMENTS,
polynomials.length, knots.length);
}
if (!isStrictlyIncreasing(knots)) {
throw MathRuntimeException.createIllegalArgumentException(
"knot values must be strictly increasing");
LocalizedFormats.NOT_STRICTLY_INCREASING_KNOT_VALUES);
}
this.n = knots.length -1;

View File

@ -21,6 +21,7 @@ import org.apache.commons.math.FunctionEvaluationException;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.MaxIterationsExceededException;
import org.apache.commons.math.analysis.UnivariateRealFunction;
import org.apache.commons.math.util.LocalizedFormats;
/**
* Implements the <a href="http://mathworld.wolfram.com/BrentsMethod.html">
@ -43,11 +44,6 @@ public class BrentSolver extends UnivariateRealSolverImpl {
*/
public static final int DEFAULT_MAXIMUM_ITERATIONS = 100;
/** Error message for non-bracketing interval. */
private static final String NON_BRACKETING_MESSAGE =
"function values at endpoints do not have different signs. " +
"Endpoints: [{0}, {1}], Values: [{2}, {3}]";
/** Serializable version identifier */
private static final long serialVersionUID = 7694577816772532779L;
@ -134,7 +130,7 @@ public class BrentSolver extends UnivariateRealSolverImpl {
clearResult();
if ((initial < min) || (initial > max)) {
throw MathRuntimeException.createIllegalArgumentException(
"invalid interval, initial value parameters: lower={0}, initial={1}, upper={2}",
LocalizedFormats.INVALID_INTERVAL_INITIAL_VALUE_PARAMETERS,
min, initial, max);
}
@ -170,7 +166,7 @@ public class BrentSolver extends UnivariateRealSolverImpl {
}
throw MathRuntimeException.createIllegalArgumentException(
NON_BRACKETING_MESSAGE, min, max, yMin, yMax);
LocalizedFormats.SAME_SIGN_AT_ENDPOINTS, min, max, yMin, yMax);
}
@ -217,7 +213,7 @@ public class BrentSolver extends UnivariateRealSolverImpl {
} else {
// neither value is close to zero and min and max do not bracket root.
throw MathRuntimeException.createIllegalArgumentException(
NON_BRACKETING_MESSAGE, min, max, yMin, yMax);
LocalizedFormats.SAME_SIGN_AT_ENDPOINTS, min, max, yMin, yMax);
}
} else if (sign < 0){
// solve using only the first endpoint as initial guess

View File

@ -23,6 +23,7 @@ import org.apache.commons.math.MaxIterationsExceededException;
import org.apache.commons.math.analysis.UnivariateRealFunction;
import org.apache.commons.math.analysis.polynomials.PolynomialFunction;
import org.apache.commons.math.complex.Complex;
import org.apache.commons.math.util.LocalizedFormats;
/**
* Implements the <a href="http://mathworld.wolfram.com/LaguerresMethod.html">
@ -38,14 +39,6 @@ import org.apache.commons.math.complex.Complex;
*/
public class LaguerreSolver extends UnivariateRealSolverImpl {
/** Message for non-polynomial function. */
private static final String NON_POLYNOMIAL_FUNCTION_MESSAGE =
"function is not polynomial";
/** Message for non-positive degree. */
private static final String NON_POSITIVE_DEGREE_MESSAGE =
"polynomial degree must be positive: degree={0}";
/** polynomial function to solve.
* @deprecated as of 2.0 the function is not stored anymore in the instance
*/
@ -69,7 +62,7 @@ public class LaguerreSolver extends UnivariateRealSolverImpl {
if (f instanceof PolynomialFunction) {
p = (PolynomialFunction) f;
} else {
throw MathRuntimeException.createIllegalArgumentException(NON_POLYNOMIAL_FUNCTION_MESSAGE);
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.FUNCTION_NOT_POLYNOMIAL);
}
}
@ -172,7 +165,7 @@ public class LaguerreSolver extends UnivariateRealSolverImpl {
// check function type
if (!(f instanceof PolynomialFunction)) {
throw MathRuntimeException.createIllegalArgumentException(NON_POLYNOMIAL_FUNCTION_MESSAGE);
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.FUNCTION_NOT_POLYNOMIAL);
}
// check for zeros before verifying bracketing
@ -265,7 +258,7 @@ public class LaguerreSolver extends UnivariateRealSolverImpl {
int iterationCount = 0;
if (n < 1) {
throw MathRuntimeException.createIllegalArgumentException(
NON_POSITIVE_DEGREE_MESSAGE, n);
LocalizedFormats.NON_POSITIVE_POLYNOMIAL_DEGREE, n);
}
Complex c[] = new Complex[n+1]; // coefficients for deflated polynomial
for (int i = 0; i <= n; i++) {
@ -313,7 +306,7 @@ public class LaguerreSolver extends UnivariateRealSolverImpl {
int n = coefficients.length - 1;
if (n < 1) {
throw MathRuntimeException.createIllegalArgumentException(
NON_POSITIVE_DEGREE_MESSAGE, n);
LocalizedFormats.NON_POSITIVE_POLYNOMIAL_DEGREE, n);
}
Complex N = new Complex(n, 0.0);
Complex N1 = new Complex(n - 1, 0.0);

View File

@ -22,6 +22,7 @@ import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.MaxIterationsExceededException;
import org.apache.commons.math.analysis.DifferentiableUnivariateRealFunction;
import org.apache.commons.math.analysis.UnivariateRealFunction;
import org.apache.commons.math.util.LocalizedFormats;
/**
* Implements <a href="http://mathworld.wolfram.com/NewtonsMethod.html">
@ -129,7 +130,7 @@ public class NewtonSolver extends UnivariateRealSolverImpl {
throw new MaxIterationsExceededException(maximalIterationCount);
} catch (ClassCastException cce) {
throw MathRuntimeException.createIllegalArgumentException("function is not differentiable");
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.FUNCTION_NOT_DIFFERENTIABLE);
}
}

View File

@ -21,6 +21,7 @@ import org.apache.commons.math.FunctionEvaluationException;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.MaxIterationsExceededException;
import org.apache.commons.math.analysis.UnivariateRealFunction;
import org.apache.commons.math.util.LocalizedFormats;
/**
@ -127,9 +128,7 @@ public class SecantSolver extends UnivariateRealSolverImpl {
// Verify bracketing
if (y0 * y1 >= 0) {
throw MathRuntimeException.createIllegalArgumentException(
"function values at endpoints do not have different signs, " +
"endpoints: [{0}, {1}], values: [{2}, {3}]",
min, max, y0, y1);
LocalizedFormats.SAME_SIGN_AT_ENDPOINTS, min, max, y0, y1);
}
double x2 = x0;

View File

@ -21,6 +21,7 @@ import org.apache.commons.math.ConvergingAlgorithmImpl;
import org.apache.commons.math.FunctionEvaluationException;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.analysis.UnivariateRealFunction;
import org.apache.commons.math.util.LocalizedFormats;
/**
* Provide a default implementation for several functions useful to generic
@ -73,7 +74,7 @@ public abstract class UnivariateRealSolverImpl
final double defaultAbsoluteAccuracy) {
super(defaultMaximalIterationCount, defaultAbsoluteAccuracy);
if (f == null) {
throw MathRuntimeException.createIllegalArgumentException("function to solve cannot be null");
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.NULL_FUNCTION);
}
this.f = f;
this.defaultFunctionValueAccuracy = 1.0e-15;
@ -100,7 +101,7 @@ public abstract class UnivariateRealSolverImpl
*/
protected void checkResultComputed() throws IllegalStateException {
if (!resultComputed) {
throw MathRuntimeException.createIllegalStateException("no result available");
throw MathRuntimeException.createIllegalStateException(LocalizedFormats.NO_RESULT_AVAILABLE);
}
}
@ -224,7 +225,7 @@ public abstract class UnivariateRealSolverImpl
protected void verifySequence(final double lower, final double initial, final double upper) {
if (!isSequence(lower, initial, upper)) {
throw MathRuntimeException.createIllegalArgumentException(
"invalid interval, initial value parameters: lower={0}, initial={1}, upper={2}",
LocalizedFormats.INVALID_INTERVAL_INITIAL_VALUE_PARAMETERS,
lower, initial, upper);
}
}
@ -247,8 +248,7 @@ public abstract class UnivariateRealSolverImpl
verifyInterval(lower, upper);
if (!isBracketing(lower, upper, function)) {
throw MathRuntimeException.createIllegalArgumentException(
"function values at endpoints do not have different signs. " +
"Endpoints: [{0}, {1}], Values: [{2}, {3}]",
LocalizedFormats.SAME_SIGN_AT_ENDPOINTS,
lower, upper, function.value(lower), function.value(upper));
}
}

View File

@ -20,6 +20,7 @@ import org.apache.commons.math.FunctionEvaluationException;
import org.apache.commons.math.ConvergenceException;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.analysis.UnivariateRealFunction;
import org.apache.commons.math.util.LocalizedFormats;
/**
* Utility routines for {@link UnivariateRealSolver} objects.
@ -28,10 +29,6 @@ import org.apache.commons.math.analysis.UnivariateRealFunction;
*/
public class UnivariateRealSolverUtils {
/** Message for null function.*/
private static final String NULL_FUNCTION_MESSAGE =
"function is null";
/**
* Default constructor.
*/
@ -173,15 +170,15 @@ public class UnivariateRealSolverUtils {
FunctionEvaluationException {
if (function == null) {
throw MathRuntimeException.createIllegalArgumentException(NULL_FUNCTION_MESSAGE);
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.NULL_FUNCTION);
}
if (maximumIterations <= 0) {
throw MathRuntimeException.createIllegalArgumentException(
"bad value for maximum iterations number: {0}", maximumIterations);
LocalizedFormats.INVALID_MAX_ITERATIONS, maximumIterations);
}
if (initial < lowerBound || initial > upperBound || lowerBound >= upperBound) {
throw MathRuntimeException.createIllegalArgumentException(
"invalid bracketing parameters: lower bound={0}, initial={1}, upper bound={2}",
LocalizedFormats.INVALID_BRACKETING_PARAMETERS,
lowerBound, initial, upperBound);
}
double a = initial;
@ -202,9 +199,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}",
LocalizedFormats.FAILED_BRACKETING,
numIterations, maximumIterations, initial,
lowerBound, upperBound, a, b, fa, fb);
}
@ -230,7 +225,7 @@ public class UnivariateRealSolverUtils {
*/
private static void setup(UnivariateRealFunction f) {
if (f == null) {
throw MathRuntimeException.createIllegalArgumentException(NULL_FUNCTION_MESSAGE);
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.NULL_FUNCTION);
}
}

View File

@ -23,6 +23,7 @@ import java.util.List;
import org.apache.commons.math.FieldElement;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.util.LocalizedFormats;
import org.apache.commons.math.util.MathUtils;
/**
@ -941,7 +942,7 @@ public class Complex implements FieldElement<Complex>, Serializable {
if (n <= 0) {
throw MathRuntimeException.createIllegalArgumentException(
"cannot compute nth root for null or negative n: {0}",
LocalizedFormats.CANNOT_COMPUTE_NTH_ROOT_FOR_NEGATIVE_N,
n);
}

View File

@ -25,6 +25,7 @@ import java.util.Locale;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.util.CompositeFormat;
import org.apache.commons.math.util.LocalizedFormats;
/**
* Formats a Complex number in cartesian format "Re(c) + Im(c)i". 'i' can
@ -192,7 +193,7 @@ public class ComplexFormat extends CompositeFormat {
toAppendTo, pos);
} else {
throw MathRuntimeException.createIllegalArgumentException(
"cannot format a {0} instance as a complex number",
LocalizedFormats.CANNOT_FORMAT_INSTANCE_AS_COMPLEX,
obj.getClass().getName());
}
@ -349,7 +350,7 @@ public class ComplexFormat extends CompositeFormat {
public void setImaginaryCharacter(String imaginaryCharacter) {
if (imaginaryCharacter == null || imaginaryCharacter.length() == 0) {
throw MathRuntimeException.createIllegalArgumentException(
"empty string for imaginary character");
LocalizedFormats.EMPTY_STRING_FOR_IMAGINARY_CHARACTER);
}
this.imaginaryCharacter = imaginaryCharacter;
}
@ -363,7 +364,7 @@ public class ComplexFormat extends CompositeFormat {
public void setImaginaryFormat(NumberFormat imaginaryFormat) {
if (imaginaryFormat == null) {
throw MathRuntimeException.createIllegalArgumentException(
"null imaginary format");
LocalizedFormats.NULL_IMAGINARY_FORMAT);
}
this.imaginaryFormat = imaginaryFormat;
}
@ -377,7 +378,7 @@ public class ComplexFormat extends CompositeFormat {
public void setRealFormat(NumberFormat realFormat) {
if (realFormat == null) {
throw MathRuntimeException.createIllegalArgumentException(
"null real format");
LocalizedFormats.NULL_REAL_FORMAT);
}
this.realFormat = realFormat;
}

View File

@ -18,6 +18,7 @@
package org.apache.commons.math.complex;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.util.LocalizedFormats;
/**
* Static implementations of common
@ -62,7 +63,7 @@ public class ComplexUtils {
public static Complex polar2Complex(double r, double theta) {
if (r < 0) {
throw MathRuntimeException.createIllegalArgumentException(
"negative complex module {0}", r);
LocalizedFormats.NEGATIVE_COMPLEX_MODULE, r);
}
return new Complex(r * Math.cos(theta), r * Math.sin(theta));
}

View File

@ -26,6 +26,7 @@ import org.apache.commons.math.analysis.UnivariateRealFunction;
import org.apache.commons.math.analysis.solvers.BrentSolver;
import org.apache.commons.math.analysis.solvers.UnivariateRealSolverUtils;
import org.apache.commons.math.random.RandomDataImpl;
import org.apache.commons.math.util.LocalizedFormats;
/**
* Base class for continuous distributions. Default implementations are
@ -69,7 +70,7 @@ public abstract class AbstractContinuousDistribution
*/
public double density(double x) throws MathRuntimeException {
throw new MathRuntimeException(new UnsupportedOperationException(),
"This distribution does not have a density function implemented");
LocalizedFormats.NO_DENSITY_FOR_THIS_DISTRIBUTION);
}
/**
@ -87,7 +88,7 @@ public abstract class AbstractContinuousDistribution
throws MathException {
if (p < 0.0 || p > 1.0) {
throw MathRuntimeException.createIllegalArgumentException(
"{0} out of [{1}, {2}] range", p, 0.0, 1.0);
LocalizedFormats.OUT_OF_RANGE_SIMPLE, p, 0.0, 1.0);
}
// by default, do simple root finding using bracketing and default solver.
@ -99,11 +100,11 @@ public abstract class AbstractContinuousDistribution
try {
ret = cumulativeProbability(x) - p;
} catch (MathException ex) {
throw new FunctionEvaluationException(ex, x, ex.getPattern(), ex.getArguments());
throw new FunctionEvaluationException(ex, x, ex.getLocalizablePattern(), ex.getArguments());
}
if (Double.isNaN(ret)) {
throw new FunctionEvaluationException(x,
"Cumulative probability function returned NaN for argument {0} p = {1}", x, p);
LocalizedFormats.CUMULATIVE_PROBABILITY_RETURNED_NAN, x, p);
}
return ret;
}
@ -176,7 +177,7 @@ public abstract class AbstractContinuousDistribution
*/
public double[] sample(int sampleSize) throws MathException {
if (sampleSize <= 0) {
MathRuntimeException.createIllegalArgumentException("Sample size must be positive");
MathRuntimeException.createIllegalArgumentException(LocalizedFormats.NOT_POSITIVE_SAMPLE_SIZE, sampleSize);
}
double[] out = new double[sampleSize];
for (int i = 0; i < sampleSize; i++) {

View File

@ -20,6 +20,7 @@ import java.io.Serializable;
import org.apache.commons.math.MathException;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.util.LocalizedFormats;
/**
* Base class for probability distributions.
@ -60,7 +61,7 @@ public abstract class AbstractDistribution
throws MathException {
if (x0 > x1) {
throw MathRuntimeException.createIllegalArgumentException(
"lower endpoint ({0}) must be less than or equal to upper endpoint ({1})",
LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT,
x0, x1);
}
return cumulativeProbability(x1) - cumulativeProbability(x0);

View File

@ -22,6 +22,7 @@ import org.apache.commons.math.FunctionEvaluationException;
import org.apache.commons.math.MathException;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.random.RandomDataImpl;
import org.apache.commons.math.util.LocalizedFormats;
/**
@ -34,15 +35,7 @@ import org.apache.commons.math.random.RandomDataImpl;
public abstract class AbstractIntegerDistribution extends AbstractDistribution
implements IntegerDistribution, Serializable {
/** Message for endpoints in wrong order. */
private static final String WRONG_ORDER_ENDPOINTS_MESSAGE =
"lower endpoint ({0}) must be less than or equal to upper endpoint ({1})";
/** Message for out of range point. */
private static final String OUT_OF_RANGE_POINT =
"{0} out of [{1}, {2}] range";
/** Serializable version identifier */
/** Serializable version identifier */
private static final long serialVersionUID = -1146319659338487221L;
/**
@ -95,7 +88,7 @@ public abstract class AbstractIntegerDistribution extends AbstractDistribution
throws MathException {
if (x0 > x1) {
throw MathRuntimeException.createIllegalArgumentException(
WRONG_ORDER_ENDPOINTS_MESSAGE, x0, x1);
LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT, x0, x1);
}
if (Math.floor(x0) < x0) {
return cumulativeProbability(((int) Math.floor(x0)) + 1,
@ -152,7 +145,7 @@ public abstract class AbstractIntegerDistribution extends AbstractDistribution
public double cumulativeProbability(int x0, int x1) throws MathException {
if (x0 > x1) {
throw MathRuntimeException.createIllegalArgumentException(
WRONG_ORDER_ENDPOINTS_MESSAGE, x0, x1);
LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT, x0, x1);
}
return cumulativeProbability(x1) - cumulativeProbability(x0 - 1);
}
@ -171,7 +164,7 @@ public abstract class AbstractIntegerDistribution extends AbstractDistribution
public int inverseCumulativeProbability(final double p) throws MathException{
if (p < 0.0 || p > 1.0) {
throw MathRuntimeException.createIllegalArgumentException(
OUT_OF_RANGE_POINT, p, 0.0, 1.0);
LocalizedFormats.OUT_OF_RANGE_SIMPLE, p, 0.0, 1.0);
}
// by default, do simple bisection.
@ -250,7 +243,7 @@ public abstract class AbstractIntegerDistribution extends AbstractDistribution
*/
public int[] sample(int sampleSize) throws MathException {
if (sampleSize <= 0) {
MathRuntimeException.createIllegalArgumentException("Sample size must be positive");
MathRuntimeException.createIllegalArgumentException(LocalizedFormats.NOT_POSITIVE_SAMPLE_SIZE, sampleSize);
}
int[] out = new int[sampleSize];
for (int i = 0; i < sampleSize; i++) {
@ -274,11 +267,11 @@ public abstract class AbstractIntegerDistribution extends AbstractDistribution
try {
result = cumulativeProbability(argument);
} catch (MathException ex) {
throw new FunctionEvaluationException(ex, argument, ex.getPattern(), ex.getArguments());
throw new FunctionEvaluationException(ex, argument, ex.getLocalizablePattern(), ex.getArguments());
}
if (Double.isNaN(result)) {
throw new FunctionEvaluationException(argument,
"Discrete cumulative probability function returned NaN for argument {0}", argument);
LocalizedFormats.DISCRETE_CUMULATIVE_PROBABILITY_RETURNED_NAN, argument);
}
return result;
}

View File

@ -21,6 +21,7 @@ import java.io.Serializable;
import org.apache.commons.math.MathException;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.special.Beta;
import org.apache.commons.math.util.LocalizedFormats;
/**
* The default implementation of {@link BinomialDistribution}.
@ -92,7 +93,7 @@ public class BinomialDistributionImpl extends AbstractIntegerDistribution
private void setNumberOfTrialsInternal(int trials) {
if (trials < 0) {
throw MathRuntimeException.createIllegalArgumentException(
"number of trials must be non-negative ({0})", trials);
LocalizedFormats.NEGATIVE_NUMBER_OF_TRIALS, trials);
}
numberOfTrials = trials;
}
@ -119,7 +120,7 @@ public class BinomialDistributionImpl extends AbstractIntegerDistribution
private void setProbabilityOfSuccessInternal(double p) {
if (p < 0.0 || p > 1.0) {
throw MathRuntimeException.createIllegalArgumentException(
"{0} out of [{1}, {2}] range", p, 0.0, 1.0);
LocalizedFormats.OUT_OF_RANGE_SIMPLE, p, 0.0, 1.0);
}
probabilityOfSuccess = p;
}

View File

@ -20,6 +20,7 @@ package org.apache.commons.math.distribution;
import java.io.Serializable;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.util.LocalizedFormats;
/**
* Default implementation of
@ -136,7 +137,7 @@ public class CauchyDistributionImpl extends AbstractContinuousDistribution
double ret;
if (p < 0.0 || p > 1.0) {
throw MathRuntimeException.createIllegalArgumentException(
"{0} out of [{1}, {2}] range", p, 0.0, 1.0);
LocalizedFormats.OUT_OF_RANGE_SIMPLE, p, 0.0, 1.0);
} else if (p == 0) {
ret = Double.NEGATIVE_INFINITY;
} else if (p == 1) {
@ -182,7 +183,7 @@ public class CauchyDistributionImpl extends AbstractContinuousDistribution
private void setScaleInternal(double s) {
if (s <= 0.0) {
throw MathRuntimeException.createIllegalArgumentException(
"scale must be positive ({0})", s);
LocalizedFormats.NOT_POSITIVE_SCALE, s);
}
scale = s;
}

View File

@ -20,6 +20,7 @@ import java.io.Serializable;
import org.apache.commons.math.MathException;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.util.LocalizedFormats;
/**
* The default implementation of {@link ExponentialDistribution}.
@ -83,7 +84,7 @@ public class ExponentialDistributionImpl extends AbstractContinuousDistribution
private void setMeanInternal(double newMean) {
if (newMean <= 0.0) {
throw MathRuntimeException.createIllegalArgumentException(
"mean must be positive ({0})", newMean);
LocalizedFormats.NOT_POSITIVE_MEAN, newMean);
}
this.mean = newMean;
}
@ -165,7 +166,7 @@ public class ExponentialDistributionImpl extends AbstractContinuousDistribution
if (p < 0.0 || p > 1.0) {
throw MathRuntimeException.createIllegalArgumentException(
"{0} out of [{1}, {2}] range", p, 0.0, 1.0);
LocalizedFormats.OUT_OF_RANGE_SIMPLE, p, 0.0, 1.0);
} else if (p == 1.0) {
ret = Double.POSITIVE_INFINITY;
} else {

View File

@ -21,6 +21,7 @@ import java.io.Serializable;
import org.apache.commons.math.MathException;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.special.Beta;
import org.apache.commons.math.util.LocalizedFormats;
/**
* Default implementation of
@ -38,10 +39,6 @@ public class FDistributionImpl
*/
public static final double DEFAULT_INVERSE_ABSOLUTE_ACCURACY = 1e-9;
/** Message for non positive degrees of freddom. */
private static final String NON_POSITIVE_DEGREES_OF_FREEDOM_MESSAGE =
"degrees of freedom must be positive ({0})";
/** Serializable version identifier */
private static final long serialVersionUID = -8516354193418641566L;
@ -222,7 +219,7 @@ public class FDistributionImpl
private void setNumeratorDegreesOfFreedomInternal(double degreesOfFreedom) {
if (degreesOfFreedom <= 0.0) {
throw MathRuntimeException.createIllegalArgumentException(
NON_POSITIVE_DEGREES_OF_FREEDOM_MESSAGE, degreesOfFreedom);
LocalizedFormats.NOT_POSITIVE_DEGREES_OF_FREEDOM, degreesOfFreedom);
}
this.numeratorDegreesOfFreedom = degreesOfFreedom;
}
@ -256,7 +253,7 @@ public class FDistributionImpl
private void setDenominatorDegreesOfFreedomInternal(double degreesOfFreedom) {
if (degreesOfFreedom <= 0.0) {
throw MathRuntimeException.createIllegalArgumentException(
NON_POSITIVE_DEGREES_OF_FREEDOM_MESSAGE, degreesOfFreedom);
LocalizedFormats.NOT_POSITIVE_DEGREES_OF_FREEDOM, degreesOfFreedom);
}
this.denominatorDegreesOfFreedom = degreesOfFreedom;
}

View File

@ -21,6 +21,7 @@ import java.io.Serializable;
import org.apache.commons.math.MathException;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.special.Gamma;
import org.apache.commons.math.util.LocalizedFormats;
/**
* The default implementation of {@link GammaDistribution}.
@ -145,7 +146,7 @@ public class GammaDistributionImpl extends AbstractContinuousDistribution
private void setAlphaInternal(double newAlpha) {
if (newAlpha <= 0.0) {
throw MathRuntimeException.createIllegalArgumentException(
"alpha must be positive ({0})",
LocalizedFormats.NOT_POSITIVE_ALPHA,
newAlpha);
}
this.alpha = newAlpha;
@ -178,7 +179,7 @@ public class GammaDistributionImpl extends AbstractContinuousDistribution
private void setBetaInternal(double newBeta) {
if (newBeta <= 0.0) {
throw MathRuntimeException.createIllegalArgumentException(
"beta must be positive ({0})",
LocalizedFormats.NOT_POSITIVE_BETA,
newBeta);
}
this.beta = newBeta;

View File

@ -20,6 +20,7 @@ package org.apache.commons.math.distribution;
import java.io.Serializable;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.util.LocalizedFormats;
import org.apache.commons.math.util.MathUtils;
/**
@ -56,13 +57,13 @@ public class HypergeometricDistributionImpl extends AbstractIntegerDistribution
if (numberOfSuccesses > populationSize) {
throw MathRuntimeException
.createIllegalArgumentException(
"number of successes ({0}) must be less than or equal to population size ({1})",
LocalizedFormats.NUMBER_OF_SUCCESS_LARGER_THAN_POPULATION_SIZE,
numberOfSuccesses, populationSize);
}
if (sampleSize > populationSize) {
throw MathRuntimeException
.createIllegalArgumentException(
"sample size ({0}) must be less than or equal to population size ({1})",
LocalizedFormats.SAMPLE_SIZE_LARGER_THAN_POPULATION_SIZE,
sampleSize, populationSize);
}
@ -249,7 +250,7 @@ public class HypergeometricDistributionImpl extends AbstractIntegerDistribution
private void setNumberOfSuccessesInternal(int num) {
if (num < 0) {
throw MathRuntimeException.createIllegalArgumentException(
"number of successes must be non-negative ({0})", num);
LocalizedFormats.NEGATIVE_NUMBER_OF_SUCCESSES, num);
}
numberOfSuccesses = num;
}
@ -274,7 +275,7 @@ public class HypergeometricDistributionImpl extends AbstractIntegerDistribution
private void setPopulationSizeInternal(int size) {
if (size <= 0) {
throw MathRuntimeException.createIllegalArgumentException(
"population size must be positive ({0})", size);
LocalizedFormats.NOT_POSITIVE_POPULATION_SIZE, size);
}
populationSize = size;
}
@ -299,7 +300,7 @@ public class HypergeometricDistributionImpl extends AbstractIntegerDistribution
private void setSampleSizeInternal(int size) {
if (size < 0) {
throw MathRuntimeException.createIllegalArgumentException(
"sample size must be positive ({0})", size);
LocalizedFormats.NOT_POSITIVE_SAMPLE_SIZE, size);
}
sampleSize = size;
}

View File

@ -23,6 +23,7 @@ import org.apache.commons.math.MathException;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.MaxIterationsExceededException;
import org.apache.commons.math.special.Erf;
import org.apache.commons.math.util.LocalizedFormats;
/**
* Default implementation of
@ -138,7 +139,7 @@ public class NormalDistributionImpl extends AbstractContinuousDistribution
private void setStandardDeviationInternal(double sd) {
if (sd <= 0.0) {
throw MathRuntimeException.createIllegalArgumentException(
"standard deviation must be positive ({0})",
LocalizedFormats.NOT_POSITIVE_STANDARD_DEVIATION,
sd);
}
standardDeviation = sd;

View File

@ -21,6 +21,7 @@ import java.io.Serializable;
import org.apache.commons.math.MathException;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.special.Beta;
import org.apache.commons.math.util.LocalizedFormats;
import org.apache.commons.math.util.MathUtils;
/**
@ -88,7 +89,7 @@ public class PascalDistributionImpl extends AbstractIntegerDistribution
private void setNumberOfSuccessesInternal(int successes) {
if (successes < 0) {
throw MathRuntimeException.createIllegalArgumentException(
"number of successes must be non-negative ({0})",
LocalizedFormats.NEGATIVE_NUMBER_OF_SUCCESSES,
successes);
}
numberOfSuccesses = successes;
@ -114,7 +115,7 @@ public class PascalDistributionImpl extends AbstractIntegerDistribution
private void setProbabilityOfSuccessInternal(double p) {
if (p < 0.0 || p > 1.0) {
throw MathRuntimeException.createIllegalArgumentException(
"{0} out of [{1}, {2}] range", p, 0.0, 1.0);
LocalizedFormats.OUT_OF_RANGE_SIMPLE, p, 0.0, 1.0);
}
probabilityOfSuccess = p;
}

View File

@ -21,6 +21,7 @@ import java.io.Serializable;
import org.apache.commons.math.MathException;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.special.Gamma;
import org.apache.commons.math.util.LocalizedFormats;
import org.apache.commons.math.util.MathUtils;
/**
@ -168,7 +169,7 @@ public class PoissonDistributionImpl extends AbstractIntegerDistribution
double p) {
if (p <= 0) {
throw MathRuntimeException.createIllegalArgumentException(
"the Poisson mean must be positive ({0})", p);
LocalizedFormats.NOT_POSITIVE_POISSON_MEAN, p);
}
mean = p;
normal = z;

View File

@ -22,6 +22,7 @@ import org.apache.commons.math.MathException;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.special.Beta;
import org.apache.commons.math.special.Gamma;
import org.apache.commons.math.util.LocalizedFormats;
/**
* Default implementation of
@ -87,7 +88,7 @@ public class TDistributionImpl
private void setDegreesOfFreedomInternal(double newDegreesOfFreedom) {
if (newDegreesOfFreedom <= 0.0) {
throw MathRuntimeException.createIllegalArgumentException(
"degrees of freedom must be positive ({0})",
LocalizedFormats.NOT_POSITIVE_DEGREES_OF_FREEDOM,
newDegreesOfFreedom);
}
this.degreesOfFreedom = newDegreesOfFreedom;

View File

@ -20,6 +20,7 @@ package org.apache.commons.math.distribution;
import java.io.Serializable;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.util.LocalizedFormats;
/**
* Default implementation of
@ -149,7 +150,7 @@ public class WeibullDistributionImpl extends AbstractContinuousDistribution
double ret;
if (p < 0.0 || p > 1.0) {
throw MathRuntimeException.createIllegalArgumentException(
"{0} out of [{1}, {2}] range", p, 0.0, 1.0);
LocalizedFormats.OUT_OF_RANGE_SIMPLE, p, 0.0, 1.0);
} else if (p == 0) {
ret = 0.0;
} else if (p == 1) {
@ -176,7 +177,7 @@ public class WeibullDistributionImpl extends AbstractContinuousDistribution
private void setShapeInternal(double alpha) {
if (alpha <= 0.0) {
throw MathRuntimeException.createIllegalArgumentException(
"shape must be positive ({0})",
LocalizedFormats.NOT_POSITIVE_SHAPE,
alpha);
}
this.shape = alpha;
@ -198,7 +199,7 @@ public class WeibullDistributionImpl extends AbstractContinuousDistribution
private void setScaleInternal(double beta) {
if (beta <= 0.0) {
throw MathRuntimeException.createIllegalArgumentException(
"scale must be positive ({0})",
LocalizedFormats.NOT_POSITIVE_SCALE,
beta);
}
this.scale = beta;

View File

@ -20,6 +20,7 @@ package org.apache.commons.math.distribution;
import java.io.Serializable;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.util.LocalizedFormats;
/**
* Implementation for the {@link ZipfDistribution}.
@ -87,8 +88,7 @@ public class ZipfDistributionImpl extends AbstractIntegerDistribution
throws IllegalArgumentException {
if (n <= 0) {
throw MathRuntimeException.createIllegalArgumentException(
"invalid number of elements {0} (must be positive)",
n);
LocalizedFormats.INSUFFICIENT_DIMENSION, n, 0);
}
this.numberOfElements = n;
}
@ -127,7 +127,7 @@ public class ZipfDistributionImpl extends AbstractIntegerDistribution
throws IllegalArgumentException {
if (s <= 0.0) {
throw MathRuntimeException.createIllegalArgumentException(
"invalid exponent {0} (must be positive)",
LocalizedFormats.NOT_POSITIVE_EXPONENT,
s);
}
this.exponent = s;

View File

@ -23,6 +23,7 @@ import org.apache.commons.math.linear.InvalidMatrixException;
import org.apache.commons.math.linear.LUDecompositionImpl;
import org.apache.commons.math.linear.MatrixUtils;
import org.apache.commons.math.linear.RealMatrix;
import org.apache.commons.math.util.LocalizedFormats;
/**
* Base class for implementing estimators.
@ -150,7 +151,7 @@ public abstract class AbstractEstimator implements Estimator {
throws EstimationException {
if (++costEvaluations > maxCostEval) {
throw new EstimationException("maximal number of evaluations exceeded ({0})",
throw new EstimationException(LocalizedFormats.MAX_EVALUATIONS_EXCEEDED,
maxCostEval);
}
@ -237,7 +238,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");
throw new EstimationException(LocalizedFormats.UNABLE_TO_COMPUTE_COVARIANCE_SINGULAR_PROBLEM);
}
}
@ -257,7 +258,7 @@ public abstract class AbstractEstimator implements Estimator {
int p = problem.getUnboundParameters().length;
if (m <= p) {
throw new EstimationException(
"no degrees of freedom ({0} measurements, {1} parameters)",
LocalizedFormats.NO_DEGREES_OF_FREEDOM,
m, p);
}
double[] errors = new double[problem.getUnboundParameters().length];

View File

@ -18,6 +18,8 @@
package org.apache.commons.math.estimation;
import org.apache.commons.math.MathException;
import org.apache.commons.math.util.DummyLocalizable;
import org.apache.commons.math.util.Localizable;
/**
* This class represents exceptions thrown by the estimation solvers.
@ -42,6 +44,16 @@ extends MathException {
* @param parts to insert in the format (no translation)
*/
public EstimationException(String specifier, Object ... parts) {
this(new DummyLocalizable(specifier), parts);
}
/**
* 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 EstimationException(Localizable specifier, Object ... parts) {
super(specifier, parts);
}

View File

@ -25,6 +25,7 @@ import org.apache.commons.math.linear.MatrixUtils;
import org.apache.commons.math.linear.RealMatrix;
import org.apache.commons.math.linear.RealVector;
import org.apache.commons.math.linear.ArrayRealVector;
import org.apache.commons.math.util.LocalizedFormats;
/**
* This class implements a solver for estimation problems.
@ -213,7 +214,7 @@ public class GaussNewtonEstimator extends AbstractEstimator implements Serializa
}
} catch(InvalidMatrixException e) {
throw new EstimationException("unable to solve: singular problem");
throw new EstimationException(LocalizedFormats.UNABLE_TO_SOLVE_SINGULAR_PROBLEM);
}

View File

@ -19,6 +19,8 @@ package org.apache.commons.math.estimation;
import java.io.Serializable;
import java.util.Arrays;
import org.apache.commons.math.util.LocalizedFormats;
/**
* This class solves a least squares problem.
@ -821,7 +823,7 @@ public class LevenbergMarquardtEstimator extends AbstractEstimator implements Se
}
if (Double.isInfinite(norm2) || Double.isNaN(norm2)) {
throw new EstimationException(
"unable to perform Q.R decomposition on the {0}x{1} jacobian matrix",
LocalizedFormats.UNABLE_TO_PERFORM_QR_DECOMPOSITION_ON_JACOBIAN,
rows, cols);
}
if (norm2 > ak2) {

View File

@ -24,6 +24,7 @@ import java.text.ParsePosition;
import java.util.Locale;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.util.LocalizedFormats;
/**
* Common part shared by both {@link FractionFormat} and {@link BigFractionFormat}.
@ -119,7 +120,7 @@ public abstract class AbstractFormat extends NumberFormat implements Serializabl
public void setDenominatorFormat(final NumberFormat format) {
if (format == null) {
throw MathRuntimeException.createIllegalArgumentException(
"denominator format can not be null");
LocalizedFormats.NULL_DENOMINATOR_FORMAT);
}
this.denominatorFormat = format;
}
@ -133,7 +134,7 @@ public abstract class AbstractFormat extends NumberFormat implements Serializabl
public void setNumeratorFormat(final NumberFormat format) {
if (format == null) {
throw MathRuntimeException.createIllegalArgumentException(
"numerator format can not be null");
LocalizedFormats.NULL_NUMERATOR_FORMAT);
}
this.numeratorFormat = format;
}

View File

@ -22,6 +22,7 @@ import java.math.BigInteger;
import org.apache.commons.math.FieldElement;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.util.LocalizedFormats;
import org.apache.commons.math.util.MathUtils;
/**
@ -80,10 +81,6 @@ public class BigFraction
/** Serializable version identifier. */
private static final long serialVersionUID = -5630213147331578515L;
/** Message for zero denominator. */
private static final String FORBIDDEN_ZERO_DENOMINATOR =
"denominator must be different from 0";
/** <code>BigInteger</code> representation of 100. */
private static final BigInteger ONE_HUNDRED_DOUBLE = BigInteger.valueOf(100);
@ -123,13 +120,13 @@ public class BigFraction
*/
public BigFraction(BigInteger num, BigInteger den) {
if (num == null) {
throw MathRuntimeException.createNullPointerException("numerator is null");
throw MathRuntimeException.createNullPointerException(LocalizedFormats.NULL_NUMERATOR);
}
if (den == null) {
throw MathRuntimeException.createNullPointerException("denominator is null");
throw MathRuntimeException.createNullPointerException(LocalizedFormats.NULL_DENOMINATOR);
}
if (BigInteger.ZERO.equals(den)) {
throw MathRuntimeException.createArithmeticException(FORBIDDEN_ZERO_DENOMINATOR);
throw MathRuntimeException.createArithmeticException(LocalizedFormats.ZERO_DENOMINATOR);
}
if (BigInteger.ZERO.equals(num)) {
numerator = BigInteger.ZERO;
@ -179,10 +176,10 @@ public class BigFraction
*/
public BigFraction(final double value) throws IllegalArgumentException {
if (Double.isNaN(value)) {
throw MathRuntimeException.createIllegalArgumentException("cannot convert NaN value");
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.NAN_VALUE_CONVERSION);
}
if (Double.isInfinite(value)) {
throw MathRuntimeException.createIllegalArgumentException("cannot convert infinite value");
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.INFINITE_VALUE_CONVERSION);
}
// compute m and k such that value = m * 2^k
@ -619,7 +616,7 @@ public class BigFraction
*/
public BigFraction divide(final BigInteger bg) {
if (BigInteger.ZERO.equals(bg)) {
throw MathRuntimeException.createArithmeticException(FORBIDDEN_ZERO_DENOMINATOR);
throw MathRuntimeException.createArithmeticException(LocalizedFormats.ZERO_DENOMINATOR);
}
return new BigFraction(numerator, denominator.multiply(bg));
}
@ -672,7 +669,7 @@ public class BigFraction
*/
public BigFraction divide(final BigFraction fraction) {
if (BigInteger.ZERO.equals(fraction.numerator)) {
throw MathRuntimeException.createArithmeticException(FORBIDDEN_ZERO_DENOMINATOR);
throw MathRuntimeException.createArithmeticException(LocalizedFormats.ZERO_DENOMINATOR);
}
return multiply(fraction.reciprocal());

View File

@ -26,6 +26,7 @@ import java.text.ParsePosition;
import java.util.Locale;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.util.LocalizedFormats;
/**
* Formats a BigFraction number in proper format or improper format.
@ -174,7 +175,7 @@ public class BigFractionFormat extends AbstractFormat implements Serializable {
toAppendTo, pos);
} else {
throw MathRuntimeException.createIllegalArgumentException(
"cannot format given object as a fraction number");
LocalizedFormats.CANNOT_FORMAT_OBJECT_TO_FRACTION);
}
return ret;

View File

@ -21,6 +21,7 @@ import java.math.BigInteger;
import org.apache.commons.math.FieldElement;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.util.LocalizedFormats;
import org.apache.commons.math.util.MathUtils;
/**
@ -77,18 +78,6 @@ public class Fraction
/** A fraction representing "-1 / 1". */
public static final Fraction MINUS_ONE = new Fraction(-1, 1);
/** Message for zero denominator. */
private static final String ZERO_DENOMINATOR_MESSAGE =
"zero denominator in fraction {0}/{1}";
/** Message for overflow. */
private static final String OVERFLOW_MESSAGE =
"overflow in fraction {0}/{1}, cannot negate";
/** Message for null fraction. */
private static final String NULL_FRACTION =
"null fraction";
/** Serializable version identifier */
private static final long serialVersionUID = 3698073679419233275L;
@ -265,12 +254,12 @@ public class Fraction
public Fraction(int num, int den) {
if (den == 0) {
throw MathRuntimeException.createArithmeticException(
ZERO_DENOMINATOR_MESSAGE, num, den);
LocalizedFormats.ZERO_DENOMINATOR_IN_FRACTION, num, den);
}
if (den < 0) {
if (num == Integer.MIN_VALUE || den == Integer.MIN_VALUE) {
throw MathRuntimeException.createArithmeticException(
OVERFLOW_MESSAGE, num, den);
LocalizedFormats.OVERFLOW_IN_FRACTION, num, den);
}
num = -num;
den = -den;
@ -413,7 +402,7 @@ public class Fraction
public Fraction negate() {
if (numerator==Integer.MIN_VALUE) {
throw MathRuntimeException.createArithmeticException(
OVERFLOW_MESSAGE, numerator, denominator);
LocalizedFormats.OVERFLOW_IN_FRACTION, numerator, denominator);
}
return new Fraction(-numerator, denominator);
}
@ -484,7 +473,7 @@ public class Fraction
*/
private Fraction addSub(Fraction fraction, boolean isAdd) {
if (fraction == null) {
throw MathRuntimeException.createIllegalArgumentException(NULL_FRACTION);
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.NULL_FRACTION);
}
// zero is identity for addition.
if (numerator == 0) {
@ -521,7 +510,7 @@ public class Fraction
// result is (t/d2) / (u'/d1)(v'/d2)
BigInteger w = t.divide(BigInteger.valueOf(d2));
if (w.bitLength() > 31) {
throw MathRuntimeException.createArithmeticException("overflow, numerator too large after multiply: {0}",
throw MathRuntimeException.createArithmeticException(LocalizedFormats.NUMERATOR_OVERFLOW_AFTER_MULTIPLY,
w);
}
return new Fraction (w.intValue(),
@ -541,7 +530,7 @@ public class Fraction
*/
public Fraction multiply(Fraction fraction) {
if (fraction == null) {
throw MathRuntimeException.createIllegalArgumentException(NULL_FRACTION);
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.NULL_FRACTION);
}
if (numerator == 0 || fraction.numerator == 0) {
return ZERO;
@ -576,11 +565,11 @@ public class Fraction
*/
public Fraction divide(Fraction fraction) {
if (fraction == null) {
throw MathRuntimeException.createIllegalArgumentException(NULL_FRACTION);
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.NULL_FRACTION);
}
if (fraction.numerator == 0) {
throw MathRuntimeException.createArithmeticException(
"the fraction to divide by must not be zero: {0}/{1}",
LocalizedFormats.ZERO_FRACTION_TO_DIVIDE_BY,
fraction.numerator, fraction.denominator);
}
return multiply(fraction.reciprocal());
@ -609,7 +598,7 @@ public class Fraction
public static Fraction getReducedFraction(int numerator, int denominator) {
if (denominator == 0) {
throw MathRuntimeException.createArithmeticException(
ZERO_DENOMINATOR_MESSAGE, numerator, denominator);
LocalizedFormats.ZERO_DENOMINATOR_IN_FRACTION, numerator, denominator);
}
if (numerator==0) {
return ZERO; // normalize zero.
@ -622,7 +611,7 @@ public class Fraction
if (numerator==Integer.MIN_VALUE ||
denominator==Integer.MIN_VALUE) {
throw MathRuntimeException.createArithmeticException(
OVERFLOW_MESSAGE, numerator, denominator);
LocalizedFormats.OVERFLOW_IN_FRACTION, numerator, denominator);
}
numerator = -numerator;
denominator = -denominator;

View File

@ -18,6 +18,7 @@
package org.apache.commons.math.fraction;
import org.apache.commons.math.ConvergenceException;
import org.apache.commons.math.util.LocalizedFormats;
/**
* Error thrown when a double value cannot be converted to a fraction
@ -38,7 +39,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", value, maxIterations);
super(LocalizedFormats.FAILED_FRACTION_CONVERSION, value, maxIterations);
}
/**
@ -49,7 +50,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})", value, p, q);
super(LocalizedFormats.FRACTION_CONVERSION_OVERFLOW, value, p, q);
}
}

View File

@ -25,6 +25,7 @@ import java.util.Locale;
import org.apache.commons.math.ConvergenceException;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.util.LocalizedFormats;
/**
* Formats a Fraction number in proper format or improper format. The number
@ -180,12 +181,12 @@ public class FractionFormat extends AbstractFormat {
toAppendTo, pos);
} catch (ConvergenceException ex) {
throw MathRuntimeException.createIllegalArgumentException(
"cannot convert given object to a fraction number: {0}",
LocalizedFormats.CANNOT_CONVERT_OBJECT_TO_FRACTION,
ex.getLocalizedMessage());
}
} else {
throw MathRuntimeException.createIllegalArgumentException(
"cannot format given object as a fraction number");
LocalizedFormats.CANNOT_FORMAT_OBJECT_TO_FRACTION);
}
return ret;

View File

@ -22,6 +22,7 @@ import java.text.NumberFormat;
import java.text.ParsePosition;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.util.LocalizedFormats;
/**
* Formats a BigFraction number in proper format. The number format for each of
@ -233,7 +234,7 @@ public class ProperBigFractionFormat extends BigFractionFormat {
public void setWholeFormat(final NumberFormat format) {
if (format == null) {
throw MathRuntimeException.createIllegalArgumentException(
"whole format can not be null");
LocalizedFormats.NULL_WHOLE_FORMAT);
}
this.wholeFormat = format;
}

View File

@ -21,6 +21,7 @@ import java.text.NumberFormat;
import java.text.ParsePosition;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.util.LocalizedFormats;
import org.apache.commons.math.util.MathUtils;
/**
@ -226,7 +227,7 @@ public class ProperFractionFormat extends FractionFormat {
public void setWholeFormat(NumberFormat format) {
if (format == null) {
throw MathRuntimeException.createIllegalArgumentException(
"whole format can not be null");
LocalizedFormats.NULL_WHOLE_FORMAT);
}
this.wholeFormat = format;
}

View File

@ -18,6 +18,7 @@
package org.apache.commons.math.geometry;
import org.apache.commons.math.MathException;
import org.apache.commons.math.util.LocalizedFormats;
/** This class represents exceptions thrown while extractiong Cardan
* or Euler angles from a rotation.
@ -38,7 +39,7 @@ public class CardanEulerSingularityException
* if false it is related to EulerAngles
*/
public CardanEulerSingularityException(boolean isCardan) {
super(isCardan ? "Cardan angles singularity" : "Euler angles singularity");
super(isCardan ? LocalizedFormats.CARDAN_ANGLES_SINGULARITY : LocalizedFormats.EULER_ANGLES_SINGULARITY);
}
}

View File

@ -18,6 +18,7 @@
package org.apache.commons.math.geometry;
import org.apache.commons.math.MathException;
import org.apache.commons.math.util.Localizable;
/**
* This class represents exceptions thrown while building rotations
@ -38,9 +39,22 @@ public class NotARotationMatrixException
* 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)
* @deprecated as of 2.2 replaced by {@link #NotARotationMatrixException(Localizable, Object...)}
*/
@Deprecated
public NotARotationMatrixException(String specifier, Object ... parts) {
super(specifier, parts);
}
/**
* 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)
* @since 2.2
*/
public NotARotationMatrixException(Localizable specifier, Object ... parts) {
super(specifier, parts);
}
}

View File

@ -20,6 +20,7 @@ package org.apache.commons.math.geometry;
import java.io.Serializable;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.util.LocalizedFormats;
/**
* This class implements rotations in a three-dimensional space.
@ -172,7 +173,7 @@ public class Rotation implements Serializable {
double norm = axis.getNorm();
if (norm == 0) {
throw MathRuntimeException.createArithmeticException("zero norm for rotation axis");
throw MathRuntimeException.createArithmeticException(LocalizedFormats.ZERO_NORM_FOR_ROTATION_AXIS);
}
double halfAngle = -0.5 * angle;
@ -222,7 +223,7 @@ public class Rotation implements Serializable {
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",
LocalizedFormats.ROTATION_MATRIX_DIMENSIONS,
m.length, m[0].length);
}
@ -235,7 +236,7 @@ public class Rotation implements Serializable {
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}",
LocalizedFormats.CLOSEST_ORTHOGONAL_MATRIX_HAS_NEGATIVE_DETERMINANT,
det);
}
@ -316,7 +317,7 @@ public class Rotation implements Serializable {
double v1v1 = Vector3D.dotProduct(v1, v1);
double v2v2 = Vector3D.dotProduct(v2, v2);
if ((u1u1 == 0) || (u2u2 == 0) || (v1v1 == 0) || (v2v2 == 0)) {
throw MathRuntimeException.createIllegalArgumentException("zero norm for rotation defining vector");
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.ZERO_NORM_FOR_ROTATION_DEFINING_VECTOR);
}
double u1x = u1.getX();
@ -447,7 +448,7 @@ public class Rotation implements Serializable {
double normProduct = u.getNorm() * v.getNorm();
if (normProduct == 0) {
throw MathRuntimeException.createIllegalArgumentException("zero norm for rotation defining vector");
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.ZERO_NORM_FOR_ROTATION_DEFINING_VECTOR);
}
double dot = Vector3D.dotProduct(u, v);
@ -1035,7 +1036,7 @@ public class Rotation implements Serializable {
// the algorithm did not converge after 10 iterations
throw new NotARotationMatrixException(
"unable to orthogonalize matrix in {0} iterations",
LocalizedFormats.UNABLE_TO_ORTHOGONOLIZE_MATRIX,
i - 1);
}

View File

@ -20,6 +20,7 @@ package org.apache.commons.math.geometry;
import java.io.Serializable;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.util.LocalizedFormats;
import org.apache.commons.math.util.MathUtils;
/**
@ -283,7 +284,7 @@ public class Vector3D
public Vector3D normalize() {
double s = getNorm();
if (s == 0) {
throw MathRuntimeException.createArithmeticException("cannot normalize a zero norm vector");
throw MathRuntimeException.createArithmeticException(LocalizedFormats.CANNOT_NORMALIZE_A_ZERO_NORM_VECTOR);
}
return scalarMultiply(1 / s);
}
@ -307,7 +308,7 @@ public class Vector3D
double threshold = 0.6 * getNorm();
if (threshold == 0) {
throw MathRuntimeException.createArithmeticException("zero norm");
throw MathRuntimeException.createArithmeticException(LocalizedFormats.ZERO_NORM);
}
if ((x >= -threshold) && (x <= threshold)) {
@ -337,7 +338,7 @@ public class Vector3D
double normProduct = v1.getNorm() * v2.getNorm();
if (normProduct == 0) {
throw MathRuntimeException.createArithmeticException("zero norm");
throw MathRuntimeException.createArithmeticException(LocalizedFormats.ZERO_NORM);
}
double dot = dotProduct(v1, v2);

View File

@ -25,6 +25,7 @@ import java.util.Locale;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.util.CompositeFormat;
import org.apache.commons.math.util.LocalizedFormats;
/**
* Formats a 3D vector in components list format "{x; y; z}".
@ -241,7 +242,7 @@ public class Vector3DFormat extends CompositeFormat {
return format( (Vector3D)obj, toAppendTo, pos);
}
throw MathRuntimeException.createIllegalArgumentException("cannot format a {0} instance as a 3D vector",
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.CANNOT_FORMAT_INSTANCE_AS_3D_VECTOR,
obj.getClass().getName());
}

View File

@ -23,6 +23,7 @@ import java.util.Arrays;
import org.apache.commons.math.Field;
import org.apache.commons.math.FieldElement;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.util.LocalizedFormats;
/**
* Basic implementation of {@link FieldMatrix} methods regardless of the underlying storage.
@ -64,15 +65,13 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>> implements
protected AbstractFieldMatrix(final Field<T> field,
final int rowDimension, final int columnDimension)
throws IllegalArgumentException {
if (rowDimension <= 0 ) {
if (rowDimension < 1 ) {
throw MathRuntimeException.createIllegalArgumentException(
"invalid row dimension {0} (must be positive)",
rowDimension);
LocalizedFormats.INSUFFICIENT_DIMENSION, rowDimension, 1);
}
if (columnDimension <= 0) {
if (columnDimension < 1) {
throw MathRuntimeException.createIllegalArgumentException(
"invalid column dimension {0} (must be positive)",
columnDimension);
LocalizedFormats.INSUFFICIENT_DIMENSION, columnDimension, 1);
}
this.field = field;
}
@ -87,10 +86,10 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>> implements
protected static <T extends FieldElement<T>> Field<T> extractField(final T[][] d)
throws IllegalArgumentException {
if (d.length == 0) {
throw MathRuntimeException.createIllegalArgumentException("matrix must have at least one row");
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.AT_LEAST_ONE_ROW);
}
if (d[0].length == 0) {
throw MathRuntimeException.createIllegalArgumentException("matrix must have at least one column");
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.AT_LEAST_ONE_COLUMN);
}
return d[0][0].getField();
}
@ -105,7 +104,7 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>> implements
protected static <T extends FieldElement<T>> Field<T> extractField(final T[] d)
throws IllegalArgumentException {
if (d.length == 0) {
throw MathRuntimeException.createIllegalArgumentException("matrix must have at least one row");
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.AT_LEAST_ONE_ROW);
}
return d[0].getField();
}
@ -338,7 +337,7 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>> implements
final int columnsCount = endColumn + 1 - startColumn;
if ((destination.length < rowsCount) || (destination[0].length < columnsCount)) {
throw MathRuntimeException.createIllegalArgumentException(
"dimensions mismatch: got {0}x{1} but expected {2}x{3}",
LocalizedFormats.DIMENSIONS_MISMATCH_2x2,
destination.length, destination[0].length,
rowsCount, columnsCount);
}
@ -380,7 +379,7 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>> implements
if ((destination.length < selectedRows.length) ||
(destination[0].length < selectedColumns.length)) {
throw MathRuntimeException.createIllegalArgumentException(
"dimensions mismatch: got {0}x{1} but expected {2}x{3}",
LocalizedFormats.DIMENSIONS_MISMATCH_2x2,
destination.length, destination[0].length,
selectedRows.length, selectedColumns.length);
}
@ -401,18 +400,18 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>> implements
final int nRows = subMatrix.length;
if (nRows == 0) {
throw MathRuntimeException.createIllegalArgumentException("matrix must have at least one row");
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.AT_LEAST_ONE_ROW);
}
final int nCols = subMatrix[0].length;
if (nCols == 0) {
throw MathRuntimeException.createIllegalArgumentException("matrix must have at least one column");
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.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}",
LocalizedFormats.DIFFERENT_ROWS_LENGTHS,
nCols, subMatrix[r].length);
}
}
@ -454,7 +453,7 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>> implements
if ((matrix.getRowDimension() != 1) ||
(matrix.getColumnDimension() != nCols)) {
throw new InvalidMatrixException(
"dimensions mismatch: got {0}x{1} but expected {2}x{3}",
LocalizedFormats.DIMENSIONS_MISMATCH_2x2,
matrix.getRowDimension(), matrix.getColumnDimension(), 1, nCols);
}
for (int i = 0; i < nCols; ++i) {
@ -487,7 +486,7 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>> implements
if ((matrix.getRowDimension() != nRows) ||
(matrix.getColumnDimension() != 1)) {
throw new InvalidMatrixException(
"dimensions mismatch: got {0}x{1} but expected {2}x{3}",
LocalizedFormats.DIMENSIONS_MISMATCH_2x2,
matrix.getRowDimension(), matrix.getColumnDimension(), nRows, 1);
}
for (int i = 0; i < nRows; ++i) {
@ -510,7 +509,7 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>> implements
final int nCols = getColumnDimension();
if (vector.getDimension() != nCols) {
throw new InvalidMatrixException(
"dimensions mismatch: got {0}x{1} but expected {2}x{3}",
LocalizedFormats.DIMENSIONS_MISMATCH_2x2,
1, vector.getDimension(), 1, nCols);
}
for (int i = 0; i < nCols; ++i) {
@ -533,7 +532,7 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>> implements
final int nRows = getRowDimension();
if (vector.getDimension() != nRows) {
throw new InvalidMatrixException(
"dimensions mismatch: got {0}x{1} but expected {2}x{3}",
LocalizedFormats.DIMENSIONS_MISMATCH_2x2,
vector.getDimension(), 1, nRows, 1);
}
for (int i = 0; i < nRows; ++i) {
@ -565,7 +564,7 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>> implements
final int nCols = getColumnDimension();
if (array.length != nCols) {
throw new InvalidMatrixException(
"dimensions mismatch: got {0}x{1} but expected {2}x{3}",
LocalizedFormats.DIMENSIONS_MISMATCH_2x2,
1, array.length, 1, nCols);
}
for (int i = 0; i < nCols; ++i) {
@ -597,7 +596,7 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>> implements
final int nRows = getRowDimension();
if (array.length != nRows) {
throw new InvalidMatrixException(
"dimensions mismatch: got {0}x{1} but expected {2}x{3}",
LocalizedFormats.DIMENSIONS_MISMATCH_2x2,
array.length, 1, nRows, 1);
}
for (int i = 0; i < nRows; ++i) {
@ -676,7 +675,7 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>> implements
final int nCols = getColumnDimension();
if (v.length != nCols) {
throw MathRuntimeException.createIllegalArgumentException(
"vector length mismatch: got {0} but expected {1}",
LocalizedFormats.VECTOR_LENGTH_MISMATCH,
v.length, nCols);
}
@ -703,7 +702,7 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>> implements
final int nCols = getColumnDimension();
if (v.getDimension() != nCols) {
throw MathRuntimeException.createIllegalArgumentException(
"vector length mismatch: got {0} but expected {1}",
LocalizedFormats.VECTOR_LENGTH_MISMATCH,
v.getDimension(), nCols);
}
@ -728,7 +727,7 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>> implements
final int nCols = getColumnDimension();
if (v.length != nRows) {
throw MathRuntimeException.createIllegalArgumentException(
"vector length mismatch: got {0} but expected {1}",
LocalizedFormats.VECTOR_LENGTH_MISMATCH,
v.length, nRows);
}
@ -756,7 +755,7 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>> implements
final int nCols = getColumnDimension();
if (v.getDimension() != nRows) {
throw MathRuntimeException.createIllegalArgumentException(
"vector length mismatch: got {0} but expected {1}",
LocalizedFormats.VECTOR_LENGTH_MISMATCH,
v.getDimension(), nRows);
}
@ -1054,14 +1053,14 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>> implements
checkRowIndex(startRow);
checkRowIndex(endRow);
if (startRow > endRow) {
throw new MatrixIndexException("initial row {0} after final row {1}",
throw new MatrixIndexException(LocalizedFormats.INITIAL_ROW_AFTER_FINAL_ROW,
startRow, endRow);
}
checkColumnIndex(startColumn);
checkColumnIndex(endColumn);
if (startColumn > endColumn) {
throw new MatrixIndexException("initial column {0} after final column {1}",
throw new MatrixIndexException(LocalizedFormats.INITIAL_COLUMN_AFTER_FINAL_COLUMN,
startColumn, endColumn);
}
@ -1079,9 +1078,9 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>> implements
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");
throw new MatrixIndexException(LocalizedFormats.EMPTY_SELECTED_ROW_INDEX_ARRAY);
}
throw new MatrixIndexException("empty selected column index array");
throw new MatrixIndexException(LocalizedFormats.EMPTY_SELECTED_COLUMN_INDEX_ARRAY);
}
for (final int row : selectedRows) {
@ -1101,7 +1100,7 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>> implements
if ((getRowDimension() != m.getRowDimension()) ||
(getColumnDimension() != m.getColumnDimension())) {
throw MathRuntimeException.createIllegalArgumentException(
"{0}x{1} and {2}x{3} matrices are not addition compatible",
LocalizedFormats.NOT_ADDITION_COMPATIBLE_MATRICES,
getRowDimension(), getColumnDimension(),
m.getRowDimension(), m.getColumnDimension());
}
@ -1116,7 +1115,7 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>> implements
if ((getRowDimension() != m.getRowDimension()) ||
(getColumnDimension() != m.getColumnDimension())) {
throw MathRuntimeException.createIllegalArgumentException(
"{0}x{1} and {2}x{3} matrices are not subtraction compatible",
LocalizedFormats.NOT_SUBTRACTION_COMPATIBLE_MATRICES,
getRowDimension(), getColumnDimension(),
m.getRowDimension(), m.getColumnDimension());
}
@ -1130,7 +1129,7 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>> implements
protected void checkMultiplicationCompatible(final FieldMatrix<T> m) {
if (getColumnDimension() != m.getRowDimension()) {
throw MathRuntimeException.createIllegalArgumentException(
"{0}x{1} and {2}x{3} matrices are not multiplication compatible",
LocalizedFormats.NOT_MULTIPLICATION_COMPATIBLE_MATRICES,
getRowDimension(), getColumnDimension(),
m.getRowDimension(), m.getColumnDimension());
}

View File

@ -18,6 +18,7 @@
package org.apache.commons.math.linear;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.util.LocalizedFormats;
import org.apache.commons.math.util.MathUtils;
/**
@ -53,15 +54,13 @@ public abstract class AbstractRealMatrix implements RealMatrix {
*/
protected AbstractRealMatrix(final int rowDimension, final int columnDimension)
throws IllegalArgumentException {
if (rowDimension <= 0 ) {
if (rowDimension < 1 ) {
throw MathRuntimeException.createIllegalArgumentException(
"invalid row dimension {0} (must be positive)",
rowDimension);
LocalizedFormats.INSUFFICIENT_DIMENSION, rowDimension, 1);
}
if (columnDimension <= 0) {
throw MathRuntimeException.createIllegalArgumentException(
"invalid column dimension {0} (must be positive)",
columnDimension);
LocalizedFormats.INSUFFICIENT_DIMENSION, columnDimension, 1);
}
lu = null;
}
@ -311,7 +310,7 @@ public abstract class AbstractRealMatrix implements RealMatrix {
final int columnsCount = endColumn + 1 - startColumn;
if ((destination.length < rowsCount) || (destination[0].length < columnsCount)) {
throw MathRuntimeException.createIllegalArgumentException(
"dimensions mismatch: got {0}x{1} but expected {2}x{3}",
LocalizedFormats.DIMENSIONS_MISMATCH_2x2,
destination.length, destination[0].length,
rowsCount, columnsCount);
}
@ -353,7 +352,7 @@ public abstract class AbstractRealMatrix implements RealMatrix {
if ((destination.length < selectedRows.length) ||
(destination[0].length < selectedColumns.length)) {
throw MathRuntimeException.createIllegalArgumentException(
"dimensions mismatch: got {0}x{1} but expected {2}x{3}",
LocalizedFormats.DIMENSIONS_MISMATCH_2x2,
destination.length, destination[0].length,
selectedRows.length, selectedColumns.length);
}
@ -374,18 +373,18 @@ public abstract class AbstractRealMatrix implements RealMatrix {
final int nRows = subMatrix.length;
if (nRows == 0) {
throw MathRuntimeException.createIllegalArgumentException("matrix must have at least one row");
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.AT_LEAST_ONE_ROW);
}
final int nCols = subMatrix[0].length;
if (nCols == 0) {
throw MathRuntimeException.createIllegalArgumentException("matrix must have at least one column");
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.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}",
LocalizedFormats.DIFFERENT_ROWS_LENGTHS,
nCols, subMatrix[r].length);
}
}
@ -429,7 +428,7 @@ public abstract class AbstractRealMatrix implements RealMatrix {
if ((matrix.getRowDimension() != 1) ||
(matrix.getColumnDimension() != nCols)) {
throw new InvalidMatrixException(
"dimensions mismatch: got {0}x{1} but expected {2}x{3}",
LocalizedFormats.DIMENSIONS_MISMATCH_2x2,
matrix.getRowDimension(), matrix.getColumnDimension(), 1, nCols);
}
for (int i = 0; i < nCols; ++i) {
@ -462,7 +461,7 @@ public abstract class AbstractRealMatrix implements RealMatrix {
if ((matrix.getRowDimension() != nRows) ||
(matrix.getColumnDimension() != 1)) {
throw new InvalidMatrixException(
"dimensions mismatch: got {0}x{1} but expected {2}x{3}",
LocalizedFormats.DIMENSIONS_MISMATCH_2x2,
matrix.getRowDimension(), matrix.getColumnDimension(), nRows, 1);
}
for (int i = 0; i < nRows; ++i) {
@ -485,7 +484,7 @@ public abstract class AbstractRealMatrix implements RealMatrix {
final int nCols = getColumnDimension();
if (vector.getDimension() != nCols) {
throw new InvalidMatrixException(
"dimensions mismatch: got {0}x{1} but expected {2}x{3}",
LocalizedFormats.DIMENSIONS_MISMATCH_2x2,
1, vector.getDimension(), 1, nCols);
}
for (int i = 0; i < nCols; ++i) {
@ -508,7 +507,7 @@ public abstract class AbstractRealMatrix implements RealMatrix {
final int nRows = getRowDimension();
if (vector.getDimension() != nRows) {
throw new InvalidMatrixException(
"dimensions mismatch: got {0}x{1} but expected {2}x{3}",
LocalizedFormats.DIMENSIONS_MISMATCH_2x2,
vector.getDimension(), 1, nRows, 1);
}
for (int i = 0; i < nRows; ++i) {
@ -540,7 +539,7 @@ public abstract class AbstractRealMatrix implements RealMatrix {
final int nCols = getColumnDimension();
if (array.length != nCols) {
throw new InvalidMatrixException(
"dimensions mismatch: got {0}x{1} but expected {2}x{3}",
LocalizedFormats.DIMENSIONS_MISMATCH_2x2,
1, array.length, 1, nCols);
}
for (int i = 0; i < nCols; ++i) {
@ -572,7 +571,7 @@ public abstract class AbstractRealMatrix implements RealMatrix {
final int nRows = getRowDimension();
if (array.length != nRows) {
throw new InvalidMatrixException(
"dimensions mismatch: got {0}x{1} but expected {2}x{3}",
LocalizedFormats.DIMENSIONS_MISMATCH_2x2,
array.length, 1, nRows, 1);
}
for (int i = 0; i < nRows; ++i) {
@ -677,7 +676,7 @@ public abstract class AbstractRealMatrix implements RealMatrix {
final int nCols = getColumnDimension();
if (v.length != nCols) {
throw MathRuntimeException.createIllegalArgumentException(
"vector length mismatch: got {0} but expected {1}",
LocalizedFormats.VECTOR_LENGTH_MISMATCH,
v.length, nCols);
}
@ -704,7 +703,7 @@ public abstract class AbstractRealMatrix implements RealMatrix {
final int nCols = getColumnDimension();
if (v.getDimension() != nCols) {
throw MathRuntimeException.createIllegalArgumentException(
"vector length mismatch: got {0} but expected {1}",
LocalizedFormats.VECTOR_LENGTH_MISMATCH,
v.getDimension(), nCols);
}
@ -729,7 +728,7 @@ public abstract class AbstractRealMatrix implements RealMatrix {
final int nCols = getColumnDimension();
if (v.length != nRows) {
throw MathRuntimeException.createIllegalArgumentException(
"vector length mismatch: got {0} but expected {1}",
LocalizedFormats.VECTOR_LENGTH_MISMATCH,
v.length, nRows);
}
@ -757,7 +756,7 @@ public abstract class AbstractRealMatrix implements RealMatrix {
final int nCols = getColumnDimension();
if (v.getDimension() != nRows) {
throw MathRuntimeException.createIllegalArgumentException(
"vector length mismatch: got {0} but expected {1}",
LocalizedFormats.VECTOR_LENGTH_MISMATCH,
v.getDimension(), nRows);
}

View File

@ -25,6 +25,7 @@ import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.analysis.BinaryFunction;
import org.apache.commons.math.analysis.UnivariateRealFunction;
import org.apache.commons.math.analysis.ComposableFunction;
import org.apache.commons.math.util.LocalizedFormats;
/**
* This class provides default basic implementations for many methods in the
@ -56,8 +57,7 @@ public abstract class AbstractRealVector implements RealVector {
double d = getDimension();
if (d != n) {
throw MathRuntimeException.createIllegalArgumentException(
"vector length mismatch: got {0} but expected {1}",
d, n);
LocalizedFormats.VECTOR_LENGTH_MISMATCH, d, n);
}
}

View File

@ -22,6 +22,7 @@ import java.io.Serializable;
import org.apache.commons.math.Field;
import org.apache.commons.math.FieldElement;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.util.LocalizedFormats;
/**
* Implementation of FieldMatrix<T> using a {@link FieldElement}[][] array to store entries.
@ -39,26 +40,6 @@ public class Array2DRowFieldMatrix<T extends FieldElement<T>> extends AbstractFi
/** Serializable version identifier */
private static final long serialVersionUID = 7260756672015356458L;
/** Message for at least one row. */
private static final String AT_LEAST_ONE_ROW_MESSAGE =
"matrix must have at least one row";
/** Message for at least one column. */
private static final String AT_LEAST_ONE_COLUMN_MESSAGE =
"matrix must have at least one column";
/** Message for different rows lengths. */
private static final String DIFFERENT_ROWS_LENGTHS_MESSAGE =
"some rows have length {0} while others have length {1}";
/** Message for no entry at selected indices. */
private static final String NO_ENTRY_MESSAGE =
"no entry at indices ({0}, {1}) in a {2}x{3} matrix";
/** Message for vector lengths mismatch. */
private static final String VECTOR_LENGTHS_MISMATCH =
"vector length mismatch: got {0} but expected {1}";
/** Entries of the matrix */
protected T[][] data;
@ -132,17 +113,17 @@ public class Array2DRowFieldMatrix<T extends FieldElement<T>> extends AbstractFi
final int nRows = d.length;
if (nRows == 0) {
throw MathRuntimeException.createIllegalArgumentException(
AT_LEAST_ONE_ROW_MESSAGE);
LocalizedFormats.AT_LEAST_ONE_ROW);
}
final int nCols = d[0].length;
if (nCols == 0) {
throw MathRuntimeException.createIllegalArgumentException(
AT_LEAST_ONE_COLUMN_MESSAGE);
LocalizedFormats.AT_LEAST_ONE_COLUMN);
}
for (int r = 1; r < nRows; r++) {
if (d[r].length != nCols) {
throw MathRuntimeException.createIllegalArgumentException(
DIFFERENT_ROWS_LENGTHS_MESSAGE, nCols, d[r].length);
LocalizedFormats.DIFFERENT_ROWS_LENGTHS, nCols, d[r].length);
}
}
data = d;
@ -327,28 +308,28 @@ public class Array2DRowFieldMatrix<T extends FieldElement<T>> extends AbstractFi
if (data == null) {
if (row > 0) {
throw MathRuntimeException.createIllegalStateException(
"first {0} rows are not initialized yet", row);
LocalizedFormats.FIRST_ROWS_NOT_INITIALIZED_YET, row);
}
if (column > 0) {
throw MathRuntimeException.createIllegalStateException(
"first {0} columns are not initialized yet", column);
LocalizedFormats.FIRST_COLUMNS_NOT_INITIALIZED_YET, column);
}
final int nRows = subMatrix.length;
if (nRows == 0) {
throw MathRuntimeException.createIllegalArgumentException(
AT_LEAST_ONE_ROW_MESSAGE);
LocalizedFormats.AT_LEAST_ONE_ROW);
}
final int nCols = subMatrix[0].length;
if (nCols == 0) {
throw MathRuntimeException.createIllegalArgumentException(
AT_LEAST_ONE_COLUMN_MESSAGE);
LocalizedFormats.AT_LEAST_ONE_COLUMN);
}
data = buildArray(getField(), subMatrix.length, nCols);
for (int i = 0; i < data.length; ++i) {
if (subMatrix[i].length != nCols) {
throw MathRuntimeException.createIllegalArgumentException(
DIFFERENT_ROWS_LENGTHS_MESSAGE, nCols, subMatrix[i].length);
LocalizedFormats.DIFFERENT_ROWS_LENGTHS, nCols, subMatrix[i].length);
}
System.arraycopy(subMatrix[i], 0, data[i + row], column, nCols);
}
@ -366,7 +347,7 @@ public class Array2DRowFieldMatrix<T extends FieldElement<T>> extends AbstractFi
return data[row][column];
} catch (ArrayIndexOutOfBoundsException e) {
throw new MatrixIndexException(
NO_ENTRY_MESSAGE, row, column, getRowDimension(), getColumnDimension());
LocalizedFormats.NO_SUCH_MATRIX_ENTRY, row, column, getRowDimension(), getColumnDimension());
}
}
@ -378,7 +359,7 @@ public class Array2DRowFieldMatrix<T extends FieldElement<T>> extends AbstractFi
data[row][column] = value;
} catch (ArrayIndexOutOfBoundsException e) {
throw new MatrixIndexException(
NO_ENTRY_MESSAGE, row, column, getRowDimension(), getColumnDimension());
LocalizedFormats.NO_SUCH_MATRIX_ENTRY, row, column, getRowDimension(), getColumnDimension());
}
}
@ -390,7 +371,7 @@ public class Array2DRowFieldMatrix<T extends FieldElement<T>> extends AbstractFi
data[row][column] = data[row][column].add(increment);
} catch (ArrayIndexOutOfBoundsException e) {
throw new MatrixIndexException(
NO_ENTRY_MESSAGE, row, column, getRowDimension(), getColumnDimension());
LocalizedFormats.NO_SUCH_MATRIX_ENTRY, row, column, getRowDimension(), getColumnDimension());
}
}
@ -402,7 +383,7 @@ public class Array2DRowFieldMatrix<T extends FieldElement<T>> extends AbstractFi
data[row][column] = data[row][column].multiply(factor);
} catch (ArrayIndexOutOfBoundsException e) {
throw new MatrixIndexException(
NO_ENTRY_MESSAGE, row, column, getRowDimension(), getColumnDimension());
LocalizedFormats.NO_SUCH_MATRIX_ENTRY, row, column, getRowDimension(), getColumnDimension());
}
}
@ -426,7 +407,7 @@ public class Array2DRowFieldMatrix<T extends FieldElement<T>> extends AbstractFi
final int nCols = this.getColumnDimension();
if (v.length != nCols) {
throw MathRuntimeException.createIllegalArgumentException(
VECTOR_LENGTHS_MISMATCH, v.length, nCols);
LocalizedFormats.VECTOR_LENGTH_MISMATCH, v.length, nCols);
}
final T[] out = buildArray(getField(), nRows);
for (int row = 0; row < nRows; row++) {
@ -449,7 +430,7 @@ public class Array2DRowFieldMatrix<T extends FieldElement<T>> extends AbstractFi
final int nCols = getColumnDimension();
if (v.length != nRows) {
throw MathRuntimeException.createIllegalArgumentException(
VECTOR_LENGTHS_MISMATCH, v.length, nRows);
LocalizedFormats.VECTOR_LENGTH_MISMATCH, v.length, nRows);
}
final T[] out = buildArray(getField(), nCols);

View File

@ -20,6 +20,7 @@ package org.apache.commons.math.linear;
import java.io.Serializable;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.util.LocalizedFormats;
/**
* Implementation of RealMatrix using a double[][] array to store entries and
@ -54,26 +55,6 @@ public class Array2DRowRealMatrix extends AbstractRealMatrix implements Serializ
/** Serializable version identifier */
private static final long serialVersionUID = -1067294169172445528L;
/** Message for at least one row. */
private static final String AT_LEAST_ONE_ROW_MESSAGE =
"matrix must have at least one row";
/** Message for at least one column. */
private static final String AT_LEAST_ONE_COLUMN_MESSAGE =
"matrix must have at least one column";
/** Message for different rows lengths. */
private static final String DIFFERENT_ROWS_LENGTHS_MESSAGE =
"some rows have length {0} while others have length {1}";
/** Message for no entry at selected indices. */
private static final String NO_ENTRY_MESSAGE =
"no entry at indices ({0}, {1}) in a {2}x{3} matrix";
/** Message for vector lengths mismatch. */
private static final String VECTOR_LENGTHS_MISMATCH =
"vector length mismatch: got {0} but expected {1}";
/** Entries of the matrix */
protected double data[][];
@ -141,17 +122,17 @@ public class Array2DRowRealMatrix extends AbstractRealMatrix implements Serializ
final int nRows = d.length;
if (nRows == 0) {
throw MathRuntimeException.createIllegalArgumentException(
AT_LEAST_ONE_ROW_MESSAGE);
LocalizedFormats.AT_LEAST_ONE_ROW);
}
final int nCols = d[0].length;
if (nCols == 0) {
throw MathRuntimeException.createIllegalArgumentException(
AT_LEAST_ONE_COLUMN_MESSAGE);
LocalizedFormats.AT_LEAST_ONE_COLUMN);
}
for (int r = 1; r < nRows; r++) {
if (d[r].length != nCols) {
throw MathRuntimeException.createIllegalArgumentException(
DIFFERENT_ROWS_LENGTHS_MESSAGE, nCols, d[r].length);
LocalizedFormats.DIFFERENT_ROWS_LENGTHS, nCols, d[r].length);
}
}
data = d;
@ -335,28 +316,28 @@ public class Array2DRowRealMatrix extends AbstractRealMatrix implements Serializ
if (data == null) {
if (row > 0) {
throw MathRuntimeException.createIllegalStateException(
"first {0} rows are not initialized yet", row);
LocalizedFormats.FIRST_ROWS_NOT_INITIALIZED_YET, row);
}
if (column > 0) {
throw MathRuntimeException.createIllegalStateException(
"first {0} columns are not initialized yet", column);
LocalizedFormats.FIRST_COLUMNS_NOT_INITIALIZED_YET, column);
}
final int nRows = subMatrix.length;
if (nRows == 0) {
throw MathRuntimeException.createIllegalArgumentException(
AT_LEAST_ONE_ROW_MESSAGE);
LocalizedFormats.AT_LEAST_ONE_ROW);
}
final int nCols = subMatrix[0].length;
if (nCols == 0) {
throw MathRuntimeException.createIllegalArgumentException(
AT_LEAST_ONE_COLUMN_MESSAGE);
LocalizedFormats.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(
DIFFERENT_ROWS_LENGTHS_MESSAGE, nCols, subMatrix[i].length);
LocalizedFormats.DIFFERENT_ROWS_LENGTHS, nCols, subMatrix[i].length);
}
System.arraycopy(subMatrix[i], 0, data[i + row], column, nCols);
}
@ -374,7 +355,7 @@ public class Array2DRowRealMatrix extends AbstractRealMatrix implements Serializ
return data[row][column];
} catch (ArrayIndexOutOfBoundsException e) {
throw new MatrixIndexException(
NO_ENTRY_MESSAGE, row, column, getRowDimension(), getColumnDimension());
LocalizedFormats.NO_SUCH_MATRIX_ENTRY, row, column, getRowDimension(), getColumnDimension());
}
}
@ -386,7 +367,7 @@ public class Array2DRowRealMatrix extends AbstractRealMatrix implements Serializ
data[row][column] = value;
} catch (ArrayIndexOutOfBoundsException e) {
throw new MatrixIndexException(
NO_ENTRY_MESSAGE, row, column, getRowDimension(), getColumnDimension());
LocalizedFormats.NO_SUCH_MATRIX_ENTRY, row, column, getRowDimension(), getColumnDimension());
}
}
@ -398,7 +379,7 @@ public class Array2DRowRealMatrix extends AbstractRealMatrix implements Serializ
data[row][column] += increment;
} catch (ArrayIndexOutOfBoundsException e) {
throw new MatrixIndexException(
NO_ENTRY_MESSAGE, row, column, getRowDimension(), getColumnDimension());
LocalizedFormats.NO_SUCH_MATRIX_ENTRY, row, column, getRowDimension(), getColumnDimension());
}
}
@ -410,7 +391,7 @@ public class Array2DRowRealMatrix extends AbstractRealMatrix implements Serializ
data[row][column] *= factor;
} catch (ArrayIndexOutOfBoundsException e) {
throw new MatrixIndexException(
NO_ENTRY_MESSAGE, row, column, getRowDimension(), getColumnDimension());
LocalizedFormats.NO_SUCH_MATRIX_ENTRY, row, column, getRowDimension(), getColumnDimension());
}
}
@ -434,7 +415,7 @@ public class Array2DRowRealMatrix extends AbstractRealMatrix implements Serializ
final int nCols = this.getColumnDimension();
if (v.length != nCols) {
throw MathRuntimeException.createIllegalArgumentException(
VECTOR_LENGTHS_MISMATCH, v.length, nCols);
LocalizedFormats.VECTOR_LENGTH_MISMATCH, v.length, nCols);
}
final double[] out = new double[nRows];
for (int row = 0; row < nRows; row++) {
@ -457,7 +438,7 @@ public class Array2DRowRealMatrix extends AbstractRealMatrix implements Serializ
final int nCols = getColumnDimension();
if (v.length != nRows) {
throw MathRuntimeException.createIllegalArgumentException(
VECTOR_LENGTHS_MISMATCH, v.length, nRows);
LocalizedFormats.VECTOR_LENGTH_MISMATCH, v.length, nRows);
}
final double[] out = new double[nCols];

View File

@ -23,6 +23,7 @@ import java.util.Arrays;
import org.apache.commons.math.Field;
import org.apache.commons.math.FieldElement;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.util.LocalizedFormats;
/**
* This class implements the {@link FieldVector} interface with a {@link FieldElement} array.
@ -88,7 +89,7 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
data = d.clone();
} catch (ArrayIndexOutOfBoundsException e) {
throw MathRuntimeException.createIllegalArgumentException(
"vector must have at least one element");
LocalizedFormats.VECTOR_MUST_HAVE_AT_LEAST_ONE_ELEMENT);
}
}
@ -113,7 +114,7 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
data = copyArray ? d.clone() : d;
} catch (ArrayIndexOutOfBoundsException e) {
throw MathRuntimeException.createIllegalArgumentException(
"vector must have at least one element");
LocalizedFormats.VECTOR_MUST_HAVE_AT_LEAST_ONE_ELEMENT);
}
}
@ -126,7 +127,7 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
public ArrayFieldVector(T[] d, int pos, int size) {
if (d.length < pos + size) {
throw MathRuntimeException.createIllegalArgumentException(
"position {0} and size {1} don't fit to the size of the input array {2}",
LocalizedFormats.POSITION_SIZE_MISMATCH_INPUT_ARRAY,
pos, size, d.length);
}
field = d[0].getField();
@ -215,7 +216,7 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
field = data[0].getField();
} catch (ArrayIndexOutOfBoundsException e) {
throw MathRuntimeException.createIllegalArgumentException(
"vector must have at least one element");
LocalizedFormats.VECTOR_MUST_HAVE_AT_LEAST_ONE_ELEMENT);
}
}
@ -715,7 +716,7 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
throws IllegalArgumentException {
if (data.length != n) {
throw MathRuntimeException.createIllegalArgumentException(
"vector length mismatch: got {0} but expected {1}",
LocalizedFormats.VECTOR_LENGTH_MISMATCH,
data.length, n);
}
}

View File

@ -21,6 +21,7 @@ import java.util.Arrays;
import java.util.Iterator;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.util.LocalizedFormats;
import org.apache.commons.math.util.MathUtils;
/**
@ -30,10 +31,6 @@ import org.apache.commons.math.util.MathUtils;
*/
public class ArrayRealVector extends AbstractRealVector implements Serializable {
/** Message for non fitting position and size. */
private static final String NON_FITTING_POSITION_AND_SIZE_MESSAGE =
"position {0} and size {1} don't fit to the size of the input array {2}";
/** Serializable version identifier. */
private static final long serialVersionUID = -1097961340710804027L;
@ -103,7 +100,7 @@ public class ArrayRealVector extends AbstractRealVector implements Serializable
throw new NullPointerException();
}
if (d.length == 0) {
throw MathRuntimeException.createIllegalArgumentException("vector must have at least one element");
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.VECTOR_MUST_HAVE_AT_LEAST_ONE_ELEMENT);
}
data = copyArray ? d.clone() : d;
}
@ -117,7 +114,7 @@ public class ArrayRealVector extends AbstractRealVector implements Serializable
public ArrayRealVector(double[] d, int pos, int size) {
if (d.length < pos + size) {
throw MathRuntimeException.createIllegalArgumentException(
NON_FITTING_POSITION_AND_SIZE_MESSAGE, pos, size, d.length);
LocalizedFormats.POSITION_SIZE_MISMATCH_INPUT_ARRAY, pos, size, d.length);
}
data = new double[size];
System.arraycopy(d, pos, data, 0, size);
@ -143,7 +140,7 @@ public class ArrayRealVector extends AbstractRealVector implements Serializable
public ArrayRealVector(Double[] d, int pos, int size) {
if (d.length < pos + size) {
throw MathRuntimeException.createIllegalArgumentException(
NON_FITTING_POSITION_AND_SIZE_MESSAGE, pos, size, d.length);
LocalizedFormats.POSITION_SIZE_MISMATCH_INPUT_ARRAY, pos, size, d.length);
}
data = new double[size];
for (int i = pos; i < pos + size; i++) {
@ -910,7 +907,7 @@ public class ArrayRealVector extends AbstractRealVector implements Serializable
public RealVector unitVector() throws ArithmeticException {
final double norm = getNorm();
if (norm == 0) {
throw MathRuntimeException.createArithmeticException("zero norm");
throw MathRuntimeException.createArithmeticException(LocalizedFormats.ZERO_NORM);
}
return mapDivide(norm);
}
@ -920,7 +917,7 @@ public class ArrayRealVector extends AbstractRealVector implements Serializable
public void unitize() throws ArithmeticException {
final double norm = getNorm();
if (norm == 0) {
throw MathRuntimeException.createArithmeticException("cannot normalize a zero norm vector");
throw MathRuntimeException.createArithmeticException(LocalizedFormats.CANNOT_NORMALIZE_A_ZERO_NORM_VECTOR);
}
mapDivideToSelf(norm);
}
@ -1135,7 +1132,7 @@ public class ArrayRealVector extends AbstractRealVector implements Serializable
throws IllegalArgumentException {
if (data.length != n) {
throw MathRuntimeException.createIllegalArgumentException(
"vector length mismatch: got {0} but expected {1}",
LocalizedFormats.VECTOR_LENGTH_MISMATCH,
data.length, n);
}
}

View File

@ -20,6 +20,7 @@ import java.io.Serializable;
import java.math.BigDecimal;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.util.LocalizedFormats;
/**
* Implementation of {@link BigMatrix} using a BigDecimal[][] array to store entries
@ -101,15 +102,13 @@ public class BigMatrixImpl implements BigMatrix, Serializable {
* positive
*/
public BigMatrixImpl(int rowDimension, int columnDimension) {
if (rowDimension <= 0 ) {
if (rowDimension < 1 ) {
throw MathRuntimeException.createIllegalArgumentException(
"invalid row dimension {0} (must be positive)",
rowDimension);
LocalizedFormats.INSUFFICIENT_DIMENSION, rowDimension, 1);
}
if (columnDimension <= 0) {
if (columnDimension < 1) {
throw MathRuntimeException.createIllegalArgumentException(
"invalid column dimension {0} (must be positive)",
columnDimension);
LocalizedFormats.INSUFFICIENT_DIMENSION, columnDimension, 1);
}
data = new BigDecimal[rowDimension][columnDimension];
lu = null;
@ -156,17 +155,17 @@ public class BigMatrixImpl implements BigMatrix, Serializable {
}
final int nRows = d.length;
if (nRows == 0) {
throw MathRuntimeException.createIllegalArgumentException("matrix must have at least one row");
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.AT_LEAST_ONE_ROW);
}
final int nCols = d[0].length;
if (nCols == 0) {
throw MathRuntimeException.createIllegalArgumentException("matrix must have at least one column");
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.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}",
LocalizedFormats.DIFFERENT_ROWS_LENGTHS,
nCols, d[r].length);
}
}
@ -189,17 +188,17 @@ public class BigMatrixImpl implements BigMatrix, Serializable {
public BigMatrixImpl(double[][] d) {
final int nRows = d.length;
if (nRows == 0) {
throw MathRuntimeException.createIllegalArgumentException("matrix must have at least one row");
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.AT_LEAST_ONE_ROW);
}
final int nCols = d[0].length;
if (nCols == 0) {
throw MathRuntimeException.createIllegalArgumentException("matrix must have at least one column");
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.AT_LEAST_ONE_COLUMN);
}
for (int row = 1; row < nRows; row++) {
if (d[row].length != nCols) {
throw MathRuntimeException.createIllegalArgumentException(
"some rows have length {0} while others have length {1}",
LocalizedFormats.DIFFERENT_ROWS_LENGTHS,
nCols, d[row].length);
}
}
@ -219,17 +218,17 @@ public class BigMatrixImpl implements BigMatrix, Serializable {
public BigMatrixImpl(String[][] d) {
final int nRows = d.length;
if (nRows == 0) {
throw MathRuntimeException.createIllegalArgumentException("matrix must have at least one row");
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.AT_LEAST_ONE_ROW);
}
final int nCols = d[0].length;
if (nCols == 0) {
throw MathRuntimeException.createIllegalArgumentException("matrix must have at least one column");
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.AT_LEAST_ONE_COLUMN);
}
for (int row = 1; row < nRows; row++) {
if (d[row].length != nCols) {
throw MathRuntimeException.createIllegalArgumentException(
"some rows have length {0} while others have length {1}",
LocalizedFormats.DIFFERENT_ROWS_LENGTHS,
nCols, d[row].length);
}
}
@ -604,14 +603,14 @@ public class BigMatrixImpl implements BigMatrix, Serializable {
MatrixUtils.checkRowIndex(this, startRow);
MatrixUtils.checkRowIndex(this, endRow);
if (startRow > endRow) {
throw new MatrixIndexException("initial row {0} after final row {1}",
throw new MatrixIndexException(LocalizedFormats.INITIAL_ROW_AFTER_FINAL_ROW,
startRow, endRow);
}
MatrixUtils.checkColumnIndex(this, startColumn);
MatrixUtils.checkColumnIndex(this, endColumn);
if (startColumn > endColumn) {
throw new MatrixIndexException("initial column {0} after final column {1}",
throw new MatrixIndexException(LocalizedFormats.INITIAL_COLUMN_AFTER_FINAL_COLUMN,
startColumn, endColumn);
}
@ -643,9 +642,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");
throw new MatrixIndexException(LocalizedFormats.EMPTY_SELECTED_ROW_INDEX_ARRAY);
}
throw new MatrixIndexException("empty selected column index array");
throw new MatrixIndexException(LocalizedFormats.EMPTY_SELECTED_COLUMN_INDEX_ARRAY);
}
final BigDecimal[][] subMatrixData =
@ -703,18 +702,18 @@ public class BigMatrixImpl implements BigMatrix, Serializable {
final int nRows = subMatrix.length;
if (nRows == 0) {
throw MathRuntimeException.createIllegalArgumentException("matrix must have at least one row");
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.AT_LEAST_ONE_ROW);
}
final int nCols = subMatrix[0].length;
if (nCols == 0) {
throw MathRuntimeException.createIllegalArgumentException("matrix must have at least one column");
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.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}",
LocalizedFormats.DIFFERENT_ROWS_LENGTHS,
nCols, subMatrix[r].length);
}
}
@ -722,12 +721,12 @@ public class BigMatrixImpl implements BigMatrix, Serializable {
if (data == null) {
if (row > 0) {
throw MathRuntimeException.createIllegalStateException(
"first {0} rows are not initialized yet",
LocalizedFormats.FIRST_ROWS_NOT_INITIALIZED_YET,
row);
}
if (column > 0) {
throw MathRuntimeException.createIllegalStateException(
"first {0} columns are not initialized yet",
LocalizedFormats.FIRST_COLUMNS_NOT_INITIALIZED_YET,
column);
}
data = new BigDecimal[nRows][nCols];
@ -881,7 +880,7 @@ public class BigMatrixImpl implements BigMatrix, Serializable {
return data[row][column];
} catch (ArrayIndexOutOfBoundsException e) {
throw new MatrixIndexException(
"no entry at indices ({0}, {1}) in a {2}x{3} matrix",
LocalizedFormats.NO_SUCH_MATRIX_ENTRY,
row, column, getRowDimension(), getColumnDimension());
}
}
@ -1027,7 +1026,7 @@ public class BigMatrixImpl implements BigMatrix, Serializable {
public BigDecimal[] operate(BigDecimal[] v) throws IllegalArgumentException {
if (v.length != getColumnDimension()) {
throw MathRuntimeException.createIllegalArgumentException(
"vector length mismatch: got {0} but expected {1}",
LocalizedFormats.VECTOR_LENGTH_MISMATCH,
v.length, getColumnDimension() );
}
final int nRows = this.getRowDimension();
@ -1069,7 +1068,7 @@ public class BigMatrixImpl implements BigMatrix, Serializable {
final int nRows = this.getRowDimension();
if (v.length != nRows) {
throw MathRuntimeException.createIllegalArgumentException(
"vector length mismatch: got {0} but expected {1}",
LocalizedFormats.VECTOR_LENGTH_MISMATCH,
v.length, nRows );
}
final int nCols = this.getColumnDimension();
@ -1099,7 +1098,7 @@ public class BigMatrixImpl implements BigMatrix, Serializable {
final int nRows = this.getRowDimension();
if (b.length != nRows) {
throw MathRuntimeException.createIllegalArgumentException(
"vector length mismatch: got {0} but expected {1}",
LocalizedFormats.VECTOR_LENGTH_MISMATCH,
b.length, nRows);
}
final BigMatrix bMatrix = new BigMatrixImpl(b);
@ -1144,7 +1143,7 @@ public class BigMatrixImpl implements BigMatrix, Serializable {
public BigMatrix solve(BigMatrix b) throws IllegalArgumentException, InvalidMatrixException {
if (b.getRowDimension() != getRowDimension()) {
throw MathRuntimeException.createIllegalArgumentException(
"dimensions mismatch: got {0}x{1} but expected {2}x{3}",
LocalizedFormats.DIMENSIONS_MISMATCH_2x2,
b.getRowDimension(), b.getColumnDimension(), getRowDimension(), "n");
}
if (!isSquare()) {

View File

@ -22,6 +22,7 @@ import java.io.Serializable;
import org.apache.commons.math.Field;
import org.apache.commons.math.FieldElement;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.util.LocalizedFormats;
/**
* Cache-friendly implementation of FieldMatrix using a flat arrays to store
@ -218,7 +219,7 @@ public class BlockFieldMatrix<T extends FieldElement<T>> extends AbstractFieldMa
final int length = rawData[i].length;
if (length != columns) {
throw MathRuntimeException.createIllegalArgumentException(
"some rows have length {0} while others have length {1}",
LocalizedFormats.DIFFERENT_ROWS_LENGTHS,
columns, length);
}
}
@ -809,7 +810,7 @@ public class BlockFieldMatrix<T extends FieldElement<T>> extends AbstractFieldMa
// safety checks
final int refLength = subMatrix[0].length;
if (refLength < 1) {
throw MathRuntimeException.createIllegalArgumentException("matrix must have at least one column");
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.AT_LEAST_ONE_COLUMN);
}
final int endRow = row + subMatrix.length - 1;
final int endColumn = column + refLength - 1;
@ -817,7 +818,7 @@ public class BlockFieldMatrix<T extends FieldElement<T>> extends AbstractFieldMa
for (final T[] subRow : subMatrix) {
if (subRow.length != refLength) {
throw MathRuntimeException.createIllegalArgumentException(
"some rows have length {0} while others have length {1}",
LocalizedFormats.DIFFERENT_ROWS_LENGTHS,
refLength, subRow.length);
}
}
@ -917,7 +918,7 @@ public class BlockFieldMatrix<T extends FieldElement<T>> extends AbstractFieldMa
if ((matrix.getRowDimension() != 1) ||
(matrix.getColumnDimension() != nCols)) {
throw new InvalidMatrixException(
"dimensions mismatch: got {0}x{1} but expected {2}x{3}",
LocalizedFormats.DIMENSIONS_MISMATCH_2x2,
matrix.getRowDimension(), matrix.getColumnDimension(),
1, nCols);
}
@ -1006,7 +1007,7 @@ public class BlockFieldMatrix<T extends FieldElement<T>> extends AbstractFieldMa
if ((matrix.getRowDimension() != nRows) ||
(matrix.getColumnDimension() != 1)) {
throw new InvalidMatrixException(
"dimensions mismatch: got {0}x{1} but expected {2}x{3}",
LocalizedFormats.DIMENSIONS_MISMATCH_2x2,
matrix.getRowDimension(), matrix.getColumnDimension(),
nRows, 1);
}
@ -1134,7 +1135,7 @@ public class BlockFieldMatrix<T extends FieldElement<T>> extends AbstractFieldMa
final int nCols = getColumnDimension();
if (array.length != nCols) {
throw new InvalidMatrixException(
"dimensions mismatch: got {0}x{1} but expected {2}x{3}",
LocalizedFormats.DIMENSIONS_MISMATCH_2x2,
1, array.length, 1, nCols);
}
@ -1185,7 +1186,7 @@ public class BlockFieldMatrix<T extends FieldElement<T>> extends AbstractFieldMa
final int nRows = getRowDimension();
if (array.length != nRows) {
throw new InvalidMatrixException(
"dimensions mismatch: got {0}x{1} but expected {2}x{3}",
LocalizedFormats.DIMENSIONS_MISMATCH_2x2,
array.length, 1, nRows, 1);
}
@ -1216,7 +1217,7 @@ public class BlockFieldMatrix<T extends FieldElement<T>> extends AbstractFieldMa
return blocks[iBlock * blockColumns + jBlock][k];
} catch (ArrayIndexOutOfBoundsException e) {
throw new MatrixIndexException(
"no entry at indices ({0}, {1}) in a {2}x{3} matrix",
LocalizedFormats.NO_SUCH_MATRIX_ENTRY,
row, column, getRowDimension(), getColumnDimension());
}
}
@ -1233,7 +1234,7 @@ public class BlockFieldMatrix<T extends FieldElement<T>> extends AbstractFieldMa
blocks[iBlock * blockColumns + jBlock][k] = value;
} catch (ArrayIndexOutOfBoundsException e) {
throw new MatrixIndexException(
"no entry at indices ({0}, {1}) in a {2}x{3} matrix",
LocalizedFormats.NO_SUCH_MATRIX_ENTRY,
row, column, getRowDimension(), getColumnDimension());
}
}
@ -1251,7 +1252,7 @@ public class BlockFieldMatrix<T extends FieldElement<T>> extends AbstractFieldMa
blockIJ[k] = blockIJ[k].add(increment);
} catch (ArrayIndexOutOfBoundsException e) {
throw new MatrixIndexException(
"no entry at indices ({0}, {1}) in a {2}x{3} matrix",
LocalizedFormats.NO_SUCH_MATRIX_ENTRY,
row, column, getRowDimension(), getColumnDimension());
}
}
@ -1269,7 +1270,7 @@ public class BlockFieldMatrix<T extends FieldElement<T>> extends AbstractFieldMa
blockIJ[k] = blockIJ[k].multiply(factor);
} catch (ArrayIndexOutOfBoundsException e) {
throw new MatrixIndexException(
"no entry at indices ({0}, {1}) in a {2}x{3} matrix",
LocalizedFormats.NO_SUCH_MATRIX_ENTRY,
row, column, getRowDimension(), getColumnDimension());
}
}
@ -1334,7 +1335,7 @@ public class BlockFieldMatrix<T extends FieldElement<T>> extends AbstractFieldMa
if (v.length != columns) {
throw MathRuntimeException.createIllegalArgumentException(
"vector length mismatch: got {0} but expected {1}",
LocalizedFormats.VECTOR_LENGTH_MISMATCH,
v.length, columns);
}
final T[] out = buildArray(getField(), rows);
@ -1380,7 +1381,7 @@ public class BlockFieldMatrix<T extends FieldElement<T>> extends AbstractFieldMa
if (v.length != rows) {
throw MathRuntimeException.createIllegalArgumentException(
"vector length mismatch: got {0} but expected {1}",
LocalizedFormats.VECTOR_LENGTH_MISMATCH,
v.length, rows);
}
final T[] out = buildArray(getField(), columns);

View File

@ -21,6 +21,7 @@ import java.io.Serializable;
import java.util.Arrays;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.util.LocalizedFormats;
/**
* Cache-friendly implementation of RealMatrix using a flat arrays to store
@ -167,7 +168,7 @@ public class BlockRealMatrix extends AbstractRealMatrix implements Serializable
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})",
LocalizedFormats.WRONG_BLOCK_LENGTH,
blockData[index].length, iHeight * blockWidth(jBlock));
}
if (copyArray) {
@ -213,7 +214,7 @@ public class BlockRealMatrix extends AbstractRealMatrix implements Serializable
final int length = rawData[i].length;
if (length != columns) {
throw MathRuntimeException.createIllegalArgumentException(
"some rows have length {0} while others have length {1}",
LocalizedFormats.DIFFERENT_ROWS_LENGTHS,
columns, length);
}
}
@ -835,7 +836,7 @@ public class BlockRealMatrix 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");
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.AT_LEAST_ONE_COLUMN);
}
final int endRow = row + subMatrix.length - 1;
final int endColumn = column + refLength - 1;
@ -843,7 +844,7 @@ public class BlockRealMatrix extends AbstractRealMatrix implements Serializable
for (final double[] subRow : subMatrix) {
if (subRow.length != refLength) {
throw MathRuntimeException.createIllegalArgumentException(
"some rows have length {0} while others have length {1}",
LocalizedFormats.DIFFERENT_ROWS_LENGTHS,
refLength, subRow.length);
}
}
@ -943,7 +944,7 @@ public class BlockRealMatrix extends AbstractRealMatrix implements Serializable
if ((matrix.getRowDimension() != 1) ||
(matrix.getColumnDimension() != nCols)) {
throw new InvalidMatrixException(
"dimensions mismatch: got {0}x{1} but expected {2}x{3}",
LocalizedFormats.DIMENSIONS_MISMATCH_2x2,
matrix.getRowDimension(), matrix.getColumnDimension(),
1, nCols);
}
@ -1032,7 +1033,7 @@ public class BlockRealMatrix extends AbstractRealMatrix implements Serializable
if ((matrix.getRowDimension() != nRows) ||
(matrix.getColumnDimension() != 1)) {
throw new InvalidMatrixException(
"dimensions mismatch: got {0}x{1} but expected {2}x{3}",
LocalizedFormats.DIMENSIONS_MISMATCH_2x2,
matrix.getRowDimension(), matrix.getColumnDimension(),
nRows, 1);
}
@ -1160,7 +1161,7 @@ public class BlockRealMatrix extends AbstractRealMatrix implements Serializable
final int nCols = getColumnDimension();
if (array.length != nCols) {
throw new InvalidMatrixException(
"dimensions mismatch: got {0}x{1} but expected {2}x{3}",
LocalizedFormats.DIMENSIONS_MISMATCH_2x2,
1, array.length, 1, nCols);
}
@ -1211,7 +1212,7 @@ public class BlockRealMatrix extends AbstractRealMatrix implements Serializable
final int nRows = getRowDimension();
if (array.length != nRows) {
throw new InvalidMatrixException(
"dimensions mismatch: got {0}x{1} but expected {2}x{3}",
LocalizedFormats.DIMENSIONS_MISMATCH_2x2,
array.length, 1, nRows, 1);
}
@ -1242,7 +1243,7 @@ public class BlockRealMatrix extends AbstractRealMatrix implements Serializable
return blocks[iBlock * blockColumns + jBlock][k];
} catch (ArrayIndexOutOfBoundsException e) {
throw new MatrixIndexException(
"no entry at indices ({0}, {1}) in a {2}x{3} matrix",
LocalizedFormats.NO_SUCH_MATRIX_ENTRY,
row, column, getRowDimension(), getColumnDimension());
}
}
@ -1259,7 +1260,7 @@ public class BlockRealMatrix extends AbstractRealMatrix implements Serializable
blocks[iBlock * blockColumns + jBlock][k] = value;
} catch (ArrayIndexOutOfBoundsException e) {
throw new MatrixIndexException(
"no entry at indices ({0}, {1}) in a {2}x{3} matrix",
LocalizedFormats.NO_SUCH_MATRIX_ENTRY,
row, column, getRowDimension(), getColumnDimension());
}
}
@ -1276,7 +1277,7 @@ public class BlockRealMatrix extends AbstractRealMatrix implements Serializable
blocks[iBlock * blockColumns + jBlock][k] += increment;
} catch (ArrayIndexOutOfBoundsException e) {
throw new MatrixIndexException(
"no entry at indices ({0}, {1}) in a {2}x{3} matrix",
LocalizedFormats.NO_SUCH_MATRIX_ENTRY,
row, column, getRowDimension(), getColumnDimension());
}
}
@ -1293,7 +1294,7 @@ public class BlockRealMatrix extends AbstractRealMatrix implements Serializable
blocks[iBlock * blockColumns + jBlock][k] *= factor;
} catch (ArrayIndexOutOfBoundsException e) {
throw new MatrixIndexException(
"no entry at indices ({0}, {1}) in a {2}x{3} matrix",
LocalizedFormats.NO_SUCH_MATRIX_ENTRY,
row, column, getRowDimension(), getColumnDimension());
}
}
@ -1358,7 +1359,7 @@ public class BlockRealMatrix extends AbstractRealMatrix implements Serializable
if (v.length != columns) {
throw MathRuntimeException.createIllegalArgumentException(
"vector length mismatch: got {0} but expected {1}",
LocalizedFormats.VECTOR_LENGTH_MISMATCH,
v.length, columns);
}
final double[] out = new double[rows];
@ -1402,7 +1403,7 @@ public class BlockRealMatrix extends AbstractRealMatrix implements Serializable
if (v.length != rows) {
throw MathRuntimeException.createIllegalArgumentException(
"vector length mismatch: got {0} but expected {1}",
LocalizedFormats.VECTOR_LENGTH_MISMATCH,
v.length, rows);
}
final double[] out = new double[columns];

View File

@ -18,6 +18,7 @@
package org.apache.commons.math.linear;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.util.LocalizedFormats;
/**
@ -212,7 +213,7 @@ public class CholeskyDecompositionImpl implements CholeskyDecomposition {
final int m = lTData.length;
if (b.length != m) {
throw MathRuntimeException.createIllegalArgumentException(
"vector length mismatch: got {0} but expected {1}",
LocalizedFormats.VECTOR_LENGTH_MISMATCH,
b.length, m);
}
@ -251,7 +252,7 @@ public class CholeskyDecompositionImpl implements CholeskyDecomposition {
final int m = lTData.length;
if (b.getDimension() != m) {
throw MathRuntimeException.createIllegalArgumentException(
"vector length mismatch: got {0} but expected {1}",
LocalizedFormats.VECTOR_LENGTH_MISMATCH,
b.getDimension(), m);
}
@ -300,7 +301,7 @@ public class CholeskyDecompositionImpl implements CholeskyDecomposition {
final int m = lTData.length;
if (b.getRowDimension() != m) {
throw MathRuntimeException.createIllegalArgumentException(
"dimensions mismatch: got {0}x{1} but expected {2}x{3}",
LocalizedFormats.DIMENSIONS_MISMATCH_2x2,
b.getRowDimension(), b.getColumnDimension(), m, "n");
}

View File

@ -19,6 +19,7 @@ package org.apache.commons.math.linear;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.MaxIterationsExceededException;
import org.apache.commons.math.util.LocalizedFormats;
import org.apache.commons.math.util.MathUtils;
/**
@ -102,7 +103,7 @@ public class EigenDecompositionImpl implements EigenDecomposition {
// NOT supported
// see issue https://issues.apache.org/jira/browse/MATH-235
throw new InvalidMatrixException(
"eigen decomposition of assymetric matrices not supported yet");
LocalizedFormats.ASSYMETRIC_EIGEN_NOT_SUPPORTED);
}
}
@ -291,7 +292,7 @@ public class EigenDecompositionImpl implements EigenDecomposition {
final int m = realEigenvalues.length;
if (b.length != m) {
throw MathRuntimeException.createIllegalArgumentException(
"vector length mismatch: got {0} but expected {1}",
LocalizedFormats.VECTOR_LENGTH_MISMATCH,
b.length, m);
}
@ -333,7 +334,7 @@ public class EigenDecompositionImpl implements EigenDecomposition {
final int m = realEigenvalues.length;
if (b.getDimension() != m) {
throw MathRuntimeException.createIllegalArgumentException(
"vector length mismatch: got {0} but expected {1}", b
LocalizedFormats.VECTOR_LENGTH_MISMATCH, b
.getDimension(), m);
}
@ -376,7 +377,7 @@ public class EigenDecompositionImpl implements EigenDecomposition {
if (b.getRowDimension() != m) {
throw MathRuntimeException
.createIllegalArgumentException(
"dimensions mismatch: got {0}x{1} but expected {2}x{3}",
LocalizedFormats.DIMENSIONS_MISMATCH_2x2,
b.getRowDimension(), b.getColumnDimension(), m,
"n");
}

View File

@ -22,6 +22,7 @@ import java.lang.reflect.Array;
import org.apache.commons.math.Field;
import org.apache.commons.math.FieldElement;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.util.LocalizedFormats;
/**
* Calculates the LUP-decomposition of a square matrix.
@ -263,7 +264,7 @@ public class FieldLUDecompositionImpl<T extends FieldElement<T>> implements Fiel
final int m = pivot.length;
if (b.length != m) {
throw MathRuntimeException.createIllegalArgumentException(
"vector length mismatch: got {0} but expected {1}",
LocalizedFormats.VECTOR_LENGTH_MISMATCH,
b.length, m);
}
if (singular) {
@ -309,7 +310,7 @@ public class FieldLUDecompositionImpl<T extends FieldElement<T>> implements Fiel
final int m = pivot.length;
if (b.getDimension() != m) {
throw MathRuntimeException.createIllegalArgumentException(
"vector length mismatch: got {0} but expected {1}",
LocalizedFormats.VECTOR_LENGTH_MISMATCH,
b.getDimension(), m);
}
if (singular) {
@ -365,7 +366,7 @@ public class FieldLUDecompositionImpl<T extends FieldElement<T>> implements Fiel
final int m = pivot.length;
if (b.getRowDimension() != m) {
throw MathRuntimeException.createIllegalArgumentException(
"dimensions mismatch: got {0}x{1} but expected {2}x{3}",
LocalizedFormats.DIMENSIONS_MISMATCH_2x2,
b.getRowDimension(), b.getColumnDimension(), m, "n");
}
if (singular) {

View File

@ -18,6 +18,8 @@
package org.apache.commons.math.linear;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.util.DummyLocalizable;
import org.apache.commons.math.util.Localizable;
/**
* Thrown when a system attempts an operation on a matrix, and
@ -28,7 +30,7 @@ import org.apache.commons.math.MathRuntimeException;
public class InvalidMatrixException extends MathRuntimeException {
/** Serializable version identifier. */
private static final long serialVersionUID = 1135533765052675495L;
private static final long serialVersionUID = -2068020346562029801L;
/**
* Construct an exception with the given message.
@ -37,6 +39,16 @@ public class InvalidMatrixException extends MathRuntimeException {
* @since 2.0
*/
public InvalidMatrixException(final String pattern, final Object ... arguments) {
this(new DummyLocalizable(pattern), arguments);
}
/**
* Construct an exception with the given message.
* @param pattern format specifier
* @param arguments format arguments
* @since 2.2
*/
public InvalidMatrixException(final Localizable pattern, final Object ... arguments) {
super(pattern, arguments);
}

View File

@ -18,6 +18,7 @@
package org.apache.commons.math.linear;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.util.LocalizedFormats;
/**
* Calculates the LUP-decomposition of a square matrix.
@ -36,10 +37,6 @@ public class LUDecompositionImpl implements LUDecomposition {
/** Default bound to determine effective singularity in LU decomposition */
private static final double DEFAULT_TOO_SMALL = 10E-12;
/** Message for vector length mismatch. */
private static final String VECTOR_LENGTH_MISMATCH_MESSAGE =
"vector length mismatch: got {0} but expected {1}";
/** Entries of LU decomposition. */
private double lu[][];
@ -266,7 +263,7 @@ public class LUDecompositionImpl implements LUDecomposition {
final int m = pivot.length;
if (b.length != m) {
throw MathRuntimeException.createIllegalArgumentException(
VECTOR_LENGTH_MISMATCH_MESSAGE, b.length, m);
LocalizedFormats.VECTOR_LENGTH_MISMATCH, b.length, m);
}
if (singular) {
throw new SingularMatrixException();
@ -310,7 +307,7 @@ public class LUDecompositionImpl implements LUDecomposition {
final int m = pivot.length;
if (b.getDimension() != m) {
throw MathRuntimeException.createIllegalArgumentException(
VECTOR_LENGTH_MISMATCH_MESSAGE, b.getDimension(), m);
LocalizedFormats.VECTOR_LENGTH_MISMATCH, b.getDimension(), m);
}
if (singular) {
throw new SingularMatrixException();
@ -364,7 +361,7 @@ public class LUDecompositionImpl implements LUDecomposition {
final int m = pivot.length;
if (b.getRowDimension() != m) {
throw MathRuntimeException.createIllegalArgumentException(
"dimensions mismatch: got {0}x{1} but expected {2}x{3}",
LocalizedFormats.DIMENSIONS_MISMATCH_2x2,
b.getRowDimension(), b.getColumnDimension(), m, "n");
}
if (singular) {

View File

@ -18,6 +18,8 @@
package org.apache.commons.math.linear;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.util.DummyLocalizable;
import org.apache.commons.math.util.Localizable;
/**
* Thrown when an operation addresses a matrix coordinate (row, col)
@ -27,7 +29,7 @@ import org.apache.commons.math.MathRuntimeException;
public class MatrixIndexException extends MathRuntimeException {
/** Serializable version identifier */
private static final long serialVersionUID = -2382324504109300625L;
private static final long serialVersionUID = 8120540015829487660L;
/**
* Constructs a new instance with specified formatted detail message.
@ -35,6 +37,16 @@ public class MatrixIndexException extends MathRuntimeException {
* @param arguments format arguments
*/
public MatrixIndexException(final String pattern, final Object ... arguments) {
this(new DummyLocalizable(pattern), arguments);
}
/**
* Constructs a new instance with specified formatted detail message.
* @param pattern format specifier
* @param arguments format arguments
* @since 2.0
*/
public MatrixIndexException(final Localizable pattern, final Object ... arguments) {
super(pattern, arguments);
}

View File

@ -29,6 +29,7 @@ import org.apache.commons.math.FieldElement;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.fraction.BigFraction;
import org.apache.commons.math.fraction.Fraction;
import org.apache.commons.math.util.LocalizedFormats;
/**
* A collection of static methods that operate on or return matrices.
@ -352,7 +353,7 @@ public class MatrixUtils {
createRowFieldMatrix(final T[] rowData) {
final int nCols = rowData.length;
if (nCols == 0) {
throw MathRuntimeException.createIllegalArgumentException("matrix must have at least one column");
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.AT_LEAST_ONE_COLUMN);
}
final FieldMatrix<T> m = createFieldMatrix(rowData[0].getField(), 1, nCols);
for (int i = 0; i < nCols; ++i) {
@ -451,7 +452,7 @@ public class MatrixUtils {
createColumnFieldMatrix(final T[] columnData) {
final int nRows = columnData.length;
if (nRows == 0) {
throw MathRuntimeException.createIllegalArgumentException("matrix must have at least one row");
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.AT_LEAST_ONE_ROW);
}
final FieldMatrix<T> m = createFieldMatrix(columnData[0].getField(), nRows, 1);
for (int i = 0; i < nRows; ++i) {
@ -564,14 +565,14 @@ public class MatrixUtils {
checkRowIndex(m, startRow);
checkRowIndex(m, endRow);
if (startRow > endRow) {
throw new MatrixIndexException("initial row {0} after final row {1}",
throw new MatrixIndexException(LocalizedFormats.INITIAL_ROW_AFTER_FINAL_ROW,
startRow, endRow);
}
checkColumnIndex(m, startColumn);
checkColumnIndex(m, endColumn);
if (startColumn > endColumn) {
throw new MatrixIndexException("initial column {0} after final column {1}",
throw new MatrixIndexException(LocalizedFormats.INITIAL_COLUMN_AFTER_FINAL_COLUMN,
startColumn, endColumn);
}
@ -592,9 +593,9 @@ public class MatrixUtils {
throws MatrixIndexException {
if (selectedRows.length * selectedColumns.length == 0) {
if (selectedRows.length == 0) {
throw new MatrixIndexException("empty selected row index array");
throw new MatrixIndexException(LocalizedFormats.EMPTY_SELECTED_ROW_INDEX_ARRAY);
}
throw new MatrixIndexException("empty selected column index array");
throw new MatrixIndexException(LocalizedFormats.EMPTY_SELECTED_COLUMN_INDEX_ARRAY);
}
for (final int row : selectedRows) {
@ -616,7 +617,7 @@ public class MatrixUtils {
if ((left.getRowDimension() != right.getRowDimension()) ||
(left.getColumnDimension() != right.getColumnDimension())) {
throw MathRuntimeException.createIllegalArgumentException(
"{0}x{1} and {2}x{3} matrices are not addition compatible",
LocalizedFormats.NOT_ADDITION_COMPATIBLE_MATRICES,
left.getRowDimension(), left.getColumnDimension(),
right.getRowDimension(), right.getColumnDimension());
}
@ -633,7 +634,7 @@ public class MatrixUtils {
if ((left.getRowDimension() != right.getRowDimension()) ||
(left.getColumnDimension() != right.getColumnDimension())) {
throw MathRuntimeException.createIllegalArgumentException(
"{0}x{1} and {2}x{3} matrices are not subtraction compatible",
LocalizedFormats.NOT_SUBTRACTION_COMPATIBLE_MATRICES,
left.getRowDimension(), left.getColumnDimension(),
right.getRowDimension(), right.getColumnDimension());
}
@ -649,7 +650,7 @@ public class MatrixUtils {
throws IllegalArgumentException {
if (left.getColumnDimension() != right.getRowDimension()) {
throw MathRuntimeException.createIllegalArgumentException(
"{0}x{1} and {2}x{3} matrices are not multiplication compatible",
LocalizedFormats.NOT_MULTIPLICATION_COMPATIBLE_MATRICES,
left.getRowDimension(), left.getColumnDimension(),
right.getRowDimension(), right.getColumnDimension());
}

View File

@ -18,6 +18,7 @@
package org.apache.commons.math.linear;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.util.Localizable;
/**
* Thrown when a visitor encounters an error while processing a matrix entry.
@ -32,9 +33,21 @@ public class MatrixVisitorException extends MathRuntimeException {
* Constructs a new instance with specified formatted detail message.
* @param pattern format specifier
* @param arguments format arguments
* @deprecated as of 2.2 replaced by {@link #MatrixVisitorException(Localizable, Object...)}
*/
@Deprecated
public MatrixVisitorException(final String pattern, final Object[] arguments) {
super(pattern, arguments);
}
/**
* Constructs a new instance with specified formatted detail message.
* @param pattern format specifier
* @param arguments format arguments
* @since 2.2
*/
public MatrixVisitorException(final Localizable pattern, final Object[] arguments) {
super(pattern, arguments);
}
}

View File

@ -17,6 +17,8 @@
package org.apache.commons.math.linear;
import org.apache.commons.math.util.LocalizedFormats;
/**
* Thrown when an operation defined only for square matrices is applied to non-square ones.
@ -34,8 +36,7 @@ public class NonSquareMatrixException extends InvalidMatrixException {
* @param columns number of columns of the faulty matrix
*/
public NonSquareMatrixException(final int rows, final int columns) {
super("a {0}x{1} matrix was provided instead of a square matrix",
rows, columns);
super(LocalizedFormats.NON_SQUARE_MATRIX, rows, columns);
}
}

View File

@ -18,6 +18,7 @@
package org.apache.commons.math.linear;
import org.apache.commons.math.MathException;
import org.apache.commons.math.util.LocalizedFormats;
/**
* This class represents exceptions thrown when a matrix expected to
@ -36,7 +37,7 @@ public class NotPositiveDefiniteMatrixException extends MathException {
* build an exception with a default message.
*/
public NotPositiveDefiniteMatrixException() {
super("not positive definite matrix");
super(LocalizedFormats.NOT_POSITIVE_DEFINITE_MATRIX);
}
}

View File

@ -18,6 +18,7 @@
package org.apache.commons.math.linear;
import org.apache.commons.math.MathException;
import org.apache.commons.math.util.LocalizedFormats;
/**
* This class represents exceptions thrown when a matrix expected to
@ -36,7 +37,7 @@ public class NotSymmetricMatrixException extends MathException {
* build an exception with a default message.
*/
public NotSymmetricMatrixException() {
super("not symmetric matrix");
super(LocalizedFormats.NOT_SYMMETRIC_MATRIX);
}
}

View File

@ -19,6 +19,7 @@ package org.apache.commons.math.linear;
import java.io.Serializable;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.util.LocalizedFormats;
import org.apache.commons.math.util.OpenIntToDoubleHashMap;
import org.apache.commons.math.util.OpenIntToDoubleHashMap.Iterator;
@ -732,7 +733,7 @@ public class OpenMapRealVector extends AbstractRealVector implements SparseRealV
public void unitize() {
double norm = getNorm();
if (isDefaultValue(norm)) {
throw MathRuntimeException.createArithmeticException("cannot normalize a zero norm vector");
throw MathRuntimeException.createArithmeticException(LocalizedFormats.CANNOT_NORMALIZE_A_ZERO_NORM_VECTOR);
}
Iterator iter = entries.iterator();
while (iter.hasNext()) {

View File

@ -20,6 +20,7 @@ package org.apache.commons.math.linear;
import java.util.Arrays;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.util.LocalizedFormats;
/**
@ -290,7 +291,7 @@ public class QRDecompositionImpl implements QRDecomposition {
final int m = qrt[0].length;
if (b.length != m) {
throw MathRuntimeException.createIllegalArgumentException(
"vector length mismatch: got {0} but expected {1}",
LocalizedFormats.VECTOR_LENGTH_MISMATCH,
b.length, m);
}
if (!isNonSingular()) {
@ -361,7 +362,7 @@ public class QRDecompositionImpl implements QRDecomposition {
final int m = qrt[0].length;
if (b.getRowDimension() != m) {
throw MathRuntimeException.createIllegalArgumentException(
"dimensions mismatch: got {0}x{1} but expected {2}x{3}",
LocalizedFormats.DIMENSIONS_MISMATCH_2x2,
b.getRowDimension(), b.getColumnDimension(), m, "n");
}
if (!isNonSingular()) {

View File

@ -20,6 +20,7 @@ package org.apache.commons.math.linear;
import java.io.Serializable;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.util.LocalizedFormats;
/**
* Implementation of RealMatrix using a double[][] array to store entries and
@ -122,16 +123,16 @@ 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");
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.AT_LEAST_ONE_ROW);
}
final int nCols = d[0].length;
if (nCols == 0) {
throw MathRuntimeException.createIllegalArgumentException("matrix must have at least one column");
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.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}",
LocalizedFormats.DIFFERENT_ROWS_LENGTHS,
nCols, d[r].length);
}
}
@ -316,28 +317,28 @@ public class RealMatrixImpl extends AbstractRealMatrix implements Serializable {
if (data == null) {
if (row > 0) {
throw MathRuntimeException.createIllegalStateException(
"first {0} rows are not initialized yet",
LocalizedFormats.FIRST_ROWS_NOT_INITIALIZED_YET,
row);
}
if (column > 0) {
throw MathRuntimeException.createIllegalStateException(
"first {0} columns are not initialized yet",
LocalizedFormats.FIRST_COLUMNS_NOT_INITIALIZED_YET,
column);
}
final int nRows = subMatrix.length;
if (nRows == 0) {
throw MathRuntimeException.createIllegalArgumentException("matrix must have at least one row");
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.AT_LEAST_ONE_ROW);
}
final int nCols = subMatrix[0].length;
if (nCols == 0) {
throw MathRuntimeException.createIllegalArgumentException("matrix must have at least one column");
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.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}",
LocalizedFormats.DIFFERENT_ROWS_LENGTHS,
nCols, subMatrix[i].length);
}
System.arraycopy(subMatrix[i], 0, data[i + row], column, nCols);
@ -356,7 +357,7 @@ public class RealMatrixImpl extends AbstractRealMatrix implements Serializable {
return data[row][column];
} catch (ArrayIndexOutOfBoundsException e) {
throw new MatrixIndexException(
"no entry at indices ({0}, {1}) in a {2}x{3} matrix",
LocalizedFormats.NO_SUCH_MATRIX_ENTRY,
row, column, getRowDimension(), getColumnDimension());
}
}
@ -369,7 +370,7 @@ public class RealMatrixImpl extends AbstractRealMatrix implements Serializable {
data[row][column] = value;
} catch (ArrayIndexOutOfBoundsException e) {
throw new MatrixIndexException(
"no entry at indices ({0}, {1}) in a {2}x{3} matrix",
LocalizedFormats.NO_SUCH_MATRIX_ENTRY,
row, column, getRowDimension(), getColumnDimension());
}
}
@ -382,7 +383,7 @@ public class RealMatrixImpl extends AbstractRealMatrix implements Serializable {
data[row][column] += increment;
} catch (ArrayIndexOutOfBoundsException e) {
throw new MatrixIndexException(
"no entry at indices ({0}, {1}) in a {2}x{3} matrix",
LocalizedFormats.NO_SUCH_MATRIX_ENTRY,
row, column, getRowDimension(), getColumnDimension());
}
}
@ -395,7 +396,7 @@ public class RealMatrixImpl extends AbstractRealMatrix implements Serializable {
data[row][column] *= factor;
} catch (ArrayIndexOutOfBoundsException e) {
throw new MatrixIndexException(
"no entry at indices ({0}, {1}) in a {2}x{3} matrix",
LocalizedFormats.NO_SUCH_MATRIX_ENTRY,
row, column, getRowDimension(), getColumnDimension());
}
}
@ -420,7 +421,7 @@ public class RealMatrixImpl extends AbstractRealMatrix implements Serializable {
final int nCols = this.getColumnDimension();
if (v.length != nCols) {
throw MathRuntimeException.createIllegalArgumentException(
"vector length mismatch: got {0} but expected {1}",
LocalizedFormats.VECTOR_LENGTH_MISMATCH,
v.length, nCols);
}
final double[] out = new double[nRows];
@ -444,7 +445,7 @@ public class RealMatrixImpl extends AbstractRealMatrix implements Serializable {
final int nCols = getColumnDimension();
if (v.length != nRows) {
throw MathRuntimeException.createIllegalArgumentException(
"vector length mismatch: got {0} but expected {1}",
LocalizedFormats.VECTOR_LENGTH_MISMATCH,
v.length, nRows);
}

View File

@ -27,6 +27,7 @@ import java.util.Locale;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.util.CompositeFormat;
import org.apache.commons.math.util.LocalizedFormats;
/**
* Formats a vector in components list format "{v0; v1; ...; vk-1}".
@ -246,7 +247,7 @@ public class RealVectorFormat extends CompositeFormat {
}
throw MathRuntimeException.createIllegalArgumentException(
"cannot format a {0} instance as a real vector",
LocalizedFormats.CANNOT_FORMAT_INSTANCE_AS_REAL_VECTOR,
obj.getClass().getName());
}

View File

@ -17,6 +17,8 @@
package org.apache.commons.math.linear;
import org.apache.commons.math.util.LocalizedFormats;
/**
* Thrown when a matrix is singular.
@ -32,7 +34,7 @@ public class SingularMatrixException extends InvalidMatrixException {
* Construct an exception with a default message.
*/
public SingularMatrixException() {
super("matrix is singular");
super(LocalizedFormats.SINGULAR_MATRIX);
}
}

View File

@ -18,6 +18,7 @@
package org.apache.commons.math.linear;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.util.LocalizedFormats;
/**
* Calculates the compact Singular Value Decomposition of a matrix.
@ -219,7 +220,7 @@ public class SingularValueDecompositionImpl implements
if (dimension == 0) {
throw MathRuntimeException.createIllegalArgumentException(
"cutoff singular value is {0}, should be at most {1}",
LocalizedFormats.TOO_LARGE_CUTOFF_SINGULAR_VALUE,
minSingularValue, singularValues[0]);
}

View File

@ -22,6 +22,7 @@ import java.lang.reflect.Array;
import org.apache.commons.math.Field;
import org.apache.commons.math.FieldElement;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.util.LocalizedFormats;
import org.apache.commons.math.util.OpenIntToFieldHashMap;
/**
@ -565,7 +566,7 @@ public class SparseFieldVector<T extends FieldElement<T>> implements FieldVector
protected void checkVectorDimensions(int n) throws IllegalArgumentException {
if (getDimension() != n) {
throw MathRuntimeException.createIllegalArgumentException(
"vector length mismatch: got {0} but expected {1}",
LocalizedFormats.VECTOR_LENGTH_MISMATCH,
getDimension(), n);
}
}

View File

@ -26,6 +26,7 @@ import org.apache.commons.math.ode.events.CombinedEventsManager;
import org.apache.commons.math.ode.events.EventHandler;
import org.apache.commons.math.ode.events.EventState;
import org.apache.commons.math.ode.sampling.StepHandler;
import org.apache.commons.math.util.LocalizedFormats;
/**
* Base class managing common boilerplate for all integrators.
@ -197,21 +198,17 @@ public abstract class AbstractIntegrator implements FirstOrderIntegrator {
if (ode.getDimension() != y0.length) {
throw new IntegratorException(
"dimensions mismatch: ODE problem has dimension {0}," +
" initial state vector has dimension {1}",
ode.getDimension(), y0.length);
LocalizedFormats.DIMENSIONS_MISMATCH_SIMPLE, ode.getDimension(), y0.length);
}
if (ode.getDimension() != y.length) {
throw new IntegratorException(
"dimensions mismatch: ODE problem has dimension {0}," +
" final state vector has dimension {1}",
ode.getDimension(), y.length);
LocalizedFormats.DIMENSIONS_MISMATCH_SIMPLE, ode.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}",
LocalizedFormats.TOO_SMALL_INTEGRATION_INTERVAL,
Math.abs(t - t0));
}

View File

@ -24,6 +24,7 @@ import java.io.Serializable;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.ode.sampling.StepHandler;
import org.apache.commons.math.ode.sampling.StepInterpolator;
import org.apache.commons.math.util.LocalizedFormats;
/**
* This class stores all information provided by an ODE integrator
@ -134,13 +135,13 @@ public class ContinuousOutputModel
if (getInterpolatedState().length != model.getInterpolatedState().length) {
throw MathRuntimeException.createIllegalArgumentException(
"dimension mismatch {0} != {1}",
LocalizedFormats.DIMENSIONS_MISMATCH_SIMPLE,
getInterpolatedState().length, model.getInterpolatedState().length);
}
if (forward ^ model.forward) {
throw MathRuntimeException.createIllegalArgumentException(
"propagation direction mismatch");
LocalizedFormats.PROPAGATION_DIRECTION_MISMATCH);
}
final StepInterpolator lastInterpolator = steps.get(index);
@ -150,7 +151,7 @@ public class ContinuousOutputModel
final double gap = model.getInitialTime() - current;
if (Math.abs(gap) > 1.0e-3 * Math.abs(step)) {
throw MathRuntimeException.createIllegalArgumentException(
"{0} wide hole between models time ranges", Math.abs(gap));
LocalizedFormats.HOLE_BETWEEN_MODELS_TIME_RANGES, Math.abs(gap));
}
}

View File

@ -18,6 +18,8 @@
package org.apache.commons.math.ode;
import org.apache.commons.math.MathException;
import org.apache.commons.math.util.DummyLocalizable;
import org.apache.commons.math.util.Localizable;
/**
* This exception is made available to users to report
@ -36,12 +38,23 @@ public class DerivativeException
* 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)
* @deprecated as of 2.2 replaced by {@link #DerivativeException(Localizable, Object...)}
*/
@Deprecated
public DerivativeException(final String specifier, final Object ... parts) {
this(new DummyLocalizable(specifier), parts);
}
/** 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 Localizable specifier, final Object ... parts) {
super(specifier, parts);
}
/** Build an instance from an underlying cause.
/** Build an instance from an underlying cause.
* @param cause cause for the exception
*/
public DerivativeException(final Throwable cause) {

Some files were not shown because too many files have changed in this diff Show More