edu.nrao.sss.math
Interface Interpolator

All Known Implementing Classes:
CubicSpline, NewtonDividedDifference

public interface Interpolator

An interpolated value calculator.

This object holds a list of two dimensional points, (xi, yi). Its main job is to calculate a value, f(x), for any x between xi and xi+1, inclusive. This object ensures that its list is ordered such that xi < xi+1, no matter the order in which a client might send it points on which to operate. Interpolators are not permitted to hold more than one point for a given x value.

Version Info:

$Revision: 568 $
$Date: 2007-04-27 16:53:09 -0600 (Fri, 27 Apr 2007) $
$Author: dharland $

Since:
2007-04-24
Author:
David M. Harland

Method Summary
 Point2D addPoint(Point2D newPoint)
          Adds a copy of newPoint to this interpolator.
 void clear()
          Clears all points from this interpolator.
 NumberInterval getDomain()
          Returns an interval whose endpoints are the smallest and largest independent ("x") values of the points held by this interpolator.
 List<Point2D> getPoints()
          Returns a list containing a copy of each point held by this interpolator.
 double getValueFor(double x)
          Returns a value, f(x), for the given value.
 Point2D removePoint(double xValue)
          Removes from this interpolator the point, if any, with an independent variable equal to xValue.
 void setPoints(List<? extends Point2D> points)
          Adds a copy of each of the points in the list to this interpolator.
 int size()
          Returns the number of points held by this interpolator.
 

Method Detail

getValueFor

double getValueFor(double x)
Returns a value, f(x), for the given value. The returned value is calculated based on an interpolation algorithm provided by concrete implementations of this interface. Some examples of such algorithms are linear, cubic spline, and polynomial.

If the value x is outside the domain of this interpolator, and IllegalArgumentException is thrown.

Parameters:
x - the independent variable for which a dependent variable, f(x) is sought.
Returns:
an interpolated value for f(x).

setPoints

void setPoints(List<? extends Point2D> points)
Adds a copy of each of the points in the list to this interpolator.

If any of the new points holds an x-value equal to that of a point already held by this interpolator, the already-held point is first removed, and then the new point is added.

Parameters:
points - a list of new points to be added to this interpolator.

addPoint

Point2D addPoint(Point2D newPoint)
Adds a copy of newPoint to this interpolator.

If this interpolator already contains a point with the same x-value as newPoint, that point is first removed and is also the value returned.

Parameters:
newPoint - a point to be added to this interpolator.
Returns:
the previously held point that has the same x-value as newPoint, or null if this interpolator held no such point.

removePoint

Point2D removePoint(double xValue)
Removes from this interpolator the point, if any, with an independent variable equal to xValue.

Parameters:
xValue - the independent variable of the point to be removed.
Returns:
a point formerly contained by this interpolator having an independent variable equal to xValue. If this interpolator holds no such point, null is returned.

clear

void clear()
Clears all points from this interpolator. Implementations of this interface may choose to reset other properties as well.


size

int size()
Returns the number of points held by this interpolator.

Returns:
the number of points held by this interpolator.

getPoints

List<Point2D> getPoints()
Returns a list containing a copy of each point held by this interpolator. The copies in the returned list will be in the same order as the actual points held by this interpolator.

Returns:
a list containing a copy of each point held by this interpolator.

getDomain

NumberInterval getDomain()
Returns an interval whose endpoints are the smallest and largest independent ("x") values of the points held by this interpolator.

Returns:
the domain of the function represented by the points of this interpolator.


Copyright © 2009. All Rights Reserved.