Mercurial > hg > x
comparison splines.cpp @ 5:5f3c32dc6e17
* Adjust comment syntax to permit Doxygen to generate HTML documentation; add Doxyfile
author | Chris Cannam |
---|---|
date | Wed, 06 Oct 2010 15:19:49 +0100 |
parents | 6422640a802f |
children | 977f541d6683 |
comparison
equal
deleted
inserted
replaced
4:92ee28024c05 | 5:5f3c32dc6e17 |
---|---|
1 //--------------------------------------------------------------------------- | 1 //--------------------------------------------------------------------------- |
2 | 2 |
3 | |
4 #include "splines.h" | 3 #include "splines.h" |
5 | 4 |
5 /** \file splines.h */ | |
6 | |
6 //--------------------------------------------------------------------------- | 7 //--------------------------------------------------------------------------- |
7 /* | 8 /** |
8 function tridiagonal: solves linear system A[N][N]x[N]=d[N] where A is tridiagonal | 9 function tridiagonal: solves linear system A[N][N]x[N]=d[N] where A is tridiagonal |
9 | 10 |
10 In: tridiagonal matrix A[N][N] gives as three vectors - lower subdiagonal | 11 In: tridiagonal matrix A[N][N] gives as three vectors - lower subdiagonal |
11 a[1:N-1], main diagonal b[0:N-1], upper subdiagonal c[0:N-2] | 12 a[1:N-1], main diagonal b[0:N-1], upper subdiagonal c[0:N-2] |
12 vector d[N] | 13 vector d[N] |
25 d[N-1]=d[N-1]/b[N-1]; | 26 d[N-1]=d[N-1]/b[N-1]; |
26 for (int k=N-2; k>=0; k--) | 27 for (int k=N-2; k>=0; k--) |
27 d[k]=(d[k]-c[k]*d[k+1])/b[k]; | 28 d[k]=(d[k]-c[k]*d[k+1])/b[k]; |
28 }//tridiagonal | 29 }//tridiagonal |
29 | 30 |
30 /* | 31 /** |
31 function CubicSpline: computing piece-wise trinomial coefficients of a cubic spline | 32 function CubicSpline: computing piece-wise trinomial coefficients of a cubic spline |
32 | 33 |
33 In: x[N+1], y[N+1]: knots | 34 In: x[N+1], y[N+1]: knots |
34 bordermode: boundary mode of cubic spline | 35 bordermode: boundary mode of cubic spline |
35 bordermode=0: natural: y''(x0)=y''(x_N)=0 | 36 bordermode=0: natural: y''(x0)=y''(x_N)=0 |
116 data[i]=d[n]+xx*(c[n]+xx*(b[n]+xx*a[n])); | 117 data[i]=d[n]+xx*(c[n]+xx*(b[n]+xx*a[n])); |
117 } | 118 } |
118 } | 119 } |
119 }//CubicSpline | 120 }//CubicSpline |
120 | 121 |
121 /* | 122 /** |
122 function CubicSpline: computing piece-wise trinomial coefficients of a cubic spline with uniformly placed knots | 123 function CubicSpline: computing piece-wise trinomial coefficients of a cubic spline with uniformly placed knots |
123 | 124 |
124 In: y[N+1]: spline values at knots (0, h, 2h, ..., Nh) | 125 In: y[N+1]: spline values at knots (0, h, 2h, ..., Nh) |
125 bordermode: boundary mode of cubic spline | 126 bordermode: boundary mode of cubic spline |
126 bordermode=0: natural: y''(x0)=y''(x_N)=0 | 127 bordermode=0: natural: y''(x0)=y''(x_N)=0 |
203 data[i]=d[n]+xx*(c[n]+xx*(b[n]+xx*a[n])); | 204 data[i]=d[n]+xx*(c[n]+xx*(b[n]+xx*a[n])); |
204 } | 205 } |
205 } | 206 } |
206 }//CubicSpline | 207 }//CubicSpline |
207 | 208 |
208 /* | 209 /** |
209 function Smooth_Interpolate: smoothly interpolate/extrapolate P-piece spline from P-1 values. The | 210 function Smooth_Interpolate: smoothly interpolate/extrapolate P-piece spline from P-1 values. The |
210 interpolation scheme is chosen according to P: | 211 interpolation scheme is chosen according to P: |
211 P-1=1: constant | 212 P-1=1: constant |
212 P-1=2: linear function | 213 P-1=2: linear function |
213 P-1=3: quadratic function | 214 P-1=3: quadratic function |