Changeset 2342 for trunk/psLib/src/math/psStats.c
- Timestamp:
- Nov 12, 2004, 9:36:07 AM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/math/psStats.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
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.
