Changeset 2342
- Timestamp:
- Nov 12, 2004, 9:36:07 AM (22 years ago)
- Location:
- trunk/psLib/src
- Files:
-
- 4 edited
-
dataManip/psConstants.h (modified) (2 diffs)
-
dataManip/psStats.c (modified) (6 diffs)
-
math/psConstants.h (modified) (2 diffs)
-
math/psStats.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/dataManip/psConstants.h
r2304 r2342 6 6 * @author GLG, MHPCC 7 7 * 8 * @version $Revision: 1.3 8$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-11- 09 00:41:35$8 * @version $Revision: 1.39 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-11-12 19:36:07 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 298 298 } \ 299 299 300 // The following macros declare and allocate a static polynomial of the 301 // specified order and type. 302 303 #define PS_POLY_1D_DECLARE_ALLOC_STATIC(NAME, ORDER, TYPE) \ 304 static psPolynomial1D *NAME = NULL; \ 305 if (NAME == NULL) { \ 306 NAME = psPolynomial1DAlloc(ORDER, TYPE); \ 307 p_psMemSetPersistent(NAME, true); \ 308 } \ 309 310 #define PS_POLY_2D_DECLARE_ALLOC_STATIC(NAME, ORDER, TYPE) \ 311 static psPolynomial2D *NAME = NULL; \ 312 if (NAME == NULL) { \ 313 NAME = psPolynomial2DAlloc(ORDER, TYPE); \ 314 p_psMemSetPersistent(NAME, true); \ 315 } \ 316 317 #define PS_POLY_3D_DECLARE_ALLOC_STATIC(NAME, ORDER, TYPE) \ 318 static psPolynomial3D *NAME = NULL; \ 319 if (NAME == NULL) { \ 320 NAME = psPolynomial3DAlloc(ORDER, TYPE); \ 321 p_psMemSetPersistent(NAME, true); \ 322 } \ 323 324 #define PS_POLY_4D_DECLARE_ALLOC_STATIC(NAME, ORDER, TYPE) \ 325 static psPolynomial4D *NAME = NULL; \ 326 if (NAME == NULL) { \ 327 NAME = psPolynomial4DAlloc(ORDER, TYPE); \ 328 p_psMemSetPersistent(NAME, true); \ 329 } \ 330 331 #define PS_POLY_1D_D_DECLARE_ALLOC_STATIC(NAME, ORDER, TYPE) \ 332 static psPolynomial1D *NAME = NULL; \ 333 if (NAME == NULL) { \ 334 NAME = psPolynomial1DAlloc(ORDER, TYPE); \ 335 p_psMemSetPersistent(NAME, true); \ 336 } \ 337 338 #define PS_POLY_2D_D_DECLARE_ALLOC_STATIC(NAME, ORDER, TYPE) \ 339 static psPolynomial2D *NAME = NULL; \ 340 if (NAME == NULL) { \ 341 NAME = psPolynomial2DAlloc(ORDER, TYPE); \ 342 p_psMemSetPersistent(NAME, true); \ 343 } \ 344 345 #define PS_POLY_3D_D_DECLARE_ALLOC_STATIC(NAME, ORDER, TYPE) \ 346 static psPolynomial3D *NAME = NULL; \ 347 if (NAME == NULL) { \ 348 NAME = psPolynomial3DAlloc(ORDER, TYPE); \ 349 p_psMemSetPersistent(NAME, true); \ 350 } \ 351 352 #define PS_POLY_4D_D_DECLARE_ALLOC_STATIC(NAME, ORDER, TYPE) \ 353 static psPolynomial4D *NAME = NULL; \ 354 if (NAME == NULL) { \ 355 NAME = psPolynomial4DAlloc(ORDER, TYPE); \ 356 p_psMemSetPersistent(NAME, true); \ 357 } \ 358 300 359 /***************************************************************************** 301 360 PS_IMAGE macros: -
trunk/psLib/src/dataManip/psStats.c
r2341 r2342 9 9 * @author GLG, MHPCC 10 10 * 11 * @version $Revision: 1.9 2$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-11-12 19: 29:39$11 * @version $Revision: 1.93 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-11-12 19:36:07 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 925 925 926 926 XXX: Should we make the arguments psScalars? 927 928 XXX: Should we make the arguments PS_TYPE_F64? 927 929 *****************************************************************************/ 928 930 #define PS_FUNC_MACRO_NORMALIZE_VECTOR_RANGE(TYPE) \ … … 983 985 XXX: Terminate when f(x)-getThisValue is within some error tolerance. 984 986 985 XXX: Solve for X analytically.987 XXX: Create a 2nd-order polynomial version and solve for X analytically. 986 988 *****************************************************************************/ 987 989 float p_ps1DPolyMedian(psPolynomial1D* myPoly, … … 1020 1022 1021 1023 /****************************************************************************** 1022 fitQuadraticSearchForYThenReturnX(*xVec, *yVec, binNum, yVal): This routine 1023 takes psVectors of x/y pairs as input, and fits a quadratic to the 3 points 1024 surrounding element binNum in the vectors (the midpoint between element i 1025 and i+1 is used for x[i]). It then determines for what value x does that 1026 quadratic f(x) = yVal (the input parameter). 1024 fitQuadraticSearchForYThenReturnX(*xVec, *yVec, binNum, yVal): A general 1025 routine which fits a quadratic to three points and returns the x-value 1026 corresponding to the input y-value. This routine takes psVectors of x/y pairs 1027 as input, and fits a quadratic to the 3 points surrounding element binNum in 1028 the vectors (the midpoint between element i and i+1 is used for x[i]). It 1029 then determines for what value x does that quadratic f(x) = yVal (the input 1030 parameter). 1027 1031 1028 1032 XXX: After you fit the polynomial, solve for X analytically. … … 1035 1039 float yVal) 1036 1040 { 1041 PS_VECTOR_CHECK_NULL(xVec, NAN); 1042 PS_VECTOR_CHECK_NULL(yVec, NAN); 1043 PS_VECTOR_CHECK_TYPE(xVec, PS_TYPE_F64, NAN); 1044 PS_VECTOR_CHECK_TYPE(yVec, PS_TYPE_F64, NAN); 1045 PS_VECTOR_CHECK_SIZE_EQUAL(xVec, yVec, NAN); 1046 PS_INT_CHECK_RANGE(binNum, 0, (xVec->n - 1), NAN); 1047 1037 1048 PS_VECTOR_DECLARE_ALLOC_STATIC(x, 3, PS_TYPE_F64); 1038 1049 PS_VECTOR_DECLARE_ALLOC_STATIC(y, 3, PS_TYPE_F64); 1039 1050 PS_VECTOR_DECLARE_ALLOC_STATIC(yErr, 3, PS_TYPE_F64); 1040 static psPolynomial1D* myPoly = NULL; 1041 1042 if (myPoly == NULL) { 1043 myPoly = psPolynomial1DAlloc(2, PS_POLYNOMIAL_ORD); 1044 p_psMemSetPersistent(myPoly, true); 1045 } 1051 PS_POLY_1D_DECLARE_ALLOC_STATIC(myPoly, 2, PS_POLYNOMIAL_ORD); 1046 1052 float tmpFloat; 1047 1053 1048 1054 if ((binNum > 0) && (binNum < (yVec->n - 2))) { 1055 // The general case. We have all three points. 1049 1056 x->data.F64[0] = (double) (0.5 * (xVec->data.F32[binNum - 1] + xVec->data.F32[binNum])); 1050 1057 x->data.F64[1] = (double) (0.5 * (xVec->data.F32[binNum] + xVec->data.F32[binNum+1])); … … 1070 1077 tmpFloat = p_ps1DPolyMedian(myPoly, x->data.F64[0], x->data.F64[2], yVal); 1071 1078 } else { 1079 // The special case where we have two points only at the beginning of 1080 // the vectors x and y. 1072 1081 if (binNum == 0) { 1073 1082 tmpFloat = 0.5 * (xVec->data.F32[binNum] + 1074 1083 xVec->data.F32[binNum + 1]); 1075 1084 } else if (binNum == (xVec->n - 1)) { 1085 // The special case where we have two points only at the end of 1086 // the vectors x and y. 1076 1087 // XXX: Is this right? 1077 1088 tmpFloat = xVec->data.F32[binNum]; -
trunk/psLib/src/math/psConstants.h
r2304 r2342 6 6 * @author GLG, MHPCC 7 7 * 8 * @version $Revision: 1.3 8$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-11- 09 00:41:35$8 * @version $Revision: 1.39 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-11-12 19:36:07 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 298 298 } \ 299 299 300 // The following macros declare and allocate a static polynomial of the 301 // specified order and type. 302 303 #define PS_POLY_1D_DECLARE_ALLOC_STATIC(NAME, ORDER, TYPE) \ 304 static psPolynomial1D *NAME = NULL; \ 305 if (NAME == NULL) { \ 306 NAME = psPolynomial1DAlloc(ORDER, TYPE); \ 307 p_psMemSetPersistent(NAME, true); \ 308 } \ 309 310 #define PS_POLY_2D_DECLARE_ALLOC_STATIC(NAME, ORDER, TYPE) \ 311 static psPolynomial2D *NAME = NULL; \ 312 if (NAME == NULL) { \ 313 NAME = psPolynomial2DAlloc(ORDER, TYPE); \ 314 p_psMemSetPersistent(NAME, true); \ 315 } \ 316 317 #define PS_POLY_3D_DECLARE_ALLOC_STATIC(NAME, ORDER, TYPE) \ 318 static psPolynomial3D *NAME = NULL; \ 319 if (NAME == NULL) { \ 320 NAME = psPolynomial3DAlloc(ORDER, TYPE); \ 321 p_psMemSetPersistent(NAME, true); \ 322 } \ 323 324 #define PS_POLY_4D_DECLARE_ALLOC_STATIC(NAME, ORDER, TYPE) \ 325 static psPolynomial4D *NAME = NULL; \ 326 if (NAME == NULL) { \ 327 NAME = psPolynomial4DAlloc(ORDER, TYPE); \ 328 p_psMemSetPersistent(NAME, true); \ 329 } \ 330 331 #define PS_POLY_1D_D_DECLARE_ALLOC_STATIC(NAME, ORDER, TYPE) \ 332 static psPolynomial1D *NAME = NULL; \ 333 if (NAME == NULL) { \ 334 NAME = psPolynomial1DAlloc(ORDER, TYPE); \ 335 p_psMemSetPersistent(NAME, true); \ 336 } \ 337 338 #define PS_POLY_2D_D_DECLARE_ALLOC_STATIC(NAME, ORDER, TYPE) \ 339 static psPolynomial2D *NAME = NULL; \ 340 if (NAME == NULL) { \ 341 NAME = psPolynomial2DAlloc(ORDER, TYPE); \ 342 p_psMemSetPersistent(NAME, true); \ 343 } \ 344 345 #define PS_POLY_3D_D_DECLARE_ALLOC_STATIC(NAME, ORDER, TYPE) \ 346 static psPolynomial3D *NAME = NULL; \ 347 if (NAME == NULL) { \ 348 NAME = psPolynomial3DAlloc(ORDER, TYPE); \ 349 p_psMemSetPersistent(NAME, true); \ 350 } \ 351 352 #define PS_POLY_4D_D_DECLARE_ALLOC_STATIC(NAME, ORDER, TYPE) \ 353 static psPolynomial4D *NAME = NULL; \ 354 if (NAME == NULL) { \ 355 NAME = psPolynomial4DAlloc(ORDER, TYPE); \ 356 p_psMemSetPersistent(NAME, true); \ 357 } \ 358 300 359 /***************************************************************************** 301 360 PS_IMAGE macros: -
trunk/psLib/src/math/psStats.c
r2341 r2342 9 9 * @author GLG, MHPCC 10 10 * 11 * @version $Revision: 1.9 2$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-11-12 19: 29:39$11 * @version $Revision: 1.93 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-11-12 19:36:07 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 925 925 926 926 XXX: Should we make the arguments psScalars? 927 928 XXX: Should we make the arguments PS_TYPE_F64? 927 929 *****************************************************************************/ 928 930 #define PS_FUNC_MACRO_NORMALIZE_VECTOR_RANGE(TYPE) \ … … 983 985 XXX: Terminate when f(x)-getThisValue is within some error tolerance. 984 986 985 XXX: Solve for X analytically.987 XXX: Create a 2nd-order polynomial version and solve for X analytically. 986 988 *****************************************************************************/ 987 989 float p_ps1DPolyMedian(psPolynomial1D* myPoly, … … 1020 1022 1021 1023 /****************************************************************************** 1022 fitQuadraticSearchForYThenReturnX(*xVec, *yVec, binNum, yVal): This routine 1023 takes psVectors of x/y pairs as input, and fits a quadratic to the 3 points 1024 surrounding element binNum in the vectors (the midpoint between element i 1025 and i+1 is used for x[i]). It then determines for what value x does that 1026 quadratic f(x) = yVal (the input parameter). 1024 fitQuadraticSearchForYThenReturnX(*xVec, *yVec, binNum, yVal): A general 1025 routine which fits a quadratic to three points and returns the x-value 1026 corresponding to the input y-value. This routine takes psVectors of x/y pairs 1027 as input, and fits a quadratic to the 3 points surrounding element binNum in 1028 the vectors (the midpoint between element i and i+1 is used for x[i]). It 1029 then determines for what value x does that quadratic f(x) = yVal (the input 1030 parameter). 1027 1031 1028 1032 XXX: After you fit the polynomial, solve for X analytically. … … 1035 1039 float yVal) 1036 1040 { 1041 PS_VECTOR_CHECK_NULL(xVec, NAN); 1042 PS_VECTOR_CHECK_NULL(yVec, NAN); 1043 PS_VECTOR_CHECK_TYPE(xVec, PS_TYPE_F64, NAN); 1044 PS_VECTOR_CHECK_TYPE(yVec, PS_TYPE_F64, NAN); 1045 PS_VECTOR_CHECK_SIZE_EQUAL(xVec, yVec, NAN); 1046 PS_INT_CHECK_RANGE(binNum, 0, (xVec->n - 1), NAN); 1047 1037 1048 PS_VECTOR_DECLARE_ALLOC_STATIC(x, 3, PS_TYPE_F64); 1038 1049 PS_VECTOR_DECLARE_ALLOC_STATIC(y, 3, PS_TYPE_F64); 1039 1050 PS_VECTOR_DECLARE_ALLOC_STATIC(yErr, 3, PS_TYPE_F64); 1040 static psPolynomial1D* myPoly = NULL; 1041 1042 if (myPoly == NULL) { 1043 myPoly = psPolynomial1DAlloc(2, PS_POLYNOMIAL_ORD); 1044 p_psMemSetPersistent(myPoly, true); 1045 } 1051 PS_POLY_1D_DECLARE_ALLOC_STATIC(myPoly, 2, PS_POLYNOMIAL_ORD); 1046 1052 float tmpFloat; 1047 1053 1048 1054 if ((binNum > 0) && (binNum < (yVec->n - 2))) { 1055 // The general case. We have all three points. 1049 1056 x->data.F64[0] = (double) (0.5 * (xVec->data.F32[binNum - 1] + xVec->data.F32[binNum])); 1050 1057 x->data.F64[1] = (double) (0.5 * (xVec->data.F32[binNum] + xVec->data.F32[binNum+1])); … … 1070 1077 tmpFloat = p_ps1DPolyMedian(myPoly, x->data.F64[0], x->data.F64[2], yVal); 1071 1078 } else { 1079 // The special case where we have two points only at the beginning of 1080 // the vectors x and y. 1072 1081 if (binNum == 0) { 1073 1082 tmpFloat = 0.5 * (xVec->data.F32[binNum] + 1074 1083 xVec->data.F32[binNum + 1]); 1075 1084 } else if (binNum == (xVec->n - 1)) { 1085 // The special case where we have two points only at the end of 1086 // the vectors x and y. 1076 1087 // XXX: Is this right? 1077 1088 tmpFloat = xVec->data.F32[binNum];
Note:
See TracChangeset
for help on using the changeset viewer.
