Changeset 42332 for trunk/Ohana/src/opihi/lib.data/spline.c
- Timestamp:
- Jan 30, 2023, 9:45:29 AM (3 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/lib.data/spline.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/lib.data/spline.c
r41341 r42332 2 2 3 3 /* construct the natural spline for x, y in y2 */ 4 void spline_construct_flt (float *x, float *y, int N, float *y2 ) {4 void spline_construct_flt (float *x, float *y, int N, float *y2, float dyLower, float dyUpper) { 5 5 6 6 int i; … … 67 67 68 68 /* construct the natural spline for x, y in y2 */ 69 void spline_construct_dbl (opihi_flt *x, opihi_flt *y, int N, opihi_flt *y2 ) {69 void spline_construct_dbl (opihi_flt *x, opihi_flt *y, int N, opihi_flt *y2, opihi_flt dyLower, opihi_flt dyUpper) { 70 70 71 71 int i; … … 77 77 ALLOCATE (tmp, opihi_flt, N); 78 78 79 y2[0] = tmp[0] = 0.0; 79 if (isnan(dyLower)) { 80 y2[0] = tmp[0] = 0.0; 81 } else { 82 y2[0] = -0.5; 83 tmp[0] = (3.0/(x[1]-x[0])) * ((y[1]-y[0])/(x[1]-x[0]) - dyLower); 84 } 80 85 81 86 for (i = 1; i < N-1; i++) { … … 86 91 tmp[i] = (6.0 * tmp[i] / (x[i+1] - x[i-1]) - dx*tmp[i-1]) / dy; 87 92 } 93 94 if (isfinite(dyUpper)) { 95 opihi_flt qn = 0.5; 96 tmp[N-1] = (3.0/(x[N-1]-x[N-2])) * (dyUpper - (y[N-1]-y[N-2])/(x[N-1]-x[N-2])); 97 y2[N-1] = (tmp[N-1] - (qn * tmp[N-2])) / ((qn * y2[N-2]) + 1.0); 98 } else { 99 y2[N-1] = 0; 100 } 88 101 89 y2[N-1] = 0; 90 for (i = N-2; i >= 1; i--) 102 for (i = N-2; i >= 0; i--) { 91 103 y2[i] = y2[i]*y2[i+1] + tmp[i]; 104 } 92 105 93 106 free (tmp);
Note:
See TracChangeset
for help on using the changeset viewer.
