NAME
PDL::Interpolate - provide a consistent interface to the interpolation routines available in PDL
SYNOPSIS
use PDL::Interpolate;
my $i = new PDL::Interpolate( x => $x, y = $y );
my $y = $i->interpolate( $xi );
DESCRIPTION
This module aims to provide a relatively-uniform interface to the various interpolation methods available to PDL. The idea is that a different interpolation scheme can be used just by changing the new
call.
At present, PDL::Interpolate itself just provides a somewhat-convoluted interface to the interpolate
function of PDL::Primitive. However, it is expected that derived classes, such as PDL::Interpolate::Slatec, will actually be used in real-world situations.
To use, create a PDL::Interpolate (or a derived class) object, supplying it with its required attributes.
LIBRARIES
Currently, the available classes are
- PDL::Interpolate
-
Provides an interface to the interpolation routines of PDL. At present this is the linear interpolation routine PDL::Primitive::interpol.
- PDL::Interpolate::Slatec
-
The SLATEC library contains several approaches to interpolation: piecewise cubic Hermite functions and B-splines. At present, only the former method is available.
It should be relatively easy to provide an interface to other interpolation routines, such as those provided by the Gnu Scientific Library (GSL).
ATTRIBUTES
The attributes (or options) of an object are as follows; derived classes may modify this list.
Attribute Flag Description
x sgr x positions of data
y sgr function values at x positions
bc g boundary conditions
err g error flag
type g type of interpolation
A flag of s
means that a user can set this attribute with the new or set methods, a flag of g
means that the user can obtain the value of this attribute using get, and a flag of r
means that the attribute is required when an object is created (see the new method).
Attribute Default value
bc "none"
type "linear"
If a routine is sent an attribute it does not understand, then it ignores that attribute, except for get, which returns undef
for that value.
METHODS
The default methods are described below. However, defined classes may extend them as they see fit, and add new methods.
Throughout this documentation, $x
and $y
refer to the function to be interpolated whilst $xi
and $yi
are the interpolated values.
THREADING
The class will thread properly if the routines it calls do so. See the SYNOPSIS section of PDL::Interpolate::Slatec (if available) for an example.
new
$obj = new PDL::Interpolate( x => $x, y => $y );
Create a PDL::Interpolate object.
The required attributes are x
and y
. At present the only available interpolation method is "linear"
- which just uses PDL::Primitive::interpolate - and there are no options for boundary conditions, which is why the type
and bc
attributes can not be changed.
set
my $nset = $obj->set( x = $newx, $y => $newy );
Set attributes for a PDL::Interpolate object.
The return value gives the number of the supplied attributes which were actually set.
get
my $x = $obj->get( x );
my ( $x, $y ) = $obj->get( qw( x y ) );
Get attributes from a PDL::Interpolate object.
Given a list of attribute names, return a list of their values; in scalar mode return a scalar value. If the supplied list contains an unknown attribute, get
returns a value of undef
for that attribute.
interpolate
my $yi = $obj->interpolate( $xi );
Returns the interpolated function at a given set of points.
A status value of -1, as returned by the status
method, means that some of the $xi
points lay outside the range of the data. The values for these points were calculated using linear extrapolation.
status
my $status = $obj->status;
Returns the status of a PDL::Interpolate object
Returns 1 if everything is okay, 0 if there has been a serious error since the last time status
was called, and -1 if there was a problem which was not serious. In the latter case, $obj->get("err")
may provide more information, depending on the particular class.
library
my $name = $obj->library;
Returns the name of the library used by a PDL::Interpolate object
For PDL::Interpolate, the library name is "PDL"
.
routine
my $name = $obj->routine;
Returns the name of the last routine called by a PDL::Interpolate object.
For PDL::Interpolate, the only routine used is "interpolate"
. This will be more useful when calling derived classes, in particular when trying to decode the values stored in the err
attribute.
attributes
$obj->attributes;
PDL::Interpolate::attributes;
Print out the flags for the attributes of an object. Useful in case the documentation is just too opaque!
PDL::Interpolate->attributes;
Flags Attribute
SGR x
SGR y
G err
G type
G bc
AUTHOR
Copyright (C) 2000 Doug Burke (burke@ifa.hawaii.edu). All rights reserved. There is no warranty. You are allowed to redistribute this software / documentation as described in the file COPYING in the PDL distribution.
SEE ALSO
PDL, perltoot(1).