Changeset 4405
- Timestamp:
- Jun 27, 2005, 2:53:54 PM (21 years ago)
- Location:
- trunk/psLib
- Files:
-
- 10 edited
-
src/dataManip/psFunctions.c (modified) (11 diffs)
-
src/dataManip/psFunctions.h (modified) (34 diffs)
-
src/math/psPolynomial.c (modified) (11 diffs)
-
src/math/psPolynomial.h (modified) (34 diffs)
-
src/math/psSpline.c (modified) (11 diffs)
-
src/math/psSpline.h (modified) (34 diffs)
-
test/dataManip/verified/tst_psFunc08.stderr (modified) (1 diff)
-
test/dataManip/verified/tst_psFunc09.stderr (modified) (1 diff)
-
test/dataManip/verified/tst_psFunc10.stderr (modified) (1 diff)
-
test/dataManip/verified/tst_psFunc11.stderr (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/dataManip/psFunctions.c
r4392 r4405 7 7 * polynomials. It also contains a Gaussian functions. 8 8 * 9 * @version $Revision: 1.11 1$ $Name: not supported by cvs2svn $10 * @date $Date: 2005-06-2 5 02:02:05$9 * @version $Revision: 1.112 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2005-06-28 00:53:53 $ 11 11 * 12 12 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 1232 1232 } 1233 1233 1234 psF 32 psPolynomial1DEval(const psPolynomial1D* myPoly, psF32x)1235 { 1236 PS_ASSERT_POLY_NON_NULL( myPoly, NAN);1237 1238 if ( myPoly->type == PS_POLYNOMIAL_ORD) {1239 return(ordPolynomial1DEval(x, myPoly));1240 } else if ( myPoly->type == PS_POLYNOMIAL_CHEB) {1241 return(chebPolynomial1DEval(x, myPoly));1234 psF64 psPolynomial1DEval(const psPolynomial1D* poly, psF64 x) 1235 { 1236 PS_ASSERT_POLY_NON_NULL(poly, NAN); 1237 1238 if (poly->type == PS_POLYNOMIAL_ORD) { 1239 return(ordPolynomial1DEval(x, poly)); 1240 } else if (poly->type == PS_POLYNOMIAL_CHEB) { 1241 return(chebPolynomial1DEval(x, poly)); 1242 1242 } else { 1243 1243 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 1244 1244 PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE, 1245 myPoly->type);1245 poly->type); 1246 1246 } 1247 1247 return(NAN); 1248 1248 } 1249 1249 1250 psVector *psPolynomial1DEvalVector(const psPolynomial1D * myPoly,1250 psVector *psPolynomial1DEvalVector(const psPolynomial1D *poly, 1251 1251 const psVector *x) 1252 1252 { 1253 PS_ASSERT_POLY_NON_NULL( myPoly, NULL);1253 PS_ASSERT_POLY_NON_NULL(poly, NULL); 1254 1254 PS_ASSERT_VECTOR_NON_NULL(x, NULL); 1255 1255 PS_ASSERT_VECTOR_TYPE(x, PS_TYPE_F32, NULL); … … 1259 1259 tmp = psVectorAlloc(x->n, PS_TYPE_F32); 1260 1260 for (psS32 i=0;i<x->n;i++) { 1261 tmp->data.F32[i] = psPolynomial1DEval( myPoly, x->data.F32[i]);1261 tmp->data.F32[i] = psPolynomial1DEval(poly, x->data.F32[i]); 1262 1262 } 1263 1263 … … 1265 1265 } 1266 1266 1267 psF 32 psPolynomial2DEval(const psPolynomial2D* myPoly, psF32 x, psF32y)1268 { 1269 PS_ASSERT_POLY_NON_NULL( myPoly, NAN);1270 1271 if ( myPoly->type == PS_POLYNOMIAL_ORD) {1272 return(ordPolynomial2DEval(x, y, myPoly));1273 } else if ( myPoly->type == PS_POLYNOMIAL_CHEB) {1274 return(chebPolynomial2DEval(x, y, myPoly));1267 psF64 psPolynomial2DEval(const psPolynomial2D* poly, psF64 x, psF64 y) 1268 { 1269 PS_ASSERT_POLY_NON_NULL(poly, NAN); 1270 1271 if (poly->type == PS_POLYNOMIAL_ORD) { 1272 return(ordPolynomial2DEval(x, y, poly)); 1273 } else if (poly->type == PS_POLYNOMIAL_CHEB) { 1274 return(chebPolynomial2DEval(x, y, poly)); 1275 1275 } else { 1276 1276 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 1277 1277 PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE, 1278 myPoly->type);1278 poly->type); 1279 1279 } 1280 1280 return(NAN); 1281 1281 } 1282 1282 1283 psVector *psPolynomial2DEvalVector(const psPolynomial2D * myPoly,1283 psVector *psPolynomial2DEvalVector(const psPolynomial2D *poly, 1284 1284 const psVector *x, 1285 1285 const psVector *y) 1286 1286 1287 1287 { 1288 PS_ASSERT_POLY_NON_NULL( myPoly, NULL);1288 PS_ASSERT_POLY_NON_NULL(poly, NULL); 1289 1289 PS_ASSERT_VECTOR_NON_NULL(x, NULL); 1290 1290 PS_ASSERT_VECTOR_TYPE(x, PS_TYPE_F32, NULL); … … 1305 1305 // Evaluate the polynomial at the specified points 1306 1306 for (psS32 i=0; i<vecLen; i++) { 1307 tmp->data.F32[i] = psPolynomial2DEval( myPoly,x->data.F32[i],y->data.F32[i]);1307 tmp->data.F32[i] = psPolynomial2DEval(poly,x->data.F32[i],y->data.F32[i]); 1308 1308 } 1309 1309 … … 1312 1312 } 1313 1313 1314 psF 32 psPolynomial3DEval(const psPolynomial3D* myPoly, psF32 x, psF32 y, psF32z)1315 { 1316 PS_ASSERT_POLY_NON_NULL( myPoly, NAN);1317 1318 if ( myPoly->type == PS_POLYNOMIAL_ORD) {1319 return(ordPolynomial3DEval(x, y, z, myPoly));1320 } else if ( myPoly->type == PS_POLYNOMIAL_CHEB) {1321 return(chebPolynomial3DEval(x, y, z, myPoly));1314 psF64 psPolynomial3DEval(const psPolynomial3D* poly, psF64 x, psF64 y, psF64 z) 1315 { 1316 PS_ASSERT_POLY_NON_NULL(poly, NAN); 1317 1318 if (poly->type == PS_POLYNOMIAL_ORD) { 1319 return(ordPolynomial3DEval(x, y, z, poly)); 1320 } else if (poly->type == PS_POLYNOMIAL_CHEB) { 1321 return(chebPolynomial3DEval(x, y, z, poly)); 1322 1322 } else { 1323 1323 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 1324 1324 PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE, 1325 myPoly->type);1325 poly->type); 1326 1326 } 1327 1327 return(NAN); 1328 1328 } 1329 1329 1330 psVector *psPolynomial3DEvalVector(const psPolynomial3D * myPoly,1330 psVector *psPolynomial3DEvalVector(const psPolynomial3D *poly, 1331 1331 const psVector *x, 1332 1332 const psVector *y, … … 1334 1334 1335 1335 { 1336 PS_ASSERT_POLY_NON_NULL( myPoly, NULL);1336 PS_ASSERT_POLY_NON_NULL(poly, NULL); 1337 1337 PS_ASSERT_VECTOR_NON_NULL(x, NULL); 1338 1338 PS_ASSERT_VECTOR_TYPE(x, PS_TYPE_F32, NULL); … … 1358 1358 // Evaluate polynomial 1359 1359 for (psS32 i = 0; i < vecLen; i++) { 1360 tmp->data.F32[i] = psPolynomial3DEval( myPoly,1360 tmp->data.F32[i] = psPolynomial3DEval(poly, 1361 1361 x->data.F32[i], 1362 1362 y->data.F32[i], … … 1368 1368 } 1369 1369 1370 psF 32 psPolynomial4DEval(const psPolynomial4D* myPoly, psF32 w, psF32 x, psF32 y, psF32 z)1371 { 1372 PS_ASSERT_POLY_NON_NULL( myPoly, NAN);1373 1374 if ( myPoly->type == PS_POLYNOMIAL_ORD) {1375 return(ordPolynomial4DEval( w,x,y,z, myPoly));1376 } else if ( myPoly->type == PS_POLYNOMIAL_CHEB) {1377 return(chebPolynomial4DEval( w,x,y,z, myPoly));1370 psF64 psPolynomial4DEval(const psPolynomial4D* poly, psF64 x, psF64 y, psF64 z, psF64 t) 1371 { 1372 PS_ASSERT_POLY_NON_NULL(poly, NAN); 1373 1374 if (poly->type == PS_POLYNOMIAL_ORD) { 1375 return(ordPolynomial4DEval(x,y,z,t, poly)); 1376 } else if (poly->type == PS_POLYNOMIAL_CHEB) { 1377 return(chebPolynomial4DEval(x,y,z,t, poly)); 1378 1378 } else { 1379 1379 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 1380 1380 PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE, 1381 myPoly->type);1381 poly->type); 1382 1382 } 1383 1383 return(NAN); 1384 1384 } 1385 1385 1386 psVector *psPolynomial4DEvalVector(const psPolynomial4D *myPoly, 1387 const psVector *w, 1386 psVector *psPolynomial4DEvalVector(const psPolynomial4D *poly, 1388 1387 const psVector *x, 1389 1388 const psVector *y, 1390 const psVector *z) 1391 { 1392 PS_ASSERT_POLY_NON_NULL(myPoly, NULL); 1393 PS_ASSERT_VECTOR_NON_NULL(w, NULL); 1394 PS_ASSERT_VECTOR_TYPE(w, PS_TYPE_F32, NULL); 1389 const psVector *z, 1390 const psVector *t) 1391 { 1392 PS_ASSERT_POLY_NON_NULL(poly, NULL); 1395 1393 PS_ASSERT_VECTOR_NON_NULL(x, NULL); 1396 1394 PS_ASSERT_VECTOR_TYPE(x, PS_TYPE_F32, NULL); … … 1399 1397 PS_ASSERT_VECTOR_NON_NULL(z, NULL); 1400 1398 PS_ASSERT_VECTOR_TYPE(z, PS_TYPE_F32, NULL); 1399 PS_ASSERT_VECTOR_NON_NULL(t, NULL); 1400 PS_ASSERT_VECTOR_TYPE(t, PS_TYPE_F32, NULL); 1401 1401 1402 1402 psVector *tmp; 1403 psS32 vecLen= w->n;1403 psS32 vecLen=x->n; 1404 1404 1405 1405 // Determine output vector size from min of input vectors 1406 if (z->n < vecLen) { 1407 vecLen = z->n; 1408 } 1406 1409 if (y->n < vecLen) { 1407 1410 vecLen = y->n; 1408 1411 } 1409 if (x->n < vecLen) { 1410 vecLen = x->n; 1411 } 1412 if (z->n < vecLen) { 1413 vecLen = z->n; 1412 if (t->n < vecLen) { 1413 vecLen = t->n; 1414 1414 } 1415 1415 … … 1419 1419 // Evaluate polynomial 1420 1420 for (psS32 i = 0; i < vecLen; i++) { 1421 tmp->data.F32[i] = psPolynomial4DEval(myPoly, 1422 w->data.F32[i], 1421 tmp->data.F32[i] = psPolynomial4DEval(poly, 1423 1422 x->data.F32[i], 1424 1423 y->data.F32[i], 1425 z->data.F32[i]); 1424 z->data.F32[i], 1425 t->data.F32[i]); 1426 1426 } 1427 1427 -
trunk/psLib/src/dataManip/psFunctions.h
r4330 r4405 12 12 * @author GLG, MHPCC 13 13 * 14 * @version $Revision: 1.4 8$ $Name: not supported by cvs2svn $15 * @date $Date: 2005-06-2 1 03:01:37$14 * @version $Revision: 1.49 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2005-06-28 00:53:53 $ 16 16 * 17 17 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 67 67 PS_POLYNOMIAL_ORD, ///< Ordinary Polynomial 68 68 PS_POLYNOMIAL_CHEB ///< Chebyshev Polynomial 69 } psPolynomialType; 69 } 70 psPolynomialType; 70 71 71 72 /** One-dimensional polynomial */ … … 73 74 { 74 75 psPolynomialType type; ///< Polynomial type 75 psS32 n; ///< Number of terms76 psS32 n; ///< Number of terms 76 77 psF32 *coeff; ///< Coefficients 77 78 psF32 *coeffErr; ///< Error in coefficients … … 84 85 { 85 86 psPolynomialType type; ///< Polynomial type 86 psS32 nX; ///< Number of terms in x87 psS32 nY; ///< Number of terms in y87 psS32 nX; ///< Number of terms in x 88 psS32 nY; ///< Number of terms in y 88 89 psF32 **coeff; ///< Coefficients 89 90 psF32 **coeffErr; ///< Error in coefficients … … 96 97 { 97 98 psPolynomialType type; ///< Polynomial type 98 psS32 nX; ///< Number of terms in x99 psS32 nY; ///< Number of terms in y100 psS32 nZ; ///< Number of terms in z99 psS32 nX; ///< Number of terms in x 100 psS32 nY; ///< Number of terms in y 101 psS32 nZ; ///< Number of terms in z 101 102 psF32 ***coeff; ///< Coefficients 102 103 psF32 ***coeffErr; ///< Error in coefficients … … 109 110 { 110 111 psPolynomialType type; ///< Polynomial type 111 psS32 nW; ///< Number of terms in w112 psS32 nX; ///< Number of terms in x113 psS32 nY; ///< Number of terms in y114 psS32 nZ; ///< Number of terms in z112 psS32 nW; ///< Number of terms in w 113 psS32 nX; ///< Number of terms in x 114 psS32 nY; ///< Number of terms in y 115 psS32 nZ; ///< Number of terms in z 115 116 psF32 ****coeff; ///< Coefficients 116 117 psF32 ****coeffErr; ///< Error in coefficients … … 125 126 */ 126 127 psPolynomial1D* psPolynomial1DAlloc( 127 psS32 n, ///< Number of terms128 psS32 n, ///< Number of terms 128 129 psPolynomialType type ///< Polynomial Type 129 130 ); … … 134 135 */ 135 136 psPolynomial2D* psPolynomial2DAlloc( 136 psS32 nX, ///< Number of terms in x137 psS32 nY, ///< Number of terms in y137 psS32 nX, ///< Number of terms in x 138 psS32 nY, ///< Number of terms in y 138 139 psPolynomialType type ///< Polynomial Type 139 140 ); … … 144 145 */ 145 146 psPolynomial3D* psPolynomial3DAlloc( 146 psS32 nX, ///< Number of terms in x147 psS32 nY, ///< Number of terms in y148 psS32 nZ, ///< Number of terms in z147 psS32 nX, ///< Number of terms in x 148 psS32 nY, ///< Number of terms in y 149 psS32 nZ, ///< Number of terms in z 149 150 psPolynomialType type ///< Polynomial Type 150 151 ); … … 155 156 */ 156 157 psPolynomial4D* psPolynomial4DAlloc( 157 psS32 nW, ///< Number of terms in w158 psS32 nX, ///< Number of terms in x159 psS32 nY, ///< Number of terms in y160 psS32 nZ, ///< Number of terms in z158 psS32 nW, ///< Number of terms in w 159 psS32 nX, ///< Number of terms in x 160 psS32 nY, ///< Number of terms in y 161 psS32 nZ, ///< Number of terms in z 161 162 psPolynomialType type ///< Polynomial Type 162 163 ); … … 164 165 /** Evaluates a 1-D polynomial at specific coordinates. 165 166 * 166 * @return psF 32result of polynomial at given location167 */ 168 psF 32psPolynomial1DEval(169 const psPolynomial1D* myPoly,///< Coefficients for the polynomial170 psF 32x ///< location at which to evaluate167 * @return psF64 result of polynomial at given location 168 */ 169 psF64 psPolynomial1DEval( 170 const psPolynomial1D* poly, ///< Coefficients for the polynomial 171 psF64 x ///< location at which to evaluate 171 172 ); 172 173 173 174 /** Evaluates a 2-D polynomial at specific coordinates. 174 175 * 175 * @return psF 32result of polynomial at given location176 */ 177 psF 32psPolynomial2DEval(178 const psPolynomial2D* myPoly,///< Coefficients for the polynomial179 psF 32x, ///< x location at which to evaluate180 psF 32y ///< y location at which to evaluate176 * @return psF64 result of polynomial at given location 177 */ 178 psF64 psPolynomial2DEval( 179 const psPolynomial2D* poly, ///< Coefficients for the polynomial 180 psF64 x, ///< x location at which to evaluate 181 psF64 y ///< y location at which to evaluate 181 182 ); 182 183 183 184 /** Evaluates a 3-D polynomial at specific coordinates. 184 185 * 185 * @return psF 32result of polynomial at given location186 */ 187 psF 32psPolynomial3DEval(188 const psPolynomial3D* myPoly,///< Coefficients for the polynomial189 psF 32 x,///< x location at which to evaluate190 psF 32 y,///< y location at which to evaluate191 psF 32 z///< z location at which to evaluate186 * @return psF64 result of polynomial at given location 187 */ 188 psF64 psPolynomial3DEval( 189 const psPolynomial3D* poly, ///< Coefficients for the polynomial 190 psF64 x, ///< x location at which to evaluate 191 psF64 y, ///< y location at which to evaluate 192 psF64 z ///< z location at which to evaluate 192 193 ); 193 194 194 195 /** Evaluates a 4-D polynomial at specific coordinates. 195 196 * 196 * @return psF 32result of polynomial at given location197 */ 198 psF 32psPolynomial4DEval(199 const psPolynomial4D* myPoly,///< Coefficients for the polynomial200 psF 32 w, ///< wlocation at which to evaluate201 psF 32 x, ///< xlocation at which to evaluate202 psF 32 y, ///< ylocation at which to evaluate203 psF 32 z ///< zlocation at which to evaluate197 * @return psF64 result of polynomial at given location 198 */ 199 psF64 psPolynomial4DEval( 200 const psPolynomial4D* poly, ///< Coefficients for the polynomial 201 psF64 x, ///< x location at which to evaluate 202 psF64 y, ///< y location at which to evaluate 203 psF64 z, ///< z location at which to evaluate 204 psF64 t ///< t location at which to evaluate 204 205 ); 205 206 … … 209 210 */ 210 211 psVector *psPolynomial1DEvalVector( 211 const psPolynomial1D * myPoly,///< Coefficients for the polynomial212 const psVector *x ///< x locations at which to evaluate212 const psPolynomial1D *poly, ///< Coefficients for the polynomial 213 const psVector *x ///< x locations at which to evaluate 213 214 ); 214 215 … … 218 219 */ 219 220 psVector *psPolynomial2DEvalVector( 220 const psPolynomial2D *poly, ///< Coefficients for the polynomial221 const psVector *x, ///< x locations at which to evaluate222 const psVector *y ///< y locations at which to evaluate221 const psPolynomial2D *poly, ///< Coefficients for the polynomial 222 const psVector *x, ///< x locations at which to evaluate 223 const psVector *y ///< y locations at which to evaluate 223 224 ); 224 225 … … 228 229 */ 229 230 psVector *psPolynomial3DEvalVector( 230 const psPolynomial3D * myPoly,///< Coefficients for the polynomial231 const psVector *x, ///< x locations at which to evaluate232 const psVector *y, ///< y locations at which to evaluate233 const psVector *z ///< z locations at which to evaluate231 const psPolynomial3D *poly, ///< Coefficients for the polynomial 232 const psVector *x, ///< x locations at which to evaluate 233 const psVector *y, ///< y locations at which to evaluate 234 const psVector *z ///< z locations at which to evaluate 234 235 ); 235 236 … … 239 240 */ 240 241 psVector *psPolynomial4DEvalVector( 241 const psPolynomial4D * myPoly,///< Coefficients for the polynomial242 const psVector * w, ///< wlocations at which to evaluate243 const psVector * x, ///< xlocations at which to evaluate244 const psVector * y, ///< ylocations at which to evaluate245 const psVector * z ///< zlocations at which to evaluate242 const psPolynomial4D *poly, ///< Coefficients for the polynomial 243 const psVector *x, ///< x locations at which to evaluate 244 const psVector *y, ///< y locations at which to evaluate 245 const psVector *z, ///< z locations at which to evaluate 246 const psVector *t ///< t locations at which to evaluate 246 247 ); 247 248 … … 254 255 { 255 256 psPolynomialType type; ///< Polynomial type 256 psS32 n; ///< Number of terms257 psS32 n; ///< Number of terms 257 258 psF64 *coeff; ///< Coefficients 258 259 psF64 *coeffErr; ///< Error in coefficients … … 265 266 { 266 267 psPolynomialType type; ///< Polynomial type 267 psS32 nX; ///< Number of terms in x268 psS32 nY; ///< Number of terms in y268 psS32 nX; ///< Number of terms in x 269 psS32 nY; ///< Number of terms in y 269 270 psF64 **coeff; ///< Coefficients 270 271 psF64 **coeffErr; ///< Error in coefficients … … 277 278 { 278 279 psPolynomialType type; ///< Polynomial type 279 psS32 nX; ///< Number of terms in x280 psS32 nY; ///< Number of terms in y281 psS32 nZ; ///< Number of terms in z280 psS32 nX; ///< Number of terms in x 281 psS32 nY; ///< Number of terms in y 282 psS32 nZ; ///< Number of terms in z 282 283 psF64 ***coeff; ///< Coefficients 283 284 psF64 ***coeffErr; ///< Error in coefficients … … 290 291 { 291 292 psPolynomialType type; ///< Polynomial type 292 psS32 nW; ///< Number of terms in w293 psS32 nX; ///< Number of terms in x294 psS32 nY; ///< Number of terms in y295 psS32 nZ; ///< Number of terms in z293 psS32 nW; ///< Number of terms in w 294 psS32 nX; ///< Number of terms in x 295 psS32 nY; ///< Number of terms in y 296 psS32 nZ; ///< Number of terms in z 296 297 psF64 ****coeff; ///< Coefficients 297 298 psF64 ****coeffErr; ///< Error in coefficients … … 305 306 */ 306 307 psDPolynomial1D* psDPolynomial1DAlloc( 307 psS32 n, ///< Number of terms308 psPolynomialType type ///< Polynomial Type308 psS32 n, ///< Number of terms 309 psPolynomialType type ///< Polynomial Type 309 310 ); 310 311 … … 314 315 */ 315 316 psDPolynomial2D* psDPolynomial2DAlloc( 316 psS32 nX, ///< Number of terms in x317 psS32 nY, ///< Number of terms in y317 psS32 nX, ///< Number of terms in x 318 psS32 nY, ///< Number of terms in y 318 319 psPolynomialType type ///< Polynomial Type 319 320 ); … … 324 325 */ 325 326 psDPolynomial3D* psDPolynomial3DAlloc( 326 psS32 nX, ///< Number of terms in x327 psS32 nY, ///< Number of terms in y328 psS32 nZ, ///< Number of terms in z327 psS32 nX, ///< Number of terms in x 328 psS32 nY, ///< Number of terms in y 329 psS32 nZ, ///< Number of terms in z 329 330 psPolynomialType type ///< Polynomial Type 330 331 ); … … 335 336 */ 336 337 psDPolynomial4D* psDPolynomial4DAlloc( 337 psS32 nW, ///< Number of terms in w338 psS32 nX, ///< Number of terms in x339 psS32 nY, ///< Number of terms in y340 psS32 nZ, ///< Number of terms in z338 psS32 nW, ///< Number of terms in w 339 psS32 nX, ///< Number of terms in x 340 psS32 nY, ///< Number of terms in y 341 psS32 nZ, ///< Number of terms in z 341 342 psPolynomialType type ///< Polynomial Type 342 343 ); … … 348 349 psF64 psDPolynomial1DEval( 349 350 const psDPolynomial1D* myPoly, ///< Coefficients for the polynomial 350 psF64 x ///< Value at which to evaluate351 psF64 x ///< Value at which to evaluate 351 352 ); 352 353 … … 357 358 psF64 psDPolynomial2DEval( 358 359 const psDPolynomial2D* myPoly, ///< Coefficients for the polynomial 359 psF64 x, ///< Value x at which to evaluate360 psF64 y ///< Value y at which to evaluate360 psF64 x, ///< Value x at which to evaluate 361 psF64 y ///< Value y at which to evaluate 361 362 ); 362 363 363 364 /** Evaluates a double-precision 3-D polynomial at specific coordinates. 364 365 * 365 * @return psF 32result of polynomial at given location366 * @return psF64 result of polynomial at given location 366 367 */ 367 368 psF64 psDPolynomial3DEval( 368 369 const psDPolynomial3D* myPoly, ///< Coefficients for the polynomial 369 psF64 x, ///< Value x at which to evaluate370 psF64 y, ///< Value y at which to evaluate371 psF64 z ///< Value z at which to evaluate370 psF64 x, ///< Value x at which to evaluate 371 psF64 y, ///< Value y at which to evaluate 372 psF64 z ///< Value z at which to evaluate 372 373 ); 373 374 374 375 /** Evaluates a double-precision 4-D polynomial at specific coordinates. 375 376 * 376 * @return psF 32result of polynomial at given location377 * @return psF64 result of polynomial at given location 377 378 */ 378 379 psF64 psDPolynomial4DEval( 379 380 const psDPolynomial4D* myPoly, ///< Coefficients for the polynomial 380 psF64 w, ///< Value w at which to evaluate381 psF64 x, ///< Value x at which to evaluate382 psF64 y, ///< Value y at which to evaluate383 psF64 z ///< Value z at which to evaluate381 psF64 w, ///< Value w at which to evaluate 382 psF64 x, ///< Value x at which to evaluate 383 psF64 y, ///< Value y at which to evaluate 384 psF64 z ///< Value z at which to evaluate 384 385 ); 385 386 … … 390 391 psVector *psDPolynomial1DEvalVector( 391 392 const psDPolynomial1D *myPoly, ///< Coefficients for the polynomial 392 const psVector *x ///< x locations at which to evaluate393 const psVector *x ///< x locations at which to evaluate 393 394 ); 394 395 … … 399 400 psVector *psDPolynomial2DEvalVector( 400 401 const psDPolynomial2D *myPoly, ///< Coefficients for the polynomial 401 const psVector *x, ///< x locations at which to evaluate402 const psVector *y ///< y locations at which to evaluate402 const psVector *x, ///< x locations at which to evaluate 403 const psVector *y ///< y locations at which to evaluate 403 404 ); 404 405 … … 409 410 psVector *psDPolynomial3DEvalVector( 410 411 const psDPolynomial3D *myPoly, ///< Coefficients for the polynomial 411 const psVector *x, ///< x locations at which to evaluate412 const psVector *y, ///< y locations at which to evaluate413 const psVector *z ///< z locations at which to evaluate412 const psVector *x, ///< x locations at which to evaluate 413 const psVector *y, ///< y locations at which to evaluate 414 const psVector *z ///< z locations at which to evaluate 414 415 ); 415 416 … … 420 421 psVector *psDPolynomial4DEvalVector( 421 422 const psDPolynomial4D *myPoly, ///< Coefficients for the polynomial 422 const psVector *w, ///< w locations at which to evaluate423 const psVector *x, ///< x locations at which to evaluate424 const psVector *y, ///< y locations at which to evaluate425 const psVector *z ///< z locations at which to evaluate423 const psVector *w, ///< w locations at which to evaluate 424 const psVector *x, ///< x locations at which to evaluate 425 const psVector *y, ///< y locations at which to evaluate 426 const psVector *z ///< z locations at which to evaluate 426 427 ); 427 428 … … 429 430 typedef struct 430 431 { 431 psS32 n; ///< The number of spline polynomials432 psS32 n; ///< The number of spline polynomials 432 433 psPolynomial1D **spline; ///< An array of n pointers to the spline polynomials 433 434 psF32 *p_psDeriv2; ///< For cubic splines, the second derivative at each domain point. Size is n+1. … … 444 445 * @return psSpline1D* new 1-D spline struct 445 446 */ 446 psSpline1D *psSpline1DAlloc(int n, ///< Number of spline polynomials 447 int order, ///< Order of spline polynomials 448 float min, ///< Lower boundary value of spline polynomials 449 float max); ///< Upper boundary value of spline polynomials 447 psSpline1D *psSpline1DAlloc( 448 int n, ///< Number of spline polynomials 449 int order, ///< Order of spline polynomials 450 float min, ///< Lower boundary value of spline polynomials 451 float max ///< Upper boundary value of spline polynomials 452 ); 450 453 451 454 /** Allocates a psSpline1D structure … … 455 458 * @return psSpline1D* new 1-D spline struct 456 459 */ 457 psSpline1D *psSpline1DAllocGeneric(const psVector *bounds, ///< Bounds for spline polynomials 458 int order); ///< Order of spline polynomials 460 psSpline1D *psSpline1DAllocGeneric( 461 const psVector *bounds, ///< Bounds for spline polynomials 462 int order ///< Order of spline polynomials 463 ); 459 464 460 465 /** Evaluates 1-D spline polynomials at a specific coordinate. … … 481 486 * @return psS32 corresponding index number of specified value 482 487 */ 483 psS32 p_psVectorBinDisect(psVector *bins, ///< Array of non-decreasing values 484 psScalar *x); ///< Target value to find 488 psS32 p_psVectorBinDisect( 489 psVector *bins, ///< Array of non-decreasing values 490 psScalar *x ///< Target value to find 491 ); 485 492 486 493 /** Interpolates a series of data points for evaluation at a specific coordinate. Uses a … … 489 496 * @return psScalar* Lagrange interpolation value at given location 490 497 */ 491 psScalar *p_psVectorInterpolate(psVector *domain, ///< Domain (x coords) for interpolation 492 psVector *range, ///< Range (y coords) for interpolation 493 psS32 order, ///< Order of interpolation function 494 psScalar *x); ///< Location at which to evaluate 498 psScalar *p_psVectorInterpolate( 499 psVector *domain, ///< Domain (x coords) for interpolation 500 psVector *range, ///< Range (y coords) for interpolation 501 psS32 order, ///< Order of interpolation function 502 psScalar *x ///< Location at which to evaluate 503 ); 495 504 496 505 #if 0 -
trunk/psLib/src/math/psPolynomial.c
r4392 r4405 7 7 * polynomials. It also contains a Gaussian functions. 8 8 * 9 * @version $Revision: 1.11 1$ $Name: not supported by cvs2svn $10 * @date $Date: 2005-06-2 5 02:02:05$9 * @version $Revision: 1.112 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2005-06-28 00:53:53 $ 11 11 * 12 12 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 1232 1232 } 1233 1233 1234 psF 32 psPolynomial1DEval(const psPolynomial1D* myPoly, psF32x)1235 { 1236 PS_ASSERT_POLY_NON_NULL( myPoly, NAN);1237 1238 if ( myPoly->type == PS_POLYNOMIAL_ORD) {1239 return(ordPolynomial1DEval(x, myPoly));1240 } else if ( myPoly->type == PS_POLYNOMIAL_CHEB) {1241 return(chebPolynomial1DEval(x, myPoly));1234 psF64 psPolynomial1DEval(const psPolynomial1D* poly, psF64 x) 1235 { 1236 PS_ASSERT_POLY_NON_NULL(poly, NAN); 1237 1238 if (poly->type == PS_POLYNOMIAL_ORD) { 1239 return(ordPolynomial1DEval(x, poly)); 1240 } else if (poly->type == PS_POLYNOMIAL_CHEB) { 1241 return(chebPolynomial1DEval(x, poly)); 1242 1242 } else { 1243 1243 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 1244 1244 PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE, 1245 myPoly->type);1245 poly->type); 1246 1246 } 1247 1247 return(NAN); 1248 1248 } 1249 1249 1250 psVector *psPolynomial1DEvalVector(const psPolynomial1D * myPoly,1250 psVector *psPolynomial1DEvalVector(const psPolynomial1D *poly, 1251 1251 const psVector *x) 1252 1252 { 1253 PS_ASSERT_POLY_NON_NULL( myPoly, NULL);1253 PS_ASSERT_POLY_NON_NULL(poly, NULL); 1254 1254 PS_ASSERT_VECTOR_NON_NULL(x, NULL); 1255 1255 PS_ASSERT_VECTOR_TYPE(x, PS_TYPE_F32, NULL); … … 1259 1259 tmp = psVectorAlloc(x->n, PS_TYPE_F32); 1260 1260 for (psS32 i=0;i<x->n;i++) { 1261 tmp->data.F32[i] = psPolynomial1DEval( myPoly, x->data.F32[i]);1261 tmp->data.F32[i] = psPolynomial1DEval(poly, x->data.F32[i]); 1262 1262 } 1263 1263 … … 1265 1265 } 1266 1266 1267 psF 32 psPolynomial2DEval(const psPolynomial2D* myPoly, psF32 x, psF32y)1268 { 1269 PS_ASSERT_POLY_NON_NULL( myPoly, NAN);1270 1271 if ( myPoly->type == PS_POLYNOMIAL_ORD) {1272 return(ordPolynomial2DEval(x, y, myPoly));1273 } else if ( myPoly->type == PS_POLYNOMIAL_CHEB) {1274 return(chebPolynomial2DEval(x, y, myPoly));1267 psF64 psPolynomial2DEval(const psPolynomial2D* poly, psF64 x, psF64 y) 1268 { 1269 PS_ASSERT_POLY_NON_NULL(poly, NAN); 1270 1271 if (poly->type == PS_POLYNOMIAL_ORD) { 1272 return(ordPolynomial2DEval(x, y, poly)); 1273 } else if (poly->type == PS_POLYNOMIAL_CHEB) { 1274 return(chebPolynomial2DEval(x, y, poly)); 1275 1275 } else { 1276 1276 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 1277 1277 PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE, 1278 myPoly->type);1278 poly->type); 1279 1279 } 1280 1280 return(NAN); 1281 1281 } 1282 1282 1283 psVector *psPolynomial2DEvalVector(const psPolynomial2D * myPoly,1283 psVector *psPolynomial2DEvalVector(const psPolynomial2D *poly, 1284 1284 const psVector *x, 1285 1285 const psVector *y) 1286 1286 1287 1287 { 1288 PS_ASSERT_POLY_NON_NULL( myPoly, NULL);1288 PS_ASSERT_POLY_NON_NULL(poly, NULL); 1289 1289 PS_ASSERT_VECTOR_NON_NULL(x, NULL); 1290 1290 PS_ASSERT_VECTOR_TYPE(x, PS_TYPE_F32, NULL); … … 1305 1305 // Evaluate the polynomial at the specified points 1306 1306 for (psS32 i=0; i<vecLen; i++) { 1307 tmp->data.F32[i] = psPolynomial2DEval( myPoly,x->data.F32[i],y->data.F32[i]);1307 tmp->data.F32[i] = psPolynomial2DEval(poly,x->data.F32[i],y->data.F32[i]); 1308 1308 } 1309 1309 … … 1312 1312 } 1313 1313 1314 psF 32 psPolynomial3DEval(const psPolynomial3D* myPoly, psF32 x, psF32 y, psF32z)1315 { 1316 PS_ASSERT_POLY_NON_NULL( myPoly, NAN);1317 1318 if ( myPoly->type == PS_POLYNOMIAL_ORD) {1319 return(ordPolynomial3DEval(x, y, z, myPoly));1320 } else if ( myPoly->type == PS_POLYNOMIAL_CHEB) {1321 return(chebPolynomial3DEval(x, y, z, myPoly));1314 psF64 psPolynomial3DEval(const psPolynomial3D* poly, psF64 x, psF64 y, psF64 z) 1315 { 1316 PS_ASSERT_POLY_NON_NULL(poly, NAN); 1317 1318 if (poly->type == PS_POLYNOMIAL_ORD) { 1319 return(ordPolynomial3DEval(x, y, z, poly)); 1320 } else if (poly->type == PS_POLYNOMIAL_CHEB) { 1321 return(chebPolynomial3DEval(x, y, z, poly)); 1322 1322 } else { 1323 1323 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 1324 1324 PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE, 1325 myPoly->type);1325 poly->type); 1326 1326 } 1327 1327 return(NAN); 1328 1328 } 1329 1329 1330 psVector *psPolynomial3DEvalVector(const psPolynomial3D * myPoly,1330 psVector *psPolynomial3DEvalVector(const psPolynomial3D *poly, 1331 1331 const psVector *x, 1332 1332 const psVector *y, … … 1334 1334 1335 1335 { 1336 PS_ASSERT_POLY_NON_NULL( myPoly, NULL);1336 PS_ASSERT_POLY_NON_NULL(poly, NULL); 1337 1337 PS_ASSERT_VECTOR_NON_NULL(x, NULL); 1338 1338 PS_ASSERT_VECTOR_TYPE(x, PS_TYPE_F32, NULL); … … 1358 1358 // Evaluate polynomial 1359 1359 for (psS32 i = 0; i < vecLen; i++) { 1360 tmp->data.F32[i] = psPolynomial3DEval( myPoly,1360 tmp->data.F32[i] = psPolynomial3DEval(poly, 1361 1361 x->data.F32[i], 1362 1362 y->data.F32[i], … … 1368 1368 } 1369 1369 1370 psF 32 psPolynomial4DEval(const psPolynomial4D* myPoly, psF32 w, psF32 x, psF32 y, psF32 z)1371 { 1372 PS_ASSERT_POLY_NON_NULL( myPoly, NAN);1373 1374 if ( myPoly->type == PS_POLYNOMIAL_ORD) {1375 return(ordPolynomial4DEval( w,x,y,z, myPoly));1376 } else if ( myPoly->type == PS_POLYNOMIAL_CHEB) {1377 return(chebPolynomial4DEval( w,x,y,z, myPoly));1370 psF64 psPolynomial4DEval(const psPolynomial4D* poly, psF64 x, psF64 y, psF64 z, psF64 t) 1371 { 1372 PS_ASSERT_POLY_NON_NULL(poly, NAN); 1373 1374 if (poly->type == PS_POLYNOMIAL_ORD) { 1375 return(ordPolynomial4DEval(x,y,z,t, poly)); 1376 } else if (poly->type == PS_POLYNOMIAL_CHEB) { 1377 return(chebPolynomial4DEval(x,y,z,t, poly)); 1378 1378 } else { 1379 1379 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 1380 1380 PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE, 1381 myPoly->type);1381 poly->type); 1382 1382 } 1383 1383 return(NAN); 1384 1384 } 1385 1385 1386 psVector *psPolynomial4DEvalVector(const psPolynomial4D *myPoly, 1387 const psVector *w, 1386 psVector *psPolynomial4DEvalVector(const psPolynomial4D *poly, 1388 1387 const psVector *x, 1389 1388 const psVector *y, 1390 const psVector *z) 1391 { 1392 PS_ASSERT_POLY_NON_NULL(myPoly, NULL); 1393 PS_ASSERT_VECTOR_NON_NULL(w, NULL); 1394 PS_ASSERT_VECTOR_TYPE(w, PS_TYPE_F32, NULL); 1389 const psVector *z, 1390 const psVector *t) 1391 { 1392 PS_ASSERT_POLY_NON_NULL(poly, NULL); 1395 1393 PS_ASSERT_VECTOR_NON_NULL(x, NULL); 1396 1394 PS_ASSERT_VECTOR_TYPE(x, PS_TYPE_F32, NULL); … … 1399 1397 PS_ASSERT_VECTOR_NON_NULL(z, NULL); 1400 1398 PS_ASSERT_VECTOR_TYPE(z, PS_TYPE_F32, NULL); 1399 PS_ASSERT_VECTOR_NON_NULL(t, NULL); 1400 PS_ASSERT_VECTOR_TYPE(t, PS_TYPE_F32, NULL); 1401 1401 1402 1402 psVector *tmp; 1403 psS32 vecLen= w->n;1403 psS32 vecLen=x->n; 1404 1404 1405 1405 // Determine output vector size from min of input vectors 1406 if (z->n < vecLen) { 1407 vecLen = z->n; 1408 } 1406 1409 if (y->n < vecLen) { 1407 1410 vecLen = y->n; 1408 1411 } 1409 if (x->n < vecLen) { 1410 vecLen = x->n; 1411 } 1412 if (z->n < vecLen) { 1413 vecLen = z->n; 1412 if (t->n < vecLen) { 1413 vecLen = t->n; 1414 1414 } 1415 1415 … … 1419 1419 // Evaluate polynomial 1420 1420 for (psS32 i = 0; i < vecLen; i++) { 1421 tmp->data.F32[i] = psPolynomial4DEval(myPoly, 1422 w->data.F32[i], 1421 tmp->data.F32[i] = psPolynomial4DEval(poly, 1423 1422 x->data.F32[i], 1424 1423 y->data.F32[i], 1425 z->data.F32[i]); 1424 z->data.F32[i], 1425 t->data.F32[i]); 1426 1426 } 1427 1427 -
trunk/psLib/src/math/psPolynomial.h
r4330 r4405 12 12 * @author GLG, MHPCC 13 13 * 14 * @version $Revision: 1.4 8$ $Name: not supported by cvs2svn $15 * @date $Date: 2005-06-2 1 03:01:37$14 * @version $Revision: 1.49 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2005-06-28 00:53:53 $ 16 16 * 17 17 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 67 67 PS_POLYNOMIAL_ORD, ///< Ordinary Polynomial 68 68 PS_POLYNOMIAL_CHEB ///< Chebyshev Polynomial 69 } psPolynomialType; 69 } 70 psPolynomialType; 70 71 71 72 /** One-dimensional polynomial */ … … 73 74 { 74 75 psPolynomialType type; ///< Polynomial type 75 psS32 n; ///< Number of terms76 psS32 n; ///< Number of terms 76 77 psF32 *coeff; ///< Coefficients 77 78 psF32 *coeffErr; ///< Error in coefficients … … 84 85 { 85 86 psPolynomialType type; ///< Polynomial type 86 psS32 nX; ///< Number of terms in x87 psS32 nY; ///< Number of terms in y87 psS32 nX; ///< Number of terms in x 88 psS32 nY; ///< Number of terms in y 88 89 psF32 **coeff; ///< Coefficients 89 90 psF32 **coeffErr; ///< Error in coefficients … … 96 97 { 97 98 psPolynomialType type; ///< Polynomial type 98 psS32 nX; ///< Number of terms in x99 psS32 nY; ///< Number of terms in y100 psS32 nZ; ///< Number of terms in z99 psS32 nX; ///< Number of terms in x 100 psS32 nY; ///< Number of terms in y 101 psS32 nZ; ///< Number of terms in z 101 102 psF32 ***coeff; ///< Coefficients 102 103 psF32 ***coeffErr; ///< Error in coefficients … … 109 110 { 110 111 psPolynomialType type; ///< Polynomial type 111 psS32 nW; ///< Number of terms in w112 psS32 nX; ///< Number of terms in x113 psS32 nY; ///< Number of terms in y114 psS32 nZ; ///< Number of terms in z112 psS32 nW; ///< Number of terms in w 113 psS32 nX; ///< Number of terms in x 114 psS32 nY; ///< Number of terms in y 115 psS32 nZ; ///< Number of terms in z 115 116 psF32 ****coeff; ///< Coefficients 116 117 psF32 ****coeffErr; ///< Error in coefficients … … 125 126 */ 126 127 psPolynomial1D* psPolynomial1DAlloc( 127 psS32 n, ///< Number of terms128 psS32 n, ///< Number of terms 128 129 psPolynomialType type ///< Polynomial Type 129 130 ); … … 134 135 */ 135 136 psPolynomial2D* psPolynomial2DAlloc( 136 psS32 nX, ///< Number of terms in x137 psS32 nY, ///< Number of terms in y137 psS32 nX, ///< Number of terms in x 138 psS32 nY, ///< Number of terms in y 138 139 psPolynomialType type ///< Polynomial Type 139 140 ); … … 144 145 */ 145 146 psPolynomial3D* psPolynomial3DAlloc( 146 psS32 nX, ///< Number of terms in x147 psS32 nY, ///< Number of terms in y148 psS32 nZ, ///< Number of terms in z147 psS32 nX, ///< Number of terms in x 148 psS32 nY, ///< Number of terms in y 149 psS32 nZ, ///< Number of terms in z 149 150 psPolynomialType type ///< Polynomial Type 150 151 ); … … 155 156 */ 156 157 psPolynomial4D* psPolynomial4DAlloc( 157 psS32 nW, ///< Number of terms in w158 psS32 nX, ///< Number of terms in x159 psS32 nY, ///< Number of terms in y160 psS32 nZ, ///< Number of terms in z158 psS32 nW, ///< Number of terms in w 159 psS32 nX, ///< Number of terms in x 160 psS32 nY, ///< Number of terms in y 161 psS32 nZ, ///< Number of terms in z 161 162 psPolynomialType type ///< Polynomial Type 162 163 ); … … 164 165 /** Evaluates a 1-D polynomial at specific coordinates. 165 166 * 166 * @return psF 32result of polynomial at given location167 */ 168 psF 32psPolynomial1DEval(169 const psPolynomial1D* myPoly,///< Coefficients for the polynomial170 psF 32x ///< location at which to evaluate167 * @return psF64 result of polynomial at given location 168 */ 169 psF64 psPolynomial1DEval( 170 const psPolynomial1D* poly, ///< Coefficients for the polynomial 171 psF64 x ///< location at which to evaluate 171 172 ); 172 173 173 174 /** Evaluates a 2-D polynomial at specific coordinates. 174 175 * 175 * @return psF 32result of polynomial at given location176 */ 177 psF 32psPolynomial2DEval(178 const psPolynomial2D* myPoly,///< Coefficients for the polynomial179 psF 32x, ///< x location at which to evaluate180 psF 32y ///< y location at which to evaluate176 * @return psF64 result of polynomial at given location 177 */ 178 psF64 psPolynomial2DEval( 179 const psPolynomial2D* poly, ///< Coefficients for the polynomial 180 psF64 x, ///< x location at which to evaluate 181 psF64 y ///< y location at which to evaluate 181 182 ); 182 183 183 184 /** Evaluates a 3-D polynomial at specific coordinates. 184 185 * 185 * @return psF 32result of polynomial at given location186 */ 187 psF 32psPolynomial3DEval(188 const psPolynomial3D* myPoly,///< Coefficients for the polynomial189 psF 32 x,///< x location at which to evaluate190 psF 32 y,///< y location at which to evaluate191 psF 32 z///< z location at which to evaluate186 * @return psF64 result of polynomial at given location 187 */ 188 psF64 psPolynomial3DEval( 189 const psPolynomial3D* poly, ///< Coefficients for the polynomial 190 psF64 x, ///< x location at which to evaluate 191 psF64 y, ///< y location at which to evaluate 192 psF64 z ///< z location at which to evaluate 192 193 ); 193 194 194 195 /** Evaluates a 4-D polynomial at specific coordinates. 195 196 * 196 * @return psF 32result of polynomial at given location197 */ 198 psF 32psPolynomial4DEval(199 const psPolynomial4D* myPoly,///< Coefficients for the polynomial200 psF 32 w, ///< wlocation at which to evaluate201 psF 32 x, ///< xlocation at which to evaluate202 psF 32 y, ///< ylocation at which to evaluate203 psF 32 z ///< zlocation at which to evaluate197 * @return psF64 result of polynomial at given location 198 */ 199 psF64 psPolynomial4DEval( 200 const psPolynomial4D* poly, ///< Coefficients for the polynomial 201 psF64 x, ///< x location at which to evaluate 202 psF64 y, ///< y location at which to evaluate 203 psF64 z, ///< z location at which to evaluate 204 psF64 t ///< t location at which to evaluate 204 205 ); 205 206 … … 209 210 */ 210 211 psVector *psPolynomial1DEvalVector( 211 const psPolynomial1D * myPoly,///< Coefficients for the polynomial212 const psVector *x ///< x locations at which to evaluate212 const psPolynomial1D *poly, ///< Coefficients for the polynomial 213 const psVector *x ///< x locations at which to evaluate 213 214 ); 214 215 … … 218 219 */ 219 220 psVector *psPolynomial2DEvalVector( 220 const psPolynomial2D *poly, ///< Coefficients for the polynomial221 const psVector *x, ///< x locations at which to evaluate222 const psVector *y ///< y locations at which to evaluate221 const psPolynomial2D *poly, ///< Coefficients for the polynomial 222 const psVector *x, ///< x locations at which to evaluate 223 const psVector *y ///< y locations at which to evaluate 223 224 ); 224 225 … … 228 229 */ 229 230 psVector *psPolynomial3DEvalVector( 230 const psPolynomial3D * myPoly,///< Coefficients for the polynomial231 const psVector *x, ///< x locations at which to evaluate232 const psVector *y, ///< y locations at which to evaluate233 const psVector *z ///< z locations at which to evaluate231 const psPolynomial3D *poly, ///< Coefficients for the polynomial 232 const psVector *x, ///< x locations at which to evaluate 233 const psVector *y, ///< y locations at which to evaluate 234 const psVector *z ///< z locations at which to evaluate 234 235 ); 235 236 … … 239 240 */ 240 241 psVector *psPolynomial4DEvalVector( 241 const psPolynomial4D * myPoly,///< Coefficients for the polynomial242 const psVector * w, ///< wlocations at which to evaluate243 const psVector * x, ///< xlocations at which to evaluate244 const psVector * y, ///< ylocations at which to evaluate245 const psVector * z ///< zlocations at which to evaluate242 const psPolynomial4D *poly, ///< Coefficients for the polynomial 243 const psVector *x, ///< x locations at which to evaluate 244 const psVector *y, ///< y locations at which to evaluate 245 const psVector *z, ///< z locations at which to evaluate 246 const psVector *t ///< t locations at which to evaluate 246 247 ); 247 248 … … 254 255 { 255 256 psPolynomialType type; ///< Polynomial type 256 psS32 n; ///< Number of terms257 psS32 n; ///< Number of terms 257 258 psF64 *coeff; ///< Coefficients 258 259 psF64 *coeffErr; ///< Error in coefficients … … 265 266 { 266 267 psPolynomialType type; ///< Polynomial type 267 psS32 nX; ///< Number of terms in x268 psS32 nY; ///< Number of terms in y268 psS32 nX; ///< Number of terms in x 269 psS32 nY; ///< Number of terms in y 269 270 psF64 **coeff; ///< Coefficients 270 271 psF64 **coeffErr; ///< Error in coefficients … … 277 278 { 278 279 psPolynomialType type; ///< Polynomial type 279 psS32 nX; ///< Number of terms in x280 psS32 nY; ///< Number of terms in y281 psS32 nZ; ///< Number of terms in z280 psS32 nX; ///< Number of terms in x 281 psS32 nY; ///< Number of terms in y 282 psS32 nZ; ///< Number of terms in z 282 283 psF64 ***coeff; ///< Coefficients 283 284 psF64 ***coeffErr; ///< Error in coefficients … … 290 291 { 291 292 psPolynomialType type; ///< Polynomial type 292 psS32 nW; ///< Number of terms in w293 psS32 nX; ///< Number of terms in x294 psS32 nY; ///< Number of terms in y295 psS32 nZ; ///< Number of terms in z293 psS32 nW; ///< Number of terms in w 294 psS32 nX; ///< Number of terms in x 295 psS32 nY; ///< Number of terms in y 296 psS32 nZ; ///< Number of terms in z 296 297 psF64 ****coeff; ///< Coefficients 297 298 psF64 ****coeffErr; ///< Error in coefficients … … 305 306 */ 306 307 psDPolynomial1D* psDPolynomial1DAlloc( 307 psS32 n, ///< Number of terms308 psPolynomialType type ///< Polynomial Type308 psS32 n, ///< Number of terms 309 psPolynomialType type ///< Polynomial Type 309 310 ); 310 311 … … 314 315 */ 315 316 psDPolynomial2D* psDPolynomial2DAlloc( 316 psS32 nX, ///< Number of terms in x317 psS32 nY, ///< Number of terms in y317 psS32 nX, ///< Number of terms in x 318 psS32 nY, ///< Number of terms in y 318 319 psPolynomialType type ///< Polynomial Type 319 320 ); … … 324 325 */ 325 326 psDPolynomial3D* psDPolynomial3DAlloc( 326 psS32 nX, ///< Number of terms in x327 psS32 nY, ///< Number of terms in y328 psS32 nZ, ///< Number of terms in z327 psS32 nX, ///< Number of terms in x 328 psS32 nY, ///< Number of terms in y 329 psS32 nZ, ///< Number of terms in z 329 330 psPolynomialType type ///< Polynomial Type 330 331 ); … … 335 336 */ 336 337 psDPolynomial4D* psDPolynomial4DAlloc( 337 psS32 nW, ///< Number of terms in w338 psS32 nX, ///< Number of terms in x339 psS32 nY, ///< Number of terms in y340 psS32 nZ, ///< Number of terms in z338 psS32 nW, ///< Number of terms in w 339 psS32 nX, ///< Number of terms in x 340 psS32 nY, ///< Number of terms in y 341 psS32 nZ, ///< Number of terms in z 341 342 psPolynomialType type ///< Polynomial Type 342 343 ); … … 348 349 psF64 psDPolynomial1DEval( 349 350 const psDPolynomial1D* myPoly, ///< Coefficients for the polynomial 350 psF64 x ///< Value at which to evaluate351 psF64 x ///< Value at which to evaluate 351 352 ); 352 353 … … 357 358 psF64 psDPolynomial2DEval( 358 359 const psDPolynomial2D* myPoly, ///< Coefficients for the polynomial 359 psF64 x, ///< Value x at which to evaluate360 psF64 y ///< Value y at which to evaluate360 psF64 x, ///< Value x at which to evaluate 361 psF64 y ///< Value y at which to evaluate 361 362 ); 362 363 363 364 /** Evaluates a double-precision 3-D polynomial at specific coordinates. 364 365 * 365 * @return psF 32result of polynomial at given location366 * @return psF64 result of polynomial at given location 366 367 */ 367 368 psF64 psDPolynomial3DEval( 368 369 const psDPolynomial3D* myPoly, ///< Coefficients for the polynomial 369 psF64 x, ///< Value x at which to evaluate370 psF64 y, ///< Value y at which to evaluate371 psF64 z ///< Value z at which to evaluate370 psF64 x, ///< Value x at which to evaluate 371 psF64 y, ///< Value y at which to evaluate 372 psF64 z ///< Value z at which to evaluate 372 373 ); 373 374 374 375 /** Evaluates a double-precision 4-D polynomial at specific coordinates. 375 376 * 376 * @return psF 32result of polynomial at given location377 * @return psF64 result of polynomial at given location 377 378 */ 378 379 psF64 psDPolynomial4DEval( 379 380 const psDPolynomial4D* myPoly, ///< Coefficients for the polynomial 380 psF64 w, ///< Value w at which to evaluate381 psF64 x, ///< Value x at which to evaluate382 psF64 y, ///< Value y at which to evaluate383 psF64 z ///< Value z at which to evaluate381 psF64 w, ///< Value w at which to evaluate 382 psF64 x, ///< Value x at which to evaluate 383 psF64 y, ///< Value y at which to evaluate 384 psF64 z ///< Value z at which to evaluate 384 385 ); 385 386 … … 390 391 psVector *psDPolynomial1DEvalVector( 391 392 const psDPolynomial1D *myPoly, ///< Coefficients for the polynomial 392 const psVector *x ///< x locations at which to evaluate393 const psVector *x ///< x locations at which to evaluate 393 394 ); 394 395 … … 399 400 psVector *psDPolynomial2DEvalVector( 400 401 const psDPolynomial2D *myPoly, ///< Coefficients for the polynomial 401 const psVector *x, ///< x locations at which to evaluate402 const psVector *y ///< y locations at which to evaluate402 const psVector *x, ///< x locations at which to evaluate 403 const psVector *y ///< y locations at which to evaluate 403 404 ); 404 405 … … 409 410 psVector *psDPolynomial3DEvalVector( 410 411 const psDPolynomial3D *myPoly, ///< Coefficients for the polynomial 411 const psVector *x, ///< x locations at which to evaluate412 const psVector *y, ///< y locations at which to evaluate413 const psVector *z ///< z locations at which to evaluate412 const psVector *x, ///< x locations at which to evaluate 413 const psVector *y, ///< y locations at which to evaluate 414 const psVector *z ///< z locations at which to evaluate 414 415 ); 415 416 … … 420 421 psVector *psDPolynomial4DEvalVector( 421 422 const psDPolynomial4D *myPoly, ///< Coefficients for the polynomial 422 const psVector *w, ///< w locations at which to evaluate423 const psVector *x, ///< x locations at which to evaluate424 const psVector *y, ///< y locations at which to evaluate425 const psVector *z ///< z locations at which to evaluate423 const psVector *w, ///< w locations at which to evaluate 424 const psVector *x, ///< x locations at which to evaluate 425 const psVector *y, ///< y locations at which to evaluate 426 const psVector *z ///< z locations at which to evaluate 426 427 ); 427 428 … … 429 430 typedef struct 430 431 { 431 psS32 n; ///< The number of spline polynomials432 psS32 n; ///< The number of spline polynomials 432 433 psPolynomial1D **spline; ///< An array of n pointers to the spline polynomials 433 434 psF32 *p_psDeriv2; ///< For cubic splines, the second derivative at each domain point. Size is n+1. … … 444 445 * @return psSpline1D* new 1-D spline struct 445 446 */ 446 psSpline1D *psSpline1DAlloc(int n, ///< Number of spline polynomials 447 int order, ///< Order of spline polynomials 448 float min, ///< Lower boundary value of spline polynomials 449 float max); ///< Upper boundary value of spline polynomials 447 psSpline1D *psSpline1DAlloc( 448 int n, ///< Number of spline polynomials 449 int order, ///< Order of spline polynomials 450 float min, ///< Lower boundary value of spline polynomials 451 float max ///< Upper boundary value of spline polynomials 452 ); 450 453 451 454 /** Allocates a psSpline1D structure … … 455 458 * @return psSpline1D* new 1-D spline struct 456 459 */ 457 psSpline1D *psSpline1DAllocGeneric(const psVector *bounds, ///< Bounds for spline polynomials 458 int order); ///< Order of spline polynomials 460 psSpline1D *psSpline1DAllocGeneric( 461 const psVector *bounds, ///< Bounds for spline polynomials 462 int order ///< Order of spline polynomials 463 ); 459 464 460 465 /** Evaluates 1-D spline polynomials at a specific coordinate. … … 481 486 * @return psS32 corresponding index number of specified value 482 487 */ 483 psS32 p_psVectorBinDisect(psVector *bins, ///< Array of non-decreasing values 484 psScalar *x); ///< Target value to find 488 psS32 p_psVectorBinDisect( 489 psVector *bins, ///< Array of non-decreasing values 490 psScalar *x ///< Target value to find 491 ); 485 492 486 493 /** Interpolates a series of data points for evaluation at a specific coordinate. Uses a … … 489 496 * @return psScalar* Lagrange interpolation value at given location 490 497 */ 491 psScalar *p_psVectorInterpolate(psVector *domain, ///< Domain (x coords) for interpolation 492 psVector *range, ///< Range (y coords) for interpolation 493 psS32 order, ///< Order of interpolation function 494 psScalar *x); ///< Location at which to evaluate 498 psScalar *p_psVectorInterpolate( 499 psVector *domain, ///< Domain (x coords) for interpolation 500 psVector *range, ///< Range (y coords) for interpolation 501 psS32 order, ///< Order of interpolation function 502 psScalar *x ///< Location at which to evaluate 503 ); 495 504 496 505 #if 0 -
trunk/psLib/src/math/psSpline.c
r4392 r4405 7 7 * polynomials. It also contains a Gaussian functions. 8 8 * 9 * @version $Revision: 1.11 1$ $Name: not supported by cvs2svn $10 * @date $Date: 2005-06-2 5 02:02:05$9 * @version $Revision: 1.112 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2005-06-28 00:53:53 $ 11 11 * 12 12 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 1232 1232 } 1233 1233 1234 psF 32 psPolynomial1DEval(const psPolynomial1D* myPoly, psF32x)1235 { 1236 PS_ASSERT_POLY_NON_NULL( myPoly, NAN);1237 1238 if ( myPoly->type == PS_POLYNOMIAL_ORD) {1239 return(ordPolynomial1DEval(x, myPoly));1240 } else if ( myPoly->type == PS_POLYNOMIAL_CHEB) {1241 return(chebPolynomial1DEval(x, myPoly));1234 psF64 psPolynomial1DEval(const psPolynomial1D* poly, psF64 x) 1235 { 1236 PS_ASSERT_POLY_NON_NULL(poly, NAN); 1237 1238 if (poly->type == PS_POLYNOMIAL_ORD) { 1239 return(ordPolynomial1DEval(x, poly)); 1240 } else if (poly->type == PS_POLYNOMIAL_CHEB) { 1241 return(chebPolynomial1DEval(x, poly)); 1242 1242 } else { 1243 1243 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 1244 1244 PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE, 1245 myPoly->type);1245 poly->type); 1246 1246 } 1247 1247 return(NAN); 1248 1248 } 1249 1249 1250 psVector *psPolynomial1DEvalVector(const psPolynomial1D * myPoly,1250 psVector *psPolynomial1DEvalVector(const psPolynomial1D *poly, 1251 1251 const psVector *x) 1252 1252 { 1253 PS_ASSERT_POLY_NON_NULL( myPoly, NULL);1253 PS_ASSERT_POLY_NON_NULL(poly, NULL); 1254 1254 PS_ASSERT_VECTOR_NON_NULL(x, NULL); 1255 1255 PS_ASSERT_VECTOR_TYPE(x, PS_TYPE_F32, NULL); … … 1259 1259 tmp = psVectorAlloc(x->n, PS_TYPE_F32); 1260 1260 for (psS32 i=0;i<x->n;i++) { 1261 tmp->data.F32[i] = psPolynomial1DEval( myPoly, x->data.F32[i]);1261 tmp->data.F32[i] = psPolynomial1DEval(poly, x->data.F32[i]); 1262 1262 } 1263 1263 … … 1265 1265 } 1266 1266 1267 psF 32 psPolynomial2DEval(const psPolynomial2D* myPoly, psF32 x, psF32y)1268 { 1269 PS_ASSERT_POLY_NON_NULL( myPoly, NAN);1270 1271 if ( myPoly->type == PS_POLYNOMIAL_ORD) {1272 return(ordPolynomial2DEval(x, y, myPoly));1273 } else if ( myPoly->type == PS_POLYNOMIAL_CHEB) {1274 return(chebPolynomial2DEval(x, y, myPoly));1267 psF64 psPolynomial2DEval(const psPolynomial2D* poly, psF64 x, psF64 y) 1268 { 1269 PS_ASSERT_POLY_NON_NULL(poly, NAN); 1270 1271 if (poly->type == PS_POLYNOMIAL_ORD) { 1272 return(ordPolynomial2DEval(x, y, poly)); 1273 } else if (poly->type == PS_POLYNOMIAL_CHEB) { 1274 return(chebPolynomial2DEval(x, y, poly)); 1275 1275 } else { 1276 1276 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 1277 1277 PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE, 1278 myPoly->type);1278 poly->type); 1279 1279 } 1280 1280 return(NAN); 1281 1281 } 1282 1282 1283 psVector *psPolynomial2DEvalVector(const psPolynomial2D * myPoly,1283 psVector *psPolynomial2DEvalVector(const psPolynomial2D *poly, 1284 1284 const psVector *x, 1285 1285 const psVector *y) 1286 1286 1287 1287 { 1288 PS_ASSERT_POLY_NON_NULL( myPoly, NULL);1288 PS_ASSERT_POLY_NON_NULL(poly, NULL); 1289 1289 PS_ASSERT_VECTOR_NON_NULL(x, NULL); 1290 1290 PS_ASSERT_VECTOR_TYPE(x, PS_TYPE_F32, NULL); … … 1305 1305 // Evaluate the polynomial at the specified points 1306 1306 for (psS32 i=0; i<vecLen; i++) { 1307 tmp->data.F32[i] = psPolynomial2DEval( myPoly,x->data.F32[i],y->data.F32[i]);1307 tmp->data.F32[i] = psPolynomial2DEval(poly,x->data.F32[i],y->data.F32[i]); 1308 1308 } 1309 1309 … … 1312 1312 } 1313 1313 1314 psF 32 psPolynomial3DEval(const psPolynomial3D* myPoly, psF32 x, psF32 y, psF32z)1315 { 1316 PS_ASSERT_POLY_NON_NULL( myPoly, NAN);1317 1318 if ( myPoly->type == PS_POLYNOMIAL_ORD) {1319 return(ordPolynomial3DEval(x, y, z, myPoly));1320 } else if ( myPoly->type == PS_POLYNOMIAL_CHEB) {1321 return(chebPolynomial3DEval(x, y, z, myPoly));1314 psF64 psPolynomial3DEval(const psPolynomial3D* poly, psF64 x, psF64 y, psF64 z) 1315 { 1316 PS_ASSERT_POLY_NON_NULL(poly, NAN); 1317 1318 if (poly->type == PS_POLYNOMIAL_ORD) { 1319 return(ordPolynomial3DEval(x, y, z, poly)); 1320 } else if (poly->type == PS_POLYNOMIAL_CHEB) { 1321 return(chebPolynomial3DEval(x, y, z, poly)); 1322 1322 } else { 1323 1323 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 1324 1324 PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE, 1325 myPoly->type);1325 poly->type); 1326 1326 } 1327 1327 return(NAN); 1328 1328 } 1329 1329 1330 psVector *psPolynomial3DEvalVector(const psPolynomial3D * myPoly,1330 psVector *psPolynomial3DEvalVector(const psPolynomial3D *poly, 1331 1331 const psVector *x, 1332 1332 const psVector *y, … … 1334 1334 1335 1335 { 1336 PS_ASSERT_POLY_NON_NULL( myPoly, NULL);1336 PS_ASSERT_POLY_NON_NULL(poly, NULL); 1337 1337 PS_ASSERT_VECTOR_NON_NULL(x, NULL); 1338 1338 PS_ASSERT_VECTOR_TYPE(x, PS_TYPE_F32, NULL); … … 1358 1358 // Evaluate polynomial 1359 1359 for (psS32 i = 0; i < vecLen; i++) { 1360 tmp->data.F32[i] = psPolynomial3DEval( myPoly,1360 tmp->data.F32[i] = psPolynomial3DEval(poly, 1361 1361 x->data.F32[i], 1362 1362 y->data.F32[i], … … 1368 1368 } 1369 1369 1370 psF 32 psPolynomial4DEval(const psPolynomial4D* myPoly, psF32 w, psF32 x, psF32 y, psF32 z)1371 { 1372 PS_ASSERT_POLY_NON_NULL( myPoly, NAN);1373 1374 if ( myPoly->type == PS_POLYNOMIAL_ORD) {1375 return(ordPolynomial4DEval( w,x,y,z, myPoly));1376 } else if ( myPoly->type == PS_POLYNOMIAL_CHEB) {1377 return(chebPolynomial4DEval( w,x,y,z, myPoly));1370 psF64 psPolynomial4DEval(const psPolynomial4D* poly, psF64 x, psF64 y, psF64 z, psF64 t) 1371 { 1372 PS_ASSERT_POLY_NON_NULL(poly, NAN); 1373 1374 if (poly->type == PS_POLYNOMIAL_ORD) { 1375 return(ordPolynomial4DEval(x,y,z,t, poly)); 1376 } else if (poly->type == PS_POLYNOMIAL_CHEB) { 1377 return(chebPolynomial4DEval(x,y,z,t, poly)); 1378 1378 } else { 1379 1379 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 1380 1380 PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE, 1381 myPoly->type);1381 poly->type); 1382 1382 } 1383 1383 return(NAN); 1384 1384 } 1385 1385 1386 psVector *psPolynomial4DEvalVector(const psPolynomial4D *myPoly, 1387 const psVector *w, 1386 psVector *psPolynomial4DEvalVector(const psPolynomial4D *poly, 1388 1387 const psVector *x, 1389 1388 const psVector *y, 1390 const psVector *z) 1391 { 1392 PS_ASSERT_POLY_NON_NULL(myPoly, NULL); 1393 PS_ASSERT_VECTOR_NON_NULL(w, NULL); 1394 PS_ASSERT_VECTOR_TYPE(w, PS_TYPE_F32, NULL); 1389 const psVector *z, 1390 const psVector *t) 1391 { 1392 PS_ASSERT_POLY_NON_NULL(poly, NULL); 1395 1393 PS_ASSERT_VECTOR_NON_NULL(x, NULL); 1396 1394 PS_ASSERT_VECTOR_TYPE(x, PS_TYPE_F32, NULL); … … 1399 1397 PS_ASSERT_VECTOR_NON_NULL(z, NULL); 1400 1398 PS_ASSERT_VECTOR_TYPE(z, PS_TYPE_F32, NULL); 1399 PS_ASSERT_VECTOR_NON_NULL(t, NULL); 1400 PS_ASSERT_VECTOR_TYPE(t, PS_TYPE_F32, NULL); 1401 1401 1402 1402 psVector *tmp; 1403 psS32 vecLen= w->n;1403 psS32 vecLen=x->n; 1404 1404 1405 1405 // Determine output vector size from min of input vectors 1406 if (z->n < vecLen) { 1407 vecLen = z->n; 1408 } 1406 1409 if (y->n < vecLen) { 1407 1410 vecLen = y->n; 1408 1411 } 1409 if (x->n < vecLen) { 1410 vecLen = x->n; 1411 } 1412 if (z->n < vecLen) { 1413 vecLen = z->n; 1412 if (t->n < vecLen) { 1413 vecLen = t->n; 1414 1414 } 1415 1415 … … 1419 1419 // Evaluate polynomial 1420 1420 for (psS32 i = 0; i < vecLen; i++) { 1421 tmp->data.F32[i] = psPolynomial4DEval(myPoly, 1422 w->data.F32[i], 1421 tmp->data.F32[i] = psPolynomial4DEval(poly, 1423 1422 x->data.F32[i], 1424 1423 y->data.F32[i], 1425 z->data.F32[i]); 1424 z->data.F32[i], 1425 t->data.F32[i]); 1426 1426 } 1427 1427 -
trunk/psLib/src/math/psSpline.h
r4330 r4405 12 12 * @author GLG, MHPCC 13 13 * 14 * @version $Revision: 1.4 8$ $Name: not supported by cvs2svn $15 * @date $Date: 2005-06-2 1 03:01:37$14 * @version $Revision: 1.49 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2005-06-28 00:53:53 $ 16 16 * 17 17 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 67 67 PS_POLYNOMIAL_ORD, ///< Ordinary Polynomial 68 68 PS_POLYNOMIAL_CHEB ///< Chebyshev Polynomial 69 } psPolynomialType; 69 } 70 psPolynomialType; 70 71 71 72 /** One-dimensional polynomial */ … … 73 74 { 74 75 psPolynomialType type; ///< Polynomial type 75 psS32 n; ///< Number of terms76 psS32 n; ///< Number of terms 76 77 psF32 *coeff; ///< Coefficients 77 78 psF32 *coeffErr; ///< Error in coefficients … … 84 85 { 85 86 psPolynomialType type; ///< Polynomial type 86 psS32 nX; ///< Number of terms in x87 psS32 nY; ///< Number of terms in y87 psS32 nX; ///< Number of terms in x 88 psS32 nY; ///< Number of terms in y 88 89 psF32 **coeff; ///< Coefficients 89 90 psF32 **coeffErr; ///< Error in coefficients … … 96 97 { 97 98 psPolynomialType type; ///< Polynomial type 98 psS32 nX; ///< Number of terms in x99 psS32 nY; ///< Number of terms in y100 psS32 nZ; ///< Number of terms in z99 psS32 nX; ///< Number of terms in x 100 psS32 nY; ///< Number of terms in y 101 psS32 nZ; ///< Number of terms in z 101 102 psF32 ***coeff; ///< Coefficients 102 103 psF32 ***coeffErr; ///< Error in coefficients … … 109 110 { 110 111 psPolynomialType type; ///< Polynomial type 111 psS32 nW; ///< Number of terms in w112 psS32 nX; ///< Number of terms in x113 psS32 nY; ///< Number of terms in y114 psS32 nZ; ///< Number of terms in z112 psS32 nW; ///< Number of terms in w 113 psS32 nX; ///< Number of terms in x 114 psS32 nY; ///< Number of terms in y 115 psS32 nZ; ///< Number of terms in z 115 116 psF32 ****coeff; ///< Coefficients 116 117 psF32 ****coeffErr; ///< Error in coefficients … … 125 126 */ 126 127 psPolynomial1D* psPolynomial1DAlloc( 127 psS32 n, ///< Number of terms128 psS32 n, ///< Number of terms 128 129 psPolynomialType type ///< Polynomial Type 129 130 ); … … 134 135 */ 135 136 psPolynomial2D* psPolynomial2DAlloc( 136 psS32 nX, ///< Number of terms in x137 psS32 nY, ///< Number of terms in y137 psS32 nX, ///< Number of terms in x 138 psS32 nY, ///< Number of terms in y 138 139 psPolynomialType type ///< Polynomial Type 139 140 ); … … 144 145 */ 145 146 psPolynomial3D* psPolynomial3DAlloc( 146 psS32 nX, ///< Number of terms in x147 psS32 nY, ///< Number of terms in y148 psS32 nZ, ///< Number of terms in z147 psS32 nX, ///< Number of terms in x 148 psS32 nY, ///< Number of terms in y 149 psS32 nZ, ///< Number of terms in z 149 150 psPolynomialType type ///< Polynomial Type 150 151 ); … … 155 156 */ 156 157 psPolynomial4D* psPolynomial4DAlloc( 157 psS32 nW, ///< Number of terms in w158 psS32 nX, ///< Number of terms in x159 psS32 nY, ///< Number of terms in y160 psS32 nZ, ///< Number of terms in z158 psS32 nW, ///< Number of terms in w 159 psS32 nX, ///< Number of terms in x 160 psS32 nY, ///< Number of terms in y 161 psS32 nZ, ///< Number of terms in z 161 162 psPolynomialType type ///< Polynomial Type 162 163 ); … … 164 165 /** Evaluates a 1-D polynomial at specific coordinates. 165 166 * 166 * @return psF 32result of polynomial at given location167 */ 168 psF 32psPolynomial1DEval(169 const psPolynomial1D* myPoly,///< Coefficients for the polynomial170 psF 32x ///< location at which to evaluate167 * @return psF64 result of polynomial at given location 168 */ 169 psF64 psPolynomial1DEval( 170 const psPolynomial1D* poly, ///< Coefficients for the polynomial 171 psF64 x ///< location at which to evaluate 171 172 ); 172 173 173 174 /** Evaluates a 2-D polynomial at specific coordinates. 174 175 * 175 * @return psF 32result of polynomial at given location176 */ 177 psF 32psPolynomial2DEval(178 const psPolynomial2D* myPoly,///< Coefficients for the polynomial179 psF 32x, ///< x location at which to evaluate180 psF 32y ///< y location at which to evaluate176 * @return psF64 result of polynomial at given location 177 */ 178 psF64 psPolynomial2DEval( 179 const psPolynomial2D* poly, ///< Coefficients for the polynomial 180 psF64 x, ///< x location at which to evaluate 181 psF64 y ///< y location at which to evaluate 181 182 ); 182 183 183 184 /** Evaluates a 3-D polynomial at specific coordinates. 184 185 * 185 * @return psF 32result of polynomial at given location186 */ 187 psF 32psPolynomial3DEval(188 const psPolynomial3D* myPoly,///< Coefficients for the polynomial189 psF 32 x,///< x location at which to evaluate190 psF 32 y,///< y location at which to evaluate191 psF 32 z///< z location at which to evaluate186 * @return psF64 result of polynomial at given location 187 */ 188 psF64 psPolynomial3DEval( 189 const psPolynomial3D* poly, ///< Coefficients for the polynomial 190 psF64 x, ///< x location at which to evaluate 191 psF64 y, ///< y location at which to evaluate 192 psF64 z ///< z location at which to evaluate 192 193 ); 193 194 194 195 /** Evaluates a 4-D polynomial at specific coordinates. 195 196 * 196 * @return psF 32result of polynomial at given location197 */ 198 psF 32psPolynomial4DEval(199 const psPolynomial4D* myPoly,///< Coefficients for the polynomial200 psF 32 w, ///< wlocation at which to evaluate201 psF 32 x, ///< xlocation at which to evaluate202 psF 32 y, ///< ylocation at which to evaluate203 psF 32 z ///< zlocation at which to evaluate197 * @return psF64 result of polynomial at given location 198 */ 199 psF64 psPolynomial4DEval( 200 const psPolynomial4D* poly, ///< Coefficients for the polynomial 201 psF64 x, ///< x location at which to evaluate 202 psF64 y, ///< y location at which to evaluate 203 psF64 z, ///< z location at which to evaluate 204 psF64 t ///< t location at which to evaluate 204 205 ); 205 206 … … 209 210 */ 210 211 psVector *psPolynomial1DEvalVector( 211 const psPolynomial1D * myPoly,///< Coefficients for the polynomial212 const psVector *x ///< x locations at which to evaluate212 const psPolynomial1D *poly, ///< Coefficients for the polynomial 213 const psVector *x ///< x locations at which to evaluate 213 214 ); 214 215 … … 218 219 */ 219 220 psVector *psPolynomial2DEvalVector( 220 const psPolynomial2D *poly, ///< Coefficients for the polynomial221 const psVector *x, ///< x locations at which to evaluate222 const psVector *y ///< y locations at which to evaluate221 const psPolynomial2D *poly, ///< Coefficients for the polynomial 222 const psVector *x, ///< x locations at which to evaluate 223 const psVector *y ///< y locations at which to evaluate 223 224 ); 224 225 … … 228 229 */ 229 230 psVector *psPolynomial3DEvalVector( 230 const psPolynomial3D * myPoly,///< Coefficients for the polynomial231 const psVector *x, ///< x locations at which to evaluate232 const psVector *y, ///< y locations at which to evaluate233 const psVector *z ///< z locations at which to evaluate231 const psPolynomial3D *poly, ///< Coefficients for the polynomial 232 const psVector *x, ///< x locations at which to evaluate 233 const psVector *y, ///< y locations at which to evaluate 234 const psVector *z ///< z locations at which to evaluate 234 235 ); 235 236 … … 239 240 */ 240 241 psVector *psPolynomial4DEvalVector( 241 const psPolynomial4D * myPoly,///< Coefficients for the polynomial242 const psVector * w, ///< wlocations at which to evaluate243 const psVector * x, ///< xlocations at which to evaluate244 const psVector * y, ///< ylocations at which to evaluate245 const psVector * z ///< zlocations at which to evaluate242 const psPolynomial4D *poly, ///< Coefficients for the polynomial 243 const psVector *x, ///< x locations at which to evaluate 244 const psVector *y, ///< y locations at which to evaluate 245 const psVector *z, ///< z locations at which to evaluate 246 const psVector *t ///< t locations at which to evaluate 246 247 ); 247 248 … … 254 255 { 255 256 psPolynomialType type; ///< Polynomial type 256 psS32 n; ///< Number of terms257 psS32 n; ///< Number of terms 257 258 psF64 *coeff; ///< Coefficients 258 259 psF64 *coeffErr; ///< Error in coefficients … … 265 266 { 266 267 psPolynomialType type; ///< Polynomial type 267 psS32 nX; ///< Number of terms in x268 psS32 nY; ///< Number of terms in y268 psS32 nX; ///< Number of terms in x 269 psS32 nY; ///< Number of terms in y 269 270 psF64 **coeff; ///< Coefficients 270 271 psF64 **coeffErr; ///< Error in coefficients … … 277 278 { 278 279 psPolynomialType type; ///< Polynomial type 279 psS32 nX; ///< Number of terms in x280 psS32 nY; ///< Number of terms in y281 psS32 nZ; ///< Number of terms in z280 psS32 nX; ///< Number of terms in x 281 psS32 nY; ///< Number of terms in y 282 psS32 nZ; ///< Number of terms in z 282 283 psF64 ***coeff; ///< Coefficients 283 284 psF64 ***coeffErr; ///< Error in coefficients … … 290 291 { 291 292 psPolynomialType type; ///< Polynomial type 292 psS32 nW; ///< Number of terms in w293 psS32 nX; ///< Number of terms in x294 psS32 nY; ///< Number of terms in y295 psS32 nZ; ///< Number of terms in z293 psS32 nW; ///< Number of terms in w 294 psS32 nX; ///< Number of terms in x 295 psS32 nY; ///< Number of terms in y 296 psS32 nZ; ///< Number of terms in z 296 297 psF64 ****coeff; ///< Coefficients 297 298 psF64 ****coeffErr; ///< Error in coefficients … … 305 306 */ 306 307 psDPolynomial1D* psDPolynomial1DAlloc( 307 psS32 n, ///< Number of terms308 psPolynomialType type ///< Polynomial Type308 psS32 n, ///< Number of terms 309 psPolynomialType type ///< Polynomial Type 309 310 ); 310 311 … … 314 315 */ 315 316 psDPolynomial2D* psDPolynomial2DAlloc( 316 psS32 nX, ///< Number of terms in x317 psS32 nY, ///< Number of terms in y317 psS32 nX, ///< Number of terms in x 318 psS32 nY, ///< Number of terms in y 318 319 psPolynomialType type ///< Polynomial Type 319 320 ); … … 324 325 */ 325 326 psDPolynomial3D* psDPolynomial3DAlloc( 326 psS32 nX, ///< Number of terms in x327 psS32 nY, ///< Number of terms in y328 psS32 nZ, ///< Number of terms in z327 psS32 nX, ///< Number of terms in x 328 psS32 nY, ///< Number of terms in y 329 psS32 nZ, ///< Number of terms in z 329 330 psPolynomialType type ///< Polynomial Type 330 331 ); … … 335 336 */ 336 337 psDPolynomial4D* psDPolynomial4DAlloc( 337 psS32 nW, ///< Number of terms in w338 psS32 nX, ///< Number of terms in x339 psS32 nY, ///< Number of terms in y340 psS32 nZ, ///< Number of terms in z338 psS32 nW, ///< Number of terms in w 339 psS32 nX, ///< Number of terms in x 340 psS32 nY, ///< Number of terms in y 341 psS32 nZ, ///< Number of terms in z 341 342 psPolynomialType type ///< Polynomial Type 342 343 ); … … 348 349 psF64 psDPolynomial1DEval( 349 350 const psDPolynomial1D* myPoly, ///< Coefficients for the polynomial 350 psF64 x ///< Value at which to evaluate351 psF64 x ///< Value at which to evaluate 351 352 ); 352 353 … … 357 358 psF64 psDPolynomial2DEval( 358 359 const psDPolynomial2D* myPoly, ///< Coefficients for the polynomial 359 psF64 x, ///< Value x at which to evaluate360 psF64 y ///< Value y at which to evaluate360 psF64 x, ///< Value x at which to evaluate 361 psF64 y ///< Value y at which to evaluate 361 362 ); 362 363 363 364 /** Evaluates a double-precision 3-D polynomial at specific coordinates. 364 365 * 365 * @return psF 32result of polynomial at given location366 * @return psF64 result of polynomial at given location 366 367 */ 367 368 psF64 psDPolynomial3DEval( 368 369 const psDPolynomial3D* myPoly, ///< Coefficients for the polynomial 369 psF64 x, ///< Value x at which to evaluate370 psF64 y, ///< Value y at which to evaluate371 psF64 z ///< Value z at which to evaluate370 psF64 x, ///< Value x at which to evaluate 371 psF64 y, ///< Value y at which to evaluate 372 psF64 z ///< Value z at which to evaluate 372 373 ); 373 374 374 375 /** Evaluates a double-precision 4-D polynomial at specific coordinates. 375 376 * 376 * @return psF 32result of polynomial at given location377 * @return psF64 result of polynomial at given location 377 378 */ 378 379 psF64 psDPolynomial4DEval( 379 380 const psDPolynomial4D* myPoly, ///< Coefficients for the polynomial 380 psF64 w, ///< Value w at which to evaluate381 psF64 x, ///< Value x at which to evaluate382 psF64 y, ///< Value y at which to evaluate383 psF64 z ///< Value z at which to evaluate381 psF64 w, ///< Value w at which to evaluate 382 psF64 x, ///< Value x at which to evaluate 383 psF64 y, ///< Value y at which to evaluate 384 psF64 z ///< Value z at which to evaluate 384 385 ); 385 386 … … 390 391 psVector *psDPolynomial1DEvalVector( 391 392 const psDPolynomial1D *myPoly, ///< Coefficients for the polynomial 392 const psVector *x ///< x locations at which to evaluate393 const psVector *x ///< x locations at which to evaluate 393 394 ); 394 395 … … 399 400 psVector *psDPolynomial2DEvalVector( 400 401 const psDPolynomial2D *myPoly, ///< Coefficients for the polynomial 401 const psVector *x, ///< x locations at which to evaluate402 const psVector *y ///< y locations at which to evaluate402 const psVector *x, ///< x locations at which to evaluate 403 const psVector *y ///< y locations at which to evaluate 403 404 ); 404 405 … … 409 410 psVector *psDPolynomial3DEvalVector( 410 411 const psDPolynomial3D *myPoly, ///< Coefficients for the polynomial 411 const psVector *x, ///< x locations at which to evaluate412 const psVector *y, ///< y locations at which to evaluate413 const psVector *z ///< z locations at which to evaluate412 const psVector *x, ///< x locations at which to evaluate 413 const psVector *y, ///< y locations at which to evaluate 414 const psVector *z ///< z locations at which to evaluate 414 415 ); 415 416 … … 420 421 psVector *psDPolynomial4DEvalVector( 421 422 const psDPolynomial4D *myPoly, ///< Coefficients for the polynomial 422 const psVector *w, ///< w locations at which to evaluate423 const psVector *x, ///< x locations at which to evaluate424 const psVector *y, ///< y locations at which to evaluate425 const psVector *z ///< z locations at which to evaluate423 const psVector *w, ///< w locations at which to evaluate 424 const psVector *x, ///< x locations at which to evaluate 425 const psVector *y, ///< y locations at which to evaluate 426 const psVector *z ///< z locations at which to evaluate 426 427 ); 427 428 … … 429 430 typedef struct 430 431 { 431 psS32 n; ///< The number of spline polynomials432 psS32 n; ///< The number of spline polynomials 432 433 psPolynomial1D **spline; ///< An array of n pointers to the spline polynomials 433 434 psF32 *p_psDeriv2; ///< For cubic splines, the second derivative at each domain point. Size is n+1. … … 444 445 * @return psSpline1D* new 1-D spline struct 445 446 */ 446 psSpline1D *psSpline1DAlloc(int n, ///< Number of spline polynomials 447 int order, ///< Order of spline polynomials 448 float min, ///< Lower boundary value of spline polynomials 449 float max); ///< Upper boundary value of spline polynomials 447 psSpline1D *psSpline1DAlloc( 448 int n, ///< Number of spline polynomials 449 int order, ///< Order of spline polynomials 450 float min, ///< Lower boundary value of spline polynomials 451 float max ///< Upper boundary value of spline polynomials 452 ); 450 453 451 454 /** Allocates a psSpline1D structure … … 455 458 * @return psSpline1D* new 1-D spline struct 456 459 */ 457 psSpline1D *psSpline1DAllocGeneric(const psVector *bounds, ///< Bounds for spline polynomials 458 int order); ///< Order of spline polynomials 460 psSpline1D *psSpline1DAllocGeneric( 461 const psVector *bounds, ///< Bounds for spline polynomials 462 int order ///< Order of spline polynomials 463 ); 459 464 460 465 /** Evaluates 1-D spline polynomials at a specific coordinate. … … 481 486 * @return psS32 corresponding index number of specified value 482 487 */ 483 psS32 p_psVectorBinDisect(psVector *bins, ///< Array of non-decreasing values 484 psScalar *x); ///< Target value to find 488 psS32 p_psVectorBinDisect( 489 psVector *bins, ///< Array of non-decreasing values 490 psScalar *x ///< Target value to find 491 ); 485 492 486 493 /** Interpolates a series of data points for evaluation at a specific coordinate. Uses a … … 489 496 * @return psScalar* Lagrange interpolation value at given location 490 497 */ 491 psScalar *p_psVectorInterpolate(psVector *domain, ///< Domain (x coords) for interpolation 492 psVector *range, ///< Range (y coords) for interpolation 493 psS32 order, ///< Order of interpolation function 494 psScalar *x); ///< Location at which to evaluate 498 psScalar *p_psVectorInterpolate( 499 psVector *domain, ///< Domain (x coords) for interpolation 500 psVector *range, ///< Range (y coords) for interpolation 501 psS32 order, ///< Order of interpolation function 502 psScalar *x ///< Location at which to evaluate 503 ); 495 504 496 505 #if 0 -
trunk/psLib/test/dataManip/verified/tst_psFunc08.stderr
r3379 r4405 34 34 Following should generate an error message for NULL polynomial 35 35 <DATE><TIME>|<HOST>|E|psPolynomial1DEvalVector (FILE:LINENO) 36 Unallowable operation: polynomial myPoly or its coeffs is NULL.36 Unallowable operation: polynomial poly or its coeffs is NULL. 37 37 <DATE><TIME>|<HOST>|I|testPoly1DEvalVector 38 38 Following should generate an error message for NULL input vector -
trunk/psLib/test/dataManip/verified/tst_psFunc09.stderr
r3385 r4405 34 34 Following should generate an error message for NULL polynomial 35 35 <DATE><TIME>|<HOST>|E|psPolynomial2DEvalVector (FILE:LINENO) 36 Unallowable operation: polynomial myPoly or its coeffs is NULL.36 Unallowable operation: polynomial poly or its coeffs is NULL. 37 37 <DATE><TIME>|<HOST>|I|testPoly2DEvalVector 38 38 Following should generate an error message for NULL input vector -
trunk/psLib/test/dataManip/verified/tst_psFunc10.stderr
r3398 r4405 34 34 Following should generate an error message for NULL polynomial 35 35 <DATE><TIME>|<HOST>|E|psPolynomial3DEvalVector (FILE:LINENO) 36 Unallowable operation: polynomial myPoly or its coeffs is NULL.36 Unallowable operation: polynomial poly or its coeffs is NULL. 37 37 <DATE><TIME>|<HOST>|I|testPoly3DEvalVector 38 38 Following should generate an error message for NULL input vector -
trunk/psLib/test/dataManip/verified/tst_psFunc11.stderr
r3406 r4405 34 34 Following should generate an error message for NULL polynomial 35 35 <DATE><TIME>|<HOST>|E|psPolynomial4DEvalVector (FILE:LINENO) 36 Unallowable operation: polynomial myPoly or its coeffs is NULL. 37 <DATE><TIME>|<HOST>|I|testPoly4DEvalVector 38 Following should generate an error message for NULL input vector 39 <DATE><TIME>|<HOST>|E|psPolynomial4DEvalVector (FILE:LINENO) 40 Unallowable operation: psVector w or its data is NULL. 36 Unallowable operation: polynomial poly or its coeffs is NULL. 41 37 <DATE><TIME>|<HOST>|I|testPoly4DEvalVector 42 38 Following should generate an error message for NULL input vector … … 52 48 Unallowable operation: psVector z or its data is NULL. 53 49 <DATE><TIME>|<HOST>|I|testPoly4DEvalVector 54 Following should generate an error message for invalid input type50 Following should generate an error message for NULL input vector 55 51 <DATE><TIME>|<HOST>|E|psPolynomial4DEvalVector (FILE:LINENO) 56 Unallowable operation: psVector x has incorrect type.52 Unallowable operation: psVector t or its data is NULL. 57 53 <DATE><TIME>|<HOST>|I|testPoly4DEvalVector 58 54 Following should generate an error message for invalid input type … … 66 62 Following should generate an error message for invalid input type 67 63 <DATE><TIME>|<HOST>|E|psPolynomial4DEvalVector (FILE:LINENO) 68 Unallowable operation: psVector w has incorrect type. 64 Unallowable operation: psVector t has incorrect type. 65 <DATE><TIME>|<HOST>|I|testPoly4DEvalVector 66 Following should generate an error message for invalid input type 67 <DATE><TIME>|<HOST>|E|psPolynomial4DEvalVector (FILE:LINENO) 68 Unallowable operation: psVector x has incorrect type. 69 69 70 70 ---> TESTPOINT PASSED (psPolynomialXDEval{psPolynomial4DEvalVector} | tst_psFunc11.c)
Note:
See TracChangeset
for help on using the changeset viewer.
