Changeset 42326 for branches/eam_branches/psLib.20230123
- Timestamp:
- Jan 26, 2023, 10:40:25 AM (3 years ago)
- Location:
- branches/eam_branches/psLib.20230123/src/math
- Files:
-
- 2 edited
-
psSpline.c (modified) (6 diffs)
-
psSpline.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/psLib.20230123/src/math/psSpline.c
r42324 r42326 72 72 *****************************************************************************/ 73 73 74 static psF32 *calculateSecondDerivs(74 void calculateSecondDerivs( 75 75 const psSpline1D *mySpline, 76 76 psF32 dyLower, // if not NAN, lower-bound 1st derivative is defined … … 82 82 psS32 n = mySpline->n; // n is the number of knots 83 83 psF32 *u = (psF32 *) psAlloc(n * sizeof(psF32)); 84 psF32 *d2y = (psF32 *) psAlloc(n * sizeof(psF32)); 85 psF32 *X = mySpline->xKnots; 86 psF32 *Y = mySpline->yKnots; 84 85 psF32 *X = mySpline->xKnots; 86 psF32 *Y = mySpline->yKnots; 87 psF32 *d2y = mySpline->d2yKnots; 87 88 88 89 if (isfinite(dyLower)) { … … 120 121 psFree(u); 121 122 psTrace("psLib.math", 4, "---- %s() end ----\n", __func__); 122 123 return(d2y); 123 return; 124 124 } 125 125 … … 151 151 152 152 return(tmpSpline); 153 } 154 155 /** Create an empty 1D spline **/ 156 psSpline1D *psSpline1DCreate( 157 int nKnots) ///< number of knots 158 { 159 psSpline1D *spline = psSpline1DAlloc(); 160 spline->n = nKnots; // number of knots 161 162 spline->xKnots = (psF32 *) psAlloc( spline->n * sizeof(psF32)); 163 spline->yKnots = (psF32 *) psAlloc( spline->n * sizeof(psF32)); 164 spline->d2yKnots = (psF32 *) psAlloc( spline->n * sizeof(psF32)); 165 166 // x & y can both be F32 or F64. should knots be F64? 167 for (psS32 i = 0 ; i < spline->n ; i++) { 168 spline->xKnots[i] = NAN; 169 spline->yKnots[i] = NAN; 170 spline->d2yKnots[i] = NAN; 171 } 172 return(spline); 153 173 } 154 174 … … 187 207 PS_ASSERT_LONG_LARGER_THAN_OR_EQUAL(y->n, (long)2, NULL); 188 208 189 psSpline1D *spline = psSpline1DAlloc(); 190 spline->n = y->n; // number of knots 191 192 spline->xKnots = (psF32 *) psAlloc( spline->n * sizeof(psF32)); 193 spline->yKnots = (psF32 *) psAlloc( spline->n * sizeof(psF32)); 194 spline->d2yKnots = (psF32 *) psAlloc( spline->n * sizeof(psF32)); 209 psSpline1D *spline = psSpline1DCreate(y->n); 195 210 196 211 // x & y can both be F32 or F64. should knots be F64? … … 201 216 202 217 // Generate the second derivatives at each data point. 203 spline->d2yKnots =calculateSecondDerivs(spline, dyLower, dyUpper);218 calculateSecondDerivs(spline, dyLower, dyUpper); 204 219 205 220 psTrace("psLib.math", 3, "---- %s() end ----\n", __func__); -
branches/eam_branches/psLib.20230123/src/math/psSpline.h
r42324 r42326 51 51 */ 52 52 psSpline1D *psSpline1DAlloc(void) PS_ATTR_MALLOC; 53 54 /** Create an empty 1D spline **/ 55 psSpline1D *psSpline1DCreate( 56 int nKnots); ///< number of knots 53 57 54 58 /** Evaluates 1-D spline polynomials at a specific coordinate.
Note:
See TracChangeset
for help on using the changeset viewer.
