Changeset 42332
- Timestamp:
- Jan 30, 2023, 9:45:29 AM (3 years ago)
- Location:
- trunk/Ohana/src/opihi
- Files:
-
- 5 edited
-
cmd.data/imspline_apply.c (modified) (1 diff)
-
cmd.data/imspline_construct.c (modified) (1 diff)
-
cmd.data/spline_commands.c (modified) (2 diffs)
-
include/data.h (modified) (1 diff)
-
lib.data/spline.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/cmd.data/imspline_apply.c
r40549 r42332 77 77 Tx1[i] = spline_apply_flt (Tyc, Ty1, Ty2, Ny, y); 78 78 } 79 spline_construct_flt (Txc, Tx1, Nx, Tx2 );79 spline_construct_flt (Txc, Tx1, Nx, Tx2, NAN, NAN); 80 80 81 81 /* apply x-dir spline to new image */ -
trunk/Ohana/src/opihi/cmd.data/imspline_construct.c
r40549 r42332 55 55 } 56 56 57 spline_construct_flt (Tx, Ty, Ny, Ty2 );57 spline_construct_flt (Tx, Ty, Ny, Ty2, NAN, NAN); 58 58 59 59 /* copy derivatives to output buffer */ -
trunk/Ohana/src/opihi/cmd.data/spline_commands.c
r41341 r42332 15 15 int spline_create (int argc, char **argv) { 16 16 17 int i ;17 int i, N; 18 18 Vector *xvec, *yvec; 19 20 double dyLower = NAN; 21 double dyUpper = NAN; 22 if ((N = get_argument (argc, argv, "-dyLower"))) { 23 remove_argument (N, &argc, argv); 24 dyLower = atof(argv[N]); 25 remove_argument (N, &argc, argv); 26 } 27 if ((N = get_argument (argc, argv, "-dyUpper"))) { 28 remove_argument (N, &argc, argv); 29 dyUpper = atof(argv[N]); 30 remove_argument (N, &argc, argv); 31 } 19 32 20 33 if (argc != 4) { … … 43 56 } 44 57 45 spline_construct_dbl (myspline->xk, myspline->yk, myspline->Nknots, myspline->y2 );58 spline_construct_dbl (myspline->xk, myspline->yk, myspline->Nknots, myspline->y2, dyLower, dyUpper); 46 59 return TRUE; 47 60 } -
trunk/Ohana/src/opihi/include/data.h
r41891 r42332 133 133 134 134 /* in spline.c */ 135 void spline_construct_flt (float *x, float *y, int N, float *y2 );135 void spline_construct_flt (float *x, float *y, int N, float *y2, float dyLower, float dyUpper); 136 136 float spline_apply_flt (float *x, float *y, float *y2, int N, float X); 137 void spline_construct_dbl (opihi_flt *x, opihi_flt *y, int N, opihi_flt *y2 );137 void spline_construct_dbl (opihi_flt *x, opihi_flt *y, int N, opihi_flt *y2, opihi_flt dyLower, opihi_flt dyUpper); 138 138 opihi_flt spline_apply_dbl (opihi_flt *x, opihi_flt *y, opihi_flt *y2, int N, opihi_flt X); 139 139 -
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.
