SEARCH NEW RPMS DIRECTORIES ABOUT FAQ VARIOUS BLOG DONATE YUM REPOSITORY

MAN page from Fedora 28 perl-Math-Spline-0.02-7.fc28.noarch.rpm

# Spline

Section: User Contributed Perl Documentation (3)
Updated: 2013-05-16
Index

## NAME

`    Math::Spline  - Cubic Spline Interpolation of data`

## SYNOPSIS

`    use Math::Spline;    \$spline = Math::Spline->new(\@x,\@y)    \$y_interp=\$spline->evaluate(\$x);    use Math::Spline qw(spline linsearch binsearch);    use Math::Derivative qw(Derivative2);    @y2=Derivative2(\@x,\@y);    \$index=binsearch(\@x,\$x);    \$index=linsearch(\@x,\$x,\$index);    \$y_interp=spline(\@x,\@y,\@y2,\$index,\$x);`

## DESCRIPTION

This package provides cubic spline interpolation of numeric data. Thedata is passed as references to two arrays containing the x and yordinates. It may be used as an exporter of the numerical functionsor, more easily as a class module.

The Math::Spline class constructor new takes references to thearrays of x and y ordinates of the data. An interpolation is performedusing the evaluate method, which, when given an x ordinate returnsthe interpolate y ordinate at that value.

The spline function takes as arguments references to the x and yordinate array, a reference to the 2nd derivatives (calculated usingDerivative2, the low index of the interval in which to interpolateand the x ordinate in that interval. Returned is the interpolated yordinate. Two functions are provided to look up the appropriate indexin the array of x data. For random calls binsearch can be used -give a reference to the x ordinates and the x loopup value it returnsthe low index of the interval in the data in which the valuelies. Where the lookups are strictly in ascending sequence (e.g. ifinterpolating to produce a higher resolution data set to draw a curve)the linsearch function may more efficiently be used. It performslike binsearch, but requires a third argument being the previousindex value, which is incremented if necessary.

## NOTE

requires Math::Derivative module

## EXAMPLE

`    require Math::Spline;    my @x=(1,3,8,10);    my @y=(1,2,3,4);                                                    \$spline = Math::Spline->new(\@x,\@y);    print \$spline->evaluate(5)."\n";`

produces the output

2.44

## HISTORY

\$Log: Spline.pm,v \$Revision 1.1 1995/12/26 17:28:17 willijarInitial revision

## BUGS

Bug reports or constructive comments are welcome.

## AUTHOR

John A.R. Williams <J.A.R.WilliamsAATTaston.ac.uk>

``Numerical Recipies: The Art of Scientific Computing''W.H. Press, B.P. Flannery, S.A. Teukolsky, W.T. Vetterling.Cambridge University Press. ISBN 0 521 30811 9.

NAME
SYNOPSIS
DESCRIPTION
NOTE
EXAMPLE
HISTORY
BUGS
AUTHOR