Java.gui
Class Pppack_smooth

java.lang.Object
  extended by Java.gui.Pppack_smooth

public class Pppack_smooth
extends java.lang.Object

Smoothing spline interpolation This class provides an interpolation/approximation facility to work with data.

Partly this code is a modification of fortran subroutine smooth (file smooth.f) from pppack library at Netlib (editor: Eric Grosse, master: netlib.bell-labs.com) Original code written by Alexander Sokolov, Department of Systems Ecology, Stockholm University, 1997 Modified by Peter Gennemark, Chalmers, May 2003

Since:
1.0

Field Summary
 double[] d1f
           
 double[] d2f
           
 double[] d3f
           
 double[] f
          Array of smoothed ordinates, corresponded to abscissae
 int lastElement
          Number of data points
 double[] x
          Array of data abscissae, assumed to be strictly increasing
 double[] y
          Array of data ordinates, corresponded to abscissae
 
Constructor Summary
Pppack_smooth(double[] x, double[] y, double[] dy)
          Constructs the spline class.
 
Method Summary
 void calcSpline(boolean isApproximation, double maxMeanDistance)
          Constructs an interpolation/approximation function to given data (x(),y()).
 void calcSpline(double maxMeanDistance)
          Constructs the cubic smoothing spline to given data (x(),y()).
 double get(double coord)
          Calculates value of the function.
 double get(double coord, int jderiv)
          Calculates value of the function.
 double getf(int index, int val)
          Get value of variable f at position val for a certain derivative [0,1,2,3}.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lastElement

public int lastElement
Number of data points


x

public double[] x
Array of data abscissae, assumed to be strictly increasing


y

public double[] y
Array of data ordinates, corresponded to abscissae


f

public double[] f
Array of smoothed ordinates, corresponded to abscissae


d1f

public double[] d1f

d2f

public double[] d2f

d3f

public double[] d3f
Constructor Detail

Pppack_smooth

public Pppack_smooth(double[] x,
                     double[] y,
                     double[] dy)
Constructs the spline class.

Parameters:
x - x-values
y - y-values
dy - - estimate of uncertainty in data (positive)
Method Detail

calcSpline

public void calcSpline(double maxMeanDistance)
Constructs the cubic smoothing spline to given data (x(),y()). This approximation has a second derivative as small as possible while sum(((y(i)-f(x(i)))/dy(i))^2) < maxMeanDistance

Parameters:
maxMeanDistance - is upper bound on the discrete weighted mean square distance of the approximation from the data

calcSpline

public void calcSpline(boolean isApproximation,
                       double maxMeanDistance)
Constructs an interpolation/approximation function to given data (x(),y()).

Parameters:
isApproximation - is type of a function. If it is true the approximative function will be made, otherwise -- a linear function.
maxMeanDistance - is upper bound on the discrete weighted mean square distance of the approximation from the data

get

public double get(double coord)
Calculates value of the function.

Parameters:
coord - is a value of abscissa for searching function's value.
Returns:
value of the interpolation/approximation function for coord value of abscissa or 0 for unappropriate abscissa's value.

get

public double get(double coord,
                  int jderiv)
Calculates value of the function.

Parameters:
coord - is a value of abscissa for searching function's value.
jderiv - 0 or 1, function value (0) or first derivative (1)
Returns:
value of the interpolation/approximation function for coord value of abscissa or 0 for unappropriate abscissa's value.

getf

public double getf(int index,
                   int val)
Get value of variable f at position val for a certain derivative [0,1,2,3}.

Parameters:
index - the index
val - the position
Returns:
the value