VERB_code_2.2  2
 All Classes Namespaces Files Functions Variables Typedefs Macros Pages
spline.cpp File Reference
#include <math.h>
#include "../../Exceptions/error.h"

Go to the source code of this file.

Functions

void spline (double *x, double *y, int n, double yp1, double ypn, double *y2)
 
void splint (double *xa, double *ya, double *y2a, int n, double x, double *y)
 

Detailed Description

Spline interpolation

Definition in file spline.cpp.

Function Documentation

void spline ( double *  x,
double *  y,
int  n,
double  yp1,
double  ypn,
double *  y2 
)

Spline interpolation - calculation of an array with second derivatives (called only once for each interpolation of an array)

Given arrays x[1..n] and y[1..n] containing a tabulated function, i.e., yi = f (xi ), with x1 < x2 < . . . < xN , and given values yp1 and ypn for the first derivative of the interpolating function at points 1 and n, respectively, this routine returns an array y2[1..n] that contains the second derivatives of the interpolating function at the tabulated points xi . If yp1 and/or ypn are equal to 1 - 10^30 or larger, the routine is signaled to set the corresponding boundary condition for a natural spline, with zero second derivative on that boundary.

Parameters
*x- old x
*y- old function
n- number of points
yp1- derivative on boundary / flag if > 10^30
ypn- derivative on boundary / flag if > 10^30
*y2- array with second derivatives of the function

Definition at line 30 of file spline.cpp.

void splint ( double *  xa,
double *  ya,
double *  y2a,
int  n,
double  x,
double *  y 
)

Spline interpolation

Given the arrays xa[1..n] and ya[1..n], which tabulate a function (with the xai -s in order), and given the array y2a[1..n], which is the output from spline above, and given a value of x, this routine returns a cubic-spline interpolated value y.

Parameters
*xa- old grid array
*ya- old function array
*y2a- old function second derivatives array
n- size of arrays
x- new grid point
*y- new grid value

Definition at line 86 of file spline.cpp.

References nrerror().