Math::Interpolator - interpolate between lazily-evaluated points
use Math::Interpolator; $ipl = Math::Interpolator->new(@points); @points = $ipl->nhood_x($x, 1); @points = $ipl->nhood_y($y, 1);
This class supports interpolation of a curve between known points, known as "knots", with the knots being lazily evaluated. An object of this type represents a set of knots on a one-dimensional curve, the knots possibly not being predetermined. The methods implemented in this class extract knots, forcing evaluation as required. Subclasses implement interpolation by various algorithms.
This code is neutral as to numeric type. The coordinate values used in interpolation may be native Perl numbers,
Math::BigRat objects, or possibly other types. Mixing types within a single interpolation is not recommended.
A list of zero or more point objects must be supplied. They are wrapped up as an interpolator object, which is returned.
The objects in the list must each implement the interface of either
Math::Interpolator::Source. It is not necessary for them to actually be of those classes; reimplementing the same interfaces is acceptable. They do not need to all be of the same class. A knot-interface object represents a single point on the curve, whereas a source-interface object represents an undetermined set of knots within a particular range of x coordinates.
The point objects must be sorted such that their x coordinates are monotonically non-decreasing. The range of x coordinates covered by each source must not include any individual knot nor overlap the range of any other source.
If reverse interpolation (determining an x coordinate given a y coordinate) is to be performed, then the y coordinates must be similarly sorted.
Normally it would not be desired to instantiate this class directly, because it contains no interpolation methods. A subclass such as
Math::Interpolator::Robust should be instantiated instead.
Returns a list of 2*N consecutive knots (with the
Math::Interpolator::Knot interface) defining the curve in the neighbourhood of x=X. There will be N knots on either side of x=X. If one of the knots has x=X exactly then that knot will be treated as if it had x<X. N must be a positive integer.
Does the same thing as
nhood_x, but for y coordinates. This is only possible if the y coordinates are monotonically non-decreasing for increasing x.
The following two methods are not implemented in this class, but are the standard interpolation interface to be implemented by subclasses.
Interpolates a y value for the given x coordinate, and returns it.
Interpolates an x value for the given y coordinate, and returns it. This is only possible if the y coordinates are monotonically non-decreasing for increasing x.
Andrew Main (Zefram) <firstname.lastname@example.org>
Copyright (C) 2006, 2007, 2009, 2010, 2012 Andrew Main (Zefram) <email@example.com>
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.