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 */ BETA("beta"), /* keep */
NOT_POSITIVE_COLUMNDIMENSION("invalid column dimension: {0} (must be positive)"), NOT_POSITIVE_COLUMNDIMENSION("invalid column dimension: {0} (must be positive)"),
NOT_POSITIVE_DEFINITE_MATRIX("not positive definite matrix"), 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_POSITIVE_DEFINITE_LINEAR_OPERATOR("non positive definite linear operator"), /* keep */
NON_SELF_ADJOINT_LINEAR_OPERATOR("non self-adjoint 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 */ 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 // check diagonal element
if (ltI[i] < absolutePositivityThreshold) { if (ltI[i] < absolutePositivityThreshold) {
throw new NonPositiveDefiniteMatrixException(i, absolutePositivityThreshold); throw new NonPositiveDefiniteMatrixException(ltI[i], i, absolutePositivityThreshold);
} }
ltI[i] = FastMath.sqrt(ltI[i]); ltI[i] = FastMath.sqrt(ltI[i]);

View File

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

View File

@ -87,7 +87,7 @@ public class RectangularCholeskyDecompositionImpl implements RectangularCholesky
if (c[ir][ir] < small) { if (c[ir][ir] < small) {
if (r == 0) { if (r == 0) {
throw new NonPositiveDefiniteMatrixException(ir, small); throw new NonPositiveDefiniteMatrixException(c[ir][ir], ir, small);
} }
// check remaining diagonal elements // check remaining diagonal elements
@ -95,7 +95,7 @@ public class RectangularCholeskyDecompositionImpl implements RectangularCholesky
if (c[index[i]][index[i]] < -small) { if (c[index[i]][index[i]] < -small) {
// there is at least one sufficiently negative diagonal element, // there is at least one sufficiently negative diagonal element,
// the symmetric positive semidefinite matrix is wrong // 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 BETA = beta
NOT_POSITIVE_COLUMNDIMENSION = nombre de colonnes invalide : {0} (doit \u00eatre positif) NOT_POSITIVE_COLUMNDIMENSION = nombre de colonnes invalide : {0} (doit \u00eatre positif)
NOT_POSITIVE_DEFINITE_MATRIX = matrice non d\u00e9finie positive 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_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_POSITIVE_DEFINITE_LINEAR_OPERATOR = op\u00e9rateur lin\u00e9aire non d\u00e9fini positif
NON_SELF_ADJOINT_LINEAR_OPERATOR = op\u00e9rateur lin\u00e9aire non auto-adjoint NON_SELF_ADJOINT_LINEAR_OPERATOR = op\u00e9rateur lin\u00e9aire non auto-adjoint