On 9/9/11 8:44 AM, er...@apache.org wrote: > Author: erans > Date: Fri Sep 9 15:44:57 2011 > New Revision: 1167252 > > URL: http://svn.apache.org/viewvc?rev=1167252&view=rev > Log: > NonPositiveDefiniteMatrixException": Changed base class, and modified message > so > that it is (a little) less misleading (it is closer to the actual check which > can > only report that it detects non-definite-positiveness at some point of the > transformation). > Changed test in "CholeskyDecompositionImpl" to allow "O" for the threshold > while > keeping the requirement that the element must be strictly positive. > > Modified: > > commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/util/LocalizedFormats.java > > commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/CholeskyDecompositionImpl.java > > commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/NonPositiveDefiniteMatrixException.java > > Modified: > commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/util/LocalizedFormats.java > URL: > http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/util/LocalizedFormats.java?rev=1167252&r1=1167251&r2=1167252&view=diff > ============================================================================== > --- > commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/util/LocalizedFormats.java > (original) > +++ > commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/util/LocalizedFormats.java > Fri Sep 9 15:44:57 2011 > @@ -185,8 +185,8 @@ public enum LocalizedFormats implements > ALPHA("alpha"), /* keep */ > 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 ({1},{1}) is smaller than {2} ({0})"), /* keep */ > + NOT_POSITIVE_DEFINITE_MATRIX("not positive definite matrix"), /* keep */
I would say we can toss the one above - it really doesn't add any information. > + NON_POSITIVE_DEFINITE_MATRIX("not positive definite matrix: diagonal > element at ({1},{1}) is smaller than {2} ({0})"), > NON_POSITIVE_DEFINITE_LINEAR_OPERATOR("non positive definite linear > operator"), /* keep */ Same comment as above on the one above. Phil > NON_SELF_ADJOINT_LINEAR_OPERATOR("non self-adjoint linear operator"), /* > keep */ > NON_SQUARE_LINEAR_OPERATOR("non square ({0}x{1}) linear operator"), /* > keep */ > > Modified: > commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/CholeskyDecompositionImpl.java > URL: > http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/CholeskyDecompositionImpl.java?rev=1167252&r1=1167251&r2=1167252&view=diff > ============================================================================== > --- > commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/CholeskyDecompositionImpl.java > (original) > +++ > commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/CholeskyDecompositionImpl.java > Fri Sep 9 15:44:57 2011 > @@ -125,7 +125,7 @@ public class CholeskyDecompositionImpl i > final double[] ltI = lTData[i]; > > // check diagonal element > - if (ltI[i] < absolutePositivityThreshold) { > + if (ltI[i] <= absolutePositivityThreshold) { > throw new NonPositiveDefiniteMatrixException(ltI[i], i, > absolutePositivityThreshold); > } > > > Modified: > commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/NonPositiveDefiniteMatrixException.java > URL: > http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/NonPositiveDefiniteMatrixException.java?rev=1167252&r1=1167251&r2=1167252&view=diff > ============================================================================== > --- > commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/NonPositiveDefiniteMatrixException.java > (original) > +++ > commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/NonPositiveDefiniteMatrixException.java > Fri Sep 9 15:44:57 2011 > @@ -16,8 +16,9 @@ > */ > package org.apache.commons.math.linear; > > -import org.apache.commons.math.exception.MathIllegalNumberException; > +import org.apache.commons.math.exception.NumberIsTooSmallException; > import org.apache.commons.math.exception.util.LocalizedFormats; > +import org.apache.commons.math.exception.util.ExceptionContext; > > /** > * Exception to be thrown when a positive definite matrix is expected. > @@ -25,7 +26,7 @@ import org.apache.commons.math.exception > * @since 3.0 > * @version $Id$ > */ > -public class NonPositiveDefiniteMatrixException extends > MathIllegalNumberException { > +public class NonPositiveDefiniteMatrixException extends > NumberIsTooSmallException { > /** Serializable version Id. */ > private static final long serialVersionUID = 1641613838113738061L; > /** Index (diagonal element). */ > @@ -43,9 +44,13 @@ public class NonPositiveDefiniteMatrixEx > public NonPositiveDefiniteMatrixException(double wrong, > int index, > double threshold) { > - super(LocalizedFormats.NON_POSITIVE_DEFINITE_MATRIX, wrong, index, > threshold); > + super(wrong, threshold, false); > this.index = index; > this.threshold = threshold; > + > + final ExceptionContext context = getContext(); > + context.addMessage(LocalizedFormats.NOT_POSITIVE_DEFINITE_MATRIX); > + context.addMessage(LocalizedFormats.ARRAY_ELEMENT, wrong, index); > } > > /** > > > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org