commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pste...@apache.org
Subject svn commit: r488828 [3/6] - in /jakarta/commons/proper/math/trunk/src/mantissa: src/org/spaceroots/mantissa/ src/org/spaceroots/mantissa/algebra/ src/org/spaceroots/mantissa/fitting/ src/org/spaceroots/mantissa/functions/scalar/ src/org/spaceroots/mant...
Date Tue, 19 Dec 2006 22:11:11 GMT
Modified: jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/ode/DummyStepInterpolator.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/ode/DummyStepInterpolator.java?view=diff&rev=488828&r1=488827&r2=488828
==============================================================================
--- jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/ode/DummyStepInterpolator.java (original)
+++ jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/ode/DummyStepInterpolator.java Tue Dec 19 14:11:07 2006
@@ -49,7 +49,7 @@
    * to create the step interpolators by cloning an uninitialized
    * model and latter initializing the copy.
    */
-  protected DummyStepInterpolator() {
+  public DummyStepInterpolator() {
     super();
   }
 
@@ -81,15 +81,6 @@
    */
   protected DummyStepInterpolator(DummyStepInterpolator interpolator) {
     super(interpolator);
-  }
-
-  /** Copy the instance.
-   * the copy is a deep copy: its arrays are separated from the
-   * original arrays of the instance
-   * @return a copy of the instance.
-   */
-  public Object clone() {
-    return new DummyStepInterpolator(this);
   }
 
   /** Compute the state at the interpolated time.

Modified: jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/ode/EulerIntegrator.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/ode/EulerIntegrator.java?view=diff&rev=488828&r1=488827&r2=488828
==============================================================================
--- jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/ode/EulerIntegrator.java (original)
+++ jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/ode/EulerIntegrator.java Tue Dec 19 14:11:07 2006
@@ -50,7 +50,7 @@
 public class EulerIntegrator
   extends RungeKuttaIntegrator {
 
-  private static final String methodName = new String("Euler");
+  private static final String methodName = "Euler";
 
   private static final double[] c = {
   };

Modified: jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/ode/GillIntegrator.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/ode/GillIntegrator.java?view=diff&rev=488828&r1=488827&r2=488828
==============================================================================
--- jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/ode/GillIntegrator.java (original)
+++ jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/ode/GillIntegrator.java Tue Dec 19 14:11:07 2006
@@ -46,7 +46,7 @@
 public class GillIntegrator
   extends RungeKuttaIntegrator {
 
-  private static final String methodName = new String("Gill");
+  private static final String methodName = "Gill";
 
   private static final double sqrt2 = Math.sqrt(2.0);
 

Modified: jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/ode/GraggBulirschStoerIntegrator.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/ode/GraggBulirschStoerIntegrator.java?view=diff&rev=488828&r1=488827&r2=488828
==============================================================================
--- jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/ode/GraggBulirschStoerIntegrator.java (original)
+++ jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/ode/GraggBulirschStoerIntegrator.java Tue Dec 19 14:11:07 2006
@@ -88,7 +88,7 @@
 public class GraggBulirschStoerIntegrator
   extends AdaptiveStepsizeIntegrator {
 
-  private static final String methodName = new String("Gragg-Bulirsch-Stoer");
+  private static final String methodName = "Gragg-Bulirsch-Stoer";
 
   /** Simple constructor.
    * Build a Gragg-Bulirsch-Stoer integrator with the given step
@@ -713,7 +713,7 @@
                     // estimate if there is a chance convergence will
                     // be reached on next iteration, using the
                     // asymptotic evolution of error
-                    double ratio = sequence [k] * sequence[k+1]
+                    double ratio = ((double) sequence [k] * sequence[k+1])
                                  / (sequence[0] * sequence[0]);
                     if (error > ratio * ratio) {
                       // we don't expect to converge on next iteration
@@ -740,7 +740,7 @@
                   // estimate if there is a chance convergence will
                   // be reached on next iteration, using the
                   // asymptotic evolution of error
-                  double ratio = sequence[k+1] / sequence[0];
+                  double ratio = ((double) sequence[k+1]) / sequence[0];
                   if (error > ratio * ratio) {
                     // we don't expect to converge on next iteration
                     // we reject the step immediately

Modified: jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/ode/HighamHall54Integrator.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/ode/HighamHall54Integrator.java?view=diff&rev=488828&r1=488827&r2=488828
==============================================================================
--- jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/ode/HighamHall54Integrator.java (original)
+++ jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/ode/HighamHall54Integrator.java Tue Dec 19 14:11:07 2006
@@ -35,7 +35,7 @@
 public class HighamHall54Integrator
   extends RungeKuttaFehlbergIntegrator {
 
-  private static final String methodName = new String("Higham-Hall 5(4)");
+  private static final String methodName = "Higham-Hall 5(4)";
 
   private static final double[] c = {
     2.0/9.0, 1.0/3.0, 1.0/2.0, 3.0/5.0, 1.0, 1.0

Modified: jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/ode/MidpointIntegrator.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/ode/MidpointIntegrator.java?view=diff&rev=488828&r1=488827&r2=488828
==============================================================================
--- jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/ode/MidpointIntegrator.java (original)
+++ jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/ode/MidpointIntegrator.java Tue Dec 19 14:11:07 2006
@@ -43,7 +43,7 @@
 public class MidpointIntegrator
   extends RungeKuttaIntegrator {
 
-  private static final String methodName = new String("midpoint");
+  private static final String methodName = "midpoint";
 
   private static final double[] c = {
     1.0 / 2.0

Modified: jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/ode/StepNormalizer.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/ode/StepNormalizer.java?view=diff&rev=488828&r1=488827&r2=488828
==============================================================================
--- jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/ode/StepNormalizer.java (original)
+++ jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/ode/StepNormalizer.java Tue Dec 19 14:11:07 2006
@@ -104,8 +104,7 @@
       interpolator.setInterpolatedTime(lastTime);
 
       double[] state = interpolator.getInterpolatedState();
-      lastState = new double[state.length];
-      System.arraycopy(state, 0, lastState, 0, lastState.length);
+      lastState = (double[]) state.clone();
 
       // take the integration direction into account
       forward = (interpolator.getCurrentTime() >= lastTime);

Modified: jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/ode/SwitchState.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/ode/SwitchState.java?view=diff&rev=488828&r1=488827&r2=488828
==============================================================================
--- jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/ode/SwitchState.java (original)
+++ jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/ode/SwitchState.java Tue Dec 19 14:11:07 2006
@@ -42,6 +42,8 @@
 class SwitchState
   implements ComputableFunction, ConvergenceChecker {
 
+  private static final long serialVersionUID = 6944466361876662425L;
+
   /** Switching function. */
   private SwitchingFunction function;
 

Modified: jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/ode/SwitchingFunction.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/ode/SwitchingFunction.java?view=diff&rev=488828&r1=488827&r2=488828
==============================================================================
--- jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/ode/SwitchingFunction.java (original)
+++ jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/ode/SwitchingFunction.java Tue Dec 19 14:11:07 2006
@@ -17,6 +17,8 @@
 
 package org.spaceroots.mantissa.ode;
 
+import java.io.Serializable;
+
 /** This interface represents a switching function.
  *
  * <p>A switching function allows to handle discrete events in
@@ -45,7 +47,7 @@
  *
  */
 
-public interface SwitchingFunction {
+public interface SwitchingFunction extends Serializable {
 
   /** Stop indicator.
    * <p>This value should be used as the return value of the {@link

Modified: jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/ode/ThreeEighthesIntegrator.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/ode/ThreeEighthesIntegrator.java?view=diff&rev=488828&r1=488827&r2=488828
==============================================================================
--- jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/ode/ThreeEighthesIntegrator.java (original)
+++ jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/ode/ThreeEighthesIntegrator.java Tue Dec 19 14:11:07 2006
@@ -46,7 +46,7 @@
 public class ThreeEighthesIntegrator
   extends RungeKuttaIntegrator {
 
-  private static final String methodName = new String("3/8");
+  private static final String methodName = "3/8";
 
   private static final double[] c = {
     1.0 / 3.0, 2.0 / 3.0, 1.0

Modified: jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/optimization/DirectSearchOptimizer.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/optimization/DirectSearchOptimizer.java?view=diff&rev=488828&r1=488827&r2=488828
==============================================================================
--- jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/optimization/DirectSearchOptimizer.java (original)
+++ jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/optimization/DirectSearchOptimizer.java Tue Dec 19 14:11:07 2006
@@ -243,7 +243,7 @@
     }
 
     RandomVectorGenerator rvg =
-      new CorrelatedRandomVectorGenerator(statistics.getMean(null),
+      new CorrelatedRandomVectorGenerator(statistics.getMean(),
                                           statistics.getCovarianceMatrix(null),
                                           new UniformRandomGenerator(seed));
     setMultiStart(starts, rvg);
@@ -344,7 +344,7 @@
       if (i < n) {
         System.arraycopy(vertexA, i, vertex, i, n - i);
       }
-      simplex[i] = new PointCostPair(vertex);
+      simplex[i] = new PointCostPair(vertex, Double.NaN);
     }
 
   }
@@ -356,7 +356,7 @@
     int n = vertices.length - 1;
     simplex = new PointCostPair[n + 1];
     for (int i = 0; i <= n; ++i) {
-      simplex[i] = new PointCostPair(vertices[i]);
+      simplex[i] = new PointCostPair(vertices[i], Double.NaN);
     }
   }
 
@@ -369,11 +369,11 @@
     double[] vertex = generator.nextVector();
     int n = vertex.length;
     simplex = new PointCostPair[n + 1];
-    simplex[0] = new PointCostPair(vertex);
+    simplex[0] = new PointCostPair(vertex, Double.NaN);
 
     // fill up the vertex
     for (int i = 1; i <= n; ++i) {
-      simplex[i] = new PointCostPair(generator.nextVector());
+      simplex[i] = new PointCostPair(generator.nextVector(), Double.NaN);
     }
 
   }
@@ -428,7 +428,7 @@
    * minimizes} has not been called
    */
   public PointCostPair[] getMinima() {
-    return minima;
+    return (PointCostPair[]) minima.clone();
   }
 
   /** Minimizes a cost function.
@@ -522,8 +522,8 @@
     // evaluate the cost at all non-evaluated simplex points
     for (int i = 0; i < simplex.length; ++i) {
       PointCostPair pair = simplex[i];
-      if (! pair.isEvaluated()) {
-        pair.setCost(evaluateCost(pair.getPoint()));
+      if (Double.isNaN(pair.cost)) {
+        simplex[i] = new PointCostPair(pair.point, evaluateCost(pair.point));
       }
     }
 
@@ -538,7 +538,7 @@
   protected void replaceWorstPoint(PointCostPair pointCostPair) {
     int n = simplex.length - 1;
     for (int i = 0; i < n; ++i) {
-      if (simplex[i].getCost() > pointCostPair.getCost()) {
+      if (simplex[i].cost > pointCostPair.cost) {
         PointCostPair tmp = simplex[i];
         simplex[i]        = pointCostPair;
         pointCostPair     = tmp;
@@ -555,8 +555,8 @@
         } else if (o2 == null) {
           return -1;
         } else {
-          double cost1 = ((PointCostPair) o1).getCost();
-          double cost2 = ((PointCostPair) o2).getCost();
+          double cost1 = ((PointCostPair) o1).cost;
+          double cost2 = ((PointCostPair) o2).cost;
           return (cost1 < cost2) ? -1 : ((o1 == o2) ? 0 : +1);
         }
       }

Modified: jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/optimization/MultiDirectional.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/optimization/MultiDirectional.java?view=diff&rev=488828&r1=488827&r2=488828
==============================================================================
--- jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/optimization/MultiDirectional.java (original)
+++ jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/optimization/MultiDirectional.java Tue Dec 19 14:11:07 2006
@@ -54,7 +54,7 @@
 
       // save the original vertex
       PointCostPair[] original = simplex;
-      double originalCost = original[0].getCost();
+      double originalCost = original[0].cost;
 
       // perform a reflection step
       double reflectedCost = evaluateNewSimplex(original, 1.0);
@@ -93,24 +93,24 @@
   private double evaluateNewSimplex(PointCostPair[] original, double coeff)
     throws CostException {
 
-    double[] xSmallest = original[0].getPoint();
+    double[] xSmallest = original[0].point;
     int n = xSmallest.length;
 
     // create the linearly transformed simplex
     simplex = new PointCostPair[n + 1];
     simplex[0] = original[0];
     for (int i = 1; i <= n; ++i) {
-      double[] xOriginal    = original[i].getPoint();
+      double[] xOriginal    = original[i].point;
       double[] xTransformed = new double[n];
       for (int j = 0; j < n; ++j) {
         xTransformed[j] = xSmallest[j] + coeff * (xSmallest[j] - xOriginal[j]);
       }
-      simplex[i] = new PointCostPair(xTransformed);
+      simplex[i] = new PointCostPair(xTransformed, Double.NaN);
     }
 
     // evaluate it
     evaluateSimplex();
-    return simplex[0].getCost();
+    return simplex[0].cost;
 
   }
 

Modified: jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/optimization/NelderMead.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/optimization/NelderMead.java?view=diff&rev=488828&r1=488827&r2=488828
==============================================================================
--- jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/optimization/NelderMead.java (original)
+++ jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/optimization/NelderMead.java Tue Dec 19 14:11:07 2006
@@ -61,16 +61,16 @@
     int n = simplex.length - 1;
 
     // interesting costs
-    double   smallest      = simplex[0].getCost();
-    double   secondLargest = simplex[n-1].getCost();
-    double   largest       = simplex[n].getCost();
-    double[] xLargest      = simplex[n].getPoint();
+    double   smallest      = simplex[0].cost;
+    double   secondLargest = simplex[n-1].cost;
+    double   largest       = simplex[n].cost;
+    double[] xLargest      = simplex[n].point;
 
     // compute the centroid of the best vertices
     // (dismissing the worst point at index n)
     double[] centroid = new double[n];
     for (int i = 0; i < n; ++i) {
-      double[] x = simplex[i].getPoint();
+      double[] x = simplex[i].point;
       for (int j = 0; j < n; ++j) {
         centroid[j] += x[j];
       }
@@ -90,9 +90,7 @@
     if ((smallest <= costR) && (costR < secondLargest)) {
 
       // accept the reflected point
-      PointCostPair r = new PointCostPair(xR);
-      r.setCost(costR);
-      replaceWorstPoint(r);
+      replaceWorstPoint(new PointCostPair(xR, costR));
 
     } else if (costR < smallest) {
 
@@ -105,14 +103,10 @@
 
       if (costE < costR) {
         // accept the expansion point
-        PointCostPair e = new PointCostPair(xE);
-        e.setCost(costE);
-        replaceWorstPoint(e);
+        replaceWorstPoint(new PointCostPair(xE, costE));
       } else {
         // accept the reflected point
-        PointCostPair r = new PointCostPair(xR);
-        r.setCost(costR);
-        replaceWorstPoint(r);
+        replaceWorstPoint(new PointCostPair(xR, costR));
       }
 
     } else {
@@ -128,9 +122,7 @@
 
         if (costC <= costR) {
           // accept the contraction point
-          PointCostPair c = new PointCostPair(xC);
-          c.setCost(costC);
-          replaceWorstPoint(c);
+          replaceWorstPoint(new PointCostPair(xC, costC));
           return;
         }
 
@@ -145,23 +137,20 @@
 
         if (costC < largest) {
           // accept the contraction point
-          PointCostPair c = new PointCostPair(xC);
-          c.setCost(costC);
-          replaceWorstPoint(c);
+          replaceWorstPoint(new PointCostPair(xC, costC));
           return;
         }
 
       }
 
       // perform a shrink
-      double[] xSmallest = simplex[0].getPoint();
+      double[] xSmallest = simplex[0].point;
       for (int i = 1; i < simplex.length; ++i) {
-        PointCostPair pair = simplex[i];
-        double[] x = pair.getPoint();
+        double[] x = simplex[i].point;
         for (int j = 0; j < n; ++j) {
           x[j] = xSmallest[j] + sigma * (x[j] - xSmallest[j]);
         }
-        pair.setCost(Double.NaN);
+        simplex[i] = new PointCostPair(x, Double.NaN);
       }
       evaluateSimplex();
 

Modified: jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/optimization/PointCostPair.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/optimization/PointCostPair.java?view=diff&rev=488828&r1=488827&r2=488828
==============================================================================
--- jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/optimization/PointCostPair.java (original)
+++ jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/optimization/PointCostPair.java Tue Dec 19 14:11:07 2006
@@ -18,72 +18,26 @@
 package org.spaceroots.mantissa.optimization;
 
 /** This class holds a point and its associated cost.
- * <p>A cost/point pair is not evaluated at build time. Its associated
- * cost set to <code>Double.NaN</code> until it is evaluated.</p>
+ * <p>This is a simple immutable container.</p>
  * @author Luc Maisonobe
- * @version $Id: PointCostPair.java 1705 2006-09-17 19:57:39Z luc $
+ * @version $Id: PointCostPair.java 1709 2006-12-03 21:16:50Z luc $
  * @see CostFunction
  */
 public class PointCostPair {
 
-  /** Build a point/cost pair with non-evaluated cost.
+  /** Build a point/cost pair.
    * @param point point coordinates
+   * @param cost point cost
    */
-  public PointCostPair(double[] point) {
-    this.point = point;
-    cost = Double.NaN;
-  }
-
-  /** Reset the point coordinates.
-   * <p>Resetting the points coordinates automatically reset the cost
-   * to non-evaluated</p>
-   * @param point new point coordinates
-   * @return old point coordinates (this can be re-used to put the
-   * coordinates of another point without re-allocating an array)
-   */
-  public double[] setPoint(double[] point) {
-    double[] oldPoint = this.point;
-    this.point = point;
-    cost = Double.NaN;
-    return oldPoint;
-  }
-
-  /** Get the point coordinates.
-   * @return point coordinates
-   */
-  public double[] getPoint() {
-    return point;
-  }
-
-  /** Set the cost.
-   * @param cost cost to store in the instance (can be
-   * <code>Double.NaN</code> to reset the instance to non-evaluated)
-   */
-  public void setCost(double cost) {
+  public PointCostPair(double[] point, double cost) {
+    this.point = (double[]) point.clone();
     this.cost = cost;
   }
 
-  /** Get the cost.
-   * @return cost associated to the point (or <code>Double.NaN</code>
-   * if the instance is not evaluated)
-   */
-  public double getCost() {
-    return cost;
-  }
-
-  /** Check if the cost has been evaluated.
-   * <p>The cost is considered to be non-evaluated if it is
-   * <code>Double.isNaN(pair.getCost())</code> would return true</p>
-   * @return true if the cost has been evaluated
-   */
-  public boolean isEvaluated() {
-    return ! Double.isNaN(cost);
-  }
-
   /** Point coordinates. */
-  private double[] point;
+  public final double[] point;
 
   /** Cost associated to the point. */
-  private double cost;
+  public final double cost;
 
 }

Modified: jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/quadrature/vectorial/EnhancedSimpsonIntegrator.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/quadrature/vectorial/EnhancedSimpsonIntegrator.java?view=diff&rev=488828&r1=488827&r2=488828
==============================================================================
--- jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/quadrature/vectorial/EnhancedSimpsonIntegrator.java (original)
+++ jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/quadrature/vectorial/EnhancedSimpsonIntegrator.java Tue Dec 19 14:11:07 2006
@@ -45,7 +45,7 @@
 
     try {
       while (true) {
-        sum = sampler.nextSamplePoint().getY();
+        sum = sampler.nextSamplePoint().y;
       }
     } catch(ExhaustedSampleException e) {
     }

Modified: jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/quadrature/vectorial/EnhancedSimpsonIntegratorSampler.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/quadrature/vectorial/EnhancedSimpsonIntegratorSampler.java?view=diff&rev=488828&r1=488827&r2=488828
==============================================================================
--- jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/quadrature/vectorial/EnhancedSimpsonIntegratorSampler.java (original)
+++ jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/quadrature/vectorial/EnhancedSimpsonIntegratorSampler.java Tue Dec 19 14:11:07 2006
@@ -85,15 +85,15 @@
     try {
       next = iter.nextSamplePoint();
 
-      double h1 = current.getX() - previous.getX();
-      double h2 = next.getX()    - current.getX();
+      double h1 = current.x - previous.x;
+      double h2 = next.x    - current.x;
       double cP = (h1 + h2) * (2 * h1 - h2) / (6 * h1);
       double cC = (h1 + h2) * (h1 + h2) * (h1 + h2) / (6 * h1 * h2);
       double cN = (h1 + h2) * (2 * h2 - h1) / (6 * h2);
 
-      double[] pY = previous.getY();
-      double[] cY = current.getY();
-      double[] nY = next.getY();
+      double[] pY = previous.y;
+      double[] cY = current.y;
+      double[] nY = next.y;
       for (int i = 0; i < sum.length; ++i) {
         sum [i] += cP * pY[i] + cC * cY[i] + cN * nY[i];
       }
@@ -101,18 +101,16 @@
     } catch(ExhaustedSampleException e) {
       // we have an incomplete step at the end of the sample
       // we use a trapezoid scheme for this last step
-      double halfDx = 0.5 * (current.getX() - previous.getX());
-      double[] pY = previous.getY();
-      double[] cY = current.getY();
+      double halfDx = 0.5 * (current.x - previous.x);
+      double[] pY = previous.y;
+      double[] cY = current.y;
       for (int i = 0; i < sum.length; ++i) {
         sum [i] += halfDx * (pY[i] + cY[i]);
       }
-      return new VectorialValuedPair(current.getX(), sum);
+      return new VectorialValuedPair(current.x, sum);
     }
 
-    double[] values = new double[sum.length];
-    System.arraycopy(sum, 0, values, 0, sum.length);
-    return new VectorialValuedPair(next.getX(), values);
+    return new VectorialValuedPair(next.x, (double[]) sum.clone());
 
   }
 

Modified: jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/quadrature/vectorial/RiemannIntegrator.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/quadrature/vectorial/RiemannIntegrator.java?view=diff&rev=488828&r1=488827&r2=488828
==============================================================================
--- jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/quadrature/vectorial/RiemannIntegrator.java (original)
+++ jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/quadrature/vectorial/RiemannIntegrator.java Tue Dec 19 14:11:07 2006
@@ -51,7 +51,7 @@
 
     try {
       while (true) {
-        sum = sampler.nextSamplePoint().getY();
+        sum = sampler.nextSamplePoint().y;
       }
     } catch(ExhaustedSampleException e) {
     }

Modified: jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/quadrature/vectorial/RiemannIntegratorSampler.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/quadrature/vectorial/RiemannIntegratorSampler.java?view=diff&rev=488828&r1=488827&r2=488828
==============================================================================
--- jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/quadrature/vectorial/RiemannIntegratorSampler.java (original)
+++ jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/quadrature/vectorial/RiemannIntegratorSampler.java Tue Dec 19 14:11:07 2006
@@ -86,15 +86,13 @@
     // performs one step of a Riemann scheme
     VectorialValuedPair previous = current;
     current = iter.nextSamplePoint();
-    double step =  (current.getX() - previous.getX());
-    double[] pY = previous.getY();
+    double step =  (current.x - previous.x);
+    double[] pY = previous.y;
     for (int i = 0; i < sum.length; ++i) {
       sum[i] += step * pY[i];
     }
 
-    double[] values = new double[sum.length];
-    System.arraycopy(sum, 0, values, 0, sum.length);
-    return new VectorialValuedPair (current.getX(), values);
+    return new VectorialValuedPair (current.x, (double[]) sum.clone());
 
   }
 

Modified: jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/quadrature/vectorial/TrapezoidIntegrator.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/quadrature/vectorial/TrapezoidIntegrator.java?view=diff&rev=488828&r1=488827&r2=488828
==============================================================================
--- jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/quadrature/vectorial/TrapezoidIntegrator.java (original)
+++ jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/quadrature/vectorial/TrapezoidIntegrator.java Tue Dec 19 14:11:07 2006
@@ -42,7 +42,7 @@
 
     try {
       while (true) {
-        sum = sampler.nextSamplePoint().getY();
+        sum = sampler.nextSamplePoint().y;
       }
     } catch(ExhaustedSampleException e) {
     }

Modified: jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/quadrature/vectorial/TrapezoidIntegratorSampler.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/quadrature/vectorial/TrapezoidIntegratorSampler.java?view=diff&rev=488828&r1=488827&r2=488828
==============================================================================
--- jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/quadrature/vectorial/TrapezoidIntegratorSampler.java (original)
+++ jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/quadrature/vectorial/TrapezoidIntegratorSampler.java Tue Dec 19 14:11:07 2006
@@ -87,16 +87,14 @@
     VectorialValuedPair previous = current;
     current = iter.nextSamplePoint();
 
-    double halfDx = 0.5 * (current.getX() - previous.getX());
-    double[] pY = previous.getY();
-    double[] cY = current.getY();
+    double halfDx = 0.5 * (current.x - previous.x);
+    double[] pY = previous.y;
+    double[] cY = current.y;
     for (int i = 0; i < sum.length; ++i) {
       sum[i] += halfDx * (pY[i] + cY[i]);
     }
 
-    double[] values = new double[sum.length];
-    System.arraycopy(sum, 0, values, 0, sum.length);
-    return new VectorialValuedPair (current.getX(), values);
+    return new VectorialValuedPair (current.x, (double[]) sum.clone());
 
   }
 

Modified: jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/random/CorrelatedRandomVectorGenerator.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/random/CorrelatedRandomVectorGenerator.java?view=diff&rev=488828&r1=488827&r2=488828
==============================================================================
--- jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/random/CorrelatedRandomVectorGenerator.java (original)
+++ jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/random/CorrelatedRandomVectorGenerator.java Tue Dec 19 14:11:07 2006
@@ -81,13 +81,12 @@
                                     });
       throw new IllegalArgumentException(message);
     }
-    this.mean = mean;
+    this.mean = (double[]) mean.clone();
 
     factorize(covariance);
 
     this.generator = generator;
     normalized = new double[rank];
-    correlated = new double[order];
 
   }
 
@@ -114,7 +113,6 @@
 
     this.generator = generator;
     normalized = new double[rank];
-    correlated = new double[order];
 
   }
 
@@ -240,10 +238,8 @@
   }
 
   /** Generate a correlated random vector.
-   * @return a random vector as an array of double. The generator
-   * <em>will</em> reuse the same array for each call, in order to
-   * save the allocation time, so the user should keep a copy by
-   * himself if he needs so.
+   * @return a random vector as an array of double. The returned array
+   * is created at each call, the caller can do what it wants with it.
    */
   public double[] nextVector() {
 
@@ -253,6 +249,7 @@
     }
 
     // compute correlated vector
+    double[] correlated = new double[mean.length];
     for (int i = 0; i < correlated.length; ++i) {
       correlated[i] = mean[i];
       for (int j = 0; j < rank; ++j) {
@@ -279,9 +276,6 @@
   /** Storage for the normalized vector. */
   private double[] normalized;
 
-  /** Storage for the random vector. */
-  private double[] correlated;
-
-  private static final long serialVersionUID = -4754497552287369719L;
+  private static final long serialVersionUID = -88563624902398453L;
 
 }

Modified: jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/random/GaussianRandomGenerator.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/random/GaussianRandomGenerator.java?view=diff&rev=488828&r1=488827&r2=488828
==============================================================================
--- jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/random/GaussianRandomGenerator.java (original)
+++ jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/random/GaussianRandomGenerator.java Tue Dec 19 14:11:07 2006
@@ -33,9 +33,6 @@
 public class GaussianRandomGenerator
   implements NormalizedRandomGenerator {
 
-  /** Underlying generator. */
-  Random generator;
-
   /** Create a new generator.
    * The seed of the generator is related to the current time.
    */
@@ -63,5 +60,10 @@
   public double nextDouble() {
     return generator.nextGaussian();
   }
+
+  /** Underlying generator. */
+  private Random generator;
+
+  private static final long serialVersionUID = 5504568059866195697L;
 
 }

Modified: jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/random/NormalizedRandomGenerator.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/random/NormalizedRandomGenerator.java?view=diff&rev=488828&r1=488827&r2=488828
==============================================================================
--- jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/random/NormalizedRandomGenerator.java (original)
+++ jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/random/NormalizedRandomGenerator.java Tue Dec 19 14:11:07 2006
@@ -17,6 +17,8 @@
 
 package org.spaceroots.mantissa.random;
 
+import java.io.Serializable;
+
 /** This interface represent a normalized random generator for
  * scalars.
  * Normalized generator should provide null mean and unit standard
@@ -24,7 +26,7 @@
  * @version $Id: NormalizedRandomGenerator.java 1705 2006-09-17 19:57:39Z luc $
  * @author L. Maisonobe
  */
-public interface NormalizedRandomGenerator {
+public interface NormalizedRandomGenerator extends Serializable {
 
   /** Generate a random scalar with null mean and unit standard deviation.
    * <p>This method does <strong>not</strong> specify the shape of the

Modified: jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/random/UncorrelatedRandomVectorGenerator.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/random/UncorrelatedRandomVectorGenerator.java?view=diff&rev=488828&r1=488827&r2=488828
==============================================================================
--- jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/random/UncorrelatedRandomVectorGenerator.java (original)
+++ jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/random/UncorrelatedRandomVectorGenerator.java Tue Dec 19 14:11:07 2006
@@ -46,11 +46,10 @@
     if (mean.length != standardDeviation.length) {
       throw new IllegalArgumentException("dimension mismatch");
     }
-    this.mean              = mean;
-    this.standardDeviation = standardDeviation;
+    this.mean              = (double[]) mean.clone();
+    this.standardDeviation = (double[]) standardDeviation.clone();
 
     this.generator = generator;
-    random = new double[mean.length];
 
   }
 
@@ -72,7 +71,6 @@
     }
 
     this.generator = generator;
-    random = new double[dimension];
 
   }
 
@@ -84,13 +82,12 @@
   }
 
   /** Generate a correlated random vector.
-   * @return a random vector as an array of double. The generator
-   * <em>will</em> reuse the same array for each call, in order to
-   * save the allocation time, so the user should keep a copy by
-   * himself if he needs so.
+   * @return a random vector as an array of double. The returned array
+   * is created at each call, the caller can do what it wants with it.
    */
   public double[] nextVector() {
 
+    double[] random = new double[mean.length]; 
     for (int i = 0; i < random.length; ++i) {
       random[i] = mean[i] + standardDeviation[i] * generator.nextDouble();
     }
@@ -108,9 +105,6 @@
   /** Underlying scalar generator. */
   NormalizedRandomGenerator generator;
 
-  /** Storage for the random vector. */
-  private double[] random;
-
-  private static final long serialVersionUID = -3323293740860311151L;
+  private static final long serialVersionUID = -9094322067568302961L;
 
 }

Modified: jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/random/UniformRandomGenerator.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/random/UniformRandomGenerator.java?view=diff&rev=488828&r1=488827&r2=488828
==============================================================================
--- jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/random/UniformRandomGenerator.java (original)
+++ jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/random/UniformRandomGenerator.java Tue Dec 19 14:11:07 2006
@@ -34,13 +34,6 @@
 public class UniformRandomGenerator
   implements NormalizedRandomGenerator {
 
-  private static final double SQRT3 = Math.sqrt(3.0);
-
-  private static final double TWOSQRT3 = 2.0 * Math.sqrt(3.0);
-
-  /** Underlying generator. */
-  Random generator;
-
   /** Create a new generator.
    * The seed of the generator is related to the current time.
    */
@@ -70,5 +63,14 @@
   public double nextDouble() {
     return TWOSQRT3 * generator.nextDouble() - SQRT3;
   }
+
+  /** Underlying generator. */
+  private Random generator;
+
+  private static final double SQRT3 = Math.sqrt(3.0);
+
+  private static final double TWOSQRT3 = 2.0 * Math.sqrt(3.0);
+
+  private static final long serialVersionUID = -6913329325753217654L;
 
 }

Modified: jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/random/VectorialSampleStatistics.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/random/VectorialSampleStatistics.java?view=diff&rev=488828&r1=488827&r2=488828
==============================================================================
--- jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/random/VectorialSampleStatistics.java (original)
+++ jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/random/VectorialSampleStatistics.java Tue Dec 19 14:11:07 2006
@@ -19,8 +19,6 @@
 
 import org.spaceroots.mantissa.linalg.SymetricalMatrix;
 
-import java.util.Arrays;
-
 /** This class compute basic statistics on a scalar sample.
  * @version $Id: VectorialSampleStatistics.java 1705 2006-09-17 19:57:39Z luc $
  * @author L. Maisonobe
@@ -65,16 +63,6 @@
     sum2       = null;
   }
 
-  /** Allocate all the arrays. */
-  private void allocate() {
-    min        = new double[dimension];
-    minIndices = new int[dimension];
-    max        = new double[dimension];
-    maxIndices = new int[dimension];
-    sum        = new double[dimension];
-    sum2       = new double[dimension * (dimension + 1) / 2];
-  }
-
   /** Add one point to the instance.
    * @param x value of the sample point
    * @exception IllegalArgumentException if there is a dimension
@@ -85,14 +73,13 @@
 
     if (n == 0) {
 
-      dimension = x.length;
-      allocate();
-
-      Arrays.fill(minIndices, 0);
-      Arrays.fill(maxIndices, 0);
-      System.arraycopy(x, 0, min, 0, dimension);
-      System.arraycopy(x, 0, max, 0, dimension);
-      System.arraycopy(x, 0, sum, 0, dimension);
+      dimension  = x.length;
+      minIndices = new int[dimension];
+      maxIndices = new int[dimension];
+      min        = (double[]) x.clone();
+      max        = (double[]) x.clone();
+      sum        = (double[]) x.clone();
+      sum2       = new double[dimension * (dimension + 1) / 2];
 
       int k = 0;
       for (int i = 0; i < dimension; ++i) {
@@ -153,14 +140,12 @@
     if (n == 0) {
 
       dimension = s.dimension;
-      allocate();
-
-      System.arraycopy(s.min,         0, min,         0, dimension);
-      System.arraycopy(s.minIndices,  0, minIndices,  0, dimension);
-      System.arraycopy(s.max,         0, max,         0, dimension);
-      System.arraycopy(s.maxIndices,  0, maxIndices,  0, dimension);
-      System.arraycopy(s.sum,         0, sum,         0, dimension);
-      System.arraycopy(s.sum2,        0, sum2,        0, sum2.length);
+      min        = (double[]) s.min.clone();
+      minIndices = (int[])    s.minIndices.clone();
+      max        = (double[]) s.max.clone();
+      maxIndices = (int[])    s.maxIndices.clone();
+      sum        = (double[]) s.sum.clone();
+      sum2       = (double[]) s.sum2.clone();
 
     } else {
       int k = 0;
@@ -203,26 +188,22 @@
    * of the sample at which the minimum was encountered can be
    * retrieved with the {@link #getMinIndices getMinIndices}
    * method.</p>
-   * @return minimal value in the sample (the array is a reference to
-   * an internal array that changes each time something is added to
-   * the instance, the caller should neither change it nor rely on its
-   * value in the long term)
+   * @return minimal value in the sample (a new array is created
+   * at each call, the caller may do what it wants to with it)
    * @see #getMinIndices
    */
   public double[] getMin() {
-    return min;
+    return (double[]) min.clone();
   }
 
   /** Get the indices at which the minimal value occurred in the sample.
    * @return a vector reporting at which occurrence each component of
-   * the sample reached its minimal value (the array is a reference to
-   * an internal array that changes each time something is added to
-   * the instance, the caller should neither change it nor rely on its
-   * value in the long term)
+   * the sample reached its minimal value (a new array is created
+   * at each call, the caller may do what it wants to with it)
    * @see #getMin
    */
   public int[] getMinIndices() {
-    return minIndices;
+    return (int[]) minIndices.clone();
   }
 
   /** Get the maximal value in the sample.
@@ -232,43 +213,34 @@
    * of the sample at which the maximum was encountered can be
    * retrieved with the {@link #getMaxIndices getMaxIndices}
    * method.</p>
-   * @return maximal value in the sample (the array is a reference to
-   * an internal array that changes each time something is added to
-   * the instance, the caller should neither change it nor rely on its
-   * value in the long term)
+   * @return maximal value in the sample (a new array is created
+   * at each call, the caller may do what it wants to with it)
    * @see #getMaxIndices
    */
   public double[] getMax() {
-    return max;
+    return (double[]) max.clone();
   }
 
   /** Get the indices at which the maximal value occurred in the sample.
    * @return a vector reporting at which occurrence each component of
-   * the sample reached its maximal value (the array is a reference to
-   * an internal array that changes each time something is added to
-   * the instance, the caller should neither change it nor rely on its
-   * value in the long term)
+   * the sample reached its maximal value (a new array is created
+   * at each call, the caller may do what it wants to with it)
    * @see #getMax
    */
   public int[] getMaxIndices() {
-    return maxIndices;
+    return (int[]) maxIndices.clone();
   }
 
   /** Get the mean value of the sample.
-   * @param mean placeholder where to store the array, if null a new
-   * array will be allocated
-   * @return mean value of the sample or null if the sample is empty
-   * and hence the dimension of the vectors is still unknown
-   * (reference to mean if it was non-null, reference to a new array
-   * otherwise)
+   * @return mean value of the sample or an empty array
+   * if the sample is empty (a new array is created
+   * at each call, the caller may do what it wants to with it)
    */
-  public double[] getMean(double[] mean) {
+  public double[] getMean() {
     if (n == 0) {
-      return null;
-    }
-    if (mean == null) {
-      mean = new double[dimension];
+      return new double[0];
     }
+    double[] mean = new double[dimension];
     for (int i = 0; i < dimension; ++i) {
       mean[i] = sum[i] / n;
     }

Modified: jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/utilities/ArrayMapper.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/utilities/ArrayMapper.java?view=diff&rev=488828&r1=488827&r2=488828
==============================================================================
--- jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/utilities/ArrayMapper.java (original)
+++ jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/utilities/ArrayMapper.java Tue Dec 19 14:11:07 2006
@@ -77,14 +77,14 @@
 
   }
 
-  /** Get the internal data array.
-   * @return internal data array
+  /** Get the data array.
+   * @return copy of the data array
    */
-  public double[] getInternalDataArray() {
+  public double[] getDataArray() {
     if (internalData == null) {
       internalData = new double [size];
     }
-    return internalData;
+    return (double[]) internalData.clone();
   }
 
   /** Map data from the internal array to the domain objects.

Modified: jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/utilities/MappableArray.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/utilities/MappableArray.java?view=diff&rev=488828&r1=488827&r2=488828
==============================================================================
--- jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/utilities/MappableArray.java (original)
+++ jakarta/commons/proper/math/trunk/src/mantissa/src/org/spaceroots/mantissa/utilities/MappableArray.java Tue Dec 19 14:11:07 2006
@@ -43,24 +43,16 @@
   /** Simple constructor.
    * Build a mappable array from an existing array
    * @param array array to use
-   * @param doReallocate true if a new array should be allocated and
-   * initialized using the other argument, false if the instance
-   * should reference the existing array throughout its lifetime
    */
-  public MappableArray(double[] array, boolean doReallocate) {
-    if (doReallocate) {
-      internalArray = new double[array.length];
-      System.arraycopy(array, 0, internalArray, 0, array.length);
-    } else {
-      internalArray = array;
-    }
+  public MappableArray(double[] array) {
+    internalArray = (double[]) array.clone();
   }
 
   /** Get the array stored in the instance.
    * @return array stored in the instance
    */
   public double[] getArray () {
-    return internalArray;
+    return (double[]) internalArray.clone();
   }
 
   /** Get the dimension of the internal array.

Modified: jakarta/commons/proper/math/trunk/src/mantissa/tests-src/org/spaceroots/mantissa/algebra/ChebyshevTest.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/math/trunk/src/mantissa/tests-src/org/spaceroots/mantissa/algebra/ChebyshevTest.java?view=diff&rev=488828&r1=488827&r2=488828
==============================================================================
--- jakarta/commons/proper/math/trunk/src/mantissa/tests-src/org/spaceroots/mantissa/algebra/ChebyshevTest.java (original)
+++ jakarta/commons/proper/math/trunk/src/mantissa/tests-src/org/spaceroots/mantissa/algebra/ChebyshevTest.java Tue Dec 19 14:11:07 2006
@@ -26,7 +26,7 @@
     super(name);
   }
 
-  public void aatestOne() {
+  public void testOne() {
     assertTrue(new Chebyshev().isOne());
   }
 
@@ -44,16 +44,16 @@
 
   }
 
-  public void aatestBounds() {
+  public void testBounds() {
     for (int k = 0; k < 12; ++k) {
-      Chebyshev Tk = new Chebyshev(k);
+      OrthogonalPolynomial Tk = new Chebyshev(k);
       for (double x = -1.0; x <= 1.0; x += 0.02) {
         assertTrue(Math.abs(Tk.valueAt(x)) < (1.0 + 1.0e-12));
       }
     }
   }
 
-  public void aatestDifferentials() {
+  public void testDifferentials() {
     for (int k = 0; k < 12; ++k) {
 
       Polynomial.Rational Tk0 = new Chebyshev(k);
@@ -64,12 +64,11 @@
       Polynomial.Rational g1 = new Polynomial.Rational(-1l, 0l);
       Polynomial.Rational g2 = new Polynomial.Rational(-1l, 0l, 1l);
 
-      Polynomial.Rational Tk0g0 = Polynomial.Rational.multiply(Tk0, g0);
-      Polynomial.Rational Tk1g1 = Polynomial.Rational.multiply(Tk1, g1);
-      Polynomial.Rational Tk2g2 = Polynomial.Rational.multiply(Tk2, g2);
+      Polynomial.Rational Tk0g0 = Tk0.multiply(g0);
+      Polynomial.Rational Tk1g1 = Tk1.multiply(g1);
+      Polynomial.Rational Tk2g2 = Tk2.multiply(g2);
 
-      Polynomial.Rational d =
-        Polynomial.Rational.add(Tk0g0, Polynomial.Rational.add(Tk1g1, Tk2g2));
+      Polynomial.Rational d = Tk0g0.add(Tk1g1.add(Tk2g2));
       assertTrue(d.isZero());
 
     }

Modified: jakarta/commons/proper/math/trunk/src/mantissa/tests-src/org/spaceroots/mantissa/algebra/HermiteTest.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/math/trunk/src/mantissa/tests-src/org/spaceroots/mantissa/algebra/HermiteTest.java?view=diff&rev=488828&r1=488827&r2=488828
==============================================================================
--- jakarta/commons/proper/math/trunk/src/mantissa/tests-src/org/spaceroots/mantissa/algebra/HermiteTest.java (original)
+++ jakarta/commons/proper/math/trunk/src/mantissa/tests-src/org/spaceroots/mantissa/algebra/HermiteTest.java Tue Dec 19 14:11:07 2006
@@ -55,12 +55,11 @@
       Polynomial.Rational g1 = new Polynomial.Rational(-2l, 0l);
       Polynomial.Rational g2 = new Polynomial.Rational(1l);
 
-      Polynomial.Rational Hk0g0 = Polynomial.Rational.multiply(Hk0, g0);
-      Polynomial.Rational Hk1g1 = Polynomial.Rational.multiply(Hk1, g1);
-      Polynomial.Rational Hk2g2 = Polynomial.Rational.multiply(Hk2, g2);
+      Polynomial.Rational Hk0g0 = Hk0.multiply(g0);
+      Polynomial.Rational Hk1g1 = Hk1.multiply(g1);
+      Polynomial.Rational Hk2g2 = Hk2.multiply(g2);
 
-      Polynomial.Rational d =
-        Polynomial.Rational.add(Hk0g0, Polynomial.Rational.add(Hk1g1, Hk2g2));
+      Polynomial.Rational d = Hk0g0.add(Hk1g1.add(Hk2g2));
       assertTrue(d.isZero());
 
     }

Modified: jakarta/commons/proper/math/trunk/src/mantissa/tests-src/org/spaceroots/mantissa/algebra/LaguerreTest.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/math/trunk/src/mantissa/tests-src/org/spaceroots/mantissa/algebra/LaguerreTest.java?view=diff&rev=488828&r1=488827&r2=488828
==============================================================================
--- jakarta/commons/proper/math/trunk/src/mantissa/tests-src/org/spaceroots/mantissa/algebra/LaguerreTest.java (original)
+++ jakarta/commons/proper/math/trunk/src/mantissa/tests-src/org/spaceroots/mantissa/algebra/LaguerreTest.java Tue Dec 19 14:11:07 2006
@@ -61,19 +61,18 @@
       Polynomial.Rational g1 = new Polynomial.Rational(-1l, 1l);
       Polynomial.Rational g2 = new Polynomial.Rational(1l, 0l);
 
-      Polynomial.Rational Lk0g0 = Polynomial.Rational.multiply(Lk0, g0);
-      Polynomial.Rational Lk1g1 = Polynomial.Rational.multiply(Lk1, g1);
-      Polynomial.Rational Lk2g2 = Polynomial.Rational.multiply(Lk2, g2);
+      Polynomial.Rational Lk0g0 = Lk0.multiply(g0);
+      Polynomial.Rational Lk1g1 = Lk1.multiply(g1);
+      Polynomial.Rational Lk2g2 = Lk2.multiply(g2);
 
-      Polynomial.Rational d =
-        Polynomial.Rational.add(Lk0g0, Polynomial.Rational.add(Lk1g1, Lk2g2));
+      Polynomial.Rational d = Lk0g0.add(Lk1g1.add(Lk2g2));
       assertTrue(d.isZero());
 
     }
   }
 
   public void checkLaguerre(Laguerre p, long denominator, String reference) {
-    assertTrue(Laguerre.multiply(p, denominator).toString().equals(reference));
+    assertTrue(p.multiply(denominator).toString().equals(reference));
   }
 
   public static Test suite() {

Modified: jakarta/commons/proper/math/trunk/src/mantissa/tests-src/org/spaceroots/mantissa/algebra/LegendreTest.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/math/trunk/src/mantissa/tests-src/org/spaceroots/mantissa/algebra/LegendreTest.java?view=diff&rev=488828&r1=488827&r2=488828
==============================================================================
--- jakarta/commons/proper/math/trunk/src/mantissa/tests-src/org/spaceroots/mantissa/algebra/LegendreTest.java (original)
+++ jakarta/commons/proper/math/trunk/src/mantissa/tests-src/org/spaceroots/mantissa/algebra/LegendreTest.java Tue Dec 19 14:11:07 2006
@@ -55,12 +55,11 @@
       Polynomial.Rational g1 = new Polynomial.Rational(-2l, 0l);
       Polynomial.Rational g2 = new Polynomial.Rational(-1l, 0l, 1l);
 
-      Polynomial.Rational Pk0g0 = Polynomial.Rational.multiply(Pk0, g0);
-      Polynomial.Rational Pk1g1 = Polynomial.Rational.multiply(Pk1, g1);
-      Polynomial.Rational Pk2g2 = Polynomial.Rational.multiply(Pk2, g2);
+      Polynomial.Rational Pk0g0 = Pk0.multiply(g0);
+      Polynomial.Rational Pk1g1 = Pk1.multiply(g1);
+      Polynomial.Rational Pk2g2 = Pk2.multiply(g2);
 
-      Polynomial.Rational d =
-        Polynomial.Rational.add(Pk0g0, Polynomial.Rational.add(Pk1g1, Pk2g2));
+      Polynomial.Rational d = Pk0g0.add(Pk1g1.add(Pk2g2));
       assertTrue(d.isZero());
 
     }
@@ -92,7 +91,7 @@
   }
 
   public void checkLegendre(Legendre p, long denominator, String reference) {
-    assertTrue(Legendre.multiply(p, denominator).toString().equals(reference));
+    assertTrue(p.multiply(denominator).toString().equals(reference));
   }
 
   public static Test suite() {

Modified: jakarta/commons/proper/math/trunk/src/mantissa/tests-src/org/spaceroots/mantissa/algebra/PolynomialDoubleTest.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/math/trunk/src/mantissa/tests-src/org/spaceroots/mantissa/algebra/PolynomialDoubleTest.java?view=diff&rev=488828&r1=488827&r2=488828
==============================================================================
--- jakarta/commons/proper/math/trunk/src/mantissa/tests-src/org/spaceroots/mantissa/algebra/PolynomialDoubleTest.java (original)
+++ jakarta/commons/proper/math/trunk/src/mantissa/tests-src/org/spaceroots/mantissa/algebra/PolynomialDoubleTest.java Tue Dec 19 14:11:07 2006
@@ -49,20 +49,14 @@
 
   public void testConversion() {
     Polynomial.Rational r = new Polynomial.Rational(1l, 3l, -5l);
-    r.multiplySelf(new RationalNumber(1l, 2l));
+    r = (Polynomial.Rational) r.multiply(new RationalNumber(1l, 2l));
     Polynomial.Double p = new Polynomial.Double(r);
     checkPolynomial(p, "-2.5 + 1.5 x + 0.5 x^2");
   }
 
   public void testString() {
-
     Polynomial.Double p = new Polynomial.Double(1.0, 3.0, -5.0);
     checkPolynomial(p, "-5.0 + 3.0 x + x^2");
-    p.setUnknownName("alpha");
-    checkPolynomial(p, "-5.0 + 3.0 alpha + alpha^2");
-    p.setUnknownName(null);
-    checkPolynomial(p, "-5.0 + 3.0 x + x^2");
-
     checkPolynomial(new Polynomial.Double(3.0, -2.0, 0.0),
                     "-2.0 x + 3.0 x^2");
     checkPolynomial(new Polynomial.Double(3.0, -2.0, 1.0),
@@ -75,22 +69,20 @@
                     "1.0 + 3.0 x^2");
     checkPolynomial(new Polynomial.Double(0.0),
                     "0");
-
   }
 
   public void testAddition() {
 
     Polynomial.Double p1 = new Polynomial.Double(1.0, -2.0);
     Polynomial.Double p2 = new Polynomial.Double(0.0, -1.0, 2.0);
-    assertTrue(Polynomial.Double.add(p1, p2).isZero());
+    assertTrue(p1.add(p2).isZero());
 
-    p2 = new Polynomial.Double(p1);
-    p2.addToSelf(p2);
+    p2 = p1.add(p1);
     checkPolynomial(p2, "-4.0 + 2.0 x");
 
     p1 = new Polynomial.Double(2.0, -4.0, 1.0);
     p2 = new Polynomial.Double(-2.0, 3.0, -1.0);
-    p1.addToSelf(p2);
+    p1 = p1.add(p2);
     assertEquals(1, p1.getDegree());
     checkPolynomial(p1, "-x");
 
@@ -99,15 +91,15 @@
   public void testSubtraction() {
 
     Polynomial.Double p1 = new Polynomial.Double(1.0, -2.0);
-    assertTrue(Polynomial.Double.subtract(p1, p1).isZero());
+    assertTrue(p1.subtract(p1).isZero());
 
     Polynomial.Double p2 = new Polynomial.Double(6.0, -2.0);
-    p2.subtractFromSelf(p1);
+    p2 = p2.subtract(p1);
     checkPolynomial(p2, "5.0 x");
 
     p1 = new Polynomial.Double(2.0, -4.0, 1.0);
     p2 = new Polynomial.Double(2.0, 3.0, -1.0);
-    p1.subtractFromSelf(p2);
+    p1 = p1.subtract(p2);
     assertEquals(1, p1.getDegree());
     checkPolynomial(p1, "2.0 - 7.0 x");
 
@@ -117,12 +109,12 @@
 
     Polynomial.Double p1 = new Polynomial.Double(2.0, -3.0);
     Polynomial.Double p2 = new Polynomial.Double(1.0, 2.0, 3.0);
-    checkPolynomial(Polynomial.Double.multiply(p1, p2), "-9.0 + x^2 + 2.0 x^3");
+    checkPolynomial(p1.multiply(p2), "-9.0 + x^2 + 2.0 x^3");
 
     p1 = new Polynomial.Double(1.0, 0.0);
-    p2 = new Polynomial.Double(p1);
+    p2 = p1;
     for (int i = 2; i < 10; ++i) {
-      p2.multiplySelf(p1);
+      p2 = p2.multiply(p1);
       checkPolynomial(p2, "x^" + i);
     }
 

Modified: jakarta/commons/proper/math/trunk/src/mantissa/tests-src/org/spaceroots/mantissa/algebra/PolynomialFractionTest.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/math/trunk/src/mantissa/tests-src/org/spaceroots/mantissa/algebra/PolynomialFractionTest.java?view=diff&rev=488828&r1=488827&r2=488828
==============================================================================
--- jakarta/commons/proper/math/trunk/src/mantissa/tests-src/org/spaceroots/mantissa/algebra/PolynomialFractionTest.java (original)
+++ jakarta/commons/proper/math/trunk/src/mantissa/tests-src/org/spaceroots/mantissa/algebra/PolynomialFractionTest.java Tue Dec 19 14:11:07 2006
@@ -55,18 +55,18 @@
   public void testInvert() {
 
     PolynomialFraction f = new PolynomialFraction(2l, 4l);
-    f.invertSelf();
+    f= f.invert();
     checkValue(f, "2");
-    f.invertSelf();
+    f = f.invert();
     checkValue(f, "1/2");
 
     f = new PolynomialFraction(120l);
-    f.invertSelf();
+    f = f.invert();
     checkValue(f, "1/120");
 
     f = new PolynomialFraction(0l, 4l);
     try {
-      f.invertSelf();
+      f = f.invert();
       fail("an exception should have been thrown");
     } catch (ArithmeticException e) {
     } catch (Exception e) {
@@ -74,7 +74,7 @@
     }
 
     f = new PolynomialFraction(307692l, 999999l);
-    PolynomialFraction fInverse = PolynomialFraction.invert(f);
+    PolynomialFraction fInverse = f.invert();
     checkValue(fInverse, "13/4");
     checkValue(f, "4/13");
 
@@ -83,23 +83,18 @@
   public void testAddition() {
 
     PolynomialFraction f1 = new PolynomialFraction(4l, 6l);
-    f1.addToSelf(f1);
+    f1 = f1.add(f1);
     checkValue(f1, "4/3");
 
-    checkValue(PolynomialFraction.add(new PolynomialFraction(17l, 3l),
-                                      new PolynomialFraction(-17l, 3l)),
+    checkValue(new PolynomialFraction(17l, 3l).add(new PolynomialFraction(-17l, 3l)),
                "0");
-    checkValue(PolynomialFraction.add(new PolynomialFraction(2l, 3l),
-                                      new PolynomialFraction(3l, 4l)),
+    checkValue(new PolynomialFraction(2l, 3l).add(new PolynomialFraction(3l, 4l)),
                "17/12");
-    checkValue(PolynomialFraction.add(new PolynomialFraction(1l, 6l),
-                                      new PolynomialFraction(2l, 6l)),
+    checkValue(new PolynomialFraction(1l, 6l).add(new PolynomialFraction(2l, 6l)),
                "1/2");
-    checkValue(PolynomialFraction.add(new PolynomialFraction(4l, 5l),
-                                      new PolynomialFraction(-3l, 4l)),
+    checkValue(new PolynomialFraction(4l, 5l).add(new PolynomialFraction(-3l, 4l)),
                "1/20");
-    checkValue(PolynomialFraction.add(new PolynomialFraction(-3l, 4l),
-                                      new PolynomialFraction(4l, 5l)),
+    checkValue(new PolynomialFraction(-3l, 4l).add(new PolynomialFraction(4l, 5l)),
                "1/20");
 
   }
@@ -107,44 +102,32 @@
   public void testSubtraction() {
 
     PolynomialFraction f1 = new PolynomialFraction(4l, 6l);
-    f1.subtractFromSelf(f1);
-    checkValue(f1, "0");
+    checkValue(f1.subtract(f1), "0");
 
-    checkValue(PolynomialFraction.subtract(new PolynomialFraction(7l, 3l),
-                                           new PolynomialFraction(-7l, 3l)),
+    checkValue(new PolynomialFraction(7l, 3l).subtract(new PolynomialFraction(-7l, 3l)),
                "14/3");
 
-    checkValue(PolynomialFraction.subtract(new PolynomialFraction(3l, 4l),
-                                           new PolynomialFraction(2l, 3l)),
+    checkValue(new PolynomialFraction(3l, 4l).subtract(new PolynomialFraction(2l, 3l)),
                "1/12");
-    checkValue(PolynomialFraction.subtract(new PolynomialFraction(3l, 4l),
-                                           new PolynomialFraction(-2l, 3l)),
+    checkValue(new PolynomialFraction(3l, 4l).subtract(new PolynomialFraction(-2l, 3l)),
                "17/12");
-    checkValue(PolynomialFraction.subtract(new PolynomialFraction(-3l, 4l),
-                                           new PolynomialFraction(2l, 3l)),
+    checkValue(new PolynomialFraction(-3l, 4l).subtract(new PolynomialFraction(2l, 3l)),
                "-17/12");
-    checkValue(PolynomialFraction.subtract(new PolynomialFraction(-3l, 4l),
-                                           new PolynomialFraction(-2l, 3l)),
+    checkValue(new PolynomialFraction(-3l, 4l).subtract(new PolynomialFraction(-2l, 3l)),
                "-1/12");
 
-    checkValue(PolynomialFraction.subtract(new PolynomialFraction(2l, 3l),
-                                           new PolynomialFraction(3l, 4l)),
+    checkValue(new PolynomialFraction(2l, 3l).subtract(new PolynomialFraction(3l, 4l)),
                "-1/12");
-    checkValue(PolynomialFraction.subtract(new PolynomialFraction(-2l, 3l),
-                                           new PolynomialFraction(3l, 4l)),
+    checkValue(new PolynomialFraction(-2l, 3l).subtract(new PolynomialFraction(3l, 4l)),
                "-17/12");
-    checkValue(PolynomialFraction.subtract(new PolynomialFraction(2l, 3l),
-                                           new PolynomialFraction(-3l, 4l)),
+    checkValue(new PolynomialFraction(2l, 3l).subtract(new PolynomialFraction(-3l, 4l)),
                "17/12");
-    checkValue(PolynomialFraction.subtract(new PolynomialFraction(-2l, 3l),
-                                           new PolynomialFraction(-3l, 4l)),
+    checkValue(new PolynomialFraction(-2l, 3l).subtract(new PolynomialFraction(-3l, 4l)),
                "1/12");
 
-    checkValue(PolynomialFraction.subtract(new PolynomialFraction(1l, 6l),
-                                           new PolynomialFraction(2l, 6l)),
+    checkValue(new PolynomialFraction(1l, 6l).subtract(new PolynomialFraction(2l, 6l)),
                "-1/6");
-    checkValue(PolynomialFraction.subtract(new PolynomialFraction(1l, 2l),
-                                           new PolynomialFraction(1l, 6l)),
+    checkValue(new PolynomialFraction(1l, 2l).subtract(new PolynomialFraction(1l, 6l)),
                "1/3");
 
   }
@@ -152,23 +135,17 @@
   public void testMultiplication() {
 
     PolynomialFraction f = new PolynomialFraction(2l, 3l);
-    f.multiplySelf(new PolynomialFraction(9l,4l));
-    checkValue(f, "3/2");
+    checkValue(f.multiply(new PolynomialFraction(9l,4l)), "3/2");
 
-    checkValue(PolynomialFraction.multiply(new PolynomialFraction(1l, 2l),
-                                           new PolynomialFraction(0l)),
+    checkValue(new PolynomialFraction(1l, 2l).multiply(new PolynomialFraction(0l)),
                "0");
-    checkValue(PolynomialFraction.multiply(new PolynomialFraction(4l, 15l),
-                                           new PolynomialFraction(-5l, 2l)),
+    checkValue(new PolynomialFraction(4l, 15l).multiply(new PolynomialFraction(-5l, 2l)),
                "-2/3");
-    checkValue(PolynomialFraction.multiply(new PolynomialFraction(-4l, 15l),
-                                           new PolynomialFraction(5l, 2l)),
+    checkValue(new PolynomialFraction(-4l, 15l).multiply(new PolynomialFraction(5l, 2l)),
                "-2/3");
-    checkValue(PolynomialFraction.multiply(new PolynomialFraction(4l, 15l),
-                                           new PolynomialFraction(5l, 2l)),
+    checkValue(new PolynomialFraction(4l, 15l).multiply(new PolynomialFraction(5l, 2l)),
                "2/3");
-    checkValue(PolynomialFraction.multiply(new PolynomialFraction(-4l, 15l),
-                                           new PolynomialFraction(-5l, 2l)),
+    checkValue(new PolynomialFraction(-4l, 15l).multiply(new PolynomialFraction(-5l, 2l)),
                "2/3");
 
   }
@@ -176,29 +153,24 @@
   public void testDivision() {
 
     PolynomialFraction f = new PolynomialFraction(2l, 3l);
-    f.divideSelf(new PolynomialFraction(4l,9l));
-    checkValue(f, "3/2");
+    ;
+    checkValue(f.divide(new PolynomialFraction(4l,9l)), "3/2");
 
     try {
-      PolynomialFraction.divide(new PolynomialFraction(1l, 2l),
-                                new PolynomialFraction(0l));
+      new PolynomialFraction(1l, 2l).divide(new PolynomialFraction(0l));
       fail("an exception should have been thrown");
     } catch (ArithmeticException e) {
     } catch (Exception e) {
       fail("wrong exception caught");
     }
 
-    checkValue(PolynomialFraction.divide(new PolynomialFraction(4l, 15l),
-                                         new PolynomialFraction(-2l, 5l)),
+    checkValue(new PolynomialFraction(4l, 15l).divide(new PolynomialFraction(-2l, 5l)),
                "-2/3");
-    checkValue(PolynomialFraction.divide(new PolynomialFraction(-4l, 15l),
-                                         new PolynomialFraction(2l, 5l)),
+    checkValue(new PolynomialFraction(-4l, 15l).divide(new PolynomialFraction(2l, 5l)),
                "-2/3");
-    checkValue(PolynomialFraction.divide(new PolynomialFraction(4l, 15l),
-                                         new PolynomialFraction(2l, 5l)),
+    checkValue(new PolynomialFraction(4l, 15l).divide(new PolynomialFraction(2l, 5l)),
                "2/3");
-    checkValue(PolynomialFraction.divide(new PolynomialFraction(-4l, 15l),
-                                         new PolynomialFraction(-2l, 5l)),
+    checkValue(new PolynomialFraction(-4l, 15l).divide(new PolynomialFraction(-2l, 5l)),
                "2/3");
 
   }

Modified: jakarta/commons/proper/math/trunk/src/mantissa/tests-src/org/spaceroots/mantissa/algebra/PolynomialRationalTest.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/math/trunk/src/mantissa/tests-src/org/spaceroots/mantissa/algebra/PolynomialRationalTest.java?view=diff&rev=488828&r1=488827&r2=488828
==============================================================================
--- jakarta/commons/proper/math/trunk/src/mantissa/tests-src/org/spaceroots/mantissa/algebra/PolynomialRationalTest.java (original)
+++ jakarta/commons/proper/math/trunk/src/mantissa/tests-src/org/spaceroots/mantissa/algebra/PolynomialRationalTest.java Tue Dec 19 14:11:07 2006
@@ -57,10 +57,6 @@
 
     Polynomial.Rational p = new Polynomial.Rational(1l, 3l, -5l);
     checkPolynomial(p, "-5 + 3 x + x^2");
-    p.setUnknownName("alpha");
-    checkPolynomial(p, "-5 + 3 alpha + alpha^2");
-    p.setUnknownName(null);
-    checkPolynomial(p, "-5 + 3 x + x^2");
 
     checkPolynomial(new Polynomial.Rational(3l, -2l, 0l), "-2 x + 3 x^2");
     checkPolynomial(new Polynomial.Rational(3l, -2l, 1l), "1 - 2 x + 3 x^2");
@@ -75,15 +71,14 @@
 
     Polynomial.Rational p1 = new Polynomial.Rational(1l, -2l);
     Polynomial.Rational p2 = new Polynomial.Rational(0l, -1l, 2l);
-    assertTrue(Polynomial.Rational.add(p1, p2).isZero());
+    assertTrue(p1.add(p2).isZero());
 
-    p2 = new Polynomial.Rational(p1);
-    p2.addToSelf(p2);
+    p2 = p1.add(p1);
     checkPolynomial(p2, "-4 + 2 x");
 
     p1 = new Polynomial.Rational(2l, -4l, 1l);
     p2 = new Polynomial.Rational(-2l, 3l, -1l);
-    p1.addToSelf(p2);
+    p1 = p1.add(p2);
     assertEquals(1, p1.getDegree());
     checkPolynomial(p1, "-x");
 
@@ -92,15 +87,15 @@
   public void testSubtraction() {
 
     Polynomial.Rational p1 = new Polynomial.Rational(1l, -2l);
-    assertTrue(Polynomial.Rational.subtract(p1, p1).isZero());
+    assertTrue(p1.subtract(p1).isZero());
 
     Polynomial.Rational p2 = new Polynomial.Rational(6l, -2l);
-    p2.subtractFromSelf(p1);
+    p2 = p2.subtract(p1);
     checkPolynomial(p2, "5 x");
 
     p1 = new Polynomial.Rational(2l, -4l, 1l);
     p2 = new Polynomial.Rational(2l, 3l, -1l);
-    p1.subtractFromSelf(p2);
+    p1 = p1.subtract(p2);
     assertEquals(1, p1.getDegree());
     checkPolynomial(p1, "2 - 7 x");
 
@@ -110,12 +105,12 @@
 
     Polynomial.Rational p1 = new Polynomial.Rational(2l, -3l);
     Polynomial.Rational p2 = new Polynomial.Rational(1l, 2l, 3l);
-    checkPolynomial(Polynomial.Rational.multiply(p1, p2), "-9 + x^2 + 2 x^3");
+    checkPolynomial(p1.multiply(p2), "-9 + x^2 + 2 x^3");
 
     p1 = new Polynomial.Rational(1l, 0l);
-    p2 = new Polynomial.Rational(p1);
+    p2 = p1;
     for (int i = 2; i < 10; ++i) {
-      p2.multiplySelf(p1);
+      p2 = p2.multiply(p1);
       checkPolynomial(p2, "x^" + i);
     }
 
@@ -128,7 +123,7 @@
     checkPolynomial(p, "3/4 - 1/6 x + 2/5 x^2");
     BigInteger lcm = p.getDenominatorsLCM();
     assertEquals(BigInteger.valueOf(60l), lcm);
-    p.multiplySelf(lcm);
+    p = (Polynomial.Rational) p.multiply(lcm);
     checkPolynomial(p, "45 - 10 x + 24 x^2");
   }
 

Modified: jakarta/commons/proper/math/trunk/src/mantissa/tests-src/org/spaceroots/mantissa/algebra/RationalNumberTest.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/math/trunk/src/mantissa/tests-src/org/spaceroots/mantissa/algebra/RationalNumberTest.java?view=diff&rev=488828&r1=488827&r2=488828
==============================================================================
--- jakarta/commons/proper/math/trunk/src/mantissa/tests-src/org/spaceroots/mantissa/algebra/RationalNumberTest.java (original)
+++ jakarta/commons/proper/math/trunk/src/mantissa/tests-src/org/spaceroots/mantissa/algebra/RationalNumberTest.java Tue Dec 19 14:11:07 2006
@@ -54,19 +54,17 @@
 
   public void testInvert() {
 
-    RationalNumber f = new RationalNumber(2l, 4l);
-    f.invertSelf();
+    RationalNumber f = new RationalNumber(2l, 4l).invert();
     checkValue(f, "2");
-    f.invertSelf();
+    f = f.invert();
     checkValue(f, "1/2");
 
-    f = new RationalNumber(120l);
-    f.invertSelf();
+    f = new RationalNumber(120l).invert();
     checkValue(f, "1/120");
 
     f = new RationalNumber(0l, 4l);
     try {
-      f.invertSelf();
+      f.invert();
       fail("an exception should have been thrown");
     } catch (ArithmeticException e) {
     } catch (Exception e) {
@@ -74,7 +72,7 @@
     }
 
     f = new RationalNumber(307692l, 999999l);
-    RationalNumber fInverse = RationalNumber.invert(f);
+    RationalNumber fInverse = f.invert();
     checkValue(fInverse, "13/4");
     checkValue(f, "4/13");
 
@@ -83,23 +81,18 @@
   public void testAddition() {
 
     RationalNumber f1 = new RationalNumber(4l, 6l);
-    f1.addToSelf(f1);
+    f1 = f1.add(f1);
     checkValue(f1, "4/3");
 
-    checkValue(RationalNumber.add(new RationalNumber(17l, 3l),
-                                  new RationalNumber(-17l, 3l)),
+    checkValue(new RationalNumber(17l, 3l).add(new RationalNumber(-17l, 3l)),
                "0");
-    checkValue(RationalNumber.add(new RationalNumber(2l, 3l),
-                                  new RationalNumber(3l, 4l)),
+    checkValue(new RationalNumber(2l, 3l).add(new RationalNumber(3l, 4l)),
                "17/12");
-    checkValue(RationalNumber.add(new RationalNumber(1l, 6l),
-                                  new RationalNumber(2l, 6l)),
+    checkValue(new RationalNumber(1l, 6l).add(new RationalNumber(2l, 6l)),
                "1/2");
-    checkValue(RationalNumber.add(new RationalNumber(4l, 5l),
-                                  new RationalNumber(-3l, 4l)),
+    checkValue(new RationalNumber(4l, 5l).add(new RationalNumber(-3l, 4l)),
                "1/20");
-    checkValue(RationalNumber.add(new RationalNumber(-3l, 4l),
-                                  new RationalNumber(4l, 5l)),
+    checkValue(new RationalNumber(-3l, 4l).add(new RationalNumber(4l, 5l)),
                "1/20");
 
   }
@@ -107,44 +100,33 @@
   public void testSubtraction() {
 
     RationalNumber f1 = new RationalNumber(4l, 6l);
-    f1.subtractFromSelf(f1);
+    f1 = f1.subtract(f1);
     checkValue(f1, "0");
 
-    checkValue(RationalNumber.subtract(new RationalNumber(7l, 3l),
-                                       new RationalNumber(-7l, 3l)),
+    checkValue(new RationalNumber(7l, 3l).subtract(new RationalNumber(-7l, 3l)),
                "14/3");
 
-    checkValue(RationalNumber.subtract(new RationalNumber(3l, 4l),
-                                       new RationalNumber(2l, 3l)),
+    checkValue(new RationalNumber(3l, 4l).subtract(new RationalNumber(2l, 3l)),
                "1/12");
-    checkValue(RationalNumber.subtract(new RationalNumber(3l, 4l),
-                                       new RationalNumber(-2l, 3l)),
+    checkValue(new RationalNumber(3l, 4l).subtract(new RationalNumber(-2l, 3l)),
                "17/12");
-    checkValue(RationalNumber.subtract(new RationalNumber(-3l, 4l),
-                                       new RationalNumber(2l, 3l)),
+    checkValue(new RationalNumber(-3l, 4l).subtract(new RationalNumber(2l, 3l)),
                "-17/12");
-    checkValue(RationalNumber.subtract(new RationalNumber(-3l, 4l),
-                                       new RationalNumber(-2l, 3l)),
+    checkValue(new RationalNumber(-3l, 4l).subtract(new RationalNumber(-2l, 3l)),
                "-1/12");
 
-    checkValue(RationalNumber.subtract(new RationalNumber(2l, 3l),
-                                       new RationalNumber(3l, 4l)),
+    checkValue(new RationalNumber(2l, 3l).subtract(new RationalNumber(3l, 4l)),
                "-1/12");
-    checkValue(RationalNumber.subtract(new RationalNumber(-2l, 3l),
-                                       new RationalNumber(3l, 4l)),
+    checkValue(new RationalNumber(-2l, 3l).subtract(new RationalNumber(3l, 4l)),
                "-17/12");
-    checkValue(RationalNumber.subtract(new RationalNumber(2l, 3l),
-                                       new RationalNumber(-3l, 4l)),
+    checkValue(new RationalNumber(2l, 3l).subtract(new RationalNumber(-3l, 4l)),
                "17/12");
-    checkValue(RationalNumber.subtract(new RationalNumber(-2l, 3l),
-                                       new RationalNumber(-3l, 4l)),
+    checkValue(new RationalNumber(-2l, 3l).subtract(new RationalNumber(-3l, 4l)),
                "1/12");
 
-    checkValue(RationalNumber.subtract(new RationalNumber(1l, 6l),
-                                       new RationalNumber(2l, 6l)),
+    checkValue(new RationalNumber(1l, 6l).subtract(new RationalNumber(2l, 6l)),
                "-1/6");
-    checkValue(RationalNumber.subtract(new RationalNumber(1l, 2l),
-                                       new RationalNumber(1l, 6l)),
+    checkValue(new RationalNumber(1l, 2l).subtract(new RationalNumber(1l, 6l)),
                "1/3");
 
   }
@@ -152,23 +134,18 @@
   public void testMultiplication() {
 
     RationalNumber f = new RationalNumber(2l, 3l);
-    f.multiplySelf(new RationalNumber(9l,4l));
+    f = f.multiply(new RationalNumber(9l,4l));
     checkValue(f, "3/2");
 
-    checkValue(RationalNumber.multiply(new RationalNumber(1l, 2l),
-                                       new RationalNumber(0l)),
+    checkValue(new RationalNumber(1l, 2l).multiply(new RationalNumber(0l)),
                "0");
-    checkValue(RationalNumber.multiply(new RationalNumber(4l, 15l),
-                                       new RationalNumber(-5l, 2l)),
+    checkValue(new RationalNumber(4l, 15l).multiply(new RationalNumber(-5l, 2l)),
                "-2/3");
-    checkValue(RationalNumber.multiply(new RationalNumber(-4l, 15l),
-                                       new RationalNumber(5l, 2l)),
+    checkValue(new RationalNumber(-4l, 15l).multiply(new RationalNumber(5l, 2l)),
                "-2/3");
-    checkValue(RationalNumber.multiply(new RationalNumber(4l, 15l),
-                                       new RationalNumber(5l, 2l)),
+    checkValue(new RationalNumber(4l, 15l).multiply(new RationalNumber(5l, 2l)),
                "2/3");
-    checkValue(RationalNumber.multiply(new RationalNumber(-4l, 15l),
-                                       new RationalNumber(-5l, 2l)),
+    checkValue(new RationalNumber(-4l, 15l).multiply(new RationalNumber(-5l, 2l)),
                "2/3");
 
   }
@@ -176,29 +153,24 @@
   public void testDivision() {
 
     RationalNumber f = new RationalNumber(2l, 3l);
-    f.divideSelf(new RationalNumber(4l,9l));
+    f = f.divide(new RationalNumber(4l,9l));
     checkValue(f, "3/2");
 
     try {
-      RationalNumber.divide(new RationalNumber(1l, 2l),
-                            new RationalNumber(0l));
+      new RationalNumber(1l, 2l).divide(new RationalNumber(0l));
       fail("an exception should have been thrown");
     } catch (ArithmeticException e) {
     } catch (Exception e) {
       fail("wrong exception caught");
     }
 
-    checkValue(RationalNumber.divide(new RationalNumber(4l, 15l),
-                                     new RationalNumber(-2l, 5l)),
+    checkValue(new RationalNumber(4l, 15l).divide(new RationalNumber(-2l, 5l)),
                "-2/3");
-    checkValue(RationalNumber.divide(new RationalNumber(-4l, 15l),
-                                     new RationalNumber(2l, 5l)),
+    checkValue(new RationalNumber(-4l, 15l).divide(new RationalNumber(2l, 5l)),
                "-2/3");
-    checkValue(RationalNumber.divide(new RationalNumber(4l, 15l),
-                                     new RationalNumber(2l, 5l)),
+    checkValue(new RationalNumber(4l, 15l).divide(new RationalNumber(2l, 5l)),
                "2/3");
-    checkValue(RationalNumber.divide(new RationalNumber(-4l, 15l),
-                                     new RationalNumber(-2l, 5l)),
+    checkValue(new RationalNumber(-4l, 15l).divide(new RationalNumber(-2l, 5l)),
                "2/3");
 
   }

Modified: jakarta/commons/proper/math/trunk/src/mantissa/tests-src/org/spaceroots/mantissa/estimation/AllTests.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/math/trunk/src/mantissa/tests-src/org/spaceroots/mantissa/estimation/AllTests.java?view=diff&rev=488828&r1=488827&r2=488828
==============================================================================
--- jakarta/commons/proper/math/trunk/src/mantissa/tests-src/org/spaceroots/mantissa/estimation/AllTests.java (original)
+++ jakarta/commons/proper/math/trunk/src/mantissa/tests-src/org/spaceroots/mantissa/estimation/AllTests.java Tue Dec 19 14:11:07 2006
@@ -30,6 +30,7 @@
     suite.addTest(WeightedMeasurementTest.suite());
     suite.addTest(GaussNewtonEstimatorTest.suite());
     suite.addTest(LevenbergMarquardtEstimatorTest.suite());
+    suite.addTest(MinpackTest.suite());
 
     return suite; 
 

Modified: jakarta/commons/proper/math/trunk/src/mantissa/tests-src/org/spaceroots/mantissa/estimation/GaussNewtonEstimatorTest.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/math/trunk/src/mantissa/tests-src/org/spaceroots/mantissa/estimation/GaussNewtonEstimatorTest.java?view=diff&rev=488828&r1=488827&r2=488828
==============================================================================
--- jakarta/commons/proper/math/trunk/src/mantissa/tests-src/org/spaceroots/mantissa/estimation/GaussNewtonEstimatorTest.java (original)
+++ jakarta/commons/proper/math/trunk/src/mantissa/tests-src/org/spaceroots/mantissa/estimation/GaussNewtonEstimatorTest.java Tue Dec 19 14:11:07 2006
@@ -106,7 +106,7 @@
     for (int i = 0; i < gridSize; ++i) {
       for (int j = 0; j < gridSize; ++j) {
 
-        String name            = new Integer(k).toString();
+        String name            = Integer.toString(k);
         perfectPars[2 * k]     = new EstimatedParameter("x" + name, i);
         perfectPars[2 * k + 1] = new EstimatedParameter("y" + name, j);
         ++k;
@@ -194,7 +194,7 @@
 
   }
 
-  private class Distance extends WeightedMeasurement {
+  private static class Distance extends WeightedMeasurement {
 
     public Distance(double weight, double measuredValue,
                     EstimatedParameter x1, EstimatedParameter y1,
@@ -243,15 +243,15 @@
   }
 
   public WeightedMeasurement[] getMeasurements() {
-    return measurements;
+    return (WeightedMeasurement[]) measurements.clone();
   }
 
   public EstimatedParameter[] getUnboundParameters() {
-    return unboundPars;
+    return (EstimatedParameter[]) unboundPars.clone();
   }
 
   public EstimatedParameter[] getAllParameters() {
-    return randomizedPars;
+    return (EstimatedParameter[]) randomizedPars.clone();
   }
 
   private EstimatedParameter[]  perfectPars;



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message