| PDL documentation | view source | Contained in the PDL distribution. |
PDL::Interpolate - provide a consistent interface to the interpolation routines available in PDL
use PDL::Interpolate; my $i = new PDL::Interpolate( x => $x, y = $y ); my $y = $i->interpolate( $xi );
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 (interpolate in 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.
Currently, the avaliable classes are
Provides an interface to the interpolation routines of PDL. At present this is the linear interpolation routine PDL::Primitive::interpol (interpol in PDL::Primitive).
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).
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.
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.
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.
$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 (PDL::Primitive::interpolate) - and
there are no options for boundary conditions, which is why
the type and bc attributes can not be changed.
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.
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.
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.
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.
my $name = $obj->library;
Returns the name of the library used by a PDL::Interpolate object
For PDL::Interpolate, the library name is "PDL".
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.
$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
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.
PDL, perltoot(1).
| PDL documentation | view source | Contained in the PDL distribution. |