diff --git a/src/java/org/apache/commons/math/estimation/LevenbergMarquardtEstimator.java b/src/java/org/apache/commons/math/estimation/LevenbergMarquardtEstimator.java index 248ebf3c9..07bffbad1 100644 --- a/src/java/org/apache/commons/math/estimation/LevenbergMarquardtEstimator.java +++ b/src/java/org/apache/commons/math/estimation/LevenbergMarquardtEstimator.java @@ -733,8 +733,9 @@ public class LevenbergMarquardtEstimator extends AbstractEstimator implements Se * are performed in non-increasing columns norms order thanks to columns * pivoting. The diagonal elements of the R matrix are therefore also in * non-increasing absolute values order.

+ * @exception EstimationException if the decomposition cannot be performed */ - private void qrDecomposition() { + private void qrDecomposition() throws EstimationException { // initializations for (int k = 0; k < cols; ++k) { @@ -760,6 +761,10 @@ public class LevenbergMarquardtEstimator extends AbstractEstimator implements Se double aki = jacobian[index]; norm2 += aki * aki; } + if (Double.isInfinite(norm2) || Double.isNaN(norm2)) { + throw new EstimationException("unable to perform Q.R decomposition on the {0}x{1} jacobian matrix", + new Object[] { new Integer(rows), new Integer(cols) }); + } if (norm2 > ak2) { nextColumn = i; ak2 = norm2; diff --git a/src/site/xdoc/changes.xml b/src/site/xdoc/changes.xml index f5aabb0d1..52c9b8a0d 100644 --- a/src/site/xdoc/changes.xml +++ b/src/site/xdoc/changes.xml @@ -47,6 +47,10 @@ Commons Math Release Notes added an error detection for missing imaginary character while parsing complex string + + detect numerical problems in Q.R decomposition for Levenberg-Marquardt estimator + and report them appropriately +