Changeset 889
- Timestamp:
- Jun 6, 2004, 2:32:53 PM (22 years ago)
- Location:
- trunk/psLib/src
- Files:
-
- 18 edited
-
dataManip/psFunctions.c (modified) (10 diffs)
-
dataManip/psFunctions.h (modified) (5 diffs)
-
dataManip/psStats.c (modified) (26 diffs)
-
dataManip/psStats.h (modified) (2 diffs)
-
image/psImage.c (modified) (1 diff)
-
image/psImageStats.c (modified) (12 diffs)
-
imageops/psImageStats.c (modified) (12 diffs)
-
math/psPolynomial.c (modified) (10 diffs)
-
math/psPolynomial.h (modified) (5 diffs)
-
math/psSpline.c (modified) (10 diffs)
-
math/psSpline.h (modified) (5 diffs)
-
math/psStats.c (modified) (26 diffs)
-
math/psStats.h (modified) (2 diffs)
-
mathtypes/psImage.c (modified) (1 diff)
-
sys/psLogMsg.c (modified) (1 diff)
-
sysUtils/psHash.c (modified) (3 diffs)
-
sysUtils/psHash.h (modified) (1 diff)
-
sysUtils/psLogMsg.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/dataManip/psFunctions.c
r845 r889 6 6 * @author George Gusciora, MHPCC 7 7 * 8 * @version $Revision: 1.1 0$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-06-0 4 01:03:11$8 * @version $Revision: 1.11 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-06-07 00:32:53 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 71 71 routines for generating both uniformly distributed numbers and the 72 72 Gaussian distribution as well. 73 74 GUS: There is no way to seed the random generator. 73 75 *****************************************************************************/ 74 76 psVector *psGaussianDev(float mean, … … 82 84 83 85 gauss = psVectorAlloc(Npts, PS_TYPE_F32); 86 gauss->n = Npts; 84 87 gsl_rng_env_setup(); 85 88 T = gsl_rng_default; … … 120 123 newPoly->nY = nY; 121 124 122 newPoly->coeff = (float **) psAlloc(nX * sizeof(float ));123 newPoly->coeffErr = (float **) psAlloc(nX * sizeof(float ));124 newPoly->mask = (char **) psAlloc(nX * sizeof(char ));125 newPoly->coeff = (float **) psAlloc(nX * sizeof(float *)); 126 newPoly->coeffErr = (float **) psAlloc(nX * sizeof(float *)); 127 newPoly->mask = (char **) psAlloc(nX * sizeof(char *)); 125 128 for (x=0;x<nX;x++) { 126 129 newPoly->coeff[x] = (float *) psAlloc(nY * sizeof(float)); … … 129 132 } 130 133 134 131 135 return(newPoly); 132 136 } … … 143 147 newPoly->nZ = nZ; 144 148 145 newPoly->coeff = (float ***) psAlloc(nX * sizeof(float ));146 newPoly->coeffErr = (float ***) psAlloc(nX * sizeof(float ));147 newPoly->mask = (char ***) psAlloc(nX * sizeof(char ));149 newPoly->coeff = (float ***) psAlloc(nX * sizeof(float **)); 150 newPoly->coeffErr = (float ***) psAlloc(nX * sizeof(float **)); 151 newPoly->mask = (char ***) psAlloc(nX * sizeof(char **)); 148 152 for (x=0;x<nX;x++) { 149 newPoly->coeff[x] = (float **) psAlloc(nY * sizeof(float ));150 newPoly->coeffErr[x] = (float **) psAlloc(nY * sizeof(float ));151 newPoly->mask[x] = (char **) psAlloc(nY * sizeof(char ));153 newPoly->coeff[x] = (float **) psAlloc(nY * sizeof(float *)); 154 newPoly->coeffErr[x] = (float **) psAlloc(nY * sizeof(float *)); 155 newPoly->mask[x] = (char **) psAlloc(nY * sizeof(char *)); 152 156 for (y=0;y<nY;y++) { 153 157 newPoly->coeff[x][y] = (float *) psAlloc(nZ * sizeof(float)); … … 173 177 newPoly->nZ = nZ; 174 178 175 newPoly->coeff = (float ****) psAlloc(nW * sizeof(float ));176 newPoly->coeffErr = (float ****) psAlloc(nW * sizeof(float ));177 newPoly->mask = (char ****) psAlloc(nW * sizeof(char ));179 newPoly->coeff = (float ****) psAlloc(nW * sizeof(float ***)); 180 newPoly->coeffErr = (float ****) psAlloc(nW * sizeof(float ***)); 181 newPoly->mask = (char ****) psAlloc(nW * sizeof(char ***)); 178 182 for (w=0;w<nW;w++) { 179 newPoly->coeff[w] = (float ***) psAlloc(nX * sizeof(float ));180 newPoly->coeffErr[w] = (float ***) psAlloc(nX * sizeof(float ));181 newPoly->mask[w] = (char ***) psAlloc(nX * sizeof(char ));183 newPoly->coeff[w] = (float ***) psAlloc(nX * sizeof(float **)); 184 newPoly->coeffErr[w] = (float ***) psAlloc(nX * sizeof(float **)); 185 newPoly->mask[w] = (char ***) psAlloc(nX * sizeof(char **)); 182 186 for (x=0;x<nX;x++) { 183 newPoly->coeff[w][x] = (float **) psAlloc(nY * sizeof(float ));184 newPoly->coeffErr[w][x] = (float **) psAlloc(nY * sizeof(float ));185 newPoly->mask[w][x] = (char **) psAlloc(nY * sizeof(char ));187 newPoly->coeff[w][x] = (float **) psAlloc(nY * sizeof(float *)); 188 newPoly->coeffErr[w][x] = (float **) psAlloc(nY * sizeof(float *)); 189 newPoly->mask[w][x] = (char **) psAlloc(nY * sizeof(char *)); 186 190 for (y=0;y<nY;y++) { 187 191 newPoly->coeff[w][x][y] = (float *) psAlloc(nZ * sizeof(float)); … … 410 414 newPoly->nY = nY; 411 415 412 newPoly->coeff = (double **) psAlloc(nX * sizeof(double ));413 newPoly->coeffErr = (double **) psAlloc(nX * sizeof(double ));414 newPoly->mask = (char **) psAlloc(nX * sizeof(char ));416 newPoly->coeff = (double **) psAlloc(nX * sizeof(double *)); 417 newPoly->coeffErr = (double **) psAlloc(nX * sizeof(double *)); 418 newPoly->mask = (char **) psAlloc(nX * sizeof(char *)); 415 419 for (x=0;x<nX;x++) { 416 420 newPoly->coeff[x] = (double *) psAlloc(nY * sizeof(double)); … … 433 437 newPoly->nZ = nZ; 434 438 435 newPoly->coeff = (double ***) psAlloc(nX * sizeof(double ));436 newPoly->coeffErr = (double ***) psAlloc(nX * sizeof(double ));437 newPoly->mask = (char ***) psAlloc(nX * sizeof(char ));439 newPoly->coeff = (double ***) psAlloc(nX * sizeof(double **)); 440 newPoly->coeffErr = (double ***) psAlloc(nX * sizeof(double **)); 441 newPoly->mask = (char ***) psAlloc(nX * sizeof(char **)); 438 442 for (x=0;x<nX;x++) { 439 newPoly->coeff[x] = (double **) psAlloc(nY * sizeof(double ));440 newPoly->coeffErr[x] = (double **) psAlloc(nY * sizeof(double ));441 newPoly->mask[x] = (char **) psAlloc(nY * sizeof(char ));443 newPoly->coeff[x] = (double **) psAlloc(nY * sizeof(double *)); 444 newPoly->coeffErr[x] = (double **) psAlloc(nY * sizeof(double *)); 445 newPoly->mask[x] = (char **) psAlloc(nY * sizeof(char *)); 442 446 for (y=0;y<nY;y++) { 443 447 newPoly->coeff[x][y] = (double *) psAlloc(nZ * sizeof(double)); … … 463 467 newPoly->nZ = nZ; 464 468 465 newPoly->coeff = (double ****) psAlloc(nW * sizeof(double ));466 newPoly->coeffErr = (double ****) psAlloc(nW * sizeof(double ));467 newPoly->mask = (char ****) psAlloc(nW * sizeof(char ));469 newPoly->coeff = (double ****) psAlloc(nW * sizeof(double ***)); 470 newPoly->coeffErr = (double ****) psAlloc(nW * sizeof(double ***)); 471 newPoly->mask = (char ****) psAlloc(nW * sizeof(char ***)); 468 472 for (w=0;w<nW;w++) { 469 newPoly->coeff[w] = (double ***) psAlloc(nX * sizeof(double ));470 newPoly->coeffErr[w] = (double ***) psAlloc(nX * sizeof(double ));471 newPoly->mask[w] = (char ***) psAlloc(nX * sizeof(char ));473 newPoly->coeff[w] = (double ***) psAlloc(nX * sizeof(double **)); 474 newPoly->coeffErr[w] = (double ***) psAlloc(nX * sizeof(double **)); 475 newPoly->mask[w] = (char ***) psAlloc(nX * sizeof(char **)); 472 476 for (x=0;x<nX;x++) { 473 newPoly->coeff[w][x] = (double **) psAlloc(nY * sizeof(double ));474 newPoly->coeffErr[w][x] = (double **) psAlloc(nY * sizeof(double ));475 newPoly->mask[w][x] = (char **) psAlloc(nY * sizeof(char ));477 newPoly->coeff[w][x] = (double **) psAlloc(nY * sizeof(double *)); 478 newPoly->coeffErr[w][x] = (double **) psAlloc(nY * sizeof(double *)); 479 newPoly->mask[w][x] = (char **) psAlloc(nY * sizeof(char *)); 476 480 for (y=0;y<nY;y++) { 477 481 newPoly->coeff[w][x][y] = (double *) psAlloc(nZ * sizeof(double)); -
trunk/psLib/src/dataManip/psFunctions.h
r751 r889 18 18 ); 19 19 20 21 psVector *psGaussianDev(float mean, 22 float sigma, 23 int Npts); 24 20 25 /*****************************************************************************/ 21 26 … … 205 210 /** Evaluate 1D polynomial (double precision) */ 206 211 double 207 ps EvalDPolynomial1D(double x, ///< Value at which to evaluate212 psDEvalPolynomial1D(double x, ///< Value at which to evaluate 208 213 const psDPolynomial1D *myPoly ///< Coefficients for the polynomial 209 214 ); … … 211 216 /** Evaluate 2D polynomial (double precision) */ 212 217 double 213 ps EvalDPolynomial2D(double x, ///< Value x at which to evaluate218 psDEvalPolynomial2D(double x, ///< Value x at which to evaluate 214 219 double y, ///< Value y at which to evaluate 215 220 const psDPolynomial2D *myPoly ///< Coefficients for the polynomial … … 218 223 /** Evaluate 3D polynomial (double precision) */ 219 224 double 220 ps EvalDPolynomial3D(double x, ///< Value x at which to evaluate225 psDEvalPolynomial3D(double x, ///< Value x at which to evaluate 221 226 double y, ///< Value y at which to evaluate 222 227 double z, ///< Value z at which to evaluate … … 226 231 /** Evaluate 4D polynomial (double precision) */ 227 232 double 228 ps EvalDPolynomial4D(double w, ///< Value w at which to evaluate233 psDEvalPolynomial4D(double w, ///< Value w at which to evaluate 229 234 double x, ///< Value x at which to evaluate 230 235 double y, ///< Value y at which to evaluate -
trunk/psLib/src/dataManip/psStats.c
r831 r889 85 85 float binSize = 0.0; 86 86 87 if (n == 0) { 88 psAbort(__func__, "psHistogram requested with 0 bins"); 89 } 90 87 91 newHist = (psHistogram *) psAlloc(sizeof(psHistogram)); 88 92 newHist->bounds = psVectorAlloc(n+1, PS_TYPE_F32); 93 newHist->bounds->n = newHist->bounds->nalloc; 94 89 95 binSize = (upper - lower) / (float) n; 90 96 for (i=0;i<n+1;i++) { … … 92 98 } 93 99 newHist->nums = psVectorAlloc(n, PS_TYPE_S32); 100 newHist->nums->n = newHist->nums->nalloc; 101 for (i=0;i<newHist->nums->n;i++) { 102 newHist->nums->data.S32[i] = 0; 103 } 94 104 newHist->minNum = 0; 95 105 newHist->maxNum = 0; … … 99 109 } 100 110 101 111 // When this is called, the number of data elements in bounds 112 // is n. Therefore, the number of bins is n-1. 102 113 psHistogram *psHistogramAllocGeneric(const psVector *restrict bounds) 103 114 { … … 107 118 newHist = (psHistogram *) psAlloc(sizeof(psHistogram)); 108 119 newHist->bounds = psVectorAlloc(bounds->n, PS_TYPE_F32); 120 newHist->bounds->n = newHist->bounds->nalloc; 109 121 for (i=0;i<bounds->n;i++) { 110 122 newHist->bounds->data.F32[i] = bounds->data.F32[i]; 111 123 } 112 124 newHist->nums = psVectorAlloc((bounds->n)-1, PS_TYPE_S32); 125 newHist->nums->n = newHist->nums->nalloc; 126 for (i=0;i<newHist->nums->n;i++) { 127 newHist->nums->data.S32[i] = 0; 128 } 113 129 114 130 newHist->minNum = 0; … … 119 135 } 120 136 121 void psHistogramFree(psHistogram *restrict myHist) 122 { 137 void psHistogramFree(psHistogram *myHist) 138 { 139 psVectorFree(myHist->bounds); 140 psVectorFree(myHist->nums); 123 141 psFree(myHist); 124 142 } … … 150 168 151 169 numBins = out->nums->n; 152 for (i=0;i<in->n;i++) { 153 // Check if this pixel is masked, and if so, skip it. 154 if (!(mask->data.S32[i] & maskVal)) { 155 // Check if this pixel is below the minimum value, and if so 156 // count it, then skip it. 170 171 if (mask != NULL) { 172 for (i=0;i<in->n;i++) { 173 // Check if this pixel is masked, and if so, skip it. 174 if (!(mask->data.U8[i] & maskVal)) { 175 // Check if this pixel is below the minimum value, and if so 176 // count it, then skip it. 177 if (in->data.F32[i] < out->bounds->data.F32[0]) { 178 out->minNum++; 179 180 // Check if this pixel is above the maximum value, and if so 181 // count it, then skip it. 182 } else if (in->data.F32[i] > out->bounds->data.F32[numBins]) { 183 out->maxNum++; 184 } else { 185 // If this is a uniform histogram, determining the correct 186 // number is trivial. 187 if (out->uniform == true) { 188 binSize = out->bounds->data.F32[1] - out->bounds->data.F32[0]; 189 190 binNum = (int) ((in->data.F32[i] - out->bounds->data.F32[0]) / 191 binSize); 192 (out->nums->data.S32[binNum])++; 193 // If this is a non-uniform histogram, determining the correct 194 // bin number requires a bit more work. 195 } else { 196 // GUS: This is slow. Put a smarter algorithm here to 197 // find the correct bin number (bin search, probably) 198 for (j=0;j<(out->bounds->n)-1;j++) { 199 if ((out->bounds->data.S32[j] <= in->data.F32[i]) && 200 (in->data.F32[i] <= out->bounds->data.S32[j+1])) { 201 (out->nums->data.S32[j])++; 202 } 203 } 204 } 205 } 206 } 207 } 208 } else { 209 for (i=0;i<in->n;i++) { 157 210 if (in->data.F32[i] < out->bounds->data.F32[0]) { 211 // Check if this pixel is below the minimum value, and if so 212 // count it, then skip it. 158 213 out->minNum++; 159 214 } else if (in->data.F32[i] > out->bounds->data.F32[numBins]) { 160 215 // Check if this pixel is above the maximum value, and if so 161 216 // count it, then skip it. 162 } else if (in->data.F32[i] > out->bounds->data.F32[numBins]) {163 217 out->maxNum++; 164 218 } else { … … 171 225 binSize); 172 226 (out->nums->data.S32[binNum])++; 227 173 228 // If this is a non-uniform histogram, determining the correct 174 229 // bin number requires a bit more work. … … 185 240 } 186 241 } 242 187 243 } 188 244 return(out); … … 471 527 unsortedVector = psVectorAlloc(nValues, PS_TYPE_F32); 472 528 unsortedVector->n = unsortedVector->nalloc; 529 473 530 sortedVector = psVectorAlloc(nValues, PS_TYPE_F32); 474 531 sortedVector->n = sortedVector->nalloc; … … 494 551 if ((rangeMin <= myVector->data.F32[i]) && 495 552 (myVector->data.F32[i] <= rangeMax)) { 496 unsortedVector->data.F32[count++] = m askVector->data.F32[i];553 unsortedVector->data.F32[count++] = myVector->data.F32[i]; 497 554 } 498 555 } … … 504 561 for (i=0;i<myVector->n;i++) { 505 562 if (!(maskVal & maskVector->data.U8[i])) { 506 unsortedVector->data.F32[count++] = m askVector->data.F32[i];507 } 508 } 509 } else { 510 for (i=0;i<myVector->n;i++) { 511 unsortedVector->data.F32[i] = m askVector->data.F32[i];563 unsortedVector->data.F32[count++] = myVector->data.F32[i]; 564 } 565 } 566 } else { 567 for (i=0;i<myVector->n;i++) { 568 unsortedVector->data.F32[i] = myVector->data.F32[i]; 512 569 } 513 570 } … … 596 653 float rangeMin = 0.0; 597 654 float rangeMax = 0.0; 598 psStats *stats2 = NULL;599 655 600 656 // Determine if the number of data points exceed a threshold which will 601 657 // cause to generate robust stats, as opposed to exact stats. 602 if (myVector->n > stats->sampleLimit) { 603 // Calculate the robust quartiles. 604 stats2 = psStatsAlloc(PS_STAT_ROBUST_QUARTILE); 605 p_psVectorRobustStats(myVector, maskVector, maskVal, stats2); 606 607 // Store the robust quartiles into the sample quartile members. 608 stats->sampleUQ = stats2->robustUQ; 609 stats->sampleLQ = stats2->robustLQ; 610 611 // Free temporary data buffers. 612 psStatsFree(stats2); 613 614 // Set the PS_STAT_ROBUST_FOR_SAMPLE bit in the stats structure. 615 stats->options = stats->options | PS_STAT_ROBUST_FOR_SAMPLE; 616 617 return; 618 } 658 /* GUS: When IfA provides the algorithm, insert is here. 659 if (myVector->n > stats->sampleLimit) { 660 psStats *stats2 = NULL; 661 // Calculate the robust quartiles. 662 stats2 = psStatsAlloc(PS_STAT_ROBUST_QUARTILE); 663 p_psVectorRobustStats(myVector, maskVector, maskVal, stats2); 664 665 // Store the robust quartiles into the sample quartile members. 666 stats->sampleUQ = stats2->robustUQ; 667 stats->sampleLQ = stats2->robustLQ; 668 669 // Free temporary data buffers. 670 psStatsFree(stats2); 671 672 // Set the PS_STAT_ROBUST_FOR_SAMPLE bit in the stats structure. 673 stats->options = stats->options | PS_STAT_ROBUST_FOR_SAMPLE; 674 675 return; 676 } 677 */ 619 678 620 679 // Determine how many data points fit inside this min/max range … … 640 699 (rangeMin <= myVector->data.F32[i]) && 641 700 (myVector->data.F32[i] <= rangeMax)) { 642 unsortedVector->data.F32[count++] = m askVector->data.F32[i];701 unsortedVector->data.F32[count++] = myVector->data.F32[i]; 643 702 } 644 703 } … … 647 706 if ((rangeMin <= myVector->data.F32[i]) && 648 707 (myVector->data.F32[i] <= rangeMax)) { 649 unsortedVector->data.F32[count++] = m askVector->data.F32[i];708 unsortedVector->data.F32[count++] = myVector->data.F32[i]; 650 709 } 651 710 } … … 657 716 for (i=0;i<myVector->n;i++) { 658 717 if (!(maskVal & maskVector->data.U8[i])) { 659 unsortedVector->data.F32[count++] = m askVector->data.F32[i];660 } 661 } 662 } else { 663 for (i=0;i<myVector->n;i++) { 664 unsortedVector->data.F32[i] = m askVector->data.F32[i];718 unsortedVector->data.F32[count++] = myVector->data.F32[i]; 719 } 720 } 721 } else { 722 for (i=0;i<myVector->n;i++) { 723 unsortedVector->data.F32[i] = myVector->data.F32[i]; 665 724 } 666 725 } … … 679 738 psVectorFree(unsortedVector); 680 739 psVectorFree(sortedVector); 740 // GUS: This is the 681 741 } 682 742 … … 691 751 PS_STAT_ROBUST_QUARTILE 692 752 I have included all that computation in a single function, as opposed to 693 breaking it across several functions for one primary reason: the all753 breaking it across several functions for one primary reason: they all 694 754 require the same basic initial processing steps (calculate the histogram, 695 755 etc.) however there is no currently defined means, in the SDRS, to … … 719 779 // is really required. 720 780 721 if (0.0 == stats->sampleUQ) { 722 723 // GUS: fix this 724 // stats->options = stats->options | PS_STAT_SAMPLE_UQ; 781 if (isnan(stats->sampleUQ) || 782 isnan(stats->sampleLQ)) { 783 stats->options = stats->options | PS_STAT_SAMPLE_QUARTILE; 725 784 p_psVectorSampleQuartiles(myVector, 726 785 maskVector, … … 729 788 } 730 789 731 if (isnan(stats->sampleLQ)) {732 // GUS: fix this733 // stats->options = stats->options | PS_STAT_SAMPLE_LQ;734 p_psVectorSampleQuartiles(myVector,735 maskVector,736 maskVal,737 stats);738 }739 740 790 // Compute the initial bin size of the robust histogram. 741 791 sigmaE = (stats->sampleUQ - stats->sampleLQ) / 1.34f; … … 753 803 robustHistogram = psHistogramAlloc(stats->min, 754 804 stats->max, 755 binSize); 756 // Populate the histogram arrat. 805 1 + (int) ((stats->max - stats->min) / binSize)); 806 807 808 // Populate the histogram array. 757 809 // GUS: fix this 758 810 // robustHistogram = psHistogramVector(robustHistogram, myVector); … … 811 863 stats->robustLQ = 0.0; 812 864 } 865 stats->robustNfit = 0.0; 866 stats->robustN50 = 0.0; 867 psHistogramFree(robustHistogram); 813 868 } 814 869 … … 836 891 837 892 if (0 != isnan(stats->sampleMean)) { 838 p sAbort(__func__, "stats->sampleMean == NAN");893 p_psVectorSampleMean(myVector, maskVector, maskVal, stats); 839 894 } 840 895 mean = stats->sampleMean; … … 920 975 } 921 976 922 tmpMask = psVectorAlloc(myVector->nalloc, maskVector->type.type); 923 924 tmpMask->n = maskVector->n; 925 for (i=0;i<tmpMask->n;i++) { 926 tmpMask->data.U8[i] = maskVector->data.U8[i]; 977 978 tmpMask = psVectorAlloc(myVector->n, PS_TYPE_U8); 979 tmpMask->n = myVector->n; 980 981 if (maskVector != NULL) { 982 for (i=0;i<tmpMask->n;i++) { 983 tmpMask->data.U8[i] = maskVector->data.U8[i]; 984 } 927 985 } 928 986 929 987 // 1. Compute the sample median. 988 // GUS: This seems odd. Verify with IfA that we want to calculate the 989 // median here, not the mean. 930 990 p_psVectorSampleMedian(myVector, maskVector, maskVal, stats); 931 991 … … 942 1002 943 1003 for (i=0;i<stats->clipIter;i++) { 1004 // printf("p_psVectorClippedStats(): Iteration %d (%f %f)\n", i, 1005 // clippedMean, clippedStdev); 944 1006 for (j=0;j<myVector->n;j++) { 945 1007 // a) Exclude all values x_i for which |x_i - x| > K * stdev 946 if ( fabs(myVector->data.F32[j] - clippedMean) >1008 if (fabs(myVector->data.F32[j] - clippedMean) > 947 1009 (stats->clipSigma * clippedStdev)) { 948 1010 tmpMask->data.U8[i] = 0xff; … … 994 1056 if (in->type.type != PS_TYPE_F32) { 995 1057 psAbort(__func__, 996 "Only data type PS_TYPE_F32 is currently supported."); 997 } 1058 "Only data type PS_TYPE_F32 is currently supported (0x%x).", 1059 in->type.type); 1060 } 1061 998 1062 if (mask != NULL) { 999 1063 if (in->n != mask->n) { … … 1018 1082 1019 1083 // ************************************************************************ 1084 // GUS: The Stdev calculation requires the mean. Should we assume the 1085 // mean has already been calculated? Or should we always calculate it? 1020 1086 if (stats->options & PS_STAT_SAMPLE_STDEV) { 1087 p_psVectorSampleMean(in, mask, maskVal, stats); 1021 1088 p_psVectorSampleStdev(in, mask, maskVal, stats); 1022 1089 } -
trunk/psLib/src/dataManip/psStats.h
r797 r889 81 81 typedef struct 82 82 { 83 const psVector *restrict bounds;///< Bounds for the bins (type F32)83 psVector *bounds; ///< Bounds for the bins (type F32) 84 84 psVector *nums; ///< Number in each of the bins (INT) 85 85 int minNum; ///< Number below the minimum … … 102 102 103 103 /** Destructor \ingroup MathGroup **/ 104 void psHistogramFree(psHistogram * restrictmyHist); ///< Histogram to destroy104 void psHistogramFree(psHistogram *myHist); ///< Histogram to destroy 105 105 106 106 -
trunk/psLib/src/image/psImage.c
r859 r889 9 9 * @author Ross Harman, MHPCC 10 10 * 11 * @version $Revision: 1.2 4$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-06-0 4 03:15:47$11 * @version $Revision: 1.25 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-06-07 00:32:53 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 15 * 16 * That is the routine used to generate matrices. 15 17 */ 16 18 -
trunk/psLib/src/image/psImageStats.c
r831 r889 19 19 20 20 /// This routine must determine the various statistics for the image. 21 /***************************************************************************** 22 GUS: verify that image/mask have the 23 correct types 24 sizes 25 *****************************************************************************/ 21 26 psStats *psImageStats(psStats *stats, 22 27 psImage *in, … … 26 31 psVector *junkData=NULL; 27 32 psVector *junkMask=NULL; 33 int ptr = 0; 34 int i = 0; 35 int j = 0; 28 36 29 37 junkData = psVectorAlloc(in->numRows * in->numCols, in->type.type); 30 junkMask = psVectorAlloc(mask->numRows * mask->numCols, mask->type.type); 31 32 // GUS: figure out mask types 33 junkData->data.F32 = (float *) in->data.F32; 34 junkMask->data.F32 = (float *) mask->data.F32; 35 stats = psVectorStats(stats, junkData, junkMask, maskVal); 38 junkData->n = junkData->nalloc; 39 ptr=0; 40 for (i=0;i<in->numRows;i++) { 41 for (j=0;j<in->numCols;j++) { 42 junkData->data.F32[ptr++] = in->data.F32[i][j]; 43 } 44 } 45 46 if (mask != NULL) { 47 // GUS: verify that mask data is PS_TYPE_U8. 48 // GUS: figure out mask types 49 50 junkMask = psVectorAlloc(mask->numRows * mask->numCols, 51 mask->type.type); 52 junkMask->n = junkMask->nalloc; 53 // GUS: Is there a more efficient way to do this? 54 ptr=0; 55 for (i=0;i<mask->numRows;i++) { 56 for (j=0;j<mask->numCols;j++) { 57 junkMask->data.U8[ptr++] = mask->data.U8[i][j]; 58 } 59 } 60 61 stats = psVectorStats(stats, junkData, junkMask, maskVal); 62 psVectorFree(junkMask); 63 } else { 64 stats = psVectorStats(stats, junkData, NULL, 0); 65 } 36 66 37 67 psVectorFree(junkData); 38 psVectorFree(junkMask);39 68 40 69 return(stats); … … 44 73 NOTE: We assume that the psHistogram structure out has already been 45 74 allocated and initialized. 75 76 GUS: verify that image/mask have the 77 correct types 78 sizes 46 79 *****************************************************************************/ 47 80 psHistogram *psImageHistogram(psHistogram *out, … … 52 85 psVector *junkData=NULL; 53 86 psVector *junkMask=NULL; 87 int ptr = 0; 88 int i = 0; 89 int j = 0; 54 90 55 91 junkData = psVectorAlloc(in->numRows * in->numCols, in->type.type); 56 junkMask = psVectorAlloc(mask->numRows * mask->numCols, mask->type.type); 57 58 // GUS: figure out mask types 59 junkData->data.F32 = (float *) in->data.F32; 60 junkMask->data.F32 = (float *) mask->data.F32; 61 62 out = psHistogramVector(out, junkData, junkMask, maskVal); 63 92 junkData->n = junkData->nalloc; 93 94 // GUS: Is there a more efficient way to do this? memcopy() won't work. 95 // Can we trick the junkData structure to use the image buffer, then 96 // untrick it before we deallocate it (so we won't deallocate that buffer 97 // twice? 98 99 // GUS: Make sure you have the numRows/NumCols in the right place. 100 ptr=0; 101 for (i=0;i<in->numRows;i++) { 102 for (j=0;j<in->numCols;j++) { 103 junkData->data.F32[ptr++] = in->data.F32[i][j]; 104 } 105 } 106 107 if (mask != NULL) { 108 // GUS: verify that mask data is PS_TYPE_U8. 109 // GUS: figure out mask types 110 111 junkMask = psVectorAlloc(mask->numRows * mask->numCols, 112 mask->type.type); 113 junkMask->n = junkMask->nalloc; 114 115 // GUS: Is there a more efficient way to do this? 116 ptr=0; 117 for (i=0;i<mask->numRows;i++) { 118 for (j=0;j<mask->numCols;j++) { 119 junkMask->data.U8[ptr++] = mask->data.U8[i][j]; 120 } 121 } 122 out = psHistogramVector(out, junkData, junkMask, maskVal); 123 psVectorFree(junkMask); 124 } else { 125 out = psHistogramVector(out, junkData, NULL, 0); 126 } 64 127 psVectorFree(junkData); 65 psVectorFree(junkMask);66 128 67 129 return(out); … … 91 153 int maxChebyPoly = 0; 92 154 155 93 156 // Create the sums[][] data structure. This will hold the LHS of equation 94 157 // 29 in the ADD: sums[k][l] = SUM { image(x,y) * Tk(x) * Tl(y) } 158 95 159 sums = (float **) psAlloc(coeffs->nX * sizeof(float *)); 96 160 for (i=0;i<coeffs->nX;i++) { … … 105 169 // Determine how many Chebyshev polynomials are needed, then create them. 106 170 maxChebyPoly = coeffs->nX; 107 if (coeffs->n X > coeffs->nY) {171 if (coeffs->nY > coeffs->nX) { 108 172 maxChebyPoly = coeffs->nY; 109 173 } … … 133 197 psEvalPolynomial1D((float) x, chebPolys[i]) * 134 198 psEvalPolynomial1D((float) y, chebPolys[j]); 199 135 200 } 136 201 } … … 160 225 } 161 226 162 163 227 // Free the Chebyshev polynomials that were created in this routine. 164 228 for (i=0;i<maxChebyPoly;i++) { 165 psFree(chebPolys[i]); 166 } 229 psPolynomial1DFree(chebPolys[i]); 230 } 231 psFree(chebPolys); 232 233 // Free some data 234 for (i=0;i<coeffs->nX;i++) { 235 psFree(sums[i]); 236 } 237 psFree(sums); 167 238 168 239 return(coeffs); … … 199 270 // Determine how many Chebyshev polynomials are needed, then create them. 200 271 maxChebyPoly = coeffs->nX; 201 if (coeffs->n X > coeffs->nY) {272 if (coeffs->nY > coeffs->nX) { 202 273 maxChebyPoly = coeffs->nY; 203 274 } … … 219 290 } 220 291 } 221 222 292 223 293 for (x=0;x<input->numRows;x++) { … … 227 297 for (j=0;j<coeffs->nY;j++) { 228 298 polySum+= psEvalPolynomial1D((float)x, chebPolys[i]) * 229 psEvalPolynomial1D((float)y, chebPolys[ y]) *299 psEvalPolynomial1D((float)y, chebPolys[j]) * 230 300 coeffs->coeff[i][j]; 231 232 301 } 233 302 } … … 236 305 } 237 306 238 239 307 // Free the Chebyshev polynomials that were created in this routine. 240 308 for (i=0;i<maxChebyPoly;i++) { 241 psFree(chebPolys[i]); 242 } 309 psPolynomial1DFree(chebPolys[i]); 310 } 311 psFree(chebPolys); 312 313 // Free some data 314 for (i=0;i<coeffs->nX;i++) { 315 psFree(sums[i]); 316 } 317 psFree(sums); 243 318 244 319 return(0); -
trunk/psLib/src/imageops/psImageStats.c
r831 r889 19 19 20 20 /// This routine must determine the various statistics for the image. 21 /***************************************************************************** 22 GUS: verify that image/mask have the 23 correct types 24 sizes 25 *****************************************************************************/ 21 26 psStats *psImageStats(psStats *stats, 22 27 psImage *in, … … 26 31 psVector *junkData=NULL; 27 32 psVector *junkMask=NULL; 33 int ptr = 0; 34 int i = 0; 35 int j = 0; 28 36 29 37 junkData = psVectorAlloc(in->numRows * in->numCols, in->type.type); 30 junkMask = psVectorAlloc(mask->numRows * mask->numCols, mask->type.type); 31 32 // GUS: figure out mask types 33 junkData->data.F32 = (float *) in->data.F32; 34 junkMask->data.F32 = (float *) mask->data.F32; 35 stats = psVectorStats(stats, junkData, junkMask, maskVal); 38 junkData->n = junkData->nalloc; 39 ptr=0; 40 for (i=0;i<in->numRows;i++) { 41 for (j=0;j<in->numCols;j++) { 42 junkData->data.F32[ptr++] = in->data.F32[i][j]; 43 } 44 } 45 46 if (mask != NULL) { 47 // GUS: verify that mask data is PS_TYPE_U8. 48 // GUS: figure out mask types 49 50 junkMask = psVectorAlloc(mask->numRows * mask->numCols, 51 mask->type.type); 52 junkMask->n = junkMask->nalloc; 53 // GUS: Is there a more efficient way to do this? 54 ptr=0; 55 for (i=0;i<mask->numRows;i++) { 56 for (j=0;j<mask->numCols;j++) { 57 junkMask->data.U8[ptr++] = mask->data.U8[i][j]; 58 } 59 } 60 61 stats = psVectorStats(stats, junkData, junkMask, maskVal); 62 psVectorFree(junkMask); 63 } else { 64 stats = psVectorStats(stats, junkData, NULL, 0); 65 } 36 66 37 67 psVectorFree(junkData); 38 psVectorFree(junkMask);39 68 40 69 return(stats); … … 44 73 NOTE: We assume that the psHistogram structure out has already been 45 74 allocated and initialized. 75 76 GUS: verify that image/mask have the 77 correct types 78 sizes 46 79 *****************************************************************************/ 47 80 psHistogram *psImageHistogram(psHistogram *out, … … 52 85 psVector *junkData=NULL; 53 86 psVector *junkMask=NULL; 87 int ptr = 0; 88 int i = 0; 89 int j = 0; 54 90 55 91 junkData = psVectorAlloc(in->numRows * in->numCols, in->type.type); 56 junkMask = psVectorAlloc(mask->numRows * mask->numCols, mask->type.type); 57 58 // GUS: figure out mask types 59 junkData->data.F32 = (float *) in->data.F32; 60 junkMask->data.F32 = (float *) mask->data.F32; 61 62 out = psHistogramVector(out, junkData, junkMask, maskVal); 63 92 junkData->n = junkData->nalloc; 93 94 // GUS: Is there a more efficient way to do this? memcopy() won't work. 95 // Can we trick the junkData structure to use the image buffer, then 96 // untrick it before we deallocate it (so we won't deallocate that buffer 97 // twice? 98 99 // GUS: Make sure you have the numRows/NumCols in the right place. 100 ptr=0; 101 for (i=0;i<in->numRows;i++) { 102 for (j=0;j<in->numCols;j++) { 103 junkData->data.F32[ptr++] = in->data.F32[i][j]; 104 } 105 } 106 107 if (mask != NULL) { 108 // GUS: verify that mask data is PS_TYPE_U8. 109 // GUS: figure out mask types 110 111 junkMask = psVectorAlloc(mask->numRows * mask->numCols, 112 mask->type.type); 113 junkMask->n = junkMask->nalloc; 114 115 // GUS: Is there a more efficient way to do this? 116 ptr=0; 117 for (i=0;i<mask->numRows;i++) { 118 for (j=0;j<mask->numCols;j++) { 119 junkMask->data.U8[ptr++] = mask->data.U8[i][j]; 120 } 121 } 122 out = psHistogramVector(out, junkData, junkMask, maskVal); 123 psVectorFree(junkMask); 124 } else { 125 out = psHistogramVector(out, junkData, NULL, 0); 126 } 64 127 psVectorFree(junkData); 65 psVectorFree(junkMask);66 128 67 129 return(out); … … 91 153 int maxChebyPoly = 0; 92 154 155 93 156 // Create the sums[][] data structure. This will hold the LHS of equation 94 157 // 29 in the ADD: sums[k][l] = SUM { image(x,y) * Tk(x) * Tl(y) } 158 95 159 sums = (float **) psAlloc(coeffs->nX * sizeof(float *)); 96 160 for (i=0;i<coeffs->nX;i++) { … … 105 169 // Determine how many Chebyshev polynomials are needed, then create them. 106 170 maxChebyPoly = coeffs->nX; 107 if (coeffs->n X > coeffs->nY) {171 if (coeffs->nY > coeffs->nX) { 108 172 maxChebyPoly = coeffs->nY; 109 173 } … … 133 197 psEvalPolynomial1D((float) x, chebPolys[i]) * 134 198 psEvalPolynomial1D((float) y, chebPolys[j]); 199 135 200 } 136 201 } … … 160 225 } 161 226 162 163 227 // Free the Chebyshev polynomials that were created in this routine. 164 228 for (i=0;i<maxChebyPoly;i++) { 165 psFree(chebPolys[i]); 166 } 229 psPolynomial1DFree(chebPolys[i]); 230 } 231 psFree(chebPolys); 232 233 // Free some data 234 for (i=0;i<coeffs->nX;i++) { 235 psFree(sums[i]); 236 } 237 psFree(sums); 167 238 168 239 return(coeffs); … … 199 270 // Determine how many Chebyshev polynomials are needed, then create them. 200 271 maxChebyPoly = coeffs->nX; 201 if (coeffs->n X > coeffs->nY) {272 if (coeffs->nY > coeffs->nX) { 202 273 maxChebyPoly = coeffs->nY; 203 274 } … … 219 290 } 220 291 } 221 222 292 223 293 for (x=0;x<input->numRows;x++) { … … 227 297 for (j=0;j<coeffs->nY;j++) { 228 298 polySum+= psEvalPolynomial1D((float)x, chebPolys[i]) * 229 psEvalPolynomial1D((float)y, chebPolys[ y]) *299 psEvalPolynomial1D((float)y, chebPolys[j]) * 230 300 coeffs->coeff[i][j]; 231 232 301 } 233 302 } … … 236 305 } 237 306 238 239 307 // Free the Chebyshev polynomials that were created in this routine. 240 308 for (i=0;i<maxChebyPoly;i++) { 241 psFree(chebPolys[i]); 242 } 309 psPolynomial1DFree(chebPolys[i]); 310 } 311 psFree(chebPolys); 312 313 // Free some data 314 for (i=0;i<coeffs->nX;i++) { 315 psFree(sums[i]); 316 } 317 psFree(sums); 243 318 244 319 return(0); -
trunk/psLib/src/math/psPolynomial.c
r845 r889 6 6 * @author George Gusciora, MHPCC 7 7 * 8 * @version $Revision: 1.1 0$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-06-0 4 01:03:11$8 * @version $Revision: 1.11 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-06-07 00:32:53 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 71 71 routines for generating both uniformly distributed numbers and the 72 72 Gaussian distribution as well. 73 74 GUS: There is no way to seed the random generator. 73 75 *****************************************************************************/ 74 76 psVector *psGaussianDev(float mean, … … 82 84 83 85 gauss = psVectorAlloc(Npts, PS_TYPE_F32); 86 gauss->n = Npts; 84 87 gsl_rng_env_setup(); 85 88 T = gsl_rng_default; … … 120 123 newPoly->nY = nY; 121 124 122 newPoly->coeff = (float **) psAlloc(nX * sizeof(float ));123 newPoly->coeffErr = (float **) psAlloc(nX * sizeof(float ));124 newPoly->mask = (char **) psAlloc(nX * sizeof(char ));125 newPoly->coeff = (float **) psAlloc(nX * sizeof(float *)); 126 newPoly->coeffErr = (float **) psAlloc(nX * sizeof(float *)); 127 newPoly->mask = (char **) psAlloc(nX * sizeof(char *)); 125 128 for (x=0;x<nX;x++) { 126 129 newPoly->coeff[x] = (float *) psAlloc(nY * sizeof(float)); … … 129 132 } 130 133 134 131 135 return(newPoly); 132 136 } … … 143 147 newPoly->nZ = nZ; 144 148 145 newPoly->coeff = (float ***) psAlloc(nX * sizeof(float ));146 newPoly->coeffErr = (float ***) psAlloc(nX * sizeof(float ));147 newPoly->mask = (char ***) psAlloc(nX * sizeof(char ));149 newPoly->coeff = (float ***) psAlloc(nX * sizeof(float **)); 150 newPoly->coeffErr = (float ***) psAlloc(nX * sizeof(float **)); 151 newPoly->mask = (char ***) psAlloc(nX * sizeof(char **)); 148 152 for (x=0;x<nX;x++) { 149 newPoly->coeff[x] = (float **) psAlloc(nY * sizeof(float ));150 newPoly->coeffErr[x] = (float **) psAlloc(nY * sizeof(float ));151 newPoly->mask[x] = (char **) psAlloc(nY * sizeof(char ));153 newPoly->coeff[x] = (float **) psAlloc(nY * sizeof(float *)); 154 newPoly->coeffErr[x] = (float **) psAlloc(nY * sizeof(float *)); 155 newPoly->mask[x] = (char **) psAlloc(nY * sizeof(char *)); 152 156 for (y=0;y<nY;y++) { 153 157 newPoly->coeff[x][y] = (float *) psAlloc(nZ * sizeof(float)); … … 173 177 newPoly->nZ = nZ; 174 178 175 newPoly->coeff = (float ****) psAlloc(nW * sizeof(float ));176 newPoly->coeffErr = (float ****) psAlloc(nW * sizeof(float ));177 newPoly->mask = (char ****) psAlloc(nW * sizeof(char ));179 newPoly->coeff = (float ****) psAlloc(nW * sizeof(float ***)); 180 newPoly->coeffErr = (float ****) psAlloc(nW * sizeof(float ***)); 181 newPoly->mask = (char ****) psAlloc(nW * sizeof(char ***)); 178 182 for (w=0;w<nW;w++) { 179 newPoly->coeff[w] = (float ***) psAlloc(nX * sizeof(float ));180 newPoly->coeffErr[w] = (float ***) psAlloc(nX * sizeof(float ));181 newPoly->mask[w] = (char ***) psAlloc(nX * sizeof(char ));183 newPoly->coeff[w] = (float ***) psAlloc(nX * sizeof(float **)); 184 newPoly->coeffErr[w] = (float ***) psAlloc(nX * sizeof(float **)); 185 newPoly->mask[w] = (char ***) psAlloc(nX * sizeof(char **)); 182 186 for (x=0;x<nX;x++) { 183 newPoly->coeff[w][x] = (float **) psAlloc(nY * sizeof(float ));184 newPoly->coeffErr[w][x] = (float **) psAlloc(nY * sizeof(float ));185 newPoly->mask[w][x] = (char **) psAlloc(nY * sizeof(char ));187 newPoly->coeff[w][x] = (float **) psAlloc(nY * sizeof(float *)); 188 newPoly->coeffErr[w][x] = (float **) psAlloc(nY * sizeof(float *)); 189 newPoly->mask[w][x] = (char **) psAlloc(nY * sizeof(char *)); 186 190 for (y=0;y<nY;y++) { 187 191 newPoly->coeff[w][x][y] = (float *) psAlloc(nZ * sizeof(float)); … … 410 414 newPoly->nY = nY; 411 415 412 newPoly->coeff = (double **) psAlloc(nX * sizeof(double ));413 newPoly->coeffErr = (double **) psAlloc(nX * sizeof(double ));414 newPoly->mask = (char **) psAlloc(nX * sizeof(char ));416 newPoly->coeff = (double **) psAlloc(nX * sizeof(double *)); 417 newPoly->coeffErr = (double **) psAlloc(nX * sizeof(double *)); 418 newPoly->mask = (char **) psAlloc(nX * sizeof(char *)); 415 419 for (x=0;x<nX;x++) { 416 420 newPoly->coeff[x] = (double *) psAlloc(nY * sizeof(double)); … … 433 437 newPoly->nZ = nZ; 434 438 435 newPoly->coeff = (double ***) psAlloc(nX * sizeof(double ));436 newPoly->coeffErr = (double ***) psAlloc(nX * sizeof(double ));437 newPoly->mask = (char ***) psAlloc(nX * sizeof(char ));439 newPoly->coeff = (double ***) psAlloc(nX * sizeof(double **)); 440 newPoly->coeffErr = (double ***) psAlloc(nX * sizeof(double **)); 441 newPoly->mask = (char ***) psAlloc(nX * sizeof(char **)); 438 442 for (x=0;x<nX;x++) { 439 newPoly->coeff[x] = (double **) psAlloc(nY * sizeof(double ));440 newPoly->coeffErr[x] = (double **) psAlloc(nY * sizeof(double ));441 newPoly->mask[x] = (char **) psAlloc(nY * sizeof(char ));443 newPoly->coeff[x] = (double **) psAlloc(nY * sizeof(double *)); 444 newPoly->coeffErr[x] = (double **) psAlloc(nY * sizeof(double *)); 445 newPoly->mask[x] = (char **) psAlloc(nY * sizeof(char *)); 442 446 for (y=0;y<nY;y++) { 443 447 newPoly->coeff[x][y] = (double *) psAlloc(nZ * sizeof(double)); … … 463 467 newPoly->nZ = nZ; 464 468 465 newPoly->coeff = (double ****) psAlloc(nW * sizeof(double ));466 newPoly->coeffErr = (double ****) psAlloc(nW * sizeof(double ));467 newPoly->mask = (char ****) psAlloc(nW * sizeof(char ));469 newPoly->coeff = (double ****) psAlloc(nW * sizeof(double ***)); 470 newPoly->coeffErr = (double ****) psAlloc(nW * sizeof(double ***)); 471 newPoly->mask = (char ****) psAlloc(nW * sizeof(char ***)); 468 472 for (w=0;w<nW;w++) { 469 newPoly->coeff[w] = (double ***) psAlloc(nX * sizeof(double ));470 newPoly->coeffErr[w] = (double ***) psAlloc(nX * sizeof(double ));471 newPoly->mask[w] = (char ***) psAlloc(nX * sizeof(char ));473 newPoly->coeff[w] = (double ***) psAlloc(nX * sizeof(double **)); 474 newPoly->coeffErr[w] = (double ***) psAlloc(nX * sizeof(double **)); 475 newPoly->mask[w] = (char ***) psAlloc(nX * sizeof(char **)); 472 476 for (x=0;x<nX;x++) { 473 newPoly->coeff[w][x] = (double **) psAlloc(nY * sizeof(double ));474 newPoly->coeffErr[w][x] = (double **) psAlloc(nY * sizeof(double ));475 newPoly->mask[w][x] = (char **) psAlloc(nY * sizeof(char ));477 newPoly->coeff[w][x] = (double **) psAlloc(nY * sizeof(double *)); 478 newPoly->coeffErr[w][x] = (double **) psAlloc(nY * sizeof(double *)); 479 newPoly->mask[w][x] = (char **) psAlloc(nY * sizeof(char *)); 476 480 for (y=0;y<nY;y++) { 477 481 newPoly->coeff[w][x][y] = (double *) psAlloc(nZ * sizeof(double)); -
trunk/psLib/src/math/psPolynomial.h
r751 r889 18 18 ); 19 19 20 21 psVector *psGaussianDev(float mean, 22 float sigma, 23 int Npts); 24 20 25 /*****************************************************************************/ 21 26 … … 205 210 /** Evaluate 1D polynomial (double precision) */ 206 211 double 207 ps EvalDPolynomial1D(double x, ///< Value at which to evaluate212 psDEvalPolynomial1D(double x, ///< Value at which to evaluate 208 213 const psDPolynomial1D *myPoly ///< Coefficients for the polynomial 209 214 ); … … 211 216 /** Evaluate 2D polynomial (double precision) */ 212 217 double 213 ps EvalDPolynomial2D(double x, ///< Value x at which to evaluate218 psDEvalPolynomial2D(double x, ///< Value x at which to evaluate 214 219 double y, ///< Value y at which to evaluate 215 220 const psDPolynomial2D *myPoly ///< Coefficients for the polynomial … … 218 223 /** Evaluate 3D polynomial (double precision) */ 219 224 double 220 ps EvalDPolynomial3D(double x, ///< Value x at which to evaluate225 psDEvalPolynomial3D(double x, ///< Value x at which to evaluate 221 226 double y, ///< Value y at which to evaluate 222 227 double z, ///< Value z at which to evaluate … … 226 231 /** Evaluate 4D polynomial (double precision) */ 227 232 double 228 ps EvalDPolynomial4D(double w, ///< Value w at which to evaluate233 psDEvalPolynomial4D(double w, ///< Value w at which to evaluate 229 234 double x, ///< Value x at which to evaluate 230 235 double y, ///< Value y at which to evaluate -
trunk/psLib/src/math/psSpline.c
r845 r889 6 6 * @author George Gusciora, MHPCC 7 7 * 8 * @version $Revision: 1.1 0$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-06-0 4 01:03:11$8 * @version $Revision: 1.11 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-06-07 00:32:53 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 71 71 routines for generating both uniformly distributed numbers and the 72 72 Gaussian distribution as well. 73 74 GUS: There is no way to seed the random generator. 73 75 *****************************************************************************/ 74 76 psVector *psGaussianDev(float mean, … … 82 84 83 85 gauss = psVectorAlloc(Npts, PS_TYPE_F32); 86 gauss->n = Npts; 84 87 gsl_rng_env_setup(); 85 88 T = gsl_rng_default; … … 120 123 newPoly->nY = nY; 121 124 122 newPoly->coeff = (float **) psAlloc(nX * sizeof(float ));123 newPoly->coeffErr = (float **) psAlloc(nX * sizeof(float ));124 newPoly->mask = (char **) psAlloc(nX * sizeof(char ));125 newPoly->coeff = (float **) psAlloc(nX * sizeof(float *)); 126 newPoly->coeffErr = (float **) psAlloc(nX * sizeof(float *)); 127 newPoly->mask = (char **) psAlloc(nX * sizeof(char *)); 125 128 for (x=0;x<nX;x++) { 126 129 newPoly->coeff[x] = (float *) psAlloc(nY * sizeof(float)); … … 129 132 } 130 133 134 131 135 return(newPoly); 132 136 } … … 143 147 newPoly->nZ = nZ; 144 148 145 newPoly->coeff = (float ***) psAlloc(nX * sizeof(float ));146 newPoly->coeffErr = (float ***) psAlloc(nX * sizeof(float ));147 newPoly->mask = (char ***) psAlloc(nX * sizeof(char ));149 newPoly->coeff = (float ***) psAlloc(nX * sizeof(float **)); 150 newPoly->coeffErr = (float ***) psAlloc(nX * sizeof(float **)); 151 newPoly->mask = (char ***) psAlloc(nX * sizeof(char **)); 148 152 for (x=0;x<nX;x++) { 149 newPoly->coeff[x] = (float **) psAlloc(nY * sizeof(float ));150 newPoly->coeffErr[x] = (float **) psAlloc(nY * sizeof(float ));151 newPoly->mask[x] = (char **) psAlloc(nY * sizeof(char ));153 newPoly->coeff[x] = (float **) psAlloc(nY * sizeof(float *)); 154 newPoly->coeffErr[x] = (float **) psAlloc(nY * sizeof(float *)); 155 newPoly->mask[x] = (char **) psAlloc(nY * sizeof(char *)); 152 156 for (y=0;y<nY;y++) { 153 157 newPoly->coeff[x][y] = (float *) psAlloc(nZ * sizeof(float)); … … 173 177 newPoly->nZ = nZ; 174 178 175 newPoly->coeff = (float ****) psAlloc(nW * sizeof(float ));176 newPoly->coeffErr = (float ****) psAlloc(nW * sizeof(float ));177 newPoly->mask = (char ****) psAlloc(nW * sizeof(char ));179 newPoly->coeff = (float ****) psAlloc(nW * sizeof(float ***)); 180 newPoly->coeffErr = (float ****) psAlloc(nW * sizeof(float ***)); 181 newPoly->mask = (char ****) psAlloc(nW * sizeof(char ***)); 178 182 for (w=0;w<nW;w++) { 179 newPoly->coeff[w] = (float ***) psAlloc(nX * sizeof(float ));180 newPoly->coeffErr[w] = (float ***) psAlloc(nX * sizeof(float ));181 newPoly->mask[w] = (char ***) psAlloc(nX * sizeof(char ));183 newPoly->coeff[w] = (float ***) psAlloc(nX * sizeof(float **)); 184 newPoly->coeffErr[w] = (float ***) psAlloc(nX * sizeof(float **)); 185 newPoly->mask[w] = (char ***) psAlloc(nX * sizeof(char **)); 182 186 for (x=0;x<nX;x++) { 183 newPoly->coeff[w][x] = (float **) psAlloc(nY * sizeof(float ));184 newPoly->coeffErr[w][x] = (float **) psAlloc(nY * sizeof(float ));185 newPoly->mask[w][x] = (char **) psAlloc(nY * sizeof(char ));187 newPoly->coeff[w][x] = (float **) psAlloc(nY * sizeof(float *)); 188 newPoly->coeffErr[w][x] = (float **) psAlloc(nY * sizeof(float *)); 189 newPoly->mask[w][x] = (char **) psAlloc(nY * sizeof(char *)); 186 190 for (y=0;y<nY;y++) { 187 191 newPoly->coeff[w][x][y] = (float *) psAlloc(nZ * sizeof(float)); … … 410 414 newPoly->nY = nY; 411 415 412 newPoly->coeff = (double **) psAlloc(nX * sizeof(double ));413 newPoly->coeffErr = (double **) psAlloc(nX * sizeof(double ));414 newPoly->mask = (char **) psAlloc(nX * sizeof(char ));416 newPoly->coeff = (double **) psAlloc(nX * sizeof(double *)); 417 newPoly->coeffErr = (double **) psAlloc(nX * sizeof(double *)); 418 newPoly->mask = (char **) psAlloc(nX * sizeof(char *)); 415 419 for (x=0;x<nX;x++) { 416 420 newPoly->coeff[x] = (double *) psAlloc(nY * sizeof(double)); … … 433 437 newPoly->nZ = nZ; 434 438 435 newPoly->coeff = (double ***) psAlloc(nX * sizeof(double ));436 newPoly->coeffErr = (double ***) psAlloc(nX * sizeof(double ));437 newPoly->mask = (char ***) psAlloc(nX * sizeof(char ));439 newPoly->coeff = (double ***) psAlloc(nX * sizeof(double **)); 440 newPoly->coeffErr = (double ***) psAlloc(nX * sizeof(double **)); 441 newPoly->mask = (char ***) psAlloc(nX * sizeof(char **)); 438 442 for (x=0;x<nX;x++) { 439 newPoly->coeff[x] = (double **) psAlloc(nY * sizeof(double ));440 newPoly->coeffErr[x] = (double **) psAlloc(nY * sizeof(double ));441 newPoly->mask[x] = (char **) psAlloc(nY * sizeof(char ));443 newPoly->coeff[x] = (double **) psAlloc(nY * sizeof(double *)); 444 newPoly->coeffErr[x] = (double **) psAlloc(nY * sizeof(double *)); 445 newPoly->mask[x] = (char **) psAlloc(nY * sizeof(char *)); 442 446 for (y=0;y<nY;y++) { 443 447 newPoly->coeff[x][y] = (double *) psAlloc(nZ * sizeof(double)); … … 463 467 newPoly->nZ = nZ; 464 468 465 newPoly->coeff = (double ****) psAlloc(nW * sizeof(double ));466 newPoly->coeffErr = (double ****) psAlloc(nW * sizeof(double ));467 newPoly->mask = (char ****) psAlloc(nW * sizeof(char ));469 newPoly->coeff = (double ****) psAlloc(nW * sizeof(double ***)); 470 newPoly->coeffErr = (double ****) psAlloc(nW * sizeof(double ***)); 471 newPoly->mask = (char ****) psAlloc(nW * sizeof(char ***)); 468 472 for (w=0;w<nW;w++) { 469 newPoly->coeff[w] = (double ***) psAlloc(nX * sizeof(double ));470 newPoly->coeffErr[w] = (double ***) psAlloc(nX * sizeof(double ));471 newPoly->mask[w] = (char ***) psAlloc(nX * sizeof(char ));473 newPoly->coeff[w] = (double ***) psAlloc(nX * sizeof(double **)); 474 newPoly->coeffErr[w] = (double ***) psAlloc(nX * sizeof(double **)); 475 newPoly->mask[w] = (char ***) psAlloc(nX * sizeof(char **)); 472 476 for (x=0;x<nX;x++) { 473 newPoly->coeff[w][x] = (double **) psAlloc(nY * sizeof(double ));474 newPoly->coeffErr[w][x] = (double **) psAlloc(nY * sizeof(double ));475 newPoly->mask[w][x] = (char **) psAlloc(nY * sizeof(char ));477 newPoly->coeff[w][x] = (double **) psAlloc(nY * sizeof(double *)); 478 newPoly->coeffErr[w][x] = (double **) psAlloc(nY * sizeof(double *)); 479 newPoly->mask[w][x] = (char **) psAlloc(nY * sizeof(char *)); 476 480 for (y=0;y<nY;y++) { 477 481 newPoly->coeff[w][x][y] = (double *) psAlloc(nZ * sizeof(double)); -
trunk/psLib/src/math/psSpline.h
r751 r889 18 18 ); 19 19 20 21 psVector *psGaussianDev(float mean, 22 float sigma, 23 int Npts); 24 20 25 /*****************************************************************************/ 21 26 … … 205 210 /** Evaluate 1D polynomial (double precision) */ 206 211 double 207 ps EvalDPolynomial1D(double x, ///< Value at which to evaluate212 psDEvalPolynomial1D(double x, ///< Value at which to evaluate 208 213 const psDPolynomial1D *myPoly ///< Coefficients for the polynomial 209 214 ); … … 211 216 /** Evaluate 2D polynomial (double precision) */ 212 217 double 213 ps EvalDPolynomial2D(double x, ///< Value x at which to evaluate218 psDEvalPolynomial2D(double x, ///< Value x at which to evaluate 214 219 double y, ///< Value y at which to evaluate 215 220 const psDPolynomial2D *myPoly ///< Coefficients for the polynomial … … 218 223 /** Evaluate 3D polynomial (double precision) */ 219 224 double 220 ps EvalDPolynomial3D(double x, ///< Value x at which to evaluate225 psDEvalPolynomial3D(double x, ///< Value x at which to evaluate 221 226 double y, ///< Value y at which to evaluate 222 227 double z, ///< Value z at which to evaluate … … 226 231 /** Evaluate 4D polynomial (double precision) */ 227 232 double 228 ps EvalDPolynomial4D(double w, ///< Value w at which to evaluate233 psDEvalPolynomial4D(double w, ///< Value w at which to evaluate 229 234 double x, ///< Value x at which to evaluate 230 235 double y, ///< Value y at which to evaluate -
trunk/psLib/src/math/psStats.c
r831 r889 85 85 float binSize = 0.0; 86 86 87 if (n == 0) { 88 psAbort(__func__, "psHistogram requested with 0 bins"); 89 } 90 87 91 newHist = (psHistogram *) psAlloc(sizeof(psHistogram)); 88 92 newHist->bounds = psVectorAlloc(n+1, PS_TYPE_F32); 93 newHist->bounds->n = newHist->bounds->nalloc; 94 89 95 binSize = (upper - lower) / (float) n; 90 96 for (i=0;i<n+1;i++) { … … 92 98 } 93 99 newHist->nums = psVectorAlloc(n, PS_TYPE_S32); 100 newHist->nums->n = newHist->nums->nalloc; 101 for (i=0;i<newHist->nums->n;i++) { 102 newHist->nums->data.S32[i] = 0; 103 } 94 104 newHist->minNum = 0; 95 105 newHist->maxNum = 0; … … 99 109 } 100 110 101 111 // When this is called, the number of data elements in bounds 112 // is n. Therefore, the number of bins is n-1. 102 113 psHistogram *psHistogramAllocGeneric(const psVector *restrict bounds) 103 114 { … … 107 118 newHist = (psHistogram *) psAlloc(sizeof(psHistogram)); 108 119 newHist->bounds = psVectorAlloc(bounds->n, PS_TYPE_F32); 120 newHist->bounds->n = newHist->bounds->nalloc; 109 121 for (i=0;i<bounds->n;i++) { 110 122 newHist->bounds->data.F32[i] = bounds->data.F32[i]; 111 123 } 112 124 newHist->nums = psVectorAlloc((bounds->n)-1, PS_TYPE_S32); 125 newHist->nums->n = newHist->nums->nalloc; 126 for (i=0;i<newHist->nums->n;i++) { 127 newHist->nums->data.S32[i] = 0; 128 } 113 129 114 130 newHist->minNum = 0; … … 119 135 } 120 136 121 void psHistogramFree(psHistogram *restrict myHist) 122 { 137 void psHistogramFree(psHistogram *myHist) 138 { 139 psVectorFree(myHist->bounds); 140 psVectorFree(myHist->nums); 123 141 psFree(myHist); 124 142 } … … 150 168 151 169 numBins = out->nums->n; 152 for (i=0;i<in->n;i++) { 153 // Check if this pixel is masked, and if so, skip it. 154 if (!(mask->data.S32[i] & maskVal)) { 155 // Check if this pixel is below the minimum value, and if so 156 // count it, then skip it. 170 171 if (mask != NULL) { 172 for (i=0;i<in->n;i++) { 173 // Check if this pixel is masked, and if so, skip it. 174 if (!(mask->data.U8[i] & maskVal)) { 175 // Check if this pixel is below the minimum value, and if so 176 // count it, then skip it. 177 if (in->data.F32[i] < out->bounds->data.F32[0]) { 178 out->minNum++; 179 180 // Check if this pixel is above the maximum value, and if so 181 // count it, then skip it. 182 } else if (in->data.F32[i] > out->bounds->data.F32[numBins]) { 183 out->maxNum++; 184 } else { 185 // If this is a uniform histogram, determining the correct 186 // number is trivial. 187 if (out->uniform == true) { 188 binSize = out->bounds->data.F32[1] - out->bounds->data.F32[0]; 189 190 binNum = (int) ((in->data.F32[i] - out->bounds->data.F32[0]) / 191 binSize); 192 (out->nums->data.S32[binNum])++; 193 // If this is a non-uniform histogram, determining the correct 194 // bin number requires a bit more work. 195 } else { 196 // GUS: This is slow. Put a smarter algorithm here to 197 // find the correct bin number (bin search, probably) 198 for (j=0;j<(out->bounds->n)-1;j++) { 199 if ((out->bounds->data.S32[j] <= in->data.F32[i]) && 200 (in->data.F32[i] <= out->bounds->data.S32[j+1])) { 201 (out->nums->data.S32[j])++; 202 } 203 } 204 } 205 } 206 } 207 } 208 } else { 209 for (i=0;i<in->n;i++) { 157 210 if (in->data.F32[i] < out->bounds->data.F32[0]) { 211 // Check if this pixel is below the minimum value, and if so 212 // count it, then skip it. 158 213 out->minNum++; 159 214 } else if (in->data.F32[i] > out->bounds->data.F32[numBins]) { 160 215 // Check if this pixel is above the maximum value, and if so 161 216 // count it, then skip it. 162 } else if (in->data.F32[i] > out->bounds->data.F32[numBins]) {163 217 out->maxNum++; 164 218 } else { … … 171 225 binSize); 172 226 (out->nums->data.S32[binNum])++; 227 173 228 // If this is a non-uniform histogram, determining the correct 174 229 // bin number requires a bit more work. … … 185 240 } 186 241 } 242 187 243 } 188 244 return(out); … … 471 527 unsortedVector = psVectorAlloc(nValues, PS_TYPE_F32); 472 528 unsortedVector->n = unsortedVector->nalloc; 529 473 530 sortedVector = psVectorAlloc(nValues, PS_TYPE_F32); 474 531 sortedVector->n = sortedVector->nalloc; … … 494 551 if ((rangeMin <= myVector->data.F32[i]) && 495 552 (myVector->data.F32[i] <= rangeMax)) { 496 unsortedVector->data.F32[count++] = m askVector->data.F32[i];553 unsortedVector->data.F32[count++] = myVector->data.F32[i]; 497 554 } 498 555 } … … 504 561 for (i=0;i<myVector->n;i++) { 505 562 if (!(maskVal & maskVector->data.U8[i])) { 506 unsortedVector->data.F32[count++] = m askVector->data.F32[i];507 } 508 } 509 } else { 510 for (i=0;i<myVector->n;i++) { 511 unsortedVector->data.F32[i] = m askVector->data.F32[i];563 unsortedVector->data.F32[count++] = myVector->data.F32[i]; 564 } 565 } 566 } else { 567 for (i=0;i<myVector->n;i++) { 568 unsortedVector->data.F32[i] = myVector->data.F32[i]; 512 569 } 513 570 } … … 596 653 float rangeMin = 0.0; 597 654 float rangeMax = 0.0; 598 psStats *stats2 = NULL;599 655 600 656 // Determine if the number of data points exceed a threshold which will 601 657 // cause to generate robust stats, as opposed to exact stats. 602 if (myVector->n > stats->sampleLimit) { 603 // Calculate the robust quartiles. 604 stats2 = psStatsAlloc(PS_STAT_ROBUST_QUARTILE); 605 p_psVectorRobustStats(myVector, maskVector, maskVal, stats2); 606 607 // Store the robust quartiles into the sample quartile members. 608 stats->sampleUQ = stats2->robustUQ; 609 stats->sampleLQ = stats2->robustLQ; 610 611 // Free temporary data buffers. 612 psStatsFree(stats2); 613 614 // Set the PS_STAT_ROBUST_FOR_SAMPLE bit in the stats structure. 615 stats->options = stats->options | PS_STAT_ROBUST_FOR_SAMPLE; 616 617 return; 618 } 658 /* GUS: When IfA provides the algorithm, insert is here. 659 if (myVector->n > stats->sampleLimit) { 660 psStats *stats2 = NULL; 661 // Calculate the robust quartiles. 662 stats2 = psStatsAlloc(PS_STAT_ROBUST_QUARTILE); 663 p_psVectorRobustStats(myVector, maskVector, maskVal, stats2); 664 665 // Store the robust quartiles into the sample quartile members. 666 stats->sampleUQ = stats2->robustUQ; 667 stats->sampleLQ = stats2->robustLQ; 668 669 // Free temporary data buffers. 670 psStatsFree(stats2); 671 672 // Set the PS_STAT_ROBUST_FOR_SAMPLE bit in the stats structure. 673 stats->options = stats->options | PS_STAT_ROBUST_FOR_SAMPLE; 674 675 return; 676 } 677 */ 619 678 620 679 // Determine how many data points fit inside this min/max range … … 640 699 (rangeMin <= myVector->data.F32[i]) && 641 700 (myVector->data.F32[i] <= rangeMax)) { 642 unsortedVector->data.F32[count++] = m askVector->data.F32[i];701 unsortedVector->data.F32[count++] = myVector->data.F32[i]; 643 702 } 644 703 } … … 647 706 if ((rangeMin <= myVector->data.F32[i]) && 648 707 (myVector->data.F32[i] <= rangeMax)) { 649 unsortedVector->data.F32[count++] = m askVector->data.F32[i];708 unsortedVector->data.F32[count++] = myVector->data.F32[i]; 650 709 } 651 710 } … … 657 716 for (i=0;i<myVector->n;i++) { 658 717 if (!(maskVal & maskVector->data.U8[i])) { 659 unsortedVector->data.F32[count++] = m askVector->data.F32[i];660 } 661 } 662 } else { 663 for (i=0;i<myVector->n;i++) { 664 unsortedVector->data.F32[i] = m askVector->data.F32[i];718 unsortedVector->data.F32[count++] = myVector->data.F32[i]; 719 } 720 } 721 } else { 722 for (i=0;i<myVector->n;i++) { 723 unsortedVector->data.F32[i] = myVector->data.F32[i]; 665 724 } 666 725 } … … 679 738 psVectorFree(unsortedVector); 680 739 psVectorFree(sortedVector); 740 // GUS: This is the 681 741 } 682 742 … … 691 751 PS_STAT_ROBUST_QUARTILE 692 752 I have included all that computation in a single function, as opposed to 693 breaking it across several functions for one primary reason: the all753 breaking it across several functions for one primary reason: they all 694 754 require the same basic initial processing steps (calculate the histogram, 695 755 etc.) however there is no currently defined means, in the SDRS, to … … 719 779 // is really required. 720 780 721 if (0.0 == stats->sampleUQ) { 722 723 // GUS: fix this 724 // stats->options = stats->options | PS_STAT_SAMPLE_UQ; 781 if (isnan(stats->sampleUQ) || 782 isnan(stats->sampleLQ)) { 783 stats->options = stats->options | PS_STAT_SAMPLE_QUARTILE; 725 784 p_psVectorSampleQuartiles(myVector, 726 785 maskVector, … … 729 788 } 730 789 731 if (isnan(stats->sampleLQ)) {732 // GUS: fix this733 // stats->options = stats->options | PS_STAT_SAMPLE_LQ;734 p_psVectorSampleQuartiles(myVector,735 maskVector,736 maskVal,737 stats);738 }739 740 790 // Compute the initial bin size of the robust histogram. 741 791 sigmaE = (stats->sampleUQ - stats->sampleLQ) / 1.34f; … … 753 803 robustHistogram = psHistogramAlloc(stats->min, 754 804 stats->max, 755 binSize); 756 // Populate the histogram arrat. 805 1 + (int) ((stats->max - stats->min) / binSize)); 806 807 808 // Populate the histogram array. 757 809 // GUS: fix this 758 810 // robustHistogram = psHistogramVector(robustHistogram, myVector); … … 811 863 stats->robustLQ = 0.0; 812 864 } 865 stats->robustNfit = 0.0; 866 stats->robustN50 = 0.0; 867 psHistogramFree(robustHistogram); 813 868 } 814 869 … … 836 891 837 892 if (0 != isnan(stats->sampleMean)) { 838 p sAbort(__func__, "stats->sampleMean == NAN");893 p_psVectorSampleMean(myVector, maskVector, maskVal, stats); 839 894 } 840 895 mean = stats->sampleMean; … … 920 975 } 921 976 922 tmpMask = psVectorAlloc(myVector->nalloc, maskVector->type.type); 923 924 tmpMask->n = maskVector->n; 925 for (i=0;i<tmpMask->n;i++) { 926 tmpMask->data.U8[i] = maskVector->data.U8[i]; 977 978 tmpMask = psVectorAlloc(myVector->n, PS_TYPE_U8); 979 tmpMask->n = myVector->n; 980 981 if (maskVector != NULL) { 982 for (i=0;i<tmpMask->n;i++) { 983 tmpMask->data.U8[i] = maskVector->data.U8[i]; 984 } 927 985 } 928 986 929 987 // 1. Compute the sample median. 988 // GUS: This seems odd. Verify with IfA that we want to calculate the 989 // median here, not the mean. 930 990 p_psVectorSampleMedian(myVector, maskVector, maskVal, stats); 931 991 … … 942 1002 943 1003 for (i=0;i<stats->clipIter;i++) { 1004 // printf("p_psVectorClippedStats(): Iteration %d (%f %f)\n", i, 1005 // clippedMean, clippedStdev); 944 1006 for (j=0;j<myVector->n;j++) { 945 1007 // a) Exclude all values x_i for which |x_i - x| > K * stdev 946 if ( fabs(myVector->data.F32[j] - clippedMean) >1008 if (fabs(myVector->data.F32[j] - clippedMean) > 947 1009 (stats->clipSigma * clippedStdev)) { 948 1010 tmpMask->data.U8[i] = 0xff; … … 994 1056 if (in->type.type != PS_TYPE_F32) { 995 1057 psAbort(__func__, 996 "Only data type PS_TYPE_F32 is currently supported."); 997 } 1058 "Only data type PS_TYPE_F32 is currently supported (0x%x).", 1059 in->type.type); 1060 } 1061 998 1062 if (mask != NULL) { 999 1063 if (in->n != mask->n) { … … 1018 1082 1019 1083 // ************************************************************************ 1084 // GUS: The Stdev calculation requires the mean. Should we assume the 1085 // mean has already been calculated? Or should we always calculate it? 1020 1086 if (stats->options & PS_STAT_SAMPLE_STDEV) { 1087 p_psVectorSampleMean(in, mask, maskVal, stats); 1021 1088 p_psVectorSampleStdev(in, mask, maskVal, stats); 1022 1089 } -
trunk/psLib/src/math/psStats.h
r797 r889 81 81 typedef struct 82 82 { 83 const psVector *restrict bounds;///< Bounds for the bins (type F32)83 psVector *bounds; ///< Bounds for the bins (type F32) 84 84 psVector *nums; ///< Number in each of the bins (INT) 85 85 int minNum; ///< Number below the minimum … … 102 102 103 103 /** Destructor \ingroup MathGroup **/ 104 void psHistogramFree(psHistogram * restrictmyHist); ///< Histogram to destroy104 void psHistogramFree(psHistogram *myHist); ///< Histogram to destroy 105 105 106 106 -
trunk/psLib/src/mathtypes/psImage.c
r859 r889 9 9 * @author Ross Harman, MHPCC 10 10 * 11 * @version $Revision: 1.2 4$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-06-0 4 03:15:47$11 * @version $Revision: 1.25 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-06-07 00:32:53 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 15 * 16 * That is the routine used to generate matrices. 15 17 */ 16 18 -
trunk/psLib/src/sys/psLogMsg.c
r560 r889 29 29 static int logDest = PS_LOG_TO_STDERR; // where to log messages 30 30 static int logLevel = PS_LOG_INFO; // log all messages at this or above 31 //static FILE *p_logFP = NULL; 31 32 // The following variables control 32 33 // which information is displayed in -
trunk/psLib/src/sysUtils/psHash.c
r885 r889 1 /****************************************************************************** 2 An interface to hash tables for Pan-STARRS 3 4 Collisions are handled by simple linked lists 5 *****************************************************************************/ 1 /** @file psHash.c 2 * 3 * @brief Contains support for basic hashing functions. 4 * 5 * This file will hold the functions for defining a hash table with arbitrary 6 * data types, allocating/deallocating that has table, adding and removing 7 * data from that hash table, and listing all keys defined in the hash table. 8 * 9 * @author Robert Lupton, Princeton University 10 * @author George Gusciora, MHPCC 11 * 12 * @version $Revision: 1.6 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-06-07 00:32:53 $ 14 * 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 16 */ 6 17 #include <stdlib.h> 7 18 #include <stdio.h> … … 12 23 #include "psString.h" 13 24 #include "psTrace.h" 25 #include "psAbort.h" 14 26 15 27 psDlist *psHashKeyList(psHash *table) … … 142 154 // bucket. 143 155 psHashBucket *optr = NULL; 156 char *tmpchar = NULL; 144 157 145 158 // NOTE: this is NOT a good hash function! See Knuth. 146 159 // 147 for (int i = 0, len = strlen(key); i < len; i++) { 148 hash = (hash << 1) ^ key[i]; 149 } 150 hash &= (table->nbucket - 1); 160 // for (int i = 0, len = strlen(key); i < len; i++) { 161 // hash = (hash << 1) ^ key[i]; 162 // } 163 // hash &= (table->nbucket - 1); 164 165 // This hash algorithm is from Sedgewick. NOTE: must reread to ensure that 166 // the size of the hash table is not required to be a prime number. 167 tmpchar = (char *) key; 168 for (hash = 0; *tmpchar != '\0'; tmpchar++) { 169 hash = (64 * hash + *tmpchar) % (table->nbucket); 170 } 171 172 // NOTE: This should not be necessary, but for now, I'm checking bounds 173 // anyway. 174 if ((hash < 0) || 175 (hash >= table->nbucket)) { 176 psAbort(__func__,"Internal hash function out of range (%d)", 177 hash); 178 } 151 179 152 180 ptr = table->buckets[hash]; -
trunk/psLib/src/sysUtils/psHash.h
r886 r889 1 /** @file psHash.c 2 * 3 * @brief Contains support for basic hashing functions. 4 * 5 * This file will hold the prototypes for defining a hash table with arbitrary 6 * data types, allocating/deallocating that has table, adding and removing 7 * data from that hash table, and listing all keys defined in the hash table. 8 * 9 * @author Robert Lupton, Princeton University 10 * @author George Gusciora, MHPCC 11 * 12 * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-06-07 00:32:53 $ 14 * 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 16 */ 17 1 18 #if !defined(PS_HASH_H) 2 19 #define PS_HASH_H -
trunk/psLib/src/sysUtils/psLogMsg.c
r560 r889 29 29 static int logDest = PS_LOG_TO_STDERR; // where to log messages 30 30 static int logLevel = PS_LOG_INFO; // log all messages at this or above 31 //static FILE *p_logFP = NULL; 31 32 // The following variables control 32 33 // which information is displayed in
Note:
See TracChangeset
for help on using the changeset viewer.
