- SEE ALSO
PDLA::Interpolate - provide a consistent interface to the interpolation routines available in PDLA
use PDLA::Interpolate; my $i = new PDLA::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 PDLA. The idea is that a different interpolation scheme can be used just by changing the
At present, PDLA::Interpolate itself just provides a somewhat-convoluted interface to the
interpolate function of PDLA::Primitive. However, it is expected that derived classes, such as PDLA::Interpolate::Slatec, will actually be used in real-world situations.
To use, create a PDLA::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 PDLA. At present this is the linear interpolation routine PDLA::Primitive::interpol.
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,
$y refer to the function to be interpolated whilst
$yi are the interpolated values.
The class will thread properly if the routines it calls do so. See the SYNOPSIS section of PDLA::Interpolate::Slatec (if available) for an example.
$obj = new PDLA::Interpolate( x => $x, y => $y );
Create a PDLA::Interpolate object.
The required attributes are
y. At present the only available interpolation method is
"linear" - which just uses PDLA::Primitive::interpolate - and there are no options for boundary conditions, which is why the
bc attributes can not be changed.
my $nset = $obj->set( x = $newx, $y => $newy );
Set attributes for a PDLA::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 PDLA::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 PDLA::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 PDLA::Interpolate object
For PDLA::Interpolate, the library name is
my $name = $obj->routine;
Returns the name of the last routine called by a PDLA::Interpolate object.
For PDLA::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
Print out the flags for the attributes of an object. Useful in case the documentation is just too opaque!
PDLA::Interpolate->attributes; Flags Attribute SGR x SGR y G err G type G bc
Copyright (C) 2000 Doug Burke (firstname.lastname@example.org). All rights reserved. There is no warranty. You are allowed to redistribute this software / documentation as described in the file COPYING in the PDLA distribution.