splinc.f
32 lines · 1 definitions · on GitHub (7be4133)
Python version: splinc.py, 45 lines, on the right (switch to Python above the code).
Variables on this page (1)
Purpose
SPLINC computes the second derivatives of a natural cubic spline through the points $(x_i, y_i)$, $i = 1, \dots, N$, for interpolation with SPLINTD2. It is the tridiagonal algorithm of Numerical Recipes' spline, with the end conditions fixed to a natural spline.
How it fits
The method
A natural spline has $y''_1 = y''_N = 0$. For the interior points the second derivatives solve
$$\frac{x_i - x_{i-1}}{6}\,y''_{i-1} + \frac{x_{i+1} - x_{i-1}}{3}\,y''_i + \frac{x_{i+1} - x_i}{6}\,y''_{i+1} = \frac{y_{i+1} - y_i}{x_{i+1} - x_i} - \frac{y_i - y_{i-1}}{x_i - x_{i-1}},$$
which the code solves by forward elimination (SIG, P, U) and back substitution.
Design
The arrays have the fixed size JSON (5000, from DIMENSIONS_MOD). splinj.f is the same routine with arrays sized N.
Definitions
subroutineSPLINC
Natural cubic spline: the second derivatives Y2 at N points (at most 5000).
Uses modules DIMENSIONS_MOD
Called by HPOINT ×3
Change log
The changes since rp_1
Changed since rp_1. Declarations only: the array size JSON from DIMENSIONS_MOD, IMPLICIT NONE.