Changeset 642
- Timestamp:
- May 11, 2004, 2:40:23 PM (22 years ago)
- Location:
- trunk/psLib/src
- Files:
-
- 5 edited
-
dataManip/Makefile (modified) (1 diff)
-
dataManip/psStats.c (modified) (16 diffs)
-
dataManip/psStats.h (modified) (5 diffs)
-
math/psStats.c (modified) (16 diffs)
-
math/psStats.h (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/dataManip/Makefile
r633 r642 3 3 endif 4 4 5 TARGET = psImage.o psStats.o libpsDataManip.a 5 #TARGET = psImage.o psStats.o libpsDataManip.a 6 TARGET = psStats.o libpsDataManip.a 6 7 7 8 all: $(TARGET) -
trunk/psLib/src/dataManip/psStats.c
r563 r642 4 4 #include <stdarg.h> 5 5 #include "pslib.h" 6 //#include "psMemory.h" 7 //#include "psTrace.h" 8 //#include "psString.h" 9 //#include "psError.h" 10 #include "psArray.h" 6 #include "psMemory.h" 7 #include "psTrace.h" 8 #include "psString.h" 9 #include "psError.h" 10 /****************************************************************************** 11 //#include "psArray.h" 12 *****************************************************************************/ 11 13 #include "psStats.h" 12 14 … … 65 67 numBins = 1 + ((upper - lower) / size); 66 68 newHist = (psHistogram *) psAlloc(sizeof(psHistogram)); 67 newHist->lower = ps FloatArrayAlloc(numBins);68 newHist->upper = ps FloatArrayAlloc(numBins);69 newHist->nums = psIntArrayAlloc(numBins);69 newHist->lower = psVectorAlloc(numBins, PS_TYPE_FLOAT); 70 newHist->upper = psVectorAlloc(numBins, PS_TYPE_FLOAT); 71 newHist->nums = psVectorAlloc(numBins, PS_TYPE_INT); 70 72 newHist->minVal = lower; 71 73 newHist->maxVal = upper; … … 76 78 } 77 79 78 psHistogram *psHistogramAllocGeneric(const ps FloatArray*restrict lower,79 const ps FloatArray*restrict upper,80 psHistogram *psHistogramAllocGeneric(const psVector *restrict lower, 81 const psVector *restrict upper, 80 82 float minVal, 81 83 float maxVal) … … 90 92 numBins = lower->n; 91 93 newHist = (psHistogram *) psAlloc(sizeof(psHistogram)); 92 newHist->lower = ps FloatArrayAlloc(numBins);93 newHist->upper = ps FloatArrayAlloc(numBins);94 newHist->lower = psVectorAlloc(numBins, PS_TYPE_FLOAT); 95 newHist->upper = psVectorAlloc(numBins, PS_TYPE_FLOAT); 94 96 for (i=0;i<numBins;i++) { 95 newHist->lower-> arr[i] = lower->arr[i];96 newHist->upper-> arr[i] = upper->arr[i];97 } 98 newHist->nums = ps IntArrayAlloc(numBins);97 newHist->lower->vec.vecF[i] = lower->vec.vecF[i]; 98 newHist->upper->vec.vecF[i] = upper->vec.vecF[i]; 99 } 100 newHist->nums = psVectorAlloc(numBins, PS_TYPE_INT); 99 101 newHist->minVal = minVal; 100 102 newHist->maxVal = maxVal; … … 124 126 myHist->maxNum 125 127 *****************************************************************************/ 126 psHistogram *psGetArrayHistogram( psHistogram *restrict myHist,127 const psFloatArray *restrict myArray)128 psHistogram *psGetArrayHistogram(psHistogram *restrict myHist, 129 const psVector *restrict myVector) 128 130 { 129 131 int i = 0; … … 132 134 133 135 binSize = (myHist->maxVal - myHist->minVal) / (float) myHist->nums->n; 134 for (i=0;i<my Array->n;i++) {135 if (my Array->arr[i] < myHist->minVal) {136 for (i=0;i<myVector->n;i++) { 137 if (myVector->vec.vecF[i] < myHist->minVal) { 136 138 myHist->minNum++; 137 } else if (my Array->arr[i] > myHist->maxVal) {139 } else if (myVector->vec.vecF[i] > myHist->maxVal) { 138 140 myHist->maxNum++; 139 141 } else { 140 binNum = (int) ((my Array->arr[i] - myHist->minVal) / binSize);141 if ((my Array->arr[i] >= myHist->lower->arr[i]) &&142 (my Array->arr[i] <= myHist->upper->arr[i])) {143 myHist->nums-> arr[i]++;142 binNum = (int) ((myVector->vec.vecF[i] - myHist->minVal) / binSize); 143 if ((myVector->vec.vecF[i] >= myHist->lower->vec.vecF[i]) && 144 (myVector->vec.vecF[i] <= myHist->upper->vec.vecF[i])) { 145 myHist->nums->vec.vecI[i]++; 144 146 } else { 145 147 psError(__func__, "data value was not within the bounds of the bin it should habe been in."); … … 153 155 MISC STATISTICAL FUNCTIONS 154 156 *****************************************************************************/ 155 float p_psArraySampleMean(const ps FloatArray *restrict myArray,156 const ps IntArray *restrict maskArray,157 float p_psArraySampleMean(const psVector *restrict myVector, 158 const psVector *restrict maskVector, 157 159 unsigned int maskVal) 158 160 { … … 160 162 float mean = 0.0; 161 163 162 if (mask Array!= NULL) {163 for (i=0;i<my Array->n;i++) {164 if (!(maskVal & mask Array->arr[i])) {165 mean+= mask Array->arr[i];164 if (maskVector != NULL) { 165 for (i=0;i<myVector->n;i++) { 166 if (!(maskVal & maskVector->vec.vecI[i])) { 167 mean+= maskVector->vec.vecI[i]; 166 168 } 167 169 } 168 170 } else { 169 for (i=0;i<my Array->n;i++) {170 mean+= mask Array->arr[i];171 for (i=0;i<myVector->n;i++) { 172 mean+= maskVector->vec.vecI[i]; 171 173 } 172 174 } … … 174 176 } 175 177 176 float p_psArrayMax(const ps FloatArray *restrict myArray,177 const ps IntArray *restrict maskArray,178 float p_psArrayMax(const psVector *restrict myVector, 179 const psVector *restrict maskVector, 178 180 unsigned int maskVal) 179 181 { … … 181 183 float max = -1e99; 182 184 183 if (mask Array!= NULL) {184 for (i=0;i<my Array->n;i++) {185 if (!(maskVal & mask Array->arr[i])) {186 if (my Array->arr[i] > max) {187 max = mask Array->arr[i];185 if (maskVector != NULL) { 186 for (i=0;i<myVector->n;i++) { 187 if (!(maskVal & maskVector->vec.vecI[i])) { 188 if (myVector->vec.vecF[i] > max) { 189 max = maskVector->vec.vecI[i]; 188 190 } 189 191 } 190 192 } 191 193 } else { 192 for (i=0;i<my Array->n;i++) {193 if (my Array->arr[i] > max) {194 max = mask Array->arr[i];194 for (i=0;i<myVector->n;i++) { 195 if (myVector->vec.vecF[i] > max) { 196 max = maskVector->vec.vecI[i]; 195 197 } 196 198 } … … 199 201 } 200 202 201 float p_psArrayMin(const ps FloatArray *restrict myArray,202 const ps IntArray *restrict maskArray,203 float p_psArrayMin(const psVector *restrict myVector, /* FLOATS */ 204 const psVector *restrict maskVector, /* INTS */ 203 205 unsigned int maskVal) 204 206 { … … 206 208 float min = 1e99; 207 209 208 if (mask Array!= NULL) {209 for (i=0;i<my Array->n;i++) {210 if (!(maskVal & mask Array->arr[i])) {211 if (my Array->arr[i] < min) {212 min = mask Array->arr[i];210 if (maskVector != NULL) { 211 for (i=0;i<myVector->n;i++) { 212 if (!(maskVal & maskVector->vec.vecI[i])) { 213 if (myVector->vec.vecF[i] < min) { 214 min = maskVector->vec.vecI[i]; 213 215 } 214 216 } 215 217 } 216 218 } else { 217 for (i=0;i<my Array->n;i++) {218 if (my Array->arr[i] < min) {219 min = mask Array->arr[i];219 for (i=0;i<myVector->n;i++) { 220 if (myVector->vec.vecF[i] < min) { 221 min = maskVector->vec.vecI[i]; 220 222 } 221 223 } … … 224 226 } 225 227 226 int p_psArrayNValues(const ps FloatArray *restrict myArray,227 const ps IntArray *restrict maskArray,228 int p_psArrayNValues(const psVector *restrict myVector, // float 229 const psVector *restrict maskVector, // ints 228 230 unsigned int maskVal) 229 231 { … … 231 233 int numData = 0; 232 234 233 if (mask Array!= NULL) {234 for (i=0;i<my Array->n;i++) {235 if (!(maskVal & mask Array->arr[i])) {235 if (maskVector != NULL) { 236 for (i=0;i<myVector->n;i++) { 237 if (!(maskVal & maskVector->vec.vecI[i])) { 236 238 numData++; 237 239 } 238 240 } 239 241 } else { 240 numData = my Array->n;242 numData = myVector->n; 241 243 } 242 244 return(numData); 243 245 } 244 246 245 psStats *psArrayStats(const ps FloatArray *restrict myArray,246 const ps IntArray *restrict maskArray,247 psStats *psArrayStats(const psVector *restrict myVector, // FLOAT 248 const psVector *restrict maskVector, // INT 247 249 unsigned int maskVal, 248 250 psStats *stats) … … 251 253 252 254 newStruct = psStatsAlloc(stats->options); 253 if (my Array== NULL) {255 if (myVector == NULL) { 254 256 psError(__func__, 255 "Input data array (my Array) was NULL.");256 } 257 258 if ((mask Array!= NULL) &&259 (my Array->n != maskArray->n)) {260 psError(__func__, " Array data and arraymask are of different sizes.");257 "Input data array (myVector) was NULL."); 258 } 259 260 if ((maskVector != NULL) && 261 (myVector->n != maskVector->n)) { 262 psError(__func__, "Vector data and vector mask are of different sizes."); 261 263 } 262 264 263 265 switch (stats->options) { 264 266 case PS_STAT_SAMPLE_MEAN: 265 newStruct->max = p_psArraySampleMean(my Array, maskArray, maskVal);267 newStruct->max = p_psArraySampleMean(myVector, maskVector, maskVal); 266 268 break; 267 269 case PS_STAT_SAMPLE_MEDIAN: … … 317 319 break; 318 320 case PS_STAT_MAX: 319 newStruct->max = p_psArrayMax(my Array, maskArray, maskVal);321 newStruct->max = p_psArrayMax(myVector, maskVector, maskVal); 320 322 break; 321 323 case PS_STAT_MIN: 322 newStruct->min = p_psArrayMin(my Array, maskArray, maskVal);324 newStruct->min = p_psArrayMin(myVector, maskVector, maskVal); 323 325 break; 324 326 case PS_STAT_NVALUES: 325 newStruct->nValues = p_psArrayNValues(my Array, maskArray, maskVal);327 newStruct->nValues = p_psArrayNValues(myVector, maskVector, maskVal); 326 328 break; 327 329 default: -
trunk/psLib/src/dataManip/psStats.h
r563 r642 6 6 * \ingroup MathGroup 7 7 */ 8 9 /****************************************************************************** 10 The following typedefs and functions belong in the psArray.h and psArray.c 11 files. However, those files are not available at this time, due to the 12 changing definition of the psLib data/functions. For temporary purposes 13 only, I am including them here so that I can continue coding while our 14 basic data types are still being implemented. 15 *****************************************************************************/ 16 typedef enum { 17 PS_TYPE_CHAR, 18 PS_TYPE_SHORT, 19 PS_TYPE_INT, 20 PS_TYPE_LONG, 21 PS_TYPE_UCHAR, 22 PS_TYPE_USHORT, 23 PS_TYPE_UINT, 24 PS_TYPE_ULONG, 25 PS_TYPE_FLOAT, 26 PS_TYPE_DOUBLE, 27 PS_TYPE_COMPLEX, 28 PS_TYPE_OTHER, 29 } psElemType; 30 31 typedef enum { 32 PS_DIMEN_SCALAR, 33 PS_DIMEN_VECTOR, 34 PS_DIMEN_TRANSV, 35 PS_DIMEN_IMAGE, 36 PS_DIMEN_OTHER 37 } psDimen; 38 39 typedef struct 40 { 41 psElemType type; 42 psDimen dimen; 43 } 44 psType; 45 46 typedef struct 47 { 48 psType type; ///< Type of data. 49 int nalloc; ///< Total number of elements available. 50 int n; ///< Number of elements in use. 51 52 union { 53 int *vecI; 54 float *vecF; 55 double *vecD; 56 // complex float *vecC; 57 void **vecP; 58 }vec; ///< Union with array data. 59 } 60 psVector; 61 62 psVector *psVectorAlloc(int nalloc, 63 psElemType type) 64 { 65 return(NULL); 66 } 67 68 psVector *psVectorRealloc(psVector myVector, 69 int nalloc) 70 { 71 return(NULL); 72 } 73 74 void psVectorFree(psVector *restrict psArr) 75 {} 8 76 9 77 /** statistics which may be calculated */ … … 65 133 /** Do Statistics on an array. Returns a status value. \ingroup MathGroup */ 66 134 psStats * 67 psArrayStats(const psFloatArray *restrict myArray, ///< Array to be analysed 68 const psIntArray *restrict maskArray, ///< Ignore elements where (maskArray & maskVal) != 0 69 ///< May be NULL 70 unsigned int maskVal, ///< Only mask elements with one of these bits set in maskArray 135 psArrayStats(const psVector *restrict myVector, ///< Vector to be analysed 136 // must be FLOAT 137 const psVector *restrict maskVector, ///< Ignore elements where (maskVector & maskVal) != 0 138 // must be INT or NULL 139 unsigned int maskVal, ///< Only mask elements with one of these bits set in maskVector 71 140 psStats *stats ///< stats structure defines stats to be calculated and how 72 141 ); … … 87 156 typedef struct 88 157 { 89 const psFloatArray *restrict lower; ///< Lower bounds for the bins 90 const psFloatArray *restrict upper; ///< Upper bounds for the bins 91 psIntArray *nums; ///< Number in each of the bins 92 float minVal, maxVal; ///< Minimum and maximum values 93 int minNum, maxNum; ///< Number below the minimum and above the maximum 158 const psVector *restrict lower; ///< Lower bounds for the bins (FLOAT) 159 const psVector *restrict upper; ///< Upper bounds for the bins (FLOAT) 160 psVector *nums; ///< Number in each of the bins (INT) 161 float minVal; 162 float maxVal; ///< Minimum and maximum values 163 int minNum; 164 int maxNum; ///< Number below the minimum and above the maximum 94 165 } 95 166 psHistogram; … … 104 175 /** Generic constructor \ingroup MathGroup */ 105 176 psHistogram * 106 psHistogramAllocGeneric(const ps FloatArray*restrict lower, ///< Lower bounds for the bins107 const ps FloatArray*restrict upper, ///< Upper bounds for the bins177 psHistogramAllocGeneric(const psVector *restrict lower, ///< Lower bounds for the bins 178 const psVector *restrict upper, ///< Upper bounds for the bins 108 179 float minVal, ///< Minimum value 109 180 float maxVal ///< Maximum value … … 119 190 psHistogram * 120 191 psGetArrayHistogram(psHistogram *restrict myHist, ///< Histogram data 121 const ps FloatArray *restrict myArray ///< Arrayto analyse192 const psVector *restrict myVector ///< Vector to analyse 122 193 ); 123 194 -
trunk/psLib/src/math/psStats.c
r563 r642 4 4 #include <stdarg.h> 5 5 #include "pslib.h" 6 //#include "psMemory.h" 7 //#include "psTrace.h" 8 //#include "psString.h" 9 //#include "psError.h" 10 #include "psArray.h" 6 #include "psMemory.h" 7 #include "psTrace.h" 8 #include "psString.h" 9 #include "psError.h" 10 /****************************************************************************** 11 //#include "psArray.h" 12 *****************************************************************************/ 11 13 #include "psStats.h" 12 14 … … 65 67 numBins = 1 + ((upper - lower) / size); 66 68 newHist = (psHistogram *) psAlloc(sizeof(psHistogram)); 67 newHist->lower = ps FloatArrayAlloc(numBins);68 newHist->upper = ps FloatArrayAlloc(numBins);69 newHist->nums = psIntArrayAlloc(numBins);69 newHist->lower = psVectorAlloc(numBins, PS_TYPE_FLOAT); 70 newHist->upper = psVectorAlloc(numBins, PS_TYPE_FLOAT); 71 newHist->nums = psVectorAlloc(numBins, PS_TYPE_INT); 70 72 newHist->minVal = lower; 71 73 newHist->maxVal = upper; … … 76 78 } 77 79 78 psHistogram *psHistogramAllocGeneric(const ps FloatArray*restrict lower,79 const ps FloatArray*restrict upper,80 psHistogram *psHistogramAllocGeneric(const psVector *restrict lower, 81 const psVector *restrict upper, 80 82 float minVal, 81 83 float maxVal) … … 90 92 numBins = lower->n; 91 93 newHist = (psHistogram *) psAlloc(sizeof(psHistogram)); 92 newHist->lower = ps FloatArrayAlloc(numBins);93 newHist->upper = ps FloatArrayAlloc(numBins);94 newHist->lower = psVectorAlloc(numBins, PS_TYPE_FLOAT); 95 newHist->upper = psVectorAlloc(numBins, PS_TYPE_FLOAT); 94 96 for (i=0;i<numBins;i++) { 95 newHist->lower-> arr[i] = lower->arr[i];96 newHist->upper-> arr[i] = upper->arr[i];97 } 98 newHist->nums = ps IntArrayAlloc(numBins);97 newHist->lower->vec.vecF[i] = lower->vec.vecF[i]; 98 newHist->upper->vec.vecF[i] = upper->vec.vecF[i]; 99 } 100 newHist->nums = psVectorAlloc(numBins, PS_TYPE_INT); 99 101 newHist->minVal = minVal; 100 102 newHist->maxVal = maxVal; … … 124 126 myHist->maxNum 125 127 *****************************************************************************/ 126 psHistogram *psGetArrayHistogram( psHistogram *restrict myHist,127 const psFloatArray *restrict myArray)128 psHistogram *psGetArrayHistogram(psHistogram *restrict myHist, 129 const psVector *restrict myVector) 128 130 { 129 131 int i = 0; … … 132 134 133 135 binSize = (myHist->maxVal - myHist->minVal) / (float) myHist->nums->n; 134 for (i=0;i<my Array->n;i++) {135 if (my Array->arr[i] < myHist->minVal) {136 for (i=0;i<myVector->n;i++) { 137 if (myVector->vec.vecF[i] < myHist->minVal) { 136 138 myHist->minNum++; 137 } else if (my Array->arr[i] > myHist->maxVal) {139 } else if (myVector->vec.vecF[i] > myHist->maxVal) { 138 140 myHist->maxNum++; 139 141 } else { 140 binNum = (int) ((my Array->arr[i] - myHist->minVal) / binSize);141 if ((my Array->arr[i] >= myHist->lower->arr[i]) &&142 (my Array->arr[i] <= myHist->upper->arr[i])) {143 myHist->nums-> arr[i]++;142 binNum = (int) ((myVector->vec.vecF[i] - myHist->minVal) / binSize); 143 if ((myVector->vec.vecF[i] >= myHist->lower->vec.vecF[i]) && 144 (myVector->vec.vecF[i] <= myHist->upper->vec.vecF[i])) { 145 myHist->nums->vec.vecI[i]++; 144 146 } else { 145 147 psError(__func__, "data value was not within the bounds of the bin it should habe been in."); … … 153 155 MISC STATISTICAL FUNCTIONS 154 156 *****************************************************************************/ 155 float p_psArraySampleMean(const ps FloatArray *restrict myArray,156 const ps IntArray *restrict maskArray,157 float p_psArraySampleMean(const psVector *restrict myVector, 158 const psVector *restrict maskVector, 157 159 unsigned int maskVal) 158 160 { … … 160 162 float mean = 0.0; 161 163 162 if (mask Array!= NULL) {163 for (i=0;i<my Array->n;i++) {164 if (!(maskVal & mask Array->arr[i])) {165 mean+= mask Array->arr[i];164 if (maskVector != NULL) { 165 for (i=0;i<myVector->n;i++) { 166 if (!(maskVal & maskVector->vec.vecI[i])) { 167 mean+= maskVector->vec.vecI[i]; 166 168 } 167 169 } 168 170 } else { 169 for (i=0;i<my Array->n;i++) {170 mean+= mask Array->arr[i];171 for (i=0;i<myVector->n;i++) { 172 mean+= maskVector->vec.vecI[i]; 171 173 } 172 174 } … … 174 176 } 175 177 176 float p_psArrayMax(const ps FloatArray *restrict myArray,177 const ps IntArray *restrict maskArray,178 float p_psArrayMax(const psVector *restrict myVector, 179 const psVector *restrict maskVector, 178 180 unsigned int maskVal) 179 181 { … … 181 183 float max = -1e99; 182 184 183 if (mask Array!= NULL) {184 for (i=0;i<my Array->n;i++) {185 if (!(maskVal & mask Array->arr[i])) {186 if (my Array->arr[i] > max) {187 max = mask Array->arr[i];185 if (maskVector != NULL) { 186 for (i=0;i<myVector->n;i++) { 187 if (!(maskVal & maskVector->vec.vecI[i])) { 188 if (myVector->vec.vecF[i] > max) { 189 max = maskVector->vec.vecI[i]; 188 190 } 189 191 } 190 192 } 191 193 } else { 192 for (i=0;i<my Array->n;i++) {193 if (my Array->arr[i] > max) {194 max = mask Array->arr[i];194 for (i=0;i<myVector->n;i++) { 195 if (myVector->vec.vecF[i] > max) { 196 max = maskVector->vec.vecI[i]; 195 197 } 196 198 } … … 199 201 } 200 202 201 float p_psArrayMin(const ps FloatArray *restrict myArray,202 const ps IntArray *restrict maskArray,203 float p_psArrayMin(const psVector *restrict myVector, /* FLOATS */ 204 const psVector *restrict maskVector, /* INTS */ 203 205 unsigned int maskVal) 204 206 { … … 206 208 float min = 1e99; 207 209 208 if (mask Array!= NULL) {209 for (i=0;i<my Array->n;i++) {210 if (!(maskVal & mask Array->arr[i])) {211 if (my Array->arr[i] < min) {212 min = mask Array->arr[i];210 if (maskVector != NULL) { 211 for (i=0;i<myVector->n;i++) { 212 if (!(maskVal & maskVector->vec.vecI[i])) { 213 if (myVector->vec.vecF[i] < min) { 214 min = maskVector->vec.vecI[i]; 213 215 } 214 216 } 215 217 } 216 218 } else { 217 for (i=0;i<my Array->n;i++) {218 if (my Array->arr[i] < min) {219 min = mask Array->arr[i];219 for (i=0;i<myVector->n;i++) { 220 if (myVector->vec.vecF[i] < min) { 221 min = maskVector->vec.vecI[i]; 220 222 } 221 223 } … … 224 226 } 225 227 226 int p_psArrayNValues(const ps FloatArray *restrict myArray,227 const ps IntArray *restrict maskArray,228 int p_psArrayNValues(const psVector *restrict myVector, // float 229 const psVector *restrict maskVector, // ints 228 230 unsigned int maskVal) 229 231 { … … 231 233 int numData = 0; 232 234 233 if (mask Array!= NULL) {234 for (i=0;i<my Array->n;i++) {235 if (!(maskVal & mask Array->arr[i])) {235 if (maskVector != NULL) { 236 for (i=0;i<myVector->n;i++) { 237 if (!(maskVal & maskVector->vec.vecI[i])) { 236 238 numData++; 237 239 } 238 240 } 239 241 } else { 240 numData = my Array->n;242 numData = myVector->n; 241 243 } 242 244 return(numData); 243 245 } 244 246 245 psStats *psArrayStats(const ps FloatArray *restrict myArray,246 const ps IntArray *restrict maskArray,247 psStats *psArrayStats(const psVector *restrict myVector, // FLOAT 248 const psVector *restrict maskVector, // INT 247 249 unsigned int maskVal, 248 250 psStats *stats) … … 251 253 252 254 newStruct = psStatsAlloc(stats->options); 253 if (my Array== NULL) {255 if (myVector == NULL) { 254 256 psError(__func__, 255 "Input data array (my Array) was NULL.");256 } 257 258 if ((mask Array!= NULL) &&259 (my Array->n != maskArray->n)) {260 psError(__func__, " Array data and arraymask are of different sizes.");257 "Input data array (myVector) was NULL."); 258 } 259 260 if ((maskVector != NULL) && 261 (myVector->n != maskVector->n)) { 262 psError(__func__, "Vector data and vector mask are of different sizes."); 261 263 } 262 264 263 265 switch (stats->options) { 264 266 case PS_STAT_SAMPLE_MEAN: 265 newStruct->max = p_psArraySampleMean(my Array, maskArray, maskVal);267 newStruct->max = p_psArraySampleMean(myVector, maskVector, maskVal); 266 268 break; 267 269 case PS_STAT_SAMPLE_MEDIAN: … … 317 319 break; 318 320 case PS_STAT_MAX: 319 newStruct->max = p_psArrayMax(my Array, maskArray, maskVal);321 newStruct->max = p_psArrayMax(myVector, maskVector, maskVal); 320 322 break; 321 323 case PS_STAT_MIN: 322 newStruct->min = p_psArrayMin(my Array, maskArray, maskVal);324 newStruct->min = p_psArrayMin(myVector, maskVector, maskVal); 323 325 break; 324 326 case PS_STAT_NVALUES: 325 newStruct->nValues = p_psArrayNValues(my Array, maskArray, maskVal);327 newStruct->nValues = p_psArrayNValues(myVector, maskVector, maskVal); 326 328 break; 327 329 default: -
trunk/psLib/src/math/psStats.h
r563 r642 6 6 * \ingroup MathGroup 7 7 */ 8 9 /****************************************************************************** 10 The following typedefs and functions belong in the psArray.h and psArray.c 11 files. However, those files are not available at this time, due to the 12 changing definition of the psLib data/functions. For temporary purposes 13 only, I am including them here so that I can continue coding while our 14 basic data types are still being implemented. 15 *****************************************************************************/ 16 typedef enum { 17 PS_TYPE_CHAR, 18 PS_TYPE_SHORT, 19 PS_TYPE_INT, 20 PS_TYPE_LONG, 21 PS_TYPE_UCHAR, 22 PS_TYPE_USHORT, 23 PS_TYPE_UINT, 24 PS_TYPE_ULONG, 25 PS_TYPE_FLOAT, 26 PS_TYPE_DOUBLE, 27 PS_TYPE_COMPLEX, 28 PS_TYPE_OTHER, 29 } psElemType; 30 31 typedef enum { 32 PS_DIMEN_SCALAR, 33 PS_DIMEN_VECTOR, 34 PS_DIMEN_TRANSV, 35 PS_DIMEN_IMAGE, 36 PS_DIMEN_OTHER 37 } psDimen; 38 39 typedef struct 40 { 41 psElemType type; 42 psDimen dimen; 43 } 44 psType; 45 46 typedef struct 47 { 48 psType type; ///< Type of data. 49 int nalloc; ///< Total number of elements available. 50 int n; ///< Number of elements in use. 51 52 union { 53 int *vecI; 54 float *vecF; 55 double *vecD; 56 // complex float *vecC; 57 void **vecP; 58 }vec; ///< Union with array data. 59 } 60 psVector; 61 62 psVector *psVectorAlloc(int nalloc, 63 psElemType type) 64 { 65 return(NULL); 66 } 67 68 psVector *psVectorRealloc(psVector myVector, 69 int nalloc) 70 { 71 return(NULL); 72 } 73 74 void psVectorFree(psVector *restrict psArr) 75 {} 8 76 9 77 /** statistics which may be calculated */ … … 65 133 /** Do Statistics on an array. Returns a status value. \ingroup MathGroup */ 66 134 psStats * 67 psArrayStats(const psFloatArray *restrict myArray, ///< Array to be analysed 68 const psIntArray *restrict maskArray, ///< Ignore elements where (maskArray & maskVal) != 0 69 ///< May be NULL 70 unsigned int maskVal, ///< Only mask elements with one of these bits set in maskArray 135 psArrayStats(const psVector *restrict myVector, ///< Vector to be analysed 136 // must be FLOAT 137 const psVector *restrict maskVector, ///< Ignore elements where (maskVector & maskVal) != 0 138 // must be INT or NULL 139 unsigned int maskVal, ///< Only mask elements with one of these bits set in maskVector 71 140 psStats *stats ///< stats structure defines stats to be calculated and how 72 141 ); … … 87 156 typedef struct 88 157 { 89 const psFloatArray *restrict lower; ///< Lower bounds for the bins 90 const psFloatArray *restrict upper; ///< Upper bounds for the bins 91 psIntArray *nums; ///< Number in each of the bins 92 float minVal, maxVal; ///< Minimum and maximum values 93 int minNum, maxNum; ///< Number below the minimum and above the maximum 158 const psVector *restrict lower; ///< Lower bounds for the bins (FLOAT) 159 const psVector *restrict upper; ///< Upper bounds for the bins (FLOAT) 160 psVector *nums; ///< Number in each of the bins (INT) 161 float minVal; 162 float maxVal; ///< Minimum and maximum values 163 int minNum; 164 int maxNum; ///< Number below the minimum and above the maximum 94 165 } 95 166 psHistogram; … … 104 175 /** Generic constructor \ingroup MathGroup */ 105 176 psHistogram * 106 psHistogramAllocGeneric(const ps FloatArray*restrict lower, ///< Lower bounds for the bins107 const ps FloatArray*restrict upper, ///< Upper bounds for the bins177 psHistogramAllocGeneric(const psVector *restrict lower, ///< Lower bounds for the bins 178 const psVector *restrict upper, ///< Upper bounds for the bins 108 179 float minVal, ///< Minimum value 109 180 float maxVal ///< Maximum value … … 119 190 psHistogram * 120 191 psGetArrayHistogram(psHistogram *restrict myHist, ///< Histogram data 121 const ps FloatArray *restrict myArray ///< Arrayto analyse192 const psVector *restrict myVector ///< Vector to analyse 122 193 ); 123 194
Note:
See TracChangeset
for help on using the changeset viewer.
