More detailed message for "NonPositiveDefiniteMatrixException".

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1166674 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gilles Sadowski 2011-09-08 13:13:16 +00:00
parent 6b9cf3c1ec
commit a4d48af48a
5 changed files with 11 additions and 9 deletions

View File

@ -186,7 +186,7 @@ public enum LocalizedFormats implements Localizable {
BETA("beta"), /* keep */
NOT_POSITIVE_COLUMNDIMENSION("invalid column dimension: {0} (must be positive)"),
NOT_POSITIVE_DEFINITE_MATRIX("not positive definite matrix"),
NON_POSITIVE_DEFINITE_MATRIX("not positive definite matrix: diagonal element at ({0},{0}) is smaller than {1}"), /* keep */
NON_POSITIVE_DEFINITE_MATRIX("not positive definite matrix: diagonal element at ({1},{1}) is smaller than {2} ({0})"), /* keep */
NON_POSITIVE_DEFINITE_LINEAR_OPERATOR("non positive definite linear operator"), /* keep */
NON_SELF_ADJOINT_LINEAR_OPERATOR("non self-adjoint linear operator"), /* keep */
NON_SQUARE_LINEAR_OPERATOR("non square ({0}x{1}) linear operator"), /* keep */

View File

@ -126,7 +126,7 @@ public class CholeskyDecompositionImpl implements CholeskyDecomposition {
// check diagonal element
if (ltI[i] < absolutePositivityThreshold) {
throw new NonPositiveDefiniteMatrixException(i, absolutePositivityThreshold);
throw new NonPositiveDefiniteMatrixException(ltI[i], i, absolutePositivityThreshold);
}
ltI[i] = FastMath.sqrt(ltI[i]);

View File

@ -16,7 +16,7 @@
*/
package org.apache.commons.math.linear;
import org.apache.commons.math.exception.MathIllegalArgumentException;
import org.apache.commons.math.exception.MathIllegalNumberException;
import org.apache.commons.math.exception.util.LocalizedFormats;
/**
@ -25,7 +25,7 @@ import org.apache.commons.math.exception.util.LocalizedFormats;
* @since 3.0
* @version $Id$
*/
public class NonPositiveDefiniteMatrixException extends MathIllegalArgumentException {
public class NonPositiveDefiniteMatrixException extends MathIllegalNumberException {
/** Serializable version Id. */
private static final long serialVersionUID = 1641613838113738061L;
/** Index (diagonal element). */
@ -36,12 +36,14 @@ public class NonPositiveDefiniteMatrixException extends MathIllegalArgumentExcep
/**
* Construct an exception.
*
* @param wrong Value that fails the positivity check.
* @param index Row (and column) index.
* @param threshold Absolute positivity threshold.
*/
public NonPositiveDefiniteMatrixException(int index,
public NonPositiveDefiniteMatrixException(double wrong,
int index,
double threshold) {
super(LocalizedFormats.NON_POSITIVE_DEFINITE_MATRIX, index, threshold);
super(LocalizedFormats.NON_POSITIVE_DEFINITE_MATRIX, wrong, index, threshold);
this.index = index;
this.threshold = threshold;
}

View File

@ -87,7 +87,7 @@ public class RectangularCholeskyDecompositionImpl implements RectangularCholesky
if (c[ir][ir] < small) {
if (r == 0) {
throw new NonPositiveDefiniteMatrixException(ir, small);
throw new NonPositiveDefiniteMatrixException(c[ir][ir], ir, small);
}
// check remaining diagonal elements
@ -95,7 +95,7 @@ public class RectangularCholeskyDecompositionImpl implements RectangularCholesky
if (c[index[i]][index[i]] < -small) {
// there is at least one sufficiently negative diagonal element,
// the symmetric positive semidefinite matrix is wrong
throw new NonPositiveDefiniteMatrixException(i, small);
throw new NonPositiveDefiniteMatrixException(c[index[i]][index[i]], i, small);
}
}

View File

@ -156,7 +156,7 @@ ALPHA = alpha
BETA = beta
NOT_POSITIVE_COLUMNDIMENSION = nombre de colonnes invalide : {0} (doit \u00eatre positif)
NOT_POSITIVE_DEFINITE_MATRIX = matrice non d\u00e9finie positive
NON_POSITIVE_DEFINITE_MATRIX = matrice non d\u00e9finie positive: l''\u00e9l\u00e9ment diagonal ({0},{0}) est sup\u00e9rieur \u0061 {1}
NON_POSITIVE_DEFINITE_MATRIX = matrice non d\u00e9finie positive: l''\u00e9l\u00e9ment diagonal ({1},{1}) est inf\u00e9rieur \u0061 {2} ({0})
NON_SELF_ADJOINT_LINEAR_OPERATOR = : |x'' A y - y'' A x| > {0} quand x est {1} et y est {2}
NON_POSITIVE_DEFINITE_LINEAR_OPERATOR = op\u00e9rateur lin\u00e9aire non d\u00e9fini positif
NON_SELF_ADJOINT_LINEAR_OPERATOR = op\u00e9rateur lin\u00e9aire non auto-adjoint