Changeset 674
- Timestamp:
- May 13, 2004, 1:53:59 PM (22 years ago)
- Location:
- trunk/psLib/src
- Files:
-
- 3 edited
-
dataManip/Makefile (modified) (1 diff)
-
dataManip/psStats.c (modified) (13 diffs)
-
math/psStats.c (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/dataManip/Makefile
r666 r674 12 12 %.o: %.c 13 13 @echo " Compiling $<. " 14 $(CC) $(CFLAGS) -I../sysUtils -I../collections - c $< -o $@14 $(CC) $(CFLAGS) -I../sysUtils -I../collections -I.. -c $< -o $@ 15 15 16 16 libpslib.a: $(SRC_OBJS) -
trunk/psLib/src/dataManip/psStats.c
r660 r674 5 5 /****************************************************************************** 6 6 //#include "pslib.h" 7 //#include "psMemory.h" 7 #include "psMemory.h" 8 #include "psVector.h" 8 9 //#include "psTrace.h" 9 10 //#include "psString.h" … … 63 64 psHistogram *newHist = NULL; 64 65 int numBins = 0; 65 psType dummyFloatType; 66 psType dummyIntType; 67 68 dummyFloatType.type = PS_TYPE_FLOAT; 69 dummyFloatType.dimen = PS_DIMEN_VECTOR; 70 dummyIntType.type = PS_TYPE_FLOAT; 71 dummyIntType.dimen = PS_DIMEN_VECTOR; 66 72 67 73 68 numBins = 1 + ((upper - lower) / size); 74 69 newHist = (psHistogram *) psAlloc(sizeof(psHistogram)); 75 newHist->lower = psVectorAlloc( dummyFloatType, numBins);76 newHist->upper = psVectorAlloc( dummyFloatType, numBins);77 newHist->nums = psVectorAlloc( dummyIntType, numBins);70 newHist->lower = psVectorAlloc(PS_TYPE_FLOAT, numBins); 71 newHist->upper = psVectorAlloc(PS_TYPE_FLOAT, numBins); 72 newHist->nums = psVectorAlloc(PS_TYPE_INT32, numBins); 78 73 newHist->minVal = lower; 79 74 newHist->maxVal = upper; … … 92 87 int numBins = 0; 93 88 int i; 94 psType dummyFloatType;95 psType dummyIntType;96 97 dummyFloatType.type = PS_TYPE_FLOAT;98 dummyFloatType.dimen = PS_DIMEN_VECTOR;99 dummyIntType.type = PS_TYPE_FLOAT;100 dummyIntType.dimen = PS_DIMEN_VECTOR;101 89 102 90 if (lower->n != upper->n) { … … 105 93 numBins = lower->n; 106 94 newHist = (psHistogram *) psAlloc(sizeof(psHistogram)); 107 newHist->lower = psVectorAlloc( dummyFloatType, numBins);108 newHist->upper = psVectorAlloc( dummyFloatType, numBins);95 newHist->lower = psVectorAlloc(PS_TYPE_FLOAT, numBins); 96 newHist->upper = psVectorAlloc(PS_TYPE_FLOAT, numBins); 109 97 for (i=0;i<numBins;i++) { 110 98 newHist->lower->vec.f[i] = lower->vec.f[i]; 111 99 newHist->upper->vec.f[i] = upper->vec.f[i]; 112 100 } 113 newHist->nums = psVectorAlloc( dummyIntType, numBins);101 newHist->nums = psVectorAlloc(PS_TYPE_INT32, numBins); 114 102 newHist->minVal = minVal; 115 103 newHist->maxVal = maxVal; … … 156 144 if ((myVector->vec.f[i] >= myHist->lower->vec.f[i]) && 157 145 (myVector->vec.f[i] <= myHist->upper->vec.f[i])) { 158 myHist->nums->vec.i [i]++;146 myHist->nums->vec.i32[i]++; 159 147 } else { 160 148 psError(__func__, "data value was not within the bounds of the bin it should habe been in."); … … 178 166 if (maskVector != NULL) { 179 167 for (i=0;i<myVector->n;i++) { 180 if (!(maskVal & maskVector->vec.i [i])) {168 if (!(maskVal & maskVector->vec.i32[i])) { 181 169 mean+= myVector->vec.f[i]; 182 170 count++; … … 203 191 if (maskVector != NULL) { 204 192 for (i=0;i<myVector->n;i++) { 205 if (!(maskVal & maskVector->vec.i [i])) {193 if (!(maskVal & maskVector->vec.i32[i])) { 206 194 if (myVector->vec.f[i] > max) { 207 max = maskVector->vec.i [i];195 max = maskVector->vec.i32[i]; 208 196 } 209 197 } … … 212 200 for (i=0;i<myVector->n;i++) { 213 201 if (myVector->vec.f[i] > max) { 214 max = maskVector->vec.i [i];202 max = maskVector->vec.i32[i]; 215 203 } 216 204 } … … 228 216 if (maskVector != NULL) { 229 217 for (i=0;i<myVector->n;i++) { 230 if (!(maskVal & maskVector->vec.i [i])) {218 if (!(maskVal & maskVector->vec.i32[i])) { 231 219 if (myVector->vec.f[i] < min) { 232 min = maskVector->vec.i [i];220 min = maskVector->vec.i32[i]; 233 221 } 234 222 } … … 237 225 for (i=0;i<myVector->n;i++) { 238 226 if (myVector->vec.f[i] < min) { 239 min = maskVector->vec.i [i];227 min = maskVector->vec.i32[i]; 240 228 } 241 229 } … … 256 244 if (maskVector != NULL) { 257 245 for (i=0;i<myVector->n;i++) { 258 if (!(maskVal & maskVector->vec.i [i])) {246 if (!(maskVal & maskVector->vec.i32[i])) { 259 247 numData++; 260 248 } … … 275 263 psVector *unsortedVector = NULL; 276 264 psVector *sortedVector = NULL; 277 psType dummyFloatType;278 265 int dataSize = 0; 279 266 int count = 0; … … 281 268 float median = 0.0; 282 269 283 dummyFloatType.type = PS_TYPE_FLOAT;284 dummyFloatType.dimen = PS_DIMEN_VECTOR;285 270 dataSize = p_psArrayNValues(myVector, maskVector, maskVal); 286 271 287 272 if (dataSize < MEDIAN_SIZE_THRESHOLD) { 288 unsortedVector = psVectorAlloc( dummyFloatType, dataSize);289 sortedVector = psVectorAlloc( dummyFloatType, dataSize);273 unsortedVector = psVectorAlloc(PS_TYPE_FLOAT, dataSize); 274 sortedVector = psVectorAlloc(PS_TYPE_FLOAT, dataSize); 290 275 291 276 count = 0; 292 277 if (maskVector != NULL) { 293 278 for (i=0;i<myVector->n;i++) { 294 if (!(maskVal & maskVector->vec.i [i])) {279 if (!(maskVal & maskVector->vec.i32[i])) { 295 280 unsortedVector->vec.f[count++] = maskVector->vec.f[i]; 296 281 } -
trunk/psLib/src/math/psStats.c
r660 r674 5 5 /****************************************************************************** 6 6 //#include "pslib.h" 7 //#include "psMemory.h" 7 #include "psMemory.h" 8 #include "psVector.h" 8 9 //#include "psTrace.h" 9 10 //#include "psString.h" … … 63 64 psHistogram *newHist = NULL; 64 65 int numBins = 0; 65 psType dummyFloatType; 66 psType dummyIntType; 67 68 dummyFloatType.type = PS_TYPE_FLOAT; 69 dummyFloatType.dimen = PS_DIMEN_VECTOR; 70 dummyIntType.type = PS_TYPE_FLOAT; 71 dummyIntType.dimen = PS_DIMEN_VECTOR; 66 72 67 73 68 numBins = 1 + ((upper - lower) / size); 74 69 newHist = (psHistogram *) psAlloc(sizeof(psHistogram)); 75 newHist->lower = psVectorAlloc( dummyFloatType, numBins);76 newHist->upper = psVectorAlloc( dummyFloatType, numBins);77 newHist->nums = psVectorAlloc( dummyIntType, numBins);70 newHist->lower = psVectorAlloc(PS_TYPE_FLOAT, numBins); 71 newHist->upper = psVectorAlloc(PS_TYPE_FLOAT, numBins); 72 newHist->nums = psVectorAlloc(PS_TYPE_INT32, numBins); 78 73 newHist->minVal = lower; 79 74 newHist->maxVal = upper; … … 92 87 int numBins = 0; 93 88 int i; 94 psType dummyFloatType;95 psType dummyIntType;96 97 dummyFloatType.type = PS_TYPE_FLOAT;98 dummyFloatType.dimen = PS_DIMEN_VECTOR;99 dummyIntType.type = PS_TYPE_FLOAT;100 dummyIntType.dimen = PS_DIMEN_VECTOR;101 89 102 90 if (lower->n != upper->n) { … … 105 93 numBins = lower->n; 106 94 newHist = (psHistogram *) psAlloc(sizeof(psHistogram)); 107 newHist->lower = psVectorAlloc( dummyFloatType, numBins);108 newHist->upper = psVectorAlloc( dummyFloatType, numBins);95 newHist->lower = psVectorAlloc(PS_TYPE_FLOAT, numBins); 96 newHist->upper = psVectorAlloc(PS_TYPE_FLOAT, numBins); 109 97 for (i=0;i<numBins;i++) { 110 98 newHist->lower->vec.f[i] = lower->vec.f[i]; 111 99 newHist->upper->vec.f[i] = upper->vec.f[i]; 112 100 } 113 newHist->nums = psVectorAlloc( dummyIntType, numBins);101 newHist->nums = psVectorAlloc(PS_TYPE_INT32, numBins); 114 102 newHist->minVal = minVal; 115 103 newHist->maxVal = maxVal; … … 156 144 if ((myVector->vec.f[i] >= myHist->lower->vec.f[i]) && 157 145 (myVector->vec.f[i] <= myHist->upper->vec.f[i])) { 158 myHist->nums->vec.i [i]++;146 myHist->nums->vec.i32[i]++; 159 147 } else { 160 148 psError(__func__, "data value was not within the bounds of the bin it should habe been in."); … … 178 166 if (maskVector != NULL) { 179 167 for (i=0;i<myVector->n;i++) { 180 if (!(maskVal & maskVector->vec.i [i])) {168 if (!(maskVal & maskVector->vec.i32[i])) { 181 169 mean+= myVector->vec.f[i]; 182 170 count++; … … 203 191 if (maskVector != NULL) { 204 192 for (i=0;i<myVector->n;i++) { 205 if (!(maskVal & maskVector->vec.i [i])) {193 if (!(maskVal & maskVector->vec.i32[i])) { 206 194 if (myVector->vec.f[i] > max) { 207 max = maskVector->vec.i [i];195 max = maskVector->vec.i32[i]; 208 196 } 209 197 } … … 212 200 for (i=0;i<myVector->n;i++) { 213 201 if (myVector->vec.f[i] > max) { 214 max = maskVector->vec.i [i];202 max = maskVector->vec.i32[i]; 215 203 } 216 204 } … … 228 216 if (maskVector != NULL) { 229 217 for (i=0;i<myVector->n;i++) { 230 if (!(maskVal & maskVector->vec.i [i])) {218 if (!(maskVal & maskVector->vec.i32[i])) { 231 219 if (myVector->vec.f[i] < min) { 232 min = maskVector->vec.i [i];220 min = maskVector->vec.i32[i]; 233 221 } 234 222 } … … 237 225 for (i=0;i<myVector->n;i++) { 238 226 if (myVector->vec.f[i] < min) { 239 min = maskVector->vec.i [i];227 min = maskVector->vec.i32[i]; 240 228 } 241 229 } … … 256 244 if (maskVector != NULL) { 257 245 for (i=0;i<myVector->n;i++) { 258 if (!(maskVal & maskVector->vec.i [i])) {246 if (!(maskVal & maskVector->vec.i32[i])) { 259 247 numData++; 260 248 } … … 275 263 psVector *unsortedVector = NULL; 276 264 psVector *sortedVector = NULL; 277 psType dummyFloatType;278 265 int dataSize = 0; 279 266 int count = 0; … … 281 268 float median = 0.0; 282 269 283 dummyFloatType.type = PS_TYPE_FLOAT;284 dummyFloatType.dimen = PS_DIMEN_VECTOR;285 270 dataSize = p_psArrayNValues(myVector, maskVector, maskVal); 286 271 287 272 if (dataSize < MEDIAN_SIZE_THRESHOLD) { 288 unsortedVector = psVectorAlloc( dummyFloatType, dataSize);289 sortedVector = psVectorAlloc( dummyFloatType, dataSize);273 unsortedVector = psVectorAlloc(PS_TYPE_FLOAT, dataSize); 274 sortedVector = psVectorAlloc(PS_TYPE_FLOAT, dataSize); 290 275 291 276 count = 0; 292 277 if (maskVector != NULL) { 293 278 for (i=0;i<myVector->n;i++) { 294 if (!(maskVal & maskVector->vec.i [i])) {279 if (!(maskVal & maskVector->vec.i32[i])) { 295 280 unsortedVector->vec.f[count++] = maskVector->vec.f[i]; 296 281 }
Note:
See TracChangeset
for help on using the changeset viewer.
