improved SOC between AbstractEstimator and its derived classes

(changed fields from protected to private, changed methods to final,
added counter incrementation final method)

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@627987 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Luc Maisonobe 2008-02-15 10:01:26 +00:00
parent 5fbdab2e13
commit 2295b7c2fb
2 changed files with 15 additions and 8 deletions

View File

@ -44,7 +44,7 @@ public abstract class AbstractEstimator implements Estimator {
* @param maxCostEval maximal number of cost evaluations allowed
* @see #estimate
*/
public void setMaxCostEval(int maxCostEval) {
public final void setMaxCostEval(int maxCostEval) {
this.maxCostEval = maxCostEval;
}
@ -53,7 +53,7 @@ public abstract class AbstractEstimator implements Estimator {
*
* @return number of cost evaluations
* */
public int getCostEvaluations() {
public final int getCostEvaluations() {
return costEvaluations;
}
@ -62,7 +62,7 @@ public abstract class AbstractEstimator implements Estimator {
*
* @return number of jacobian evaluations
* */
public int getJacobianEvaluations() {
public final int getJacobianEvaluations() {
return jacobianEvaluations;
}
@ -70,7 +70,7 @@ public abstract class AbstractEstimator implements Estimator {
* Update the jacobian matrix.
*/
protected void updateJacobian() {
++jacobianEvaluations;
incrementJacobianEvaluationsCounter();
Arrays.fill(jacobian, 0);
for (int i = 0, index = 0; i < rows; i++) {
WeightedMeasurement wm = measurements[i];
@ -81,6 +81,13 @@ public abstract class AbstractEstimator implements Estimator {
}
}
/**
* Increment the jacobian evaluations counter.
*/
protected final void incrementJacobianEvaluationsCounter() {
++jacobianEvaluations;
}
/**
* Update the residuals array and cost function value.
* @exception EstimationException if the number of cost evaluations
@ -283,12 +290,12 @@ public abstract class AbstractEstimator implements Estimator {
protected double cost;
/** Maximal allowed number of cost evaluations. */
protected int maxCostEval;
private int maxCostEval;
/** Number of cost evaluations. */
protected int costEvaluations;
private int costEvaluations;
/** Number of jacobian evaluations. */
protected int jacobianEvaluations;
private int jacobianEvaluations;
}

View File

@ -116,7 +116,7 @@ public class GaussNewtonEstimator extends AbstractEstimator implements Serializa
do {
// build the linear problem
++jacobianEvaluations;
incrementJacobianEvaluationsCounter();
RealMatrix b = new RealMatrixImpl(parameters.length, 1);
RealMatrix a = new RealMatrixImpl(parameters.length, parameters.length);
for (int i = 0; i < measurements.length; ++i) {