You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by tn...@apache.org on 2015/02/19 22:23:21 UTC
[math] [MATH-1204] backport to 3.5 branch.
Repository: commons-math
Updated Branches:
refs/heads/MATH_3_X 68e6de351 -> 9aa638267
[MATH-1204] backport to 3.5 branch.
Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/9aa63826
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/9aa63826
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/9aa63826
Branch: refs/heads/MATH_3_X
Commit: 9aa63826735104080d8eb612fd3a5c84264c9c17
Parents: 68e6de3
Author: Thomas Neidhart <th...@gmail.com>
Authored: Thu Feb 19 22:23:10 2015 +0100
Committer: Thomas Neidhart <th...@gmail.com>
Committed: Thu Feb 19 22:23:10 2015 +0100
----------------------------------------------------------------------
src/changes/changes.xml | 4 ++++
.../math3/analysis/solvers/UnivariateSolverUtils.java | 6 +++---
.../math3/analysis/solvers/UnivariateSolverUtilsTest.java | 8 ++++++++
3 files changed, 15 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-math/blob/9aa63826/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 3309edf..b512dc8 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -54,6 +54,10 @@ If the output is not quite correct, check for invisible trailing spaces!
</release>
<release version="3.5" date="2015-01-11" description="">
+ <action dev="evanward" type="fix" issue="MATH-1204">
+ "UnivariateSolverUtils#bracket(...)" sometimes failed to bracket
+ if a reached the lower bound.
+ </action>
<action dev="sebb" type="add" issue="MATH-1198">
Simplified "FastMath#exp(double)" in order to avoid a potential
Java 1.5 JIT bug when calling with negative infinity as argument.
http://git-wip-us.apache.org/repos/asf/commons-math/blob/9aa63826/src/main/java/org/apache/commons/math3/analysis/solvers/UnivariateSolverUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math3/analysis/solvers/UnivariateSolverUtils.java b/src/main/java/org/apache/commons/math3/analysis/solvers/UnivariateSolverUtils.java
index 4c2dd90..b1ecded 100644
--- a/src/main/java/org/apache/commons/math3/analysis/solvers/UnivariateSolverUtils.java
+++ b/src/main/java/org/apache/commons/math3/analysis/solvers/UnivariateSolverUtils.java
@@ -243,7 +243,7 @@ public class UnivariateSolverUtils {
* \( \delta_{k+1} = r \delta_k + q, \delta_0 = 0\) and starting search with \( k=1 \).
* The algorithm stops when one of the following happens: <ul>
* <li> at least one positive and one negative value have been found -- success!</li>
- * <li> both endpoints have reached their respective limites -- NoBracketingException </li>
+ * <li> both endpoints have reached their respective limits -- NoBracketingException </li>
* <li> {@code maximumIterations} iterations elapse -- NoBracketingException </li></ul></p>
* <p>
* If different signs are found at first iteration ({@code k=1}), then the returned
@@ -257,7 +257,7 @@ public class UnivariateSolverUtils {
* Interval expansion rate is tuned by changing the recurrence parameters {@code r} and
* {@code q}. When the multiplicative factor {@code r} is set to 1, the sequence is a
* simple arithmetic sequence with linear increase. When the multiplicative factor {@code r}
- * is larger than 1, the sequence has an asymtotically exponential rate. Note than the
+ * is larger than 1, the sequence has an asymptotically exponential rate. Note than the
* additive parameter {@code q} should never be set to zero, otherwise the interval would
* degenerate to the single initial point for all values of {@code k}.
* </p>
@@ -314,7 +314,7 @@ public class UnivariateSolverUtils {
double delta = 0;
for (int numIterations = 0;
- (numIterations < maximumIterations) && (a > lowerBound || b > upperBound);
+ (numIterations < maximumIterations) && (a > lowerBound || b < upperBound);
++numIterations) {
final double previousA = a;
http://git-wip-us.apache.org/repos/asf/commons-math/blob/9aa63826/src/test/java/org/apache/commons/math3/analysis/solvers/UnivariateSolverUtilsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math3/analysis/solvers/UnivariateSolverUtilsTest.java b/src/test/java/org/apache/commons/math3/analysis/solvers/UnivariateSolverUtilsTest.java
index 97c387e..e84a18d 100644
--- a/src/test/java/org/apache/commons/math3/analysis/solvers/UnivariateSolverUtilsTest.java
+++ b/src/test/java/org/apache/commons/math3/analysis/solvers/UnivariateSolverUtilsTest.java
@@ -175,6 +175,14 @@ public class UnivariateSolverUtilsTest {
UnivariateSolverUtils.bracket(sin, 1.5, 0, 2.0, 0);
}
+ /** check the search continues when a = lowerBound and b < upperBound. */
+ @Test
+ public void testBracketLoopConditionForB() {
+ double[] result = UnivariateSolverUtils.bracket(sin, -0.9, -1, 1, 0.1, 1, 100);
+ Assert.assertTrue(result[0] <= 0);
+ Assert.assertTrue(result[1] >= 0);
+ }
+
@Test
public void testMisc() {
UnivariateFunction f = new QuinticFunction();