Changeset 42967 for trunk/Ohana/src/opihi/lib.data/spline.c
- Timestamp:
- Mar 9, 2026, 11:26:15 AM (4 months 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
r42821 r42967 1 1 # include "data.h" 2 3 static SplineMode MODE = SPLINE_SATURATE; // SATURATE or EXTRAPOLATE? 4 5 int spline_contruct_mode (SplineMode mode) { 6 7 switch (mode) { 8 case SPLINE_SATURATE: 9 case SPLINE_EXTRAPOLATE: 10 MODE = mode; 11 break; 12 default: 13 return FALSE; 14 } 15 return TRUE; 16 } 2 17 3 18 /* construct the natural spline for x, y in y2 */ … … 36 51 37 52 // saturate correction at high and low ends 38 if (X < x[0]) return y[0]; 39 if (X > x[N-1]) return y[N-1]; 53 if (MODE == SPLINE_SATURATE) { 54 if (X < x[0]) return y[0]; 55 if (X > x[N-1]) return y[N-1]; 56 } 40 57 41 58 /* find correct element in array (x must be sorted) */ … … 113 130 opihi_flt dx, a, b, value; 114 131 115 // linear extrapolation past endpoints 116 if (X < x[0]) { 117 hi = 1; 118 lo = 0; 119 goto evaluate; 120 // alternative: saturate correction at high and low ends 121 // return y[0]; 122 } 123 if (X > x[N-1]) { 124 hi = N - 1; 125 lo = N - 2; 126 goto evaluate; 127 // alternative: saturate correction at high and low ends 128 // return y[N-1]; 132 // saturate correction at high and low ends 133 if (MODE == SPLINE_SATURATE) { 134 if (X < x[0]) return y[0]; 135 if (X > x[N-1]) return y[N-1]; 129 136 } 130 137 … … 140 147 } 141 148 } 142 143 evaluate:144 149 145 150 /* error condition: duplicate abssisca */
Note:
See TracChangeset
for help on using the changeset viewer.
