Changeset 12692 for trunk/psLib/src/math/psStats.c
- Timestamp:
- Mar 29, 2007, 5:24:38 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/math/psStats.c (modified) (89 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/math/psStats.c
r12691 r12692 13 13 * use ->min and ->max (PS_STAT_USE_RANGE) 14 14 * 15 * @version $Revision: 1.20 6$ $Name: not supported by cvs2svn $16 * @date $Date: 2007-03-30 0 2:53:26$15 * @version $Revision: 1.207 $ $Name: not supported by cvs2svn $ 16 * @date $Date: 2007-03-30 03:24:38 $ 17 17 * 18 18 * Copyright 2006 IfA, University of Hawaii 19 19 */ 20 21 22 // Note: choice of return values in many places is quite grey. For example, calculating the sample standard 23 // deviation: here it's an error to get an array of size zero, but it's not an error to get an array of size 24 // unity, even though the standard deviation is not defined in that case (NAN). 20 25 21 26 #ifdef HAVE_CONFIG_H … … 112 117 RESULT = Xt; } 113 118 119 #define TRACE "psLib.math" 120 114 121 /*****************************************************************************/ 115 122 /* TYPE DEFINITIONS */ … … 171 178 psStats* stats) 172 179 { 173 psTrace( "psLib.math", 4, "---- %s() begin ----\n", __func__);180 psTrace(TRACE, 4, "---- %s() begin ----\n", __func__); 174 181 175 182 long count = 0; // Number of points contributing to this mean … … 211 218 if (isnan(mean)) { 212 219 // XXX raise an error here? 213 psTrace( "psLib.math", 4, "---- %s(false) end ----\n", __func__);214 return false;220 psTrace(TRACE, 4, "---- %s(false) end ----\n", __func__); 221 return true; 215 222 } 216 223 217 224 stats->results |= PS_STAT_SAMPLE_MEAN; 218 psTrace( "psLib.math", 4, "---- %s(true) end ----\n", __func__);225 psTrace(TRACE, 4, "---- %s(true) end ----\n", __func__); 219 226 return true; 220 227 } … … 239 246 ) 240 247 { 241 psTrace( "psLib.math", 4, "---- %s() begin ----\n", __func__);248 psTrace(TRACE, 4, "---- %s() begin ----\n", __func__); 242 249 psF32 max = -PS_MAX_F32; // The calculated maximum 243 250 psF32 min = PS_MAX_F32; // The calculated minimum … … 273 280 stats->results |= PS_STAT_MAX; 274 281 } 275 psTrace( "psLib.math", 4, "---- %s(%d) end ----\n", __func__, numValid);282 psTrace(TRACE, 4, "---- %s(%d) end ----\n", __func__, numValid); 276 283 return numValid; 277 284 } … … 287 294 psStats* stats) 288 295 { 289 psTrace( "psLib.math", 4, "---- %s() begin ----\n", __func__);296 psTrace(TRACE, 4, "---- %s() begin ----\n", __func__); 290 297 291 298 bool useRange = stats->options & PS_STAT_USE_RANGE; … … 320 327 stats->sampleLQ = NAN; 321 328 stats->sampleMedian = NAN; 322 return false;329 return true; 323 330 } 324 331 … … 330 337 stats->sampleLQ = NAN; 331 338 stats->sampleMedian = NAN; 332 return false;339 return true; 333 340 } 334 341 … … 351 358 352 359 // Return "true" on success. 353 psTrace( "psLib.math", 4, "---- %s(true) end ----\n", __func__);360 psTrace(TRACE, 4, "---- %s(true) end ----\n", __func__); 354 361 return true; 355 362 } … … 382 389 psStats* stats) 383 390 { 384 psTrace( "psLib.math", 4, "---- %s() begin ----\n", __func__);391 psTrace(TRACE, 4, "---- %s() begin ----\n", __func__); 385 392 386 393 // This procedure requires the mean. If it has not been already … … 392 399 // If the mean is NAN, then generate a warning and set the stdev to NAN. 393 400 if (isnan(stats->sampleMean)) { 401 psTrace(TRACE, 5, "WARNING: vectorSampleStdev(): sample mean is NAN. Setting stats->sampleStdev = NAN.\n"); 394 402 stats->sampleStdev = NAN; 395 psWarning("WARNING: vectorSampleStdev(): vectorSampleMean() reported a NAN mean.\n"); 396 psTrace("psLib.math", 4, "---- %s() end ----\n", __func__); 397 return false; 403 return true; 398 404 } 399 405 … … 411 417 for (long i = 0; i < myVector->n; i++) { 412 418 // Check if the data is with the specified range 413 if (useRange && (data[i] < stats->min)) 419 if (useRange && (data[i] < stats->min)) { 414 420 continue; 415 if (useRange && (data[i] > stats->max)) 421 } 422 if (useRange && (data[i] > stats->max)) { 416 423 continue; 417 if (maskData && (maskData[i] & maskVal)) 424 } 425 if (maskData && (maskData[i] & maskVal)) { 418 426 continue; 427 } 419 428 420 429 double diff = data[i] - mean; … … 428 437 429 438 if (count == 0) { 439 // This is an ambiguous case: error or not? 440 // It's not an empty array (that's been asserted on previously), but everything's been masked out. 441 // Assume that the user knows what he's doing when he masks out everything --> no error. 430 442 stats->sampleStdev = NAN; 431 ps Warning("WARNING: vectorSampleStdev(): no valid psVector elements (%ld). Setting stats->sampleStdev = NAN.\n", count);432 return false;443 psTrace(TRACE, 5, "WARNING: vectorSampleStdev(): no valid psVector elements (%ld). Setting stats->sampleStdev = NAN.\n", count); 444 return true; 433 445 } 434 446 if (count == 1) { 435 447 stats->sampleStdev = 0.0; 436 ps Warning("WARNING: vectorSampleStdev(): only one valid psVector elements (%ld). Setting stats->sampleStdev = 0.0.\n", count);437 return false;448 psTrace(TRACE, 5, "WARNING: vectorSampleStdev(): only one valid psVector elements (%ld). Setting stats->sampleStdev = 0.0.\n", count); 449 return true; 438 450 } 439 451 … … 445 457 stats->results |= PS_STAT_SAMPLE_STDEV; 446 458 447 psTrace( "psLib.math", 4, "---- %s() end ----\n", __func__);459 psTrace(TRACE, 4, "---- %s() end ----\n", __func__); 448 460 449 461 return true; … … 469 481 ) 470 482 { 471 psTrace( "psLib.math", 4, "---- %s() begin ----\n", __func__);472 psTrace( "psLib.math", 4, "Trace level is %d\n", psTraceGetLevel("psLib.math"));483 psTrace(TRACE, 4, "---- %s() begin ----\n", __func__); 484 psTrace(TRACE, 4, "Trace level is %d\n", psTraceGetLevel("psLib.math")); 473 485 474 486 // Ensure that stats->clipIter is within the proper range. … … 502 514 vectorSampleMedian(myVector, tmpMask, maskVal, stats); 503 515 if (isnan(stats->sampleMedian)) { 504 ps Warning("Call to vectorSampleMedian returned NAN\n");505 psTrace( "psLib.math", 4, "---- %s(false) end ----\n", __func__);516 psTrace(TRACE, 5, "Call to vectorSampleMedian returned NAN\n"); 517 psTrace(TRACE, 4, "---- %s(false) end ----\n", __func__); 506 518 psFree(tmpMask); 507 519 return false; 508 520 } 509 psTrace( "psLib.math", 6, "The initial sample median is %f\n", stats->sampleMedian);521 psTrace(TRACE, 6, "The initial sample median is %f\n", stats->sampleMedian); 510 522 511 523 // 2. Compute the sample standard deviation, which we save for output 512 524 vectorSampleStdev(myVector, errors, tmpMask, maskVal, stats); 513 525 if (isnan(stats->sampleStdev)) { 514 ps Warning("Call to vectorSampleStdev returned NAN\n");515 psTrace( "psLib.math", 4, "---- %s(false) end ----\n", __func__);526 psTrace(TRACE, 5, "Call to vectorSampleStdev returned NAN\n"); 527 psTrace(TRACE, 4, "---- %s(false) end ----\n", __func__); 516 528 psFree(tmpMask); 517 529 return false; 518 530 } 519 psTrace( "psLib.math", 6, "The initial sample stdev is %f\n", stats->sampleStdev);531 psTrace(TRACE, 6, "The initial sample stdev is %f\n", stats->sampleStdev); 520 532 521 533 // 3. Use the sample median as the first estimator of the mean X. … … 530 542 for (int iter = 0; iter < stats->clipIter && clipped; iter++) { 531 543 clipped = false; 532 psTrace( "psLib.math", 6, "------------ Iteration %d ------------\n", iter);544 psTrace(TRACE, 6, "------------ Iteration %d ------------\n", iter); 533 545 // a) Exclude all values x_i for which |x_i - x| > K * stdev 534 546 if (errors) { … … 538 550 fabsf(myVector->data.F32[j] - clippedMean) > stats->clipSigma * errors->data.F32[j]) { 539 551 tmpMask->data.U8[j] = 0xff; 540 psTrace( "psLib.math", 10, "Clipped %ld: %f +/- %f\n", j,552 psTrace(TRACE, 10, "Clipped %ld: %f +/- %f\n", j, 541 553 myVector->data.F32[j], errors->data.F32[j]); 542 554 numClipped++; … … 549 561 fabsf(myVector->data.F32[j] - clippedMean) > (stats->clipSigma * clippedStdev)) { 550 562 tmpMask->data.U8[j] = 0xff; 551 psTrace( "psLib.math", 10, "Clipped %ld: %f\n", j, myVector->data.F32[j]);563 psTrace(TRACE, 10, "Clipped %ld: %f\n", j, myVector->data.F32[j]); 552 564 numClipped++; 553 565 clipped = true; … … 561 573 vectorSampleMean(myVector, errors, tmpMask, maskVal, statsTmp); 562 574 vectorSampleStdev(myVector, errors, tmpMask, maskVal, statsTmp); 563 psTrace( "psLib.math", 6, "The new sample mean is %f\n", statsTmp->sampleMean);564 psTrace( "psLib.math", 6, "The new sample stdev is %f\n", statsTmp->sampleStdev);575 psTrace(TRACE, 6, "The new sample mean is %f\n", statsTmp->sampleMean); 576 psTrace(TRACE, 6, "The new sample stdev is %f\n", statsTmp->sampleStdev); 565 577 566 578 // If the new mean and stdev are NAN, we must exit the loop. … … 591 603 stats->results |= PS_STAT_CLIPPED_STDEV; 592 604 593 psTrace( "psLib.math", 6, "The final clipped mean is %f\n", clippedMean);594 psTrace( "psLib.math", 6, "The final clipped stdev is %f\n", clippedStdev);605 psTrace(TRACE, 6, "The final clipped mean is %f\n", clippedMean); 606 psTrace(TRACE, 6, "The final clipped stdev is %f\n", clippedStdev); 595 607 596 608 psFree(tmpMask); 597 psTrace( "psLib.math", 4, "---- %s(true) end ----\n", __func__);609 psTrace(TRACE, 4, "---- %s(true) end ----\n", __func__); 598 610 return true; 599 611 } … … 624 636 psStats* stats) 625 637 { 626 psTrace( "psLib.math", 4, "---- %s() begin ----\n", __func__);638 psTrace(TRACE, 4, "---- %s() begin ----\n", __func__); 627 639 if (psTraceGetLevel("psLib.math") >= 8) { 628 640 PS_VECTOR_PRINT_F32(myVector); … … 658 670 // Iterate to get the best bin size 659 671 for (int iterate = 1; iterate > 0; iterate++) { 660 psTrace( "psLib.math", 6, "-------------------- Iterating on Bin size. Iteration number %d --------------------\n", iterate);672 psTrace(TRACE, 6, "-------------------- Iterating on Bin size. Iteration number %d --------------------\n", iterate); 661 673 662 674 // Get the minimum and maximum values … … 669 681 goto escape; 670 682 } 671 psTrace( "psLib.math", 6, "Data min/max is (%.2f, %.2f)\n", min, max);683 psTrace(TRACE, 6, "Data min/max is (%.2f, %.2f)\n", min, max); 672 684 673 685 // If all data points have the same value, then we set the appropriate members of stats and return. … … 681 693 stats->results |= PS_STAT_ROBUST_STDEV; 682 694 stats->results |= PS_STAT_ROBUST_QUARTILE; 683 psTrace( "psLib.math", 5, "All data points have the same value: %f.\n", min);684 psTrace( "psLib.math", 4, "---- %s(0) end ----\n", __func__);695 psTrace(TRACE, 5, "All data points have the same value: %f.\n", min); 696 psTrace(TRACE, 4, "---- %s(0) end ----\n", __func__); 685 697 psFree(mask); 686 698 psFree(statsMinMax); … … 691 703 // Set initial bin size to the specified value. 692 704 binSize = stats->binsize; 693 psTrace( "psLib.math", 6, "Setting initial robust bin size to %.2f\n", binSize);705 psTrace(TRACE, 6, "Setting initial robust bin size to %.2f\n", binSize); 694 706 } else { 695 707 // Determine the bin size of the robust histogram, using the pre-defined number of bins 696 708 binSize = (max - min) / INITIAL_NUM_BINS; 697 709 } 698 psTrace( "psLib.math", 6, "Initial robust bin size is %.2f\n", binSize);710 psTrace(TRACE, 6, "Initial robust bin size is %.2f\n", binSize); 699 711 700 712 // ADD step 0: Construct the histogram with the specified bin size. NOTE: we can not specify the bin … … 702 714 // we get here, we know that binSize != 0.0. 703 715 long numBins = (max - min) / binSize; // Number of bins 704 psTrace( "psLib.math", 6, "Numbins is %ld\n", numBins);705 psTrace( "psLib.math", 6, "Creating a robust histogram from data range (%.2f - %.2f)\n", min, max);716 psTrace(TRACE, 6, "Numbins is %ld\n", numBins); 717 psTrace(TRACE, 6, "Creating a robust histogram from data range (%.2f - %.2f)\n", min, max); 706 718 // Generate the histogram 707 719 histogram = psHistogramAlloc(min, max, numBins); … … 729 741 // ADD step 2: Find the bin which contains the 50% data point. 730 742 totalDataPoints = cumulative->nums->data.F32[numBins - 1]; 731 psTrace( "psLib.math", 6, "Total data points is %ld\n", totalDataPoints);743 psTrace(TRACE, 6, "Total data points is %ld\n", totalDataPoints); 732 744 733 745 PS_BIN_FOR_VALUE(binMedian, cumulative->nums, totalDataPoints/2.0, 0); 734 psTrace( "psLib.math", 6, "The median bin is %ld (%.2f to %.2f)\n", binMedian,746 psTrace(TRACE, 6, "The median bin is %ld (%.2f to %.2f)\n", binMedian, 735 747 cumulative->bounds->data.F32[binMedian], cumulative->bounds->data.F32[binMedian+1]); 736 748 … … 742 754 goto escape; 743 755 } 744 psTrace( "psLib.math", 6, "Current robust median is %f\n", stats->robustMedian);756 psTrace(TRACE, 6, "Current robust median is %f\n", stats->robustMedian); 745 757 746 758 // ADD step 4: Find the bins which contains the 15.8655% (-1 sigma) and 84.1345% (+1 sigma) data points … … 751 763 PS_BIN_FOR_VALUE(binH2, cumulative->nums, totalDataPoints * 0.691462f, 0); 752 764 753 psTrace( "psLib.math", 6, "The 15.8655%% and 84.1345%% data point bins are (%ld, %ld).\n",765 psTrace(TRACE, 6, "The 15.8655%% and 84.1345%% data point bins are (%ld, %ld).\n", 754 766 binLo, binHi); 755 psTrace( "psLib.math", 6, "binLo midpoint is %f\n", PS_BIN_MIDPOINT(cumulative, binLo));756 psTrace( "psLib.math", 6, "binHi midpoint is %f\n", PS_BIN_MIDPOINT(cumulative, binHi));757 psTrace( "psLib.math", 6, "binL2 midpoint is %f\n", PS_BIN_MIDPOINT(cumulative, binL2));758 psTrace( "psLib.math", 6, "binH2 midpoint is %f\n", PS_BIN_MIDPOINT(cumulative, binH2));767 psTrace(TRACE, 6, "binLo midpoint is %f\n", PS_BIN_MIDPOINT(cumulative, binLo)); 768 psTrace(TRACE, 6, "binHi midpoint is %f\n", PS_BIN_MIDPOINT(cumulative, binHi)); 769 psTrace(TRACE, 6, "binL2 midpoint is %f\n", PS_BIN_MIDPOINT(cumulative, binL2)); 770 psTrace(TRACE, 6, "binH2 midpoint is %f\n", PS_BIN_MIDPOINT(cumulative, binH2)); 759 771 760 772 if ((binLo < 0) || (binHi < 0)) { … … 764 776 765 777 // ADD step 4b: Interpolate Sigma (linearly) to find these two positions exactly: these are the 1sigma positions. 766 psTrace( "psLib.math", 6, "binLo is %ld. Nums at that bin and the next are (%.2f, %.2f)\n",778 psTrace(TRACE, 6, "binLo is %ld. Nums at that bin and the next are (%.2f, %.2f)\n", 767 779 binLo, cumulative->nums->data.F32[binLo], cumulative->nums->data.F32[binLo+1]); 768 psTrace( "psLib.math", 6, "binHi is %ld. Nums at that bin and the next are (%.2f, %.2f)\n",780 psTrace(TRACE, 6, "binHi is %ld. Nums at that bin and the next are (%.2f, %.2f)\n", 769 781 binHi, cumulative->nums->data.F32[binHi], cumulative->nums->data.F32[binHi+1]); 770 782 … … 779 791 780 792 // report +/- 1 sigma points 781 psTrace( "psLib.math", 5,793 psTrace(TRACE, 5, 782 794 "The exact 15.8655 and 84.1345 percent data point positions are: (%f, %f)\n", 783 795 binLoF32, binHiF32); … … 787 799 sigma = (binH2F32 - binL2F32); 788 800 789 psTrace( "psLib.math", 6, "The current sigma is %f.\n", sigma);801 psTrace(TRACE, 6, "The current sigma is %f.\n", sigma); 790 802 stats->robustStdev = sigma; 791 803 … … 793 805 // than 25 bins from the median, recalculate the bin size, and perform the algorithm again. 794 806 if (sigma < (2 * binSize)) { 795 psTrace( "psLib.math", 6, "*************: Do another iteration (%f %f).\n", sigma, binSize);807 psTrace(TRACE, 6, "*************: Do another iteration (%f %f).\n", sigma, binSize); 796 808 long maskLo = PS_MAX(0, (binMedian - 25)); // Low index for masking region 797 809 long maskHi = PS_MIN(histogram->bounds->n - 1, (binMedian + 25)); // High index for masking 798 810 psF32 medianLo = histogram->bounds->data.F32[maskLo]; // Value at low index 799 811 psF32 medianHi = histogram->bounds->data.F32[maskHi]; // Value at high index 800 psTrace( "psLib.math", 6, "Masking data more than 25 bins from the median\n");801 psTrace( "psLib.math", 6,812 psTrace(TRACE, 6, "Masking data more than 25 bins from the median\n"); 813 psTrace(TRACE, 6, 802 814 "The median is at bin number %ld. We mask bins outside the bin range (%ld:%ld)\n", 803 815 binMedian, maskLo, maskHi); 804 psTrace( "psLib.math", 6, "Masking data outside (%f %f)\n", medianLo, medianHi);816 psTrace(TRACE, 6, "Masking data outside (%f %f)\n", medianLo, medianHi); 805 817 for (long i = 0 ; i < myVector->n ; i++) { 806 818 if ((myVector->data.F32[i] < medianLo) || (myVector->data.F32[i] > medianHi)) { 807 819 mask->data.U8[i] |= MASK_MARK; 808 psTrace( "psLib.math", 6, "Masking element %ld is %f\n", i, myVector->data.F32[i]);820 psTrace(TRACE, 6, "Masking element %ld is %f\n", i, myVector->data.F32[i]); 809 821 } 810 822 } … … 817 829 } else { 818 830 // We've got the bin size correct now 819 psTrace( "psLib.math", 6, "*************: No more iteration. sigma is %f\n", sigma);831 psTrace(TRACE, 6, "*************: No more iteration. sigma is %f\n", sigma); 820 832 iterate = -1; 821 833 } … … 831 843 PS_BIN_FOR_VALUE (binLo25, cumulative->nums, totalDataPoints * 0.25f, 0); 832 844 PS_BIN_FOR_VALUE (binHi25, cumulative->nums, totalDataPoints * 0.75f, 0); 833 psTrace( "psLib.math", 6, "The 25-percent and 75-precent data point bins are (%ld, %ld).\n", binLo25, binHi25);845 psTrace(TRACE, 6, "The 25-percent and 75-precent data point bins are (%ld, %ld).\n", binLo25, binHi25); 834 846 835 847 // ADD step 8: Interpolate to find these two positions exactly: these are the upper and lower quartile … … 847 859 stats->robustLQ = binLo25F32; 848 860 stats->robustUQ = binHi25F32; 849 psTrace( "psLib.math", 6, "The 25 and 75 percent data point exact positions are (%f, %f).\n",861 psTrace(TRACE, 6, "The 25 and 75 percent data point exact positions are (%f, %f).\n", 850 862 binLo25F32, binHi25F32); 851 863 long N50 = 0; … … 857 869 } 858 870 stats->robustN50 = N50; 859 psTrace( "psLib.math", 6, "The robustN50 is %ld.\n", N50);871 psTrace(TRACE, 6, "The robustN50 is %ld.\n", N50); 860 872 861 873 // Clean up … … 869 881 stats->results |= PS_STAT_ROBUST_QUARTILE; 870 882 871 psTrace( "psLib.math", 4, "---- %s(0) end ----\n", __func__);883 psTrace(TRACE, 4, "---- %s(0) end ----\n", __func__); 872 884 return true; 873 885 … … 882 894 stats->results |= PS_STAT_ROBUST_QUARTILE; 883 895 884 psTrace( "psLib.math", 4, "---- %s(false) end ----\n", __func__);896 psTrace(TRACE, 4, "---- %s(false) end ----\n", __func__); 885 897 886 898 psFree(histogram); … … 913 925 stats->fittedStdev = NAN; 914 926 stats->fittedStdev = NAN; 915 psTrace( "psLib.math", 4, "---- %s() end ----\n", __func__);927 psTrace(TRACE, 4, "---- %s() end ----\n", __func__); 916 928 return false; 917 929 } … … 920 932 float guessMean = stats->robustMedian; // pass the guess mean 921 933 922 psTrace( "psLib.math", 6, "The guess mean is %f.\n", guessMean);923 psTrace( "psLib.math", 6, "The guess stdev is %f.\n", guessStdev);934 psTrace(TRACE, 6, "The guess mean is %f.\n", guessMean); 935 psTrace(TRACE, 6, "The guess stdev is %f.\n", guessStdev); 924 936 925 937 bool done = false; … … 931 943 // Set initial bin size to the specified value. 932 944 binSize = stats->binsize; 933 psTrace( "psLib.math", 6, "Setting initial robust bin size to %.2f\n", binSize);945 psTrace(TRACE, 6, "Setting initial robust bin size to %.2f\n", binSize); 934 946 } else { 935 947 // construct a histogram with (sigma/10 < binsize < sigma) … … 947 959 psError(PS_ERR_UNKNOWN, false, "Failed to calculate the min/max of the input vector.\n"); 948 960 psFree(statsMinMax); 949 psTrace( "psLib.math", 4, "---- %s(false) end ----\n", __func__);961 psTrace(TRACE, 4, "---- %s(false) end ----\n", __func__); 950 962 return false; 951 963 } … … 954 966 // XXX can we calculate the binMin, binMax **before** building this histogram? 955 967 long numBins = (max - min) / binSize; 956 psTrace( "psLib.math", 6, "The new min/max values are (%f, %f).\n", min, max);957 psTrace( "psLib.math", 6, "The new bin size is %f.\n", binSize);958 psTrace( "psLib.math", 6, "The numBins is %ld\n", numBins);968 psTrace(TRACE, 6, "The new min/max values are (%f, %f).\n", min, max); 969 psTrace(TRACE, 6, "The new bin size is %f.\n", binSize); 970 psTrace(TRACE, 6, "The numBins is %ld\n", numBins); 959 971 960 972 psHistogram *histogram = psHistogramAlloc(min, max, numBins); // A new histogram (without outliers) … … 1006 1018 PS_VECTOR_PRINT_F32(y); 1007 1019 } 1008 psTrace( "psLib.math", 6, "The clipped numBins is %ld\n", y->n);1009 psTrace( "psLib.math", 6, "The clipped min is %f (%ld)\n", PS_BIN_MIDPOINT(histogram, binMin), binMin);1010 psTrace( "psLib.math", 6, "The clipped max is %f (%ld)\n", PS_BIN_MIDPOINT(histogram, binMax), binMax);1020 psTrace(TRACE, 6, "The clipped numBins is %ld\n", y->n); 1021 psTrace(TRACE, 6, "The clipped min is %f (%ld)\n", PS_BIN_MIDPOINT(histogram, binMin), binMin); 1022 psTrace(TRACE, 6, "The clipped max is %f (%ld)\n", PS_BIN_MIDPOINT(histogram, binMax), binMax); 1011 1023 1012 1024 // Normalize y to [0.0:1.0] (since the psMinimizeLMChi2Gauss1D() functions is [0.0:1.0]) … … 1032 1044 psFree(histogram); 1033 1045 psFree(statsMinMax); 1034 psTrace( "psLib.math", 4, "---- %s(false) end ----\n", __func__);1046 psTrace(TRACE, 4, "---- %s(false) end ----\n", __func__); 1035 1047 return false; 1036 1048 } … … 1056 1068 // The fitted mean is the Gaussian mean. 1057 1069 stats->fittedMean = guessMean; 1058 psTrace( "psLib.math", 6, "The fitted mean is %f.\n", stats->fittedMean);1070 psTrace(TRACE, 6, "The fitted mean is %f.\n", stats->fittedMean); 1059 1071 1060 1072 // The fitted standard deviation 1061 1073 stats->fittedStdev = guessStdev; 1062 psTrace( "psLib.math", 6, "The fitted stdev is %f.\n", stats->fittedStdev);1074 psTrace(TRACE, 6, "The fitted stdev is %f.\n", stats->fittedStdev); 1063 1075 1064 1076 stats->results |= PS_STAT_FITTED_MEAN; … … 1091 1103 stats->fittedStdev = NAN; 1092 1104 stats->fittedStdev = NAN; 1093 psTrace( "psLib.math", 4, "---- %s() end ----\n", __func__);1105 psTrace(TRACE, 4, "---- %s() end ----\n", __func__); 1094 1106 return false; 1095 1107 } … … 1098 1110 float guessMean = stats->robustMedian; // pass the guess mean 1099 1111 1100 psTrace( "psLib.math", 6, "The ** starting ** guess mean is %f.\n", guessMean);1101 psTrace( "psLib.math", 6, "The ** starting ** guess stdev is %f.\n", guessStdev);1112 psTrace(TRACE, 6, "The ** starting ** guess mean is %f.\n", guessMean); 1113 psTrace(TRACE, 6, "The ** starting ** guess stdev is %f.\n", guessStdev); 1102 1114 1103 1115 bool done = false; … … 1109 1121 // Set initial bin size to the specified value. 1110 1122 binSize = stats->binsize; 1111 psTrace( "psLib.math", 6, "Setting initial robust bin size to %.2f\n", binSize);1123 psTrace(TRACE, 6, "Setting initial robust bin size to %.2f\n", binSize); 1112 1124 } else { 1113 1125 // construct a histogram with (sigma/10 < binsize < sigma) … … 1125 1137 psError(PS_ERR_UNKNOWN, false, "Failed to calculate the min/max of the input vector.\n"); 1126 1138 psFree(statsMinMax); 1127 psTrace( "psLib.math", 4, "---- %s(false) end ----\n", __func__);1139 psTrace(TRACE, 4, "---- %s(false) end ----\n", __func__); 1128 1140 return false; 1129 1141 } … … 1132 1144 // XXX can we calculate the binMin, binMax **before** building this histogram? 1133 1145 long numBins = (max - min) / binSize; 1134 psTrace( "psLib.math", 6, "The new min/max values are (%f, %f).\n", min, max);1135 psTrace( "psLib.math", 6, "The new bin size is %f.\n", binSize);1136 psTrace( "psLib.math", 6, "The numBins is %ld\n", numBins);1146 psTrace(TRACE, 6, "The new min/max values are (%f, %f).\n", min, max); 1147 psTrace(TRACE, 6, "The new bin size is %f.\n", binSize); 1148 psTrace(TRACE, 6, "The numBins is %ld\n", numBins); 1137 1149 1138 1150 psHistogram *histogram = psHistogramAlloc(min, max, numBins); // A new histogram (without outliers) … … 1188 1200 PS_VECTOR_PRINT_F32(y); 1189 1201 } 1190 psTrace( "psLib.math", 6, "The clipped numBins is %ld\n", y->n);1191 psTrace( "psLib.math", 6, "The clipped min is %f (%ld)\n", PS_BIN_MIDPOINT(histogram, binMin), binMin);1192 psTrace( "psLib.math", 6, "The clipped max is %f (%ld)\n", PS_BIN_MIDPOINT(histogram, binMax), binMax);1202 psTrace(TRACE, 6, "The clipped numBins is %ld\n", y->n); 1203 psTrace(TRACE, 6, "The clipped min is %f (%ld)\n", PS_BIN_MIDPOINT(histogram, binMin), binMin); 1204 psTrace(TRACE, 6, "The clipped max is %f (%ld)\n", PS_BIN_MIDPOINT(histogram, binMax), binMax); 1193 1205 1194 1206 // fit 2nd order polynomial to ln(y) = -(x-xo)^2/2sigma^2 … … 1210 1222 psFree(histogram); 1211 1223 psFree(statsMinMax); 1212 psTrace( "psLib.math", 4, "---- %s(false) end ----\n", __func__);1224 psTrace(TRACE, 4, "---- %s(false) end ----\n", __func__); 1213 1225 return false; 1214 1226 } 1215 1227 1216 1228 if (poly->coeff[2] >= 0.0) { 1217 psTrace( "psLib.math", 6, "Parabolic fit results: %f + %f x + %f x^2\n", poly->coeff[0], poly->coeff[1], poly->coeff[2]);1229 psTrace(TRACE, 6, "Parabolic fit results: %f + %f x + %f x^2\n", poly->coeff[0], poly->coeff[1], poly->coeff[2]); 1218 1230 psError(PS_ERR_UNKNOWN, false, "fit did not converge\n"); 1219 1231 psFree(x); … … 1222 1234 psFree(histogram); 1223 1235 psFree(statsMinMax); 1224 psTrace( "psLib.math", 4, "---- %s(false) end ----\n", __func__);1236 psTrace(TRACE, 4, "---- %s(false) end ----\n", __func__); 1225 1237 return false; 1226 1238 } … … 1231 1243 done = true; 1232 1244 } else { 1233 psTrace( "psLib.math", 6, "Parabolic fit results: %f + %f x + %f x^2\n", poly->coeff[0], poly->coeff[1], poly->coeff[2]);1234 psTrace( "psLib.math", 6, "The new guess mean is %f.\n", guessMean);1235 psTrace( "psLib.math", 6, "The new guess stdev is %f.\n", guessStdev);1245 psTrace(TRACE, 6, "Parabolic fit results: %f + %f x + %f x^2\n", poly->coeff[0], poly->coeff[1], poly->coeff[2]); 1246 psTrace(TRACE, 6, "The new guess mean is %f.\n", guessMean); 1247 psTrace(TRACE, 6, "The new guess stdev is %f.\n", guessStdev); 1236 1248 } 1237 1249 … … 1248 1260 // The fitted mean is the Gaussian mean. 1249 1261 stats->fittedMean = guessMean; 1250 psTrace( "psLib.math", 6, "The fitted mean is %f.\n", stats->fittedMean);1262 psTrace(TRACE, 6, "The fitted mean is %f.\n", stats->fittedMean); 1251 1263 1252 1264 // The fitted standard deviation 1253 1265 stats->fittedStdev = guessStdev; 1254 psTrace( "psLib.math", 6, "The fitted stdev is %f.\n", stats->fittedStdev);1266 psTrace(TRACE, 6, "The fitted stdev is %f.\n", stats->fittedStdev); 1255 1267 1256 1268 stats->results |= PS_STAT_FITTED_MEAN_V2; … … 1283 1295 stats->fittedStdev = NAN; 1284 1296 stats->fittedStdev = NAN; 1285 psTrace( "psLib.math", 4, "---- %s() end ----\n", __func__);1297 psTrace(TRACE, 4, "---- %s() end ----\n", __func__); 1286 1298 return false; 1287 1299 } … … 1290 1302 float guessMean = stats->robustMedian; // pass the guess mean 1291 1303 1292 psTrace( "psLib.math", 6, "The ** starting ** guess mean is %f.\n", guessMean);1293 psTrace( "psLib.math", 6, "The ** starting ** guess stdev is %f.\n", guessStdev);1304 psTrace(TRACE, 6, "The ** starting ** guess mean is %f.\n", guessMean); 1305 psTrace(TRACE, 6, "The ** starting ** guess stdev is %f.\n", guessStdev); 1294 1306 1295 1307 bool done = false; … … 1301 1313 // Set initial bin size to the specified value. 1302 1314 binSize = stats->binsize; 1303 psTrace( "psLib.math", 6, "Setting initial robust bin size to %.2f\n", binSize);1315 psTrace(TRACE, 6, "Setting initial robust bin size to %.2f\n", binSize); 1304 1316 } else { 1305 1317 // construct a histogram with (sigma/2 < binsize < sigma) … … 1317 1329 psError(PS_ERR_UNKNOWN, false, "Failed to calculate the min/max of the input vector.\n"); 1318 1330 psFree(statsMinMax); 1319 psTrace( "psLib.math", 4, "---- %s(false) end ----\n", __func__);1331 psTrace(TRACE, 4, "---- %s(false) end ----\n", __func__); 1320 1332 return false; 1321 1333 } … … 1324 1336 // XXX can we calculate the binMin, binMax **before** building this histogram? 1325 1337 long numBins = (max - min) / binSize; 1326 psTrace( "psLib.math", 6, "The new min/max values are (%f, %f).\n", min, max);1327 psTrace( "psLib.math", 6, "The new bin size is %f.\n", binSize);1328 psTrace( "psLib.math", 6, "The numBins is %ld\n", numBins);1338 psTrace(TRACE, 6, "The new min/max values are (%f, %f).\n", min, max); 1339 psTrace(TRACE, 6, "The new bin size is %f.\n", binSize); 1340 psTrace(TRACE, 6, "The numBins is %ld\n", numBins); 1329 1341 1330 1342 psHistogram *histogram = psHistogramAlloc(min, max, numBins); // A new histogram (without outliers) … … 1378 1390 // assume a reasonably well-defined gaussian-like population; run from peak out until val < 0.25*peak 1379 1391 1380 psTrace( "psLib.math", 6, "The clipped numBins is %ld\n", binMax - binMin);1381 psTrace( "psLib.math", 6, "The clipped min is %f (%ld)\n", PS_BIN_MIDPOINT(histogram, binMin), binMin);1382 psTrace( "psLib.math", 6, "The clipped max is %f (%ld)\n", PS_BIN_MIDPOINT(histogram, binMax - 1), binMax - 1);1383 psTrace( "psLib.math", 6, "The clipped peak is %f (%ld)\n", PS_BIN_MIDPOINT(histogram, binPeak), binPeak);1392 psTrace(TRACE, 6, "The clipped numBins is %ld\n", binMax - binMin); 1393 psTrace(TRACE, 6, "The clipped min is %f (%ld)\n", PS_BIN_MIDPOINT(histogram, binMin), binMin); 1394 psTrace(TRACE, 6, "The clipped max is %f (%ld)\n", PS_BIN_MIDPOINT(histogram, binMax - 1), binMax - 1); 1395 psTrace(TRACE, 6, "The clipped peak is %f (%ld)\n", PS_BIN_MIDPOINT(histogram, binPeak), binPeak); 1384 1396 1385 1397 { … … 1394 1406 } 1395 1407 } 1396 psTrace( "psLib.math", 6, "Lower bound for lower half: %f (%ld)\n", PS_BIN_MIDPOINT(histogram, binS), binS);1397 psTrace( "psLib.math", 6, "Upper bound for lower half: %f (%ld)\n", PS_BIN_MIDPOINT(histogram, binE), binE);1408 psTrace(TRACE, 6, "Lower bound for lower half: %f (%ld)\n", PS_BIN_MIDPOINT(histogram, binS), binS); 1409 psTrace(TRACE, 6, "Upper bound for lower half: %f (%ld)\n", PS_BIN_MIDPOINT(histogram, binE), binE); 1398 1410 1399 1411 psVector *y = psVectorAllocEmpty(binE - binS, PS_TYPE_F32); // Vector of coordinates … … 1420 1432 psFree(histogram); 1421 1433 psFree(statsMinMax); 1422 psTrace( "psLib.math", 4, "---- %s(false) end ----\n", __func__);1434 psTrace(TRACE, 4, "---- %s(false) end ----\n", __func__); 1423 1435 return false; 1424 1436 } 1425 1437 1426 1438 if (poly->coeff[2] >= 0.0) { 1427 psTrace( "psLib.math", 6, "Failed parabolic fit: %f + %f x + %f x^2\n", poly->coeff[0], poly->coeff[1], poly->coeff[2]);1439 psTrace(TRACE, 6, "Failed parabolic fit: %f + %f x + %f x^2\n", poly->coeff[0], poly->coeff[1], poly->coeff[2]); 1428 1440 psFree(poly); 1429 1441 psFree(histogram); … … 1434 1446 if (iteration == 0) { 1435 1447 guessStdev = 0.25*guessStdev; 1436 psTrace( "psLib.math", 6, "*** retry stdev is %f.\n", guessStdev);1448 psTrace(TRACE, 6, "*** retry stdev is %f.\n", guessStdev); 1437 1449 continue; 1438 1450 } 1439 1451 1440 1452 psError(PS_ERR_UNKNOWN, false, "fit did not converge\n"); 1441 psTrace( "psLib.math", 4, "---- %s(false) end ----\n", __func__);1453 psTrace(TRACE, 4, "---- %s(false) end ----\n", __func__); 1442 1454 return false; 1443 1455 } … … 1449 1461 done = true; 1450 1462 } 1451 psTrace( "psLib.math", 6, "Parabolic Lower fit results: %f + %f x + %f x^2\n", poly->coeff[0], poly->coeff[1], poly->coeff[2]);1452 psTrace( "psLib.math", 6, "The lower mean is %f.\n", guessMean);1453 psTrace( "psLib.math", 6, "The lower stdev is %f.\n", guessStdev);1463 psTrace(TRACE, 6, "Parabolic Lower fit results: %f + %f x + %f x^2\n", poly->coeff[0], poly->coeff[1], poly->coeff[2]); 1464 psTrace(TRACE, 6, "The lower mean is %f.\n", guessMean); 1465 psTrace(TRACE, 6, "The lower stdev is %f.\n", guessStdev); 1454 1466 1455 1467 psFree(poly); … … 1467 1479 } 1468 1480 } 1469 psTrace( "psLib.math", 6, "Lower bound for upper half: %f (%ld)\n", PS_BIN_MIDPOINT(histogram, binS), binS);1470 psTrace( "psLib.math", 6, "Upper bound for upper half: %f (%ld)\n", PS_BIN_MIDPOINT(histogram, binE), binE);1481 psTrace(TRACE, 6, "Lower bound for upper half: %f (%ld)\n", PS_BIN_MIDPOINT(histogram, binS), binS); 1482 psTrace(TRACE, 6, "Upper bound for upper half: %f (%ld)\n", PS_BIN_MIDPOINT(histogram, binE), binE); 1471 1483 1472 1484 psVector *y = psVectorAllocEmpty(binE - binS, PS_TYPE_F32); // Vector of coordinates … … 1493 1505 psFree(histogram); 1494 1506 psFree(statsMinMax); 1495 psTrace( "psLib.math", 4, "---- %s(false) end ----\n", __func__);1507 psTrace(TRACE, 4, "---- %s(false) end ----\n", __func__); 1496 1508 return false; 1497 1509 } … … 1501 1513 float upperStdev = sqrt(-0.5/poly->coeff[2]); 1502 1514 float upperMean = poly->coeff[1]*PS_SQR(upperStdev); 1503 psTrace( "psLib.math", 6, "Parabolic Upper fit results: %f + %f x + %f x^2\n", poly->coeff[0], poly->coeff[1], poly->coeff[2]);1504 psTrace( "psLib.math", 6, "The upper mean is %f.\n", upperMean);1505 psTrace( "psLib.math", 6, "The upper stdev is %f.\n", upperStdev);1515 psTrace(TRACE, 6, "Parabolic Upper fit results: %f + %f x + %f x^2\n", poly->coeff[0], poly->coeff[1], poly->coeff[2]); 1516 psTrace(TRACE, 6, "The upper mean is %f.\n", upperMean); 1517 psTrace(TRACE, 6, "The upper stdev is %f.\n", upperStdev); 1506 1518 #endif 1507 1519 … … 1516 1528 // The fitted mean is the Gaussian mean. 1517 1529 stats->fittedMean = guessMean; 1518 psTrace( "psLib.math", 6, "The fitted mean is %f.\n", stats->fittedMean);1530 psTrace(TRACE, 6, "The fitted mean is %f.\n", stats->fittedMean); 1519 1531 1520 1532 // The fitted standard deviation 1521 1533 stats->fittedStdev = guessStdev; 1522 psTrace( "psLib.math", 6, "The fitted stdev is %f.\n", stats->fittedStdev);1534 psTrace(TRACE, 6, "The fitted stdev is %f.\n", stats->fittedStdev); 1523 1535 1524 1536 stats->results |= PS_STAT_FITTED_MEAN_V3; … … 1539 1551 psF32 sigma) 1540 1552 { 1541 psTrace( "psLib.math", 4, "---- %s() begin ----\n", __func__);1542 psTrace( "psLib.math", 5, "(histogram->nums->n, sigma) is (%d, %.2f\n", (int) histogram->nums->n, sigma);1553 psTrace(TRACE, 4, "---- %s() begin ----\n", __func__); 1554 psTrace(TRACE, 5, "(histogram->nums->n, sigma) is (%d, %.2f\n", (int) histogram->nums->n, sigma); 1543 1555 PS_ASSERT_PTR_NON_NULL(histogram, NULL); 1544 1556 PS_ASSERT_PTR_NON_NULL(histogram->bounds, NULL); … … 1627 1639 PS_VECTOR_PRINT_F32(smooth); 1628 1640 } 1629 psTrace( "psLib.math", 4, "---- %s() end ----\n", __func__);1641 psTrace(TRACE, 4, "---- %s() end ----\n", __func__); 1630 1642 return(smooth); 1631 1643 } … … 1648 1660 psStats* psStatsAlloc(psStatsOptions options) 1649 1661 { 1650 psTrace( "psLib.math", 3,"---- %s() begin ----\n", __func__);1662 psTrace(TRACE, 3,"---- %s() begin ----\n", __func__); 1651 1663 psStats* newStruct = NULL; 1652 1664 … … 1677 1689 newStruct->options = options; 1678 1690 1679 psTrace( "psLib.math", 3, "---- %s() end ----\n", __func__);1691 psTrace(TRACE, 3, "---- %s() end ----\n", __func__); 1680 1692 return (newStruct); 1681 1693 } … … 1709 1721 psMaskType maskVal) 1710 1722 { 1711 psTrace("psLib.math", 3,"---- %s() begin ----\n", __func__); 1712 PS_ASSERT_PTR_NON_NULL(stats, NULL); 1713 PS_ASSERT_VECTOR_NON_NULL(in, NULL); 1723 psTrace(TRACE, 3,"---- %s() begin ----\n", __func__); 1724 PS_ASSERT_PTR_NON_NULL(stats, false); 1725 PS_ASSERT_VECTOR_NON_NULL(in, false); 1726 PS_ASSERT_VECTOR_NON_EMPTY(in, false); 1714 1727 if (mask) { 1715 PS_ASSERT_VECTORS_SIZE_EQUAL(mask, in, stats);1716 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_U8, stats);1728 PS_ASSERT_VECTORS_SIZE_EQUAL(mask, in, false); 1729 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_U8, false); 1717 1730 } 1718 1731 if (errors) { 1719 PS_ASSERT_VECTORS_SIZE_EQUAL(errors, in, stats);1720 PS_ASSERT_VECTOR_TYPE(errors, in->type.type, stats);1732 PS_ASSERT_VECTORS_SIZE_EQUAL(errors, in, false); 1733 PS_ASSERT_VECTOR_TYPE(errors, in->type.type, false); 1721 1734 } 1722 1735 … … 1746 1759 1747 1760 if ((stats->options & PS_STAT_USE_RANGE) && (stats->min >= stats->max)) { 1748 PS_ASSERT_FLOAT_LARGER_THAN_OR_EQUAL(stats->max, stats->min, stats);1761 PS_ASSERT_FLOAT_LARGER_THAN_OR_EQUAL(stats->max, stats->min, false); 1749 1762 } 1750 1763 1751 1764 if ((stats->options & PS_STAT_USE_BINSIZE) && (stats->min >= stats->max)) { 1752 PS_ASSERT_FLOAT_LARGER_THAN_OR_EQUAL(stats->binsize, 0.0, stats);1765 PS_ASSERT_FLOAT_LARGER_THAN_OR_EQUAL(stats->binsize, 0.0, false); 1753 1766 } 1754 1767 … … 1839 1852 psFree(errorsF32); 1840 1853 psFree(maskU8); 1841 psTrace( "psLib.math", 3,"---- %s() end ----\n", __func__);1842 return (status);1854 psTrace(TRACE, 3,"---- %s() end ----\n", __func__); 1855 return status; 1843 1856 } 1844 1857 … … 1923 1936 psStatsOptions option = psStatsOptionFromString(statString); 1924 1937 if (option == 0) { 1925 psWarning("Unable to interpret statistic option: %s --- ignored.\n", 1926 statString); 1938 psWarning("Unable to interpret statistic option: %s --- ignored.\n", statString); 1927 1939 continue; 1928 1940 } … … 2054 2066 ) 2055 2067 { 2056 psTrace( "psLib.math", 4, "---- %s() begin ----\n", __func__);2057 psTrace( "psLib.math", 5, "binNum, yVal is (%d, %f)\n", binNum, yVal);2068 psTrace(TRACE, 4, "---- %s() begin ----\n", __func__); 2069 psTrace(TRACE, 5, "binNum, yVal is (%d, %f)\n", binNum, yVal); 2058 2070 if (psTraceGetLevel("psLib.math") >= 8) { 2059 2071 PS_VECTOR_PRINT_F32(xVec); … … 2081 2093 y->data.F64[1] = yVec->data.F32[binNum]; 2082 2094 y->data.F64[2] = yVec->data.F32[binNum + 1]; 2083 psTrace( "psLib.math", 6, "x vec (orig) is (%f %f %f %f)\n", xVec->data.F32[binNum - 1],2095 psTrace(TRACE, 6, "x vec (orig) is (%f %f %f %f)\n", xVec->data.F32[binNum - 1], 2084 2096 xVec->data.F32[binNum], xVec->data.F32[binNum+1], xVec->data.F32[binNum+2]); 2085 psTrace( "psLib.math", 6, "x data is (%f %f %f)\n", x->data.F64[0], x->data.F64[1], x->data.F64[2]);2086 psTrace( "psLib.math", 6, "y data is (%f %f %f)\n", y->data.F64[0], y->data.F64[1], y->data.F64[2]);2097 psTrace(TRACE, 6, "x data is (%f %f %f)\n", x->data.F64[0], x->data.F64[1], x->data.F64[2]); 2098 psTrace(TRACE, 6, "y data is (%f %f %f)\n", y->data.F64[0], y->data.F64[1], y->data.F64[2]); 2087 2099 2088 2100 // … … 2105 2117 psFree(x); 2106 2118 psFree(y); 2107 psTrace( "psLib.math", 5, "---- %s() end ----\n", __func__);2119 psTrace(TRACE, 5, "---- %s() end ----\n", __func__); 2108 2120 return NAN; 2109 2121 } … … 2116 2128 psFree(x); 2117 2129 psFree(y); 2118 psTrace( "psLib.math", 5, "---- %s(NAN) end ----\n", __func__);2130 psTrace(TRACE, 5, "---- %s(NAN) end ----\n", __func__); 2119 2131 return NAN; 2120 2132 } 2121 psTrace( "psLib.math", 6, "myPoly->coeff[0] is %f\n", myPoly->coeff[0]);2122 psTrace( "psLib.math", 6, "myPoly->coeff[1] is %f\n", myPoly->coeff[1]);2123 psTrace( "psLib.math", 6, "myPoly->coeff[2] is %f\n", myPoly->coeff[2]);2124 psTrace( "psLib.math", 6, "Fitted y vec is (%f %f %f)\n",2133 psTrace(TRACE, 6, "myPoly->coeff[0] is %f\n", myPoly->coeff[0]); 2134 psTrace(TRACE, 6, "myPoly->coeff[1] is %f\n", myPoly->coeff[1]); 2135 psTrace(TRACE, 6, "myPoly->coeff[2] is %f\n", myPoly->coeff[2]); 2136 psTrace(TRACE, 6, "Fitted y vec is (%f %f %f)\n", 2125 2137 (psF32) psPolynomial1DEval(myPoly, (psF64) x->data.F64[0]), 2126 2138 (psF32) psPolynomial1DEval(myPoly, (psF64) x->data.F64[1]), 2127 2139 (psF32) psPolynomial1DEval(myPoly, (psF64) x->data.F64[2])); 2128 2140 2129 psTrace( "psLib.math", 6, "We fit the polynomial, now find x such that f(x) equals %f\n", yVal);2141 psTrace(TRACE, 6, "We fit the polynomial, now find x such that f(x) equals %f\n", yVal); 2130 2142 tmpFloat = QuadraticInverse(myPoly->coeff[2], myPoly->coeff[1], myPoly->coeff[0], yVal, 2131 2143 x->data.F64[0], x->data.F64[2]); … … 2137 2149 psFree(x); 2138 2150 psFree(y); 2139 psTrace( "psLib.math", 5, "---- %s(NAN) end ----\n", __func__);2151 psTrace(TRACE, 5, "---- %s(NAN) end ----\n", __func__); 2140 2152 return(NAN); 2141 2153 } … … 2157 2169 } 2158 2170 2159 psTrace( "psLib.math", 6, "FIT: return %f\n", tmpFloat);2171 psTrace(TRACE, 6, "FIT: return %f\n", tmpFloat); 2160 2172 psFree(x); 2161 2173 psFree(y); 2162 2174 2163 psTrace( "psLib.math", 5, "---- %s(%f) end ----\n", __func__, tmpFloat);2175 psTrace(TRACE, 5, "---- %s(%f) end ----\n", __func__, tmpFloat); 2164 2176 return tmpFloat; 2165 2177 } … … 2173 2185 ) 2174 2186 { 2175 psTrace( "psLib.math", 4, "---- %s() begin ----\n", __func__);2187 psTrace(TRACE, 4, "---- %s() begin ----\n", __func__); 2176 2188 PS_ASSERT_VECTOR_NON_NULL(params, NAN); 2177 2189 PS_ASSERT_VECTOR_SIZE(params, (long)2, NAN); … … 2196 2208 2197 2209 2198 psTrace( "psLib.math", 4, "---- %s() end ----\n", __func__);2210 psTrace(TRACE, 4, "---- %s() end ----\n", __func__); 2199 2211 return gauss; 2200 2212 }
Note:
See TracChangeset
for help on using the changeset viewer.
