uk.ac.starlink.diva.interp
Class PolynomialInterp

java.lang.Object
  extended by uk.ac.starlink.diva.interp.AbstractInterpolator
      extended by uk.ac.starlink.diva.interp.LinearInterp
          extended by uk.ac.starlink.diva.interp.PolynomialInterp
All Implemented Interfaces:
Interpolator

public class PolynomialInterp
extends LinearInterp

Interpolate values using a simple polynomial fit.

Version:
$Id$
Author:
Peter W. Draper

Field Summary
 
Fields inherited from class uk.ac.starlink.diva.interp.AbstractInterpolator
c, decr, x, y
 
Constructor Summary
PolynomialInterp()
          Create an instance with no coordinates.
PolynomialInterp(double[] x, double[] y)
          Create an instance with the given coordinates.
 
Method Summary
protected  void evalCoeffs()
          Compute coefficients of Langrange interpolating polynomial of degree x.length - 1.
 double evalPolynomial(double xp)
          Evaluate a polynomial by Horner's schema
 double interpolate(double xp)
          Return the interpolated value corresponding to some arbitrary X coordinate.
static void main(String[] args)
          Simple test entry point
 void setCoords(double[] x, double[] y, boolean check)
          Set or reset the coordinates used by this interpolator.
 
Methods inherited from class uk.ac.starlink.diva.interp.LinearInterp
guessStep
 
Methods inherited from class uk.ac.starlink.diva.interp.AbstractInterpolator
appendValue, binarySearch, evalYData, evalYDataArray, getCount, getXCoord, getXCoords, getYCoord, getYCoords, isFull, isIncreasing, stepGuess
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PolynomialInterp

public PolynomialInterp()
Create an instance with no coordinates. A call to setValues must be made before any other methods.


PolynomialInterp

public PolynomialInterp(double[] x,
                        double[] y)
Create an instance with the given coordinates. Interpolation is by X coordinate see the interpolate method. The X coordinates should be monotonic, either increasing or decreasing. Same value X coordinates are not allowed.

Parameters:
x - the X coordinates.
y - the Y coordinates.
Method Detail

setCoords

public void setCoords(double[] x,
                      double[] y,
                      boolean check)
Description copied from interface: Interpolator
Set or reset the coordinates used by this interpolator.

Specified by:
setCoords in interface Interpolator
Overrides:
setCoords in class AbstractInterpolator
Parameters:
x - the X coordinates.
y - the Y coordinates.
check - whether to check the monotonic direction (compares 0 and 1 values of x). Use this when you need to preserve the direction temporarily even though the order may currently be switched, but take care to reorder before interpolating.

interpolate

public double interpolate(double xp)
Description copied from interface: Interpolator
Return the interpolated value corresponding to some arbitrary X coordinate.

Specified by:
interpolate in interface Interpolator
Overrides:
interpolate in class LinearInterp
Parameters:
xp - the X coordinate at which an interpolated Y coordinate is required.
Returns:
the interpolated value.

evalPolynomial

public double evalPolynomial(double xp)
Evaluate a polynomial by Horner's schema


evalCoeffs

protected void evalCoeffs()
Compute coefficients of Langrange interpolating polynomial of degree x.length - 1. Algorithm due to G.B. Rybicki.


main

public static void main(String[] args)
Simple test entry point



Copyright © 2015 Central Laboratory of the Research Councils. All Rights Reserved.