You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by lu...@apache.org on 2008/02/15 11:01:28 UTC

svn commit: r627987 - in /commons/proper/math/trunk/src/java/org/apache/commons/math/estimation: AbstractEstimator.java GaussNewtonEstimator.java

Author: luc
Date: Fri Feb 15 02:01:26 2008
New Revision: 627987

URL: http://svn.apache.org/viewvc?rev=627987&view=rev
Log:
improved SOC between AbstractEstimator and its derived classes
(changed fields from protected to private, changed methods to final,
added counter incrementation final method)

Modified:
    commons/proper/math/trunk/src/java/org/apache/commons/math/estimation/AbstractEstimator.java
    commons/proper/math/trunk/src/java/org/apache/commons/math/estimation/GaussNewtonEstimator.java

Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/estimation/AbstractEstimator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/estimation/AbstractEstimator.java?rev=627987&r1=627986&r2=627987&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/estimation/AbstractEstimator.java (original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/estimation/AbstractEstimator.java Fri Feb 15 02:01:26 2008
@@ -44,7 +44,7 @@
      * @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 @@
      * 
      * @return number of cost evaluations
      * */
-    public int getCostEvaluations() {
+    public final int getCostEvaluations() {
         return costEvaluations;
     }
 
@@ -62,7 +62,7 @@
      * 
      * @return number of jacobian evaluations
      * */
-    public int getJacobianEvaluations() {
+    public final int getJacobianEvaluations() {
         return jacobianEvaluations;
     }
 
@@ -70,7 +70,7 @@
      * 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 @@
         }
     }
 
+    /**
+     * 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 @@
     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;
 
 }

Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/estimation/GaussNewtonEstimator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/estimation/GaussNewtonEstimator.java?rev=627987&r1=627986&r2=627987&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/estimation/GaussNewtonEstimator.java (original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/estimation/GaussNewtonEstimator.java Fri Feb 15 02:01:26 2008
@@ -116,7 +116,7 @@
         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) {