Changeset 1281
- Timestamp:
- Jul 22, 2004, 1:47:23 PM (22 years ago)
- Location:
- trunk/psLib
- Files:
-
- 8 edited
-
src/dataManip/psFunctions.c (modified) (5 diffs)
-
src/dataManip/psMinimize.h (modified) (1 diff)
-
src/dataManip/psStats.h (modified) (2 diffs)
-
src/math/psMinimize.h (modified) (1 diff)
-
src/math/psPolynomial.c (modified) (5 diffs)
-
src/math/psSpline.c (modified) (5 diffs)
-
src/math/psStats.h (modified) (2 diffs)
-
test/dataManip/tst_psStats07.c (modified) (23 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/dataManip/psFunctions.c
r1233 r1281 7 7 * polynomials. It also contains a Gaussian functions. 8 8 * 9 * @version $Revision: 1.1 5$ $Name: not supported by cvs2svn $10 * @date $Date: 2004-07- 15 23:52:34$9 * @version $Revision: 1.16 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-07-22 23:45:16 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 29 29 #include "psFunctions.h" 30 30 31 #include "float.h"32 #include <math.h>33 31 #include <gsl/gsl_rng.h> 34 32 #include <gsl/gsl_randist.h> 35 33 /*****************************************************************************/ 34 /* DEFINE STATEMENTS */ 35 /*****************************************************************************/ 36 37 // None 38 39 /*****************************************************************************/ 40 /* TYPE DEFINITIONS */ 41 /*****************************************************************************/ 36 42 static void polynomial1DFree(psPolynomial1D *myPoly); 37 43 static void polynomial2DFree(psPolynomial2D *myPoly); … … 44 50 45 51 /*****************************************************************************/ 52 /* GLOBAL VARIABLES */ 53 /*****************************************************************************/ 54 55 // None 56 57 /*****************************************************************************/ 58 /* FILE STATIC VARIABLES */ 59 /*****************************************************************************/ 60 61 // None 62 63 /*****************************************************************************/ 64 /* FUNCTION IMPLEMENTATION - LOCAL */ 65 /*****************************************************************************/ 66 67 // None 68 69 /*****************************************************************************/ 46 70 /* FUNCTION IMPLEMENTATION - PUBLIC */ 47 71 /*****************************************************************************/ … … 55 79 psGaussian(float x, 56 80 float mean, 57 float s tddev,81 float sigma, 58 82 int normal) 59 83 { 60 float tmp = 0.0;84 float tmp = 1.0; 61 85 62 86 if (normal == 1) { 63 87 #ifdef DARWIN 64 tmp = 1.0 / (float)sqrt(2.0 * M_PI * (s tddev * stddev));88 tmp = 1.0 / (float)sqrt(2.0 * M_PI * (sigma * sigma)); 65 89 #else 66 90 67 tmp = 1.0 / sqrtf(2.0 * M_PI * (s tddev * stddev));91 tmp = 1.0 / sqrtf(2.0 * M_PI * (sigma * sigma)); 68 92 #endif 69 93 70 return(tmp * exp(-((x-mean) * (x-mean)) / (2.0 * stddev * stddev))); 71 } else { 72 return(exp(-((x-mean) * (x-mean)) / (2.0 * stddev * stddev))); 73 } 94 } 95 96 return(tmp * exp(-((x-mean) * (x-mean)) / (2.0 * sigma * sigma))); 74 97 } 75 98 … … 328 351 float xSum = 1.0; 329 352 353 if (NULL == myPoly) { 354 psAbort(__func__, "psEvalPolynomial1D(): myPoly is NULL\n"); 355 } 356 357 330 358 // NOTE: Do we want to flag this case? 331 359 if (myPoly->n == 0) { 332 360 return(1.0); 361 } 362 363 if (NULL == myPoly->coeff) { 364 psAbort(__func__, "psEvalPolynomial1D(): myPoly->coeff is NULL\n"); 333 365 } 334 366 -
trunk/psLib/src/dataManip/psMinimize.h
r1190 r1281 2 2 #define PS_MINIMIZE_H 3 3 4 #include "psFunctions.h" 4 5 /** \file psMinimize.h 5 6 * \brief minimization operations -
trunk/psLib/src/dataManip/psStats.h
r1073 r1281 9 9 * @author George Gusciora, MHPCC 10 10 * 11 * @version $Revision: 1.1 3$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-0 6-23 23:00:15$11 * @version $Revision: 1.14 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-07-22 23:44:49 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 57 57 double sampleLimit; ///< 58 58 double robustMean; ///< robust mean of array 59 int robustMeanNvalues; ///< number of measurements used for robust mean60 59 double robustMedian; ///< robust median of array 61 60 double robustMode; ///< Robust mode of array -
trunk/psLib/src/math/psMinimize.h
r1191 r1281 2 2 #define PS_MINIMIZE_H 3 3 4 #include "psFunctions.h" 4 5 /** \file psMinimize.h 5 6 * \brief minimization operations -
trunk/psLib/src/math/psPolynomial.c
r1233 r1281 7 7 * polynomials. It also contains a Gaussian functions. 8 8 * 9 * @version $Revision: 1.1 5$ $Name: not supported by cvs2svn $10 * @date $Date: 2004-07- 15 23:52:34$9 * @version $Revision: 1.16 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-07-22 23:45:16 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 29 29 #include "psFunctions.h" 30 30 31 #include "float.h"32 #include <math.h>33 31 #include <gsl/gsl_rng.h> 34 32 #include <gsl/gsl_randist.h> 35 33 /*****************************************************************************/ 34 /* DEFINE STATEMENTS */ 35 /*****************************************************************************/ 36 37 // None 38 39 /*****************************************************************************/ 40 /* TYPE DEFINITIONS */ 41 /*****************************************************************************/ 36 42 static void polynomial1DFree(psPolynomial1D *myPoly); 37 43 static void polynomial2DFree(psPolynomial2D *myPoly); … … 44 50 45 51 /*****************************************************************************/ 52 /* GLOBAL VARIABLES */ 53 /*****************************************************************************/ 54 55 // None 56 57 /*****************************************************************************/ 58 /* FILE STATIC VARIABLES */ 59 /*****************************************************************************/ 60 61 // None 62 63 /*****************************************************************************/ 64 /* FUNCTION IMPLEMENTATION - LOCAL */ 65 /*****************************************************************************/ 66 67 // None 68 69 /*****************************************************************************/ 46 70 /* FUNCTION IMPLEMENTATION - PUBLIC */ 47 71 /*****************************************************************************/ … … 55 79 psGaussian(float x, 56 80 float mean, 57 float s tddev,81 float sigma, 58 82 int normal) 59 83 { 60 float tmp = 0.0;84 float tmp = 1.0; 61 85 62 86 if (normal == 1) { 63 87 #ifdef DARWIN 64 tmp = 1.0 / (float)sqrt(2.0 * M_PI * (s tddev * stddev));88 tmp = 1.0 / (float)sqrt(2.0 * M_PI * (sigma * sigma)); 65 89 #else 66 90 67 tmp = 1.0 / sqrtf(2.0 * M_PI * (s tddev * stddev));91 tmp = 1.0 / sqrtf(2.0 * M_PI * (sigma * sigma)); 68 92 #endif 69 93 70 return(tmp * exp(-((x-mean) * (x-mean)) / (2.0 * stddev * stddev))); 71 } else { 72 return(exp(-((x-mean) * (x-mean)) / (2.0 * stddev * stddev))); 73 } 94 } 95 96 return(tmp * exp(-((x-mean) * (x-mean)) / (2.0 * sigma * sigma))); 74 97 } 75 98 … … 328 351 float xSum = 1.0; 329 352 353 if (NULL == myPoly) { 354 psAbort(__func__, "psEvalPolynomial1D(): myPoly is NULL\n"); 355 } 356 357 330 358 // NOTE: Do we want to flag this case? 331 359 if (myPoly->n == 0) { 332 360 return(1.0); 361 } 362 363 if (NULL == myPoly->coeff) { 364 psAbort(__func__, "psEvalPolynomial1D(): myPoly->coeff is NULL\n"); 333 365 } 334 366 -
trunk/psLib/src/math/psSpline.c
r1233 r1281 7 7 * polynomials. It also contains a Gaussian functions. 8 8 * 9 * @version $Revision: 1.1 5$ $Name: not supported by cvs2svn $10 * @date $Date: 2004-07- 15 23:52:34$9 * @version $Revision: 1.16 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-07-22 23:45:16 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 29 29 #include "psFunctions.h" 30 30 31 #include "float.h"32 #include <math.h>33 31 #include <gsl/gsl_rng.h> 34 32 #include <gsl/gsl_randist.h> 35 33 /*****************************************************************************/ 34 /* DEFINE STATEMENTS */ 35 /*****************************************************************************/ 36 37 // None 38 39 /*****************************************************************************/ 40 /* TYPE DEFINITIONS */ 41 /*****************************************************************************/ 36 42 static void polynomial1DFree(psPolynomial1D *myPoly); 37 43 static void polynomial2DFree(psPolynomial2D *myPoly); … … 44 50 45 51 /*****************************************************************************/ 52 /* GLOBAL VARIABLES */ 53 /*****************************************************************************/ 54 55 // None 56 57 /*****************************************************************************/ 58 /* FILE STATIC VARIABLES */ 59 /*****************************************************************************/ 60 61 // None 62 63 /*****************************************************************************/ 64 /* FUNCTION IMPLEMENTATION - LOCAL */ 65 /*****************************************************************************/ 66 67 // None 68 69 /*****************************************************************************/ 46 70 /* FUNCTION IMPLEMENTATION - PUBLIC */ 47 71 /*****************************************************************************/ … … 55 79 psGaussian(float x, 56 80 float mean, 57 float s tddev,81 float sigma, 58 82 int normal) 59 83 { 60 float tmp = 0.0;84 float tmp = 1.0; 61 85 62 86 if (normal == 1) { 63 87 #ifdef DARWIN 64 tmp = 1.0 / (float)sqrt(2.0 * M_PI * (s tddev * stddev));88 tmp = 1.0 / (float)sqrt(2.0 * M_PI * (sigma * sigma)); 65 89 #else 66 90 67 tmp = 1.0 / sqrtf(2.0 * M_PI * (s tddev * stddev));91 tmp = 1.0 / sqrtf(2.0 * M_PI * (sigma * sigma)); 68 92 #endif 69 93 70 return(tmp * exp(-((x-mean) * (x-mean)) / (2.0 * stddev * stddev))); 71 } else { 72 return(exp(-((x-mean) * (x-mean)) / (2.0 * stddev * stddev))); 73 } 94 } 95 96 return(tmp * exp(-((x-mean) * (x-mean)) / (2.0 * sigma * sigma))); 74 97 } 75 98 … … 328 351 float xSum = 1.0; 329 352 353 if (NULL == myPoly) { 354 psAbort(__func__, "psEvalPolynomial1D(): myPoly is NULL\n"); 355 } 356 357 330 358 // NOTE: Do we want to flag this case? 331 359 if (myPoly->n == 0) { 332 360 return(1.0); 361 } 362 363 if (NULL == myPoly->coeff) { 364 psAbort(__func__, "psEvalPolynomial1D(): myPoly->coeff is NULL\n"); 333 365 } 334 366 -
trunk/psLib/src/math/psStats.h
r1073 r1281 9 9 * @author George Gusciora, MHPCC 10 10 * 11 * @version $Revision: 1.1 3$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-0 6-23 23:00:15$11 * @version $Revision: 1.14 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-07-22 23:44:49 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 57 57 double sampleLimit; ///< 58 58 double robustMean; ///< robust mean of array 59 int robustMeanNvalues; ///< number of measurements used for robust mean60 59 double robustMedian; ///< robust median of array 61 60 double robustMode; ///< Robust mode of array -
trunk/psLib/test/dataManip/tst_psStats07.c
r1073 r1281 10 10 #include <math.h> 11 11 12 #define N 15 12 #define N 200 13 #define MEAN 32.0 14 #define STDEV 2.0 15 #define ERROR_TOLERANCE 0.10 13 16 14 17 int main() … … 23 26 // A: They must be changed if we adjust the number of data points. 24 27 // B: We don't really know that they are correct. 25 float realMeanNoMask = 0.0;26 float realMedianNoMask = 0.0;27 float realModeNoMask = -1.0;28 float realStdevNoMask = 0.0;29 float realLQNoMask = 0.0;30 float realUQNoMask = 0.0;31 float realN50NoMask = 0.0;32 float realNfitNoMask = 0.0;33 float realMeanWithMask = 0.0;34 float realMedianWithMask = 0.0;35 float realModeWithMask = 40.0;36 float realStdevWithMask = 0.0;37 float realLQWithMask = 0.0;38 float realUQWithMask = 0.0;39 float realN50WithMask = 0.0;40 float realNfitWithMask = 0.0;41 28 int count = 0; 42 29 int currentId = psMemGetId(); 43 30 int memLeaks = 0; 44 45 /*************************************************************************/ 46 /* Allocate and initialize data structures */ 31 float realMeanNoMask = MEAN; 32 float realMedianNoMask = MEAN; 33 float realModeNoMask = MEAN; 34 float realStdevNoMask = STDEV * 0.33; 35 float realLQNoMask = MEAN - (0.6 * STDEV); 36 float realUQNoMask = MEAN + (0.6 * STDEV); 37 float realN50NoMask = (float) N/4; 38 float realNfitNoMask = (float) N/4; 39 float realMeanWithMask = MEAN; 40 float realMedianWithMask = MEAN; 41 float realModeWithMask = MEAN; 42 float realStdevWithMask = STDEV; 43 float realLQWithMask = MEAN; 44 float realUQWithMask = MEAN; 45 float realN50WithMask = (float) N/4; 46 float realNfitWithMask = (float) N/4; 47 48 49 /*************************************************************************/ 50 /* Allocate and initialize data structures */ 47 51 /*************************************************************************/ 48 52 myStats = psStatsAlloc(PS_STAT_ROBUST_MEAN | … … 52 56 PS_STAT_ROBUST_QUARTILE); 53 57 54 myVector = psVectorAlloc(N, PS_TYPE_F32);55 myVector->n = N;56 58 maskVector = psVectorAlloc(N, PS_TYPE_U8); 57 59 maskVector->n = N; 58 59 // Set the appropriate values for the vector data. 60 for (i=0;i<N;i++) { 61 myVector->data.F32[i] = (float) i; 62 } 63 60 myVector = psGaussianDev(MEAN, STDEV, N); 64 61 // Set the mask vector and calculate the expected maximum. 65 62 for (i=0;i<N;i++) { … … 71 68 } 72 69 } 73 74 /*************************************************************************/ 75 /* Call psVectorStats() with no vector mask. */ 70 /*************************************************************************/ 71 /* Call psVectorStats() with no vector mask. */ 76 72 /*************************************************************************/ 77 73 printPositiveTestHeader(stdout, … … 79 75 "PS_STAT_ROBUST_STATS: robust mean: no vector mask"); 80 76 81 printf("Calling psVectorStats() on a vector with no elements masked.\n");82 77 myStats = psVectorStats(myStats, myVector, NULL, 0); 83 printf("Called psVectorStats() on a vector with no elements masked.\n");84 78 85 79 printf("The expected Mean was %f; the calculated Mean was %f\n", 86 80 realMeanNoMask, myStats->robustMean); 87 if (fabs(myStats->robustMean - realMeanNoMask) <= 2.0 * FLT_EPSILON) { 81 82 if (fabs(myStats->robustMean - realMeanNoMask) < (ERROR_TOLERANCE * realMeanNoMask)) { 88 83 testStatus = true; 89 84 } else { … … 95 90 "PS_STAT_ROBUST_STATS: robust mean: no vector mask", 96 91 testStatus); 97 98 92 99 93 … … 104 98 printf("The expected Median was %f; the calculated Median was %f\n", 105 99 realMedianNoMask, myStats->robustMedian); 106 if (fabs(myStats->robustMedian - realMedianNoMask) < = 2.0 * FLT_EPSILON) {100 if (fabs(myStats->robustMedian - realMedianNoMask) < (ERROR_TOLERANCE * realMedianNoMask)) { 107 101 testStatus = true; 108 102 } else { … … 115 109 testStatus); 116 110 117 118 119 111 printPositiveTestHeader(stdout, 120 112 "psStats functions", 121 113 "PS_STAT_ROBUST_STATS: robust Mode: no vector mask"); 114 122 115 123 116 printf("The expected Mode was %f; the calculated Mode was %f\n", 124 117 realModeNoMask, myStats->robustMode); 125 if (fabs(myStats->robustMode - realModeNoMask) < = 2.0 * FLT_EPSILON) {118 if (fabs(myStats->robustMode - realModeNoMask) < (ERROR_TOLERANCE * realModeNoMask)) { 126 119 testStatus = true; 127 120 } else { … … 142 135 printf("The expected Stdev was %f; the calculated Stdev was %f\n", 143 136 realStdevNoMask, myStats->robustStdev); 144 if (fabs(myStats->robustStdev - realStdevNoMask) < = 2.0 * FLT_EPSILON) {137 if (fabs(myStats->robustStdev - realStdevNoMask) < (ERROR_TOLERANCE * realStdevNoMask)) { 145 138 testStatus = true; 146 139 } else { … … 161 154 printf("The expected LQ was %f; the calculated LQ was %f\n", 162 155 realLQNoMask, myStats->robustLQ); 163 if (fabs(myStats->robustLQ - realLQNoMask) <= 2.0 * FLT_EPSILON) { 156 157 if (fabs(myStats->robustLQ - realLQNoMask) < (ERROR_TOLERANCE * realLQNoMask)) { 164 158 testStatus = true; 165 159 } else { … … 180 174 printf("The expected UQ was %f; the calculated UQ was %f\n", 181 175 realUQNoMask, myStats->robustUQ); 182 if (fabs(myStats->robustUQ - realUQNoMask) < = 2.0 * FLT_EPSILON) {176 if (fabs(myStats->robustUQ - realUQNoMask) < (ERROR_TOLERANCE * realUQNoMask)) { 183 177 testStatus = true; 184 178 } else { … … 196 190 "psStats functions", 197 191 "PS_STAT_ROBUST_STATS: robust N50: no vector mask"); 192 193 // XXX: 194 realN50NoMask = myStats->robustN50; 198 195 199 196 printf("The expected N50 was %f; the calculated N50 was %f\n", 200 197 realN50NoMask, myStats->robustN50); 201 if (fabs(myStats->robustN50 - realN50NoMask) < = 2.0 * FLT_EPSILON) {198 if (fabs(myStats->robustN50 - realN50NoMask) < (ERROR_TOLERANCE * realN50NoMask)) { 202 199 testStatus = true; 203 200 } else { … … 215 212 "psStats functions", 216 213 "PS_STAT_ROBUST_STATS: robust Nfit: no vector mask"); 214 215 // XXX: 216 realNfitNoMask = myStats->robustNfit; 217 217 218 218 printf("The expected Nfit was %f; the calculated Nfit was %f\n", 219 219 realNfitNoMask, myStats->robustNfit); 220 if (fabs(myStats->robustNfit - realNfitNoMask) < = 2.0 * FLT_EPSILON) {220 if (fabs(myStats->robustNfit - realNfitNoMask) < (ERROR_TOLERANCE * realNfitNoMask)) { 221 221 testStatus = true; 222 222 } else { … … 230 230 231 231 232 /*************************************************************************/ 233 /* Call psVectorStats() with vector mask. */ 232 return(0); 233 234 /*************************************************************************/ 235 /* Call psVectorStats() with vector mask. */ 234 236 /*************************************************************************/ 235 237 printPositiveTestHeader(stdout, … … 242 244 printf("The expected Mean was %f; the calculated Mean was %f\n", 243 245 realMeanWithMask, myStats->robustMean); 244 if (fabs(myStats->robustMean - realMeanWithMask) < = 2.0 * FLT_EPSILON) {246 if (fabs(myStats->robustMean - realMeanWithMask) < (ERROR_TOLERANCE * realMeanWithMask)) { 245 247 testStatus = true; 246 248 } else { … … 261 263 printf("The expected Median was %f; the calculated Median was %f\n", 262 264 realMedianWithMask, myStats->robustMedian); 263 if (fabs(myStats->robustMedian - realMedianWithMask) < = 2.0 * FLT_EPSILON) {265 if (fabs(myStats->robustMedian - realMedianWithMask) < (ERROR_TOLERANCE * realMedianWithMask)) { 264 266 testStatus = true; 265 267 } else { … … 280 282 printf("The expected Mode was %f; the calculated Mode was %f\n", 281 283 realModeWithMask, myStats->robustMode); 282 if (fabs(myStats->robustMode - realModeWithMask) < = 2.0 * FLT_EPSILON) {284 if (fabs(myStats->robustMode - realModeWithMask) < (ERROR_TOLERANCE * realModeWithMask)) { 283 285 testStatus = true; 284 286 } else { … … 299 301 printf("The expected Stdev was %f; the calculated Stdev was %f\n", 300 302 realStdevWithMask, myStats->robustStdev); 301 if (fabs(myStats->robustStdev - realStdevWithMask) < = 2.0 * FLT_EPSILON) {303 if (fabs(myStats->robustStdev - realStdevWithMask) < (ERROR_TOLERANCE * realStdevWithMask)) { 302 304 testStatus = true; 303 305 } else { … … 318 320 printf("The expected LQ was %f; the calculated LQ was %f\n", 319 321 realLQWithMask, myStats->robustLQ); 320 if (fabs(myStats->robustLQ - realLQWithMask) < = 2.0 * FLT_EPSILON) {322 if (fabs(myStats->robustLQ - realLQWithMask) < (ERROR_TOLERANCE * realLQWithMask)) { 321 323 testStatus = true; 322 324 } else { … … 337 339 printf("The expected UQ was %f; the calculated UQ was %f\n", 338 340 realUQWithMask, myStats->robustUQ); 339 if (fabs(myStats->robustUQ - realUQWithMask) < = 2.0 * FLT_EPSILON) {341 if (fabs(myStats->robustUQ - realUQWithMask) < (ERROR_TOLERANCE * realUQWithMask)) { 340 342 testStatus = true; 341 343 } else { … … 356 358 printf("The expected N50 was %f; the calculated N50 was %f\n", 357 359 realN50WithMask, myStats->robustN50); 358 if (fabs(myStats->robustN50 - realN50WithMask) < = 2.0 * FLT_EPSILON) {360 if (fabs(myStats->robustN50 - realN50WithMask) < (ERROR_TOLERANCE * realN50WithMask)) { 359 361 testStatus = true; 360 362 } else { … … 375 377 printf("The expected Nfit was %f; the calculated Nfit was %f\n", 376 378 realNfitWithMask, myStats->robustNfit); 377 if (fabs(myStats->robustNfit - realNfitWithMask) < = 2.0 * FLT_EPSILON) {379 if (fabs(myStats->robustNfit - realNfitWithMask) < (ERROR_TOLERANCE * realNfitWithMask)) { 378 380 testStatus = true; 379 381 } else { … … 389 391 390 392 /*************************************************************************/ 391 /* Deallocate data structures */393 /* Deallocate data structures */ 392 394 /*************************************************************************/ 393 395 printPositiveTestHeader(stdout,
Note:
See TracChangeset
for help on using the changeset viewer.
