commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pste...@apache.org
Subject cvs commit: jakarta-commons/math/src/java/org/apache/commons/math/analysis SplineInterpolator.java
Date Sat, 22 May 2004 19:59:22 GMT
psteitz     2004/05/22 12:59:22

  Modified:    math/src/java/org/apache/commons/math/analysis
                        SplineInterpolator.java
  Log:
  Improved efficiency.
  
  Revision  Changes    Path
  1.17      +7 -13     jakarta-commons/math/src/java/org/apache/commons/math/analysis/SplineInterpolator.java
  
  Index: SplineInterpolator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/analysis/SplineInterpolator.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- SplineInterpolator.java	27 Apr 2004 04:37:58 -0000	1.16
  +++ SplineInterpolator.java	22 May 2004 19:59:22 -0000	1.17
  @@ -69,27 +69,22 @@
               }
           }
           
  +        // Differences between knot points
           double h[] = new double[n];
           for (int i = 0; i < n; i++) {
               h[i] = x[i + 1] - x[i];
           }
           
  -        double alpha[] = new double[n];
  -        for (int i = 1; i < n; i++) {
  -            alpha[i] = 3d * (y[i + 1] * h[i - 1] - y[i] * (x[i + 1] - x[i - 1])+ y[i -
1] * h[i]) /
  -                            (h[i - 1] * h[i]);
  -        }
  -        
  -        double l[] = new double[n + 1];
           double mu[] = new double[n];
           double z[] = new double[n + 1];
  -        l[0] = 1d;
           mu[0] = 0d;
           z[0] = 0d;
  +        double g = 0;
           for (int i = 1; i < n; i++) {
  -            l[i] = 2d * (x[i+1]  - x[i - 1]) - h[i - 1] * mu[i -1];
  -            mu[i] = h[i] / l[i];
  -            z[i] = (alpha[i] - h[i - 1] * z[i - 1]) / l[i];
  +            g = 2d * (x[i+1]  - x[i - 1]) - h[i - 1] * mu[i -1];
  +            mu[i] = h[i] / g;
  +            z[i] = (3d * (y[i + 1] * h[i - 1] - y[i] * (x[i + 1] - x[i - 1])+ y[i - 1]
* h[i]) /
  +                    (h[i - 1] * h[i]) - h[i - 1] * z[i - 1]) / g;
           }
          
           // cubic spline coefficients --  b is linear, c quadratic, d is cubic (original
y's are constants)
  @@ -97,7 +92,6 @@
           double c[] = new double[n + 1];
           double d[] = new double[n];
           
  -        l[n] = 1d;
           z[n] = 0d;
           c[n] = 0d;
           
  
  
  

---------------------------------------------------------------------
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