Author: erans
Date: Sat Mar 3 03:55:24 2012
New Revision: 1296571
URL: http://svn.apache.org/viewvc?rev=1296571&view=rev
Log:
Variable visibility: "protected" -> "private". Added "protected"
getter methods.
Modified:
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/BaseAbstractUnivariateIntegrator.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/LegendreGaussIntegrator.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/RombergIntegrator.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/SimpsonIntegrator.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/TrapezoidIntegrator.java
Modified:
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/BaseAbstractUnivariateIntegrator.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/BaseAbstractUnivariateIntegrator.java?rev=1296571&r1=1296570&r2=1296571&view=diff
==============================================================================
---
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/BaseAbstractUnivariateIntegrator.java
(original)
+++
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/BaseAbstractUnivariateIntegrator.java
Sat Mar 3 03:55:24 2012
@@ -48,28 +48,28 @@ public abstract class BaseAbstractUnivar
public static final int DEFAULT_MAX_ITERATIONS_COUNT = Integer.MAX_VALUE;
/** Maximum absolute error. */
- protected double absoluteAccuracy;
+ private final double absoluteAccuracy;
/** Maximum relative error. */
- protected double relativeAccuracy;
+ private final double relativeAccuracy;
/** minimum number of iterations */
- protected int minimalIterationCount;
+ private final int minimalIterationCount;
/** The iteration count. */
- protected Incrementor iterations;
+ protected final Incrementor iterations;
/** The functions evaluation count. */
- protected Incrementor evaluations;
+ private final Incrementor evaluations;
/** Function to integrate. */
- protected UnivariateFunction function;
+ private UnivariateFunction function;
/** Lower bound for the interval. */
- protected double min;
+ private double min;
/** Upper bound for the interval. */
- protected double max;
+ private double max;
/**
* Construct an integrator with given accuracies and iteration counts.
@@ -190,6 +190,19 @@ public abstract class BaseAbstractUnivar
}
/**
+ * @return the lower bound.
+ */
+ protected double getMin() {
+ return min;
+ }
+ /**
+ * @return the upper bound.
+ */
+ protected double getMax() {
+ return max;
+ }
+
+ /**
* Compute the objective function value.
*
* @param point Point at which the objective function must be evaluated.
@@ -229,8 +242,8 @@ public abstract class BaseAbstractUnivar
UnivariateSolverUtils.verifyInterval(lower, upper);
// Reset.
- this.min = lower;
- this.max = upper;
+ min = lower;
+ max = upper;
function = f;
evaluations.setMaximalCount(maxEval);
evaluations.resetCount();
Modified:
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/LegendreGaussIntegrator.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/LegendreGaussIntegrator.java?rev=1296571&r1=1296570&r2=1296571&view=diff
==============================================================================
---
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/LegendreGaussIntegrator.java
(original)
+++
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/LegendreGaussIntegrator.java
Sat Mar 3 03:55:24 2012
@@ -210,11 +210,11 @@ public class LegendreGaussIntegrator ext
// estimate error
final double delta = FastMath.abs(t - oldt);
final double limit =
- FastMath.max(absoluteAccuracy,
- relativeAccuracy * (FastMath.abs(oldt) +
FastMath.abs(t)) * 0.5);
+ FastMath.max(getAbsoluteAccuracy(),
+ getRelativeAccuracy() * (FastMath.abs(oldt) +
FastMath.abs(t)) * 0.5);
// check convergence
- if ((iterations.getCount() + 1 >= minimalIterationCount) && (delta
<= limit)) {
+ if ((iterations.getCount() + 1 >= getMinimalIterationCount()) &&
(delta <= limit)) {
return t;
}
@@ -239,11 +239,11 @@ public class LegendreGaussIntegrator ext
throws TooManyEvaluationsException {
// set up the step for the current stage
- final double step = (max - min) / n;
+ final double step = (getMax() - getMin()) / n;
final double halfStep = step / 2.0;
// integrate over all elementary steps
- double midPoint = min + halfStep;
+ double midPoint = getMin() + halfStep;
double sum = 0.0;
for (int i = 0; i < n; ++i) {
for (int j = 0; j < abscissas.length; ++j) {
Modified:
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/RombergIntegrator.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/RombergIntegrator.java?rev=1296571&r1=1296570&r2=1296571&view=diff
==============================================================================
---
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/RombergIntegrator.java
(original)
+++
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/RombergIntegrator.java
Sat Mar 3 03:55:24 2012
@@ -128,10 +128,10 @@ public class RombergIntegrator extends B
currentRow[j] = tIJm1 + (tIJm1 - previousRow[j - 1]) / r;
}
final double s = currentRow[i];
- if (i >= minimalIterationCount) {
+ if (i >= getMinimalIterationCount()) {
final double delta = FastMath.abs(s - olds);
- final double rLimit = relativeAccuracy * (FastMath.abs(olds) +
FastMath.abs(s)) * 0.5;
- if ((delta <= rLimit) || (delta <= absoluteAccuracy)) {
+ final double rLimit = getRelativeAccuracy() *
(FastMath.abs(olds) + FastMath.abs(s)) * 0.5;
+ if ((delta <= rLimit) || (delta <= getAbsoluteAccuracy())) {
return s;
}
}
Modified:
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/SimpsonIntegrator.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/SimpsonIntegrator.java?rev=1296571&r1=1296570&r2=1296571&view=diff
==============================================================================
---
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/SimpsonIntegrator.java
(original)
+++
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/SimpsonIntegrator.java
Sat Mar 3 03:55:24 2012
@@ -102,7 +102,7 @@ public class SimpsonIntegrator extends B
throws TooManyEvaluationsException, MaxCountExceededException {
TrapezoidIntegrator qtrap = new TrapezoidIntegrator();
- if (minimalIterationCount == 1) {
+ if (getMinimalIterationCount() == 1) {
return (4 * qtrap.stage(this, 1) - qtrap.stage(this, 0)) / 3.0;
}
@@ -113,11 +113,11 @@ public class SimpsonIntegrator extends B
final double t = qtrap.stage(this, iterations.getCount());
iterations.incrementCount();
final double s = (4 * t - oldt) / 3.0;
- if (iterations.getCount() >= minimalIterationCount) {
+ if (iterations.getCount() >= getMinimalIterationCount()) {
final double delta = FastMath.abs(s - olds);
final double rLimit =
- relativeAccuracy * (FastMath.abs(olds) + FastMath.abs(s))
* 0.5;
- if ((delta <= rLimit) || (delta <= absoluteAccuracy)) {
+ getRelativeAccuracy() * (FastMath.abs(olds) +
FastMath.abs(s)) * 0.5;
+ if ((delta <= rLimit) || (delta <= getAbsoluteAccuracy())) {
return s;
}
}
Modified:
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/TrapezoidIntegrator.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/TrapezoidIntegrator.java?rev=1296571&r1=1296570&r2=1296571&view=diff
==============================================================================
---
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/TrapezoidIntegrator.java
(original)
+++
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/TrapezoidIntegrator.java
Sat Mar 3 03:55:24 2012
@@ -117,16 +117,20 @@ public class TrapezoidIntegrator extends
throws TooManyEvaluationsException {
if (n == 0) {
- s = 0.5 * (baseIntegrator.max - baseIntegrator.min) *
-
(baseIntegrator.computeObjectiveValue(baseIntegrator.min) +
-
baseIntegrator.computeObjectiveValue(baseIntegrator.max));
+ final double max = baseIntegrator.getMax();
+ final double min = baseIntegrator.getMin();
+ s = 0.5 * (max - min) *
+ (baseIntegrator.computeObjectiveValue(min) +
+ baseIntegrator.computeObjectiveValue(max));
return s;
} else {
final long np = 1L << (n-1); // number of new points in
this stage
double sum = 0;
+ final double max = baseIntegrator.getMax();
+ final double min = baseIntegrator.getMin();
// spacing between adjacent new points
- final double spacing = (baseIntegrator.max - baseIntegrator.min) /
np;
- double x = baseIntegrator.min + 0.5 * spacing; // the first new
point
+ final double spacing = (max - min) / np;
+ double x = min + 0.5 * spacing; // the first new point
for (long i = 0; i < np; i++) {
sum += baseIntegrator.computeObjectiveValue(x);
x += spacing;
@@ -147,11 +151,11 @@ public class TrapezoidIntegrator extends
while (true) {
final int i = iterations.getCount();
final double t = stage(this, i);
- if (i >= minimalIterationCount) {
+ if (i >= getMinimalIterationCount()) {
final double delta = FastMath.abs(t - oldt);
final double rLimit =
- relativeAccuracy * (FastMath.abs(oldt) + FastMath.abs(t))
* 0.5;
- if ((delta <= rLimit) || (delta <= absoluteAccuracy)) {
+ getRelativeAccuracy() * (FastMath.abs(oldt) +
FastMath.abs(t)) * 0.5;
+ if ((delta <= rLimit) || (delta <= getAbsoluteAccuracy())) {
return t;
}
}