Multiple computations of the same value.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1488942 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e0e56f8055
commit
0b2d417d52
|
@ -116,17 +116,17 @@ public class MidPointIntegrator extends BaseAbstractUnivariateIntegrator {
|
|||
double previousStageResult)
|
||||
throws TooManyEvaluationsException {
|
||||
|
||||
final double max = getMax();
|
||||
final double min = getMin();
|
||||
final double diff = getMax() - min;
|
||||
|
||||
if (n == 0) {
|
||||
final double midPoint = 0.5 * (max - min);
|
||||
return (max - min) * computeObjectiveValue(midPoint);
|
||||
final double midPoint = 0.5 * diff;
|
||||
return diff * computeObjectiveValue(midPoint);
|
||||
} else {
|
||||
final long np = 1L << (n - 1); // number of new points in this stage
|
||||
double sum = 0;
|
||||
// spacing between adjacent new points
|
||||
final double spacing = (max - min) / np;
|
||||
final double spacing = diff / np;
|
||||
double x = min + 0.5 * spacing; // the first new point
|
||||
for (long i = 0; i < np; i++) {
|
||||
sum += computeObjectiveValue(x);
|
||||
|
|
Loading…
Reference in New Issue