help-octave
[Top][All Lists]

## Re: spline.m

 From: Dirk Eddelbuettel Subject: Re: spline.m Date: Wed, 14 Oct 1998 20:22:33 -0400 (EDT)

```  Wulf> Does somebody out there know where to find a "spline"-command
Wulf> compatible with the MATLAB spline.m??

John> I don't know of one.  Is anyone interested in providing an
John> independent implementation for Octave?

Jim>  I have a C program (spline) at netlib that implements slines under
Jim> tension.  If I remember correctly, it is based on a FORTRAN program in
Jim> TOMS.  One of these might be a suitable starting point.

GNU R has quite at least two parts which we might reuse:

-- a 'splines' package licensed under GPL:

Package: splines
Version: 2.0-3
Authors: Douglas M. Bates <address@hidden> and
Description: Functions and classes for defining B-spline representations
or polynomial spline representations of regression splines or
interpolation splines.

-- and two 'base' functions (ie part of the core R package) spline and
splinefun:

Interpolating Splines

splinefun(x, y, method = "fmm")
spline(x, y, n = 3*length(x), method = "fmm",
xmin = min(x), xmax = max(x))

Arguments:

x,y: vectors giving the coordinates of the points to be
interpolated.  Alternatively a single plotting
structure can be specified.

method: specifies the type of spline to be used.  Possible
values are `"fmm"', `"natural"' and `"periodic"'.

n: interpolation takes place at `n' equally spaced
points spanning the interval [`xmin', `xmax'].

xmin: left-hand endpoint of the interpolation interval.

xmax: right-hand endpoint of the interpolation interval.

Description:

`spline' performs cubic spline interpolation of the
given data points.  It returns a list containing compo-
nents `x' and `y' which give the ordinates where inter-
polation took place and the interpolated values.

`splinefun' returns a function which will perform cubic
spline interpolation of the given data points.  This is
often more useful than `spline'.

If `method="fmm"', the spline used is that of Forsythe,
Malcolm and Moler (an exact cubic is fitted through the
four points at each end of the data, and this is used
to determine the end conditions).  Natural splines are
used when `method="natural"', and periodic splines when
`method="periodic"'.

References:

Forsythe, G. E., M. A. Malcolm and C. B. Moler (1977).
Computer Methods for Mathematical Computations.

--
Linux is not only free; it is, arguably, a better operating system, offering
a degree of stability and an ability to scale up that NT cannot match.
-- The Economist, Oct 3, 1998

```