Index: /trunk/psLib/src/math/psStats.c
===================================================================
--- /trunk/psLib/src/math/psStats.c	(revision 12691)
+++ /trunk/psLib/src/math/psStats.c	(revision 12692)
@@ -13,9 +13,14 @@
  * use ->min and ->max (PS_STAT_USE_RANGE)
  *
- *  @version $Revision: 1.206 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-03-30 02:53:26 $
+ *  @version $Revision: 1.207 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-03-30 03:24:38 $
  *
  *  Copyright 2006 IfA, University of Hawaii
  */
+
+
+// Note: choice of return values in many places is quite grey.  For example, calculating the sample standard
+// 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
+// unity, even though the standard deviation is not defined in that case (NAN).
 
 #ifdef HAVE_CONFIG_H
@@ -112,4 +117,6 @@
         RESULT = Xt; }
 
+#define TRACE "psLib.math"
+
 /*****************************************************************************/
 /* TYPE DEFINITIONS                                                          */
@@ -171,5 +178,5 @@
                                  psStats* stats)
 {
-    psTrace("psLib.math", 4, "---- %s() begin ----\n", __func__);
+    psTrace(TRACE, 4, "---- %s() begin ----\n", __func__);
 
     long count = 0;                     // Number of points contributing to this mean
@@ -211,10 +218,10 @@
     if (isnan(mean)) {
         // XXX raise an error here?
-        psTrace("psLib.math", 4, "---- %s(false) end ----\n", __func__);
-        return false;
+        psTrace(TRACE, 4, "---- %s(false) end ----\n", __func__);
+        return true;
     }
 
     stats->results |= PS_STAT_SAMPLE_MEAN;
-    psTrace("psLib.math", 4, "---- %s(true) end ----\n", __func__);
+    psTrace(TRACE, 4, "---- %s(true) end ----\n", __func__);
     return true;
 }
@@ -239,5 +246,5 @@
         )
 {
-    psTrace("psLib.math", 4, "---- %s() begin ----\n", __func__);
+    psTrace(TRACE, 4, "---- %s() begin ----\n", __func__);
     psF32 max = -PS_MAX_F32;            // The calculated maximum
     psF32 min = PS_MAX_F32;             // The calculated minimum
@@ -273,5 +280,5 @@
         stats->results |= PS_STAT_MAX;
     }
-    psTrace("psLib.math", 4, "---- %s(%d) end ----\n", __func__, numValid);
+    psTrace(TRACE, 4, "---- %s(%d) end ----\n", __func__, numValid);
     return numValid;
 }
@@ -287,5 +294,5 @@
                                psStats* stats)
 {
-    psTrace("psLib.math", 4, "---- %s() begin ----\n", __func__);
+    psTrace(TRACE, 4, "---- %s() begin ----\n", __func__);
 
     bool useRange = stats->options & PS_STAT_USE_RANGE;
@@ -320,5 +327,5 @@
         stats->sampleLQ = NAN;
         stats->sampleMedian = NAN;
-        return false;
+        return true;
     }
 
@@ -330,5 +337,5 @@
         stats->sampleLQ = NAN;
         stats->sampleMedian = NAN;
-        return false;
+        return true;
     }
 
@@ -351,5 +358,5 @@
 
     // Return "true" on success.
-    psTrace("psLib.math", 4, "---- %s(true) end ----\n", __func__);
+    psTrace(TRACE, 4, "---- %s(true) end ----\n", __func__);
     return true;
 }
@@ -382,5 +389,5 @@
                                   psStats* stats)
 {
-    psTrace("psLib.math", 4, "---- %s() begin ----\n", __func__);
+    psTrace(TRACE, 4, "---- %s() begin ----\n", __func__);
 
     // This procedure requires the mean.  If it has not been already
@@ -392,8 +399,7 @@
     // If the mean is NAN, then generate a warning and set the stdev to NAN.
     if (isnan(stats->sampleMean)) {
+        psTrace(TRACE, 5, "WARNING: vectorSampleStdev(): sample mean is NAN.  Setting stats->sampleStdev = NAN.\n");
         stats->sampleStdev = NAN;
-        psWarning("WARNING: vectorSampleStdev(): vectorSampleMean() reported a NAN mean.\n");
-        psTrace("psLib.math", 4, "---- %s() end ----\n", __func__);
-        return false;
+        return true;
     }
 
@@ -411,10 +417,13 @@
     for (long i = 0; i < myVector->n; i++) {
         // Check if the data is with the specified range
-        if (useRange && (data[i] < stats->min))
+        if (useRange && (data[i] < stats->min)) {
             continue;
-        if (useRange && (data[i] > stats->max))
+        }
+        if (useRange && (data[i] > stats->max)) {
             continue;
-        if (maskData && (maskData[i] & maskVal))
+        }
+        if (maskData && (maskData[i] & maskVal)) {
             continue;
+        }
 
         double diff = data[i] - mean;
@@ -428,12 +437,15 @@
 
     if (count == 0) {
+        // This is an ambiguous case: error or not?
+        // It's not an empty array (that's been asserted on previously), but everything's been masked out.
+        // Assume that the user knows what he's doing when he masks out everything --> no error.
         stats->sampleStdev = NAN;
-        psWarning("WARNING: vectorSampleStdev(): no valid psVector elements (%ld).  Setting stats->sampleStdev = NAN.\n", count);
-        return false;
+        psTrace(TRACE, 5, "WARNING: vectorSampleStdev(): no valid psVector elements (%ld).  Setting stats->sampleStdev = NAN.\n", count);
+        return true;
     }
     if (count == 1) {
         stats->sampleStdev = 0.0;
-        psWarning("WARNING: vectorSampleStdev(): only one valid psVector elements (%ld).  Setting stats->sampleStdev = 0.0.\n", count);
-        return false;
+        psTrace(TRACE, 5, "WARNING: vectorSampleStdev(): only one valid psVector elements (%ld).  Setting stats->sampleStdev = 0.0.\n", count);
+        return true;
     }
 
@@ -445,5 +457,5 @@
     stats->results |= PS_STAT_SAMPLE_STDEV;
 
-    psTrace("psLib.math", 4, "---- %s() end ----\n", __func__);
+    psTrace(TRACE, 4, "---- %s() end ----\n", __func__);
 
     return true;
@@ -469,6 +481,6 @@
     )
 {
-    psTrace("psLib.math", 4, "---- %s() begin ----\n", __func__);
-    psTrace("psLib.math", 4, "Trace level is %d\n", psTraceGetLevel("psLib.math"));
+    psTrace(TRACE, 4, "---- %s() begin ----\n", __func__);
+    psTrace(TRACE, 4, "Trace level is %d\n", psTraceGetLevel("psLib.math"));
 
     // Ensure that stats->clipIter is within the proper range.
@@ -502,20 +514,20 @@
     vectorSampleMedian(myVector, tmpMask, maskVal, stats);
     if (isnan(stats->sampleMedian)) {
-        psWarning("Call to vectorSampleMedian returned NAN\n");
-        psTrace("psLib.math", 4, "---- %s(false) end ----\n", __func__);
+        psTrace(TRACE, 5, "Call to vectorSampleMedian returned NAN\n");
+        psTrace(TRACE, 4, "---- %s(false) end ----\n", __func__);
         psFree(tmpMask);
         return false;
     }
-    psTrace("psLib.math", 6, "The initial sample median is %f\n", stats->sampleMedian);
+    psTrace(TRACE, 6, "The initial sample median is %f\n", stats->sampleMedian);
 
     // 2. Compute the sample standard deviation, which we save for output
     vectorSampleStdev(myVector, errors, tmpMask, maskVal, stats);
     if (isnan(stats->sampleStdev)) {
-        psWarning("Call to vectorSampleStdev returned NAN\n");
-        psTrace("psLib.math", 4, "---- %s(false) end ----\n", __func__);
+        psTrace(TRACE, 5, "Call to vectorSampleStdev returned NAN\n");
+        psTrace(TRACE, 4, "---- %s(false) end ----\n", __func__);
         psFree(tmpMask);
         return false;
     }
-    psTrace("psLib.math", 6, "The initial sample stdev is %f\n", stats->sampleStdev);
+    psTrace(TRACE, 6, "The initial sample stdev is %f\n", stats->sampleStdev);
 
     // 3. Use the sample median as the first estimator of the mean X.
@@ -530,5 +542,5 @@
     for (int iter = 0; iter < stats->clipIter && clipped; iter++) {
         clipped = false;
-        psTrace("psLib.math", 6, "------------ Iteration %d ------------\n", iter);
+        psTrace(TRACE, 6, "------------ Iteration %d ------------\n", iter);
         // a) Exclude all values x_i for which |x_i - x| > K * stdev
         if (errors) {
@@ -538,5 +550,5 @@
                     fabsf(myVector->data.F32[j] - clippedMean) > stats->clipSigma * errors->data.F32[j]) {
                     tmpMask->data.U8[j] = 0xff;
-                    psTrace("psLib.math", 10, "Clipped %ld: %f +/- %f\n", j,
+                    psTrace(TRACE, 10, "Clipped %ld: %f +/- %f\n", j,
                             myVector->data.F32[j], errors->data.F32[j]);
                     numClipped++;
@@ -549,5 +561,5 @@
                     fabsf(myVector->data.F32[j] - clippedMean) > (stats->clipSigma * clippedStdev)) {
                     tmpMask->data.U8[j] = 0xff;
-                    psTrace("psLib.math", 10, "Clipped %ld: %f\n", j, myVector->data.F32[j]);
+                    psTrace(TRACE, 10, "Clipped %ld: %f\n", j, myVector->data.F32[j]);
                     numClipped++;
                     clipped = true;
@@ -561,6 +573,6 @@
         vectorSampleMean(myVector, errors, tmpMask, maskVal, statsTmp);
         vectorSampleStdev(myVector, errors, tmpMask, maskVal, statsTmp);
-        psTrace("psLib.math", 6, "The new sample mean is %f\n", statsTmp->sampleMean);
-        psTrace("psLib.math", 6, "The new sample stdev is %f\n", statsTmp->sampleStdev);
+        psTrace(TRACE, 6, "The new sample mean is %f\n", statsTmp->sampleMean);
+        psTrace(TRACE, 6, "The new sample stdev is %f\n", statsTmp->sampleStdev);
 
         // If the new mean and stdev are NAN, we must exit the loop.
@@ -591,9 +603,9 @@
     stats->results |= PS_STAT_CLIPPED_STDEV;
 
-    psTrace("psLib.math", 6, "The final clipped mean is %f\n", clippedMean);
-    psTrace("psLib.math", 6, "The final clipped stdev is %f\n", clippedStdev);
+    psTrace(TRACE, 6, "The final clipped mean is %f\n", clippedMean);
+    psTrace(TRACE, 6, "The final clipped stdev is %f\n", clippedStdev);
 
     psFree(tmpMask);
-    psTrace("psLib.math", 4, "---- %s(true) end ----\n", __func__);
+    psTrace(TRACE, 4, "---- %s(true) end ----\n", __func__);
     return true;
 }
@@ -624,5 +636,5 @@
                               psStats* stats)
 {
-    psTrace("psLib.math", 4, "---- %s() begin ----\n", __func__);
+    psTrace(TRACE, 4, "---- %s() begin ----\n", __func__);
     if (psTraceGetLevel("psLib.math") >= 8) {
         PS_VECTOR_PRINT_F32(myVector);
@@ -658,5 +670,5 @@
     // Iterate to get the best bin size
     for (int iterate = 1; iterate > 0; iterate++) {
-        psTrace("psLib.math", 6, "-------------------- Iterating on Bin size.  Iteration number %d --------------------\n", iterate);
+        psTrace(TRACE, 6, "-------------------- Iterating on Bin size.  Iteration number %d --------------------\n", iterate);
 
         // Get the minimum and maximum values
@@ -669,5 +681,5 @@
             goto escape;
         }
-        psTrace("psLib.math", 6, "Data min/max is (%.2f, %.2f)\n", min, max);
+        psTrace(TRACE, 6, "Data min/max is (%.2f, %.2f)\n", min, max);
 
         // If all data points have the same value, then we set the appropriate members of stats and return.
@@ -681,6 +693,6 @@
             stats->results |= PS_STAT_ROBUST_STDEV;
             stats->results |= PS_STAT_ROBUST_QUARTILE;
-            psTrace("psLib.math", 5, "All data points have the same value: %f.\n", min);
-            psTrace("psLib.math", 4, "---- %s(0) end  ----\n", __func__);
+            psTrace(TRACE, 5, "All data points have the same value: %f.\n", min);
+            psTrace(TRACE, 4, "---- %s(0) end  ----\n", __func__);
             psFree(mask);
             psFree(statsMinMax);
@@ -691,10 +703,10 @@
             // Set initial bin size to the specified value.
             binSize = stats->binsize;
-            psTrace("psLib.math", 6, "Setting initial robust bin size to %.2f\n", binSize);
+            psTrace(TRACE, 6, "Setting initial robust bin size to %.2f\n", binSize);
         } else {
             // Determine the bin size of the robust histogram, using the pre-defined number of bins
             binSize = (max - min) / INITIAL_NUM_BINS;
         }
-        psTrace("psLib.math", 6, "Initial robust bin size is %.2f\n", binSize);
+        psTrace(TRACE, 6, "Initial robust bin size is %.2f\n", binSize);
 
         // ADD step 0: Construct the histogram with the specified bin size.  NOTE: we can not specify the bin
@@ -702,6 +714,6 @@
         // we get here, we know that binSize != 0.0.
         long numBins = (max - min) / binSize; // Number of bins
-        psTrace("psLib.math", 6, "Numbins is %ld\n", numBins);
-        psTrace("psLib.math", 6, "Creating a robust histogram from data range (%.2f - %.2f)\n", min, max);
+        psTrace(TRACE, 6, "Numbins is %ld\n", numBins);
+        psTrace(TRACE, 6, "Creating a robust histogram from data range (%.2f - %.2f)\n", min, max);
         // Generate the histogram
         histogram = psHistogramAlloc(min, max, numBins);
@@ -729,8 +741,8 @@
         // ADD step 2: Find the bin which contains the 50% data point.
         totalDataPoints = cumulative->nums->data.F32[numBins - 1];
-        psTrace("psLib.math", 6, "Total data points is %ld\n", totalDataPoints);
+        psTrace(TRACE, 6, "Total data points is %ld\n", totalDataPoints);
 
         PS_BIN_FOR_VALUE(binMedian, cumulative->nums, totalDataPoints/2.0, 0);
-        psTrace("psLib.math", 6, "The median bin is %ld (%.2f to %.2f)\n", binMedian,
+        psTrace(TRACE, 6, "The median bin is %ld (%.2f to %.2f)\n", binMedian,
                 cumulative->bounds->data.F32[binMedian], cumulative->bounds->data.F32[binMedian+1]);
 
@@ -742,5 +754,5 @@
             goto escape;
         }
-        psTrace("psLib.math", 6, "Current robust median is %f\n", stats->robustMedian);
+        psTrace(TRACE, 6, "Current robust median is %f\n", stats->robustMedian);
 
         // ADD step 4: Find the bins which contains the 15.8655% (-1 sigma) and 84.1345% (+1 sigma) data points
@@ -751,10 +763,10 @@
         PS_BIN_FOR_VALUE(binH2, cumulative->nums, totalDataPoints * 0.691462f, 0);
 
-        psTrace("psLib.math", 6, "The 15.8655%% and 84.1345%% data point bins are (%ld, %ld).\n",
+        psTrace(TRACE, 6, "The 15.8655%% and 84.1345%% data point bins are (%ld, %ld).\n",
                 binLo, binHi);
-        psTrace("psLib.math", 6, "binLo midpoint is %f\n", PS_BIN_MIDPOINT(cumulative, binLo));
-        psTrace("psLib.math", 6, "binHi midpoint is %f\n", PS_BIN_MIDPOINT(cumulative, binHi));
-        psTrace("psLib.math", 6, "binL2 midpoint is %f\n", PS_BIN_MIDPOINT(cumulative, binL2));
-        psTrace("psLib.math", 6, "binH2 midpoint is %f\n", PS_BIN_MIDPOINT(cumulative, binH2));
+        psTrace(TRACE, 6, "binLo midpoint is %f\n", PS_BIN_MIDPOINT(cumulative, binLo));
+        psTrace(TRACE, 6, "binHi midpoint is %f\n", PS_BIN_MIDPOINT(cumulative, binHi));
+        psTrace(TRACE, 6, "binL2 midpoint is %f\n", PS_BIN_MIDPOINT(cumulative, binL2));
+        psTrace(TRACE, 6, "binH2 midpoint is %f\n", PS_BIN_MIDPOINT(cumulative, binH2));
 
         if ((binLo < 0) || (binHi < 0)) {
@@ -764,7 +776,7 @@
 
         // ADD step 4b: Interpolate Sigma (linearly) to find these two positions exactly: these are the 1sigma positions.
-        psTrace("psLib.math", 6, "binLo is %ld.  Nums at that bin and the next are (%.2f, %.2f)\n",
+        psTrace(TRACE, 6, "binLo is %ld.  Nums at that bin and the next are (%.2f, %.2f)\n",
                 binLo, cumulative->nums->data.F32[binLo], cumulative->nums->data.F32[binLo+1]);
-        psTrace("psLib.math", 6, "binHi is %ld.  Nums at that bin and the next are (%.2f, %.2f)\n",
+        psTrace(TRACE, 6, "binHi is %ld.  Nums at that bin and the next are (%.2f, %.2f)\n",
                 binHi, cumulative->nums->data.F32[binHi], cumulative->nums->data.F32[binHi+1]);
 
@@ -779,5 +791,5 @@
 
         // report +/- 1 sigma points
-        psTrace("psLib.math", 5,
+        psTrace(TRACE, 5,
                 "The exact 15.8655 and 84.1345 percent data point positions are: (%f, %f)\n",
                 binLoF32, binHiF32);
@@ -787,5 +799,5 @@
         sigma = (binH2F32 - binL2F32);
 
-        psTrace("psLib.math", 6, "The current sigma is %f.\n", sigma);
+        psTrace(TRACE, 6, "The current sigma is %f.\n", sigma);
         stats->robustStdev = sigma;
 
@@ -793,18 +805,18 @@
         // than 25 bins from the median, recalculate the bin size, and perform the algorithm again.
         if (sigma < (2 * binSize)) {
-            psTrace("psLib.math", 6, "*************: Do another iteration (%f %f).\n", sigma, binSize);
+            psTrace(TRACE, 6, "*************: Do another iteration (%f %f).\n", sigma, binSize);
             long maskLo = PS_MAX(0, (binMedian - 25)); // Low index for masking region
             long maskHi = PS_MIN(histogram->bounds->n - 1, (binMedian + 25)); // High index for masking
             psF32 medianLo = histogram->bounds->data.F32[maskLo]; // Value at low index
             psF32 medianHi = histogram->bounds->data.F32[maskHi]; // Value at high index
-            psTrace("psLib.math", 6, "Masking data more than 25 bins from the median\n");
-            psTrace("psLib.math", 6,
+            psTrace(TRACE, 6, "Masking data more than 25 bins from the median\n");
+            psTrace(TRACE, 6,
                     "The median is at bin number %ld.  We mask bins outside the bin range (%ld:%ld)\n",
                     binMedian, maskLo, maskHi);
-            psTrace("psLib.math", 6, "Masking data outside (%f %f)\n", medianLo, medianHi);
+            psTrace(TRACE, 6, "Masking data outside (%f %f)\n", medianLo, medianHi);
             for (long i = 0 ; i < myVector->n ; i++) {
                 if ((myVector->data.F32[i] < medianLo) || (myVector->data.F32[i] > medianHi)) {
                     mask->data.U8[i] |= MASK_MARK;
-                    psTrace("psLib.math", 6, "Masking element %ld is %f\n", i, myVector->data.F32[i]);
+                    psTrace(TRACE, 6, "Masking element %ld is %f\n", i, myVector->data.F32[i]);
                 }
             }
@@ -817,5 +829,5 @@
         } else {
             // We've got the bin size correct now
-            psTrace("psLib.math", 6, "*************: No more iteration.  sigma is %f\n", sigma);
+            psTrace(TRACE, 6, "*************: No more iteration.  sigma is %f\n", sigma);
             iterate = -1;
         }
@@ -831,5 +843,5 @@
     PS_BIN_FOR_VALUE (binLo25, cumulative->nums, totalDataPoints * 0.25f, 0);
     PS_BIN_FOR_VALUE (binHi25, cumulative->nums, totalDataPoints * 0.75f, 0);
-    psTrace("psLib.math", 6, "The 25-percent and 75-precent data point bins are (%ld, %ld).\n", binLo25, binHi25);
+    psTrace(TRACE, 6, "The 25-percent and 75-precent data point bins are (%ld, %ld).\n", binLo25, binHi25);
 
     // ADD step 8: Interpolate to find these two positions exactly: these are the upper and lower quartile
@@ -847,5 +859,5 @@
     stats->robustLQ = binLo25F32;
     stats->robustUQ = binHi25F32;
-    psTrace("psLib.math", 6, "The 25 and 75 percent data point exact positions are (%f, %f).\n",
+    psTrace(TRACE, 6, "The 25 and 75 percent data point exact positions are (%f, %f).\n",
             binLo25F32, binHi25F32);
     long N50 = 0;
@@ -857,5 +869,5 @@
     }
     stats->robustN50 = N50;
-    psTrace("psLib.math", 6, "The robustN50 is %ld.\n", N50);
+    psTrace(TRACE, 6, "The robustN50 is %ld.\n", N50);
 
     // Clean up
@@ -869,5 +881,5 @@
     stats->results |= PS_STAT_ROBUST_QUARTILE;
 
-    psTrace("psLib.math", 4, "---- %s(0) end  ----\n", __func__);
+    psTrace(TRACE, 4, "---- %s(0) end  ----\n", __func__);
     return true;
 
@@ -882,5 +894,5 @@
     stats->results |= PS_STAT_ROBUST_QUARTILE;
 
-    psTrace("psLib.math", 4, "---- %s(false) end  ----\n", __func__);
+    psTrace(TRACE, 4, "---- %s(false) end  ----\n", __func__);
 
     psFree(histogram);
@@ -913,5 +925,5 @@
         stats->fittedStdev = NAN;
         stats->fittedStdev = NAN;
-        psTrace("psLib.math", 4, "---- %s() end ----\n", __func__);
+        psTrace(TRACE, 4, "---- %s() end ----\n", __func__);
         return false;
     }
@@ -920,6 +932,6 @@
     float guessMean = stats->robustMedian;  // pass the guess mean
 
-    psTrace("psLib.math", 6, "The guess mean  is %f.\n", guessMean);
-    psTrace("psLib.math", 6, "The guess stdev is %f.\n", guessStdev);
+    psTrace(TRACE, 6, "The guess mean  is %f.\n", guessMean);
+    psTrace(TRACE, 6, "The guess stdev is %f.\n", guessStdev);
 
     bool done = false;
@@ -931,5 +943,5 @@
             // Set initial bin size to the specified value.
             binSize = stats->binsize;
-            psTrace("psLib.math", 6, "Setting initial robust bin size to %.2f\n", binSize);
+            psTrace(TRACE, 6, "Setting initial robust bin size to %.2f\n", binSize);
         } else {
             // construct a histogram with (sigma/10 < binsize < sigma)
@@ -947,5 +959,5 @@
             psError(PS_ERR_UNKNOWN, false, "Failed to calculate the min/max of the input vector.\n");
             psFree(statsMinMax);
-            psTrace("psLib.math", 4, "---- %s(false) end  ----\n", __func__);
+            psTrace(TRACE, 4, "---- %s(false) end  ----\n", __func__);
             return false;
         }
@@ -954,7 +966,7 @@
         // XXX can we calculate the binMin, binMax **before** building this histogram?
         long numBins = (max - min) / binSize;
-        psTrace("psLib.math", 6, "The new min/max values are (%f, %f).\n", min, max);
-        psTrace("psLib.math", 6, "The new bin size is %f.\n", binSize);
-        psTrace("psLib.math", 6, "The numBins is %ld\n", numBins);
+        psTrace(TRACE, 6, "The new min/max values are (%f, %f).\n", min, max);
+        psTrace(TRACE, 6, "The new bin size is %f.\n", binSize);
+        psTrace(TRACE, 6, "The numBins is %ld\n", numBins);
 
         psHistogram *histogram = psHistogramAlloc(min, max, numBins); // A new histogram (without outliers)
@@ -1006,7 +1018,7 @@
             PS_VECTOR_PRINT_F32(y);
         }
-        psTrace("psLib.math", 6, "The clipped numBins is %ld\n", y->n);
-        psTrace("psLib.math", 6, "The clipped min is %f (%ld)\n", PS_BIN_MIDPOINT(histogram, binMin), binMin);
-        psTrace("psLib.math", 6, "The clipped max is %f (%ld)\n", PS_BIN_MIDPOINT(histogram, binMax), binMax);
+        psTrace(TRACE, 6, "The clipped numBins is %ld\n", y->n);
+        psTrace(TRACE, 6, "The clipped min is %f (%ld)\n", PS_BIN_MIDPOINT(histogram, binMin), binMin);
+        psTrace(TRACE, 6, "The clipped max is %f (%ld)\n", PS_BIN_MIDPOINT(histogram, binMax), binMax);
 
         // Normalize y to [0.0:1.0] (since the psMinimizeLMChi2Gauss1D() functions is [0.0:1.0])
@@ -1032,5 +1044,5 @@
             psFree(histogram);
             psFree(statsMinMax);
-            psTrace("psLib.math", 4, "---- %s(false) end  ----\n", __func__);
+            psTrace(TRACE, 4, "---- %s(false) end  ----\n", __func__);
             return false;
         }
@@ -1056,9 +1068,9 @@
     // The fitted mean is the Gaussian mean.
     stats->fittedMean = guessMean;
-    psTrace("psLib.math", 6, "The fitted mean is %f.\n", stats->fittedMean);
+    psTrace(TRACE, 6, "The fitted mean is %f.\n", stats->fittedMean);
 
     // The fitted standard deviation
     stats->fittedStdev = guessStdev;
-    psTrace("psLib.math", 6, "The fitted stdev is %f.\n", stats->fittedStdev);
+    psTrace(TRACE, 6, "The fitted stdev is %f.\n", stats->fittedStdev);
 
     stats->results |= PS_STAT_FITTED_MEAN;
@@ -1091,5 +1103,5 @@
         stats->fittedStdev = NAN;
         stats->fittedStdev = NAN;
-        psTrace("psLib.math", 4, "---- %s() end ----\n", __func__);
+        psTrace(TRACE, 4, "---- %s() end ----\n", __func__);
         return false;
     }
@@ -1098,6 +1110,6 @@
     float guessMean = stats->robustMedian;  // pass the guess mean
 
-    psTrace("psLib.math", 6, "The ** starting ** guess mean  is %f.\n", guessMean);
-    psTrace("psLib.math", 6, "The ** starting ** guess stdev is %f.\n", guessStdev);
+    psTrace(TRACE, 6, "The ** starting ** guess mean  is %f.\n", guessMean);
+    psTrace(TRACE, 6, "The ** starting ** guess stdev is %f.\n", guessStdev);
 
     bool done = false;
@@ -1109,5 +1121,5 @@
             // Set initial bin size to the specified value.
             binSize = stats->binsize;
-            psTrace("psLib.math", 6, "Setting initial robust bin size to %.2f\n", binSize);
+            psTrace(TRACE, 6, "Setting initial robust bin size to %.2f\n", binSize);
         } else {
             // construct a histogram with (sigma/10 < binsize < sigma)
@@ -1125,5 +1137,5 @@
             psError(PS_ERR_UNKNOWN, false, "Failed to calculate the min/max of the input vector.\n");
             psFree(statsMinMax);
-            psTrace("psLib.math", 4, "---- %s(false) end  ----\n", __func__);
+            psTrace(TRACE, 4, "---- %s(false) end  ----\n", __func__);
             return false;
         }
@@ -1132,7 +1144,7 @@
         // XXX can we calculate the binMin, binMax **before** building this histogram?
         long numBins = (max - min) / binSize;
-        psTrace("psLib.math", 6, "The new min/max values are (%f, %f).\n", min, max);
-        psTrace("psLib.math", 6, "The new bin size is %f.\n", binSize);
-        psTrace("psLib.math", 6, "The numBins is %ld\n", numBins);
+        psTrace(TRACE, 6, "The new min/max values are (%f, %f).\n", min, max);
+        psTrace(TRACE, 6, "The new bin size is %f.\n", binSize);
+        psTrace(TRACE, 6, "The numBins is %ld\n", numBins);
 
         psHistogram *histogram = psHistogramAlloc(min, max, numBins); // A new histogram (without outliers)
@@ -1188,7 +1200,7 @@
             PS_VECTOR_PRINT_F32(y);
         }
-        psTrace("psLib.math", 6, "The clipped numBins is %ld\n", y->n);
-        psTrace("psLib.math", 6, "The clipped min is %f (%ld)\n", PS_BIN_MIDPOINT(histogram, binMin), binMin);
-        psTrace("psLib.math", 6, "The clipped max is %f (%ld)\n", PS_BIN_MIDPOINT(histogram, binMax), binMax);
+        psTrace(TRACE, 6, "The clipped numBins is %ld\n", y->n);
+        psTrace(TRACE, 6, "The clipped min is %f (%ld)\n", PS_BIN_MIDPOINT(histogram, binMin), binMin);
+        psTrace(TRACE, 6, "The clipped max is %f (%ld)\n", PS_BIN_MIDPOINT(histogram, binMax), binMax);
 
         // fit 2nd order polynomial to ln(y) = -(x-xo)^2/2sigma^2
@@ -1210,10 +1222,10 @@
             psFree(histogram);
             psFree(statsMinMax);
-            psTrace("psLib.math", 4, "---- %s(false) end  ----\n", __func__);
+            psTrace(TRACE, 4, "---- %s(false) end  ----\n", __func__);
             return false;
         }
 
         if (poly->coeff[2] >= 0.0) {
-            psTrace("psLib.math", 6, "Parabolic fit results: %f + %f x + %f x^2\n", poly->coeff[0], poly->coeff[1], poly->coeff[2]);
+            psTrace(TRACE, 6, "Parabolic fit results: %f + %f x + %f x^2\n", poly->coeff[0], poly->coeff[1], poly->coeff[2]);
             psError(PS_ERR_UNKNOWN, false, "fit did not converge\n");
             psFree(x);
@@ -1222,5 +1234,5 @@
             psFree(histogram);
             psFree(statsMinMax);
-            psTrace("psLib.math", 4, "---- %s(false) end  ----\n", __func__);
+            psTrace(TRACE, 4, "---- %s(false) end  ----\n", __func__);
             return false;
         }
@@ -1231,7 +1243,7 @@
             done = true;
         } else {
-            psTrace("psLib.math", 6, "Parabolic fit results: %f + %f x + %f x^2\n", poly->coeff[0], poly->coeff[1], poly->coeff[2]);
-            psTrace("psLib.math", 6, "The new guess mean  is %f.\n", guessMean);
-            psTrace("psLib.math", 6, "The new guess stdev is %f.\n", guessStdev);
+            psTrace(TRACE, 6, "Parabolic fit results: %f + %f x + %f x^2\n", poly->coeff[0], poly->coeff[1], poly->coeff[2]);
+            psTrace(TRACE, 6, "The new guess mean  is %f.\n", guessMean);
+            psTrace(TRACE, 6, "The new guess stdev is %f.\n", guessStdev);
         }
 
@@ -1248,9 +1260,9 @@
     // The fitted mean is the Gaussian mean.
     stats->fittedMean = guessMean;
-    psTrace("psLib.math", 6, "The fitted mean is %f.\n", stats->fittedMean);
+    psTrace(TRACE, 6, "The fitted mean is %f.\n", stats->fittedMean);
 
     // The fitted standard deviation
     stats->fittedStdev = guessStdev;
-    psTrace("psLib.math", 6, "The fitted stdev is %f.\n", stats->fittedStdev);
+    psTrace(TRACE, 6, "The fitted stdev is %f.\n", stats->fittedStdev);
 
     stats->results |= PS_STAT_FITTED_MEAN_V2;
@@ -1283,5 +1295,5 @@
         stats->fittedStdev = NAN;
         stats->fittedStdev = NAN;
-        psTrace("psLib.math", 4, "---- %s() end ----\n", __func__);
+        psTrace(TRACE, 4, "---- %s() end ----\n", __func__);
         return false;
     }
@@ -1290,6 +1302,6 @@
     float guessMean = stats->robustMedian;  // pass the guess mean
 
-    psTrace("psLib.math", 6, "The ** starting ** guess mean  is %f.\n", guessMean);
-    psTrace("psLib.math", 6, "The ** starting ** guess stdev is %f.\n", guessStdev);
+    psTrace(TRACE, 6, "The ** starting ** guess mean  is %f.\n", guessMean);
+    psTrace(TRACE, 6, "The ** starting ** guess stdev is %f.\n", guessStdev);
 
     bool done = false;
@@ -1301,5 +1313,5 @@
             // Set initial bin size to the specified value.
             binSize = stats->binsize;
-            psTrace("psLib.math", 6, "Setting initial robust bin size to %.2f\n", binSize);
+            psTrace(TRACE, 6, "Setting initial robust bin size to %.2f\n", binSize);
         } else {
             // construct a histogram with (sigma/2 < binsize < sigma)
@@ -1317,5 +1329,5 @@
             psError(PS_ERR_UNKNOWN, false, "Failed to calculate the min/max of the input vector.\n");
             psFree(statsMinMax);
-            psTrace("psLib.math", 4, "---- %s(false) end  ----\n", __func__);
+            psTrace(TRACE, 4, "---- %s(false) end  ----\n", __func__);
             return false;
         }
@@ -1324,7 +1336,7 @@
         // XXX can we calculate the binMin, binMax **before** building this histogram?
         long numBins = (max - min) / binSize;
-        psTrace("psLib.math", 6, "The new min/max values are (%f, %f).\n", min, max);
-        psTrace("psLib.math", 6, "The new bin size is %f.\n", binSize);
-        psTrace("psLib.math", 6, "The numBins is %ld\n", numBins);
+        psTrace(TRACE, 6, "The new min/max values are (%f, %f).\n", min, max);
+        psTrace(TRACE, 6, "The new bin size is %f.\n", binSize);
+        psTrace(TRACE, 6, "The numBins is %ld\n", numBins);
 
         psHistogram *histogram = psHistogramAlloc(min, max, numBins); // A new histogram (without outliers)
@@ -1378,8 +1390,8 @@
         // assume a reasonably well-defined gaussian-like population; run from peak out until val < 0.25*peak
 
-        psTrace("psLib.math", 6, "The clipped numBins is %ld\n", binMax - binMin);
-        psTrace("psLib.math", 6, "The clipped min is %f (%ld)\n", PS_BIN_MIDPOINT(histogram, binMin), binMin);
-        psTrace("psLib.math", 6, "The clipped max is %f (%ld)\n", PS_BIN_MIDPOINT(histogram, binMax - 1), binMax - 1);
-        psTrace("psLib.math", 6, "The clipped peak is %f (%ld)\n", PS_BIN_MIDPOINT(histogram, binPeak), binPeak);
+        psTrace(TRACE, 6, "The clipped numBins is %ld\n", binMax - binMin);
+        psTrace(TRACE, 6, "The clipped min is %f (%ld)\n", PS_BIN_MIDPOINT(histogram, binMin), binMin);
+        psTrace(TRACE, 6, "The clipped max is %f (%ld)\n", PS_BIN_MIDPOINT(histogram, binMax - 1), binMax - 1);
+        psTrace(TRACE, 6, "The clipped peak is %f (%ld)\n", PS_BIN_MIDPOINT(histogram, binPeak), binPeak);
 
         {
@@ -1394,6 +1406,6 @@
                 }
             }
-            psTrace("psLib.math", 6, "Lower bound for lower half: %f (%ld)\n", PS_BIN_MIDPOINT(histogram, binS), binS);
-            psTrace("psLib.math", 6, "Upper bound for lower half: %f (%ld)\n", PS_BIN_MIDPOINT(histogram, binE), binE);
+            psTrace(TRACE, 6, "Lower bound for lower half: %f (%ld)\n", PS_BIN_MIDPOINT(histogram, binS), binS);
+            psTrace(TRACE, 6, "Upper bound for lower half: %f (%ld)\n", PS_BIN_MIDPOINT(histogram, binE), binE);
 
             psVector *y = psVectorAllocEmpty(binE - binS, PS_TYPE_F32); // Vector of coordinates
@@ -1420,10 +1432,10 @@
                 psFree(histogram);
                 psFree(statsMinMax);
-                psTrace("psLib.math", 4, "---- %s(false) end  ----\n", __func__);
+                psTrace(TRACE, 4, "---- %s(false) end  ----\n", __func__);
                 return false;
             }
 
             if (poly->coeff[2] >= 0.0) {
-                psTrace("psLib.math", 6, "Failed parabolic fit: %f + %f x + %f x^2\n", poly->coeff[0], poly->coeff[1], poly->coeff[2]);
+                psTrace(TRACE, 6, "Failed parabolic fit: %f + %f x + %f x^2\n", poly->coeff[0], poly->coeff[1], poly->coeff[2]);
                 psFree(poly);
                 psFree(histogram);
@@ -1434,10 +1446,10 @@
                 if (iteration == 0) {
                     guessStdev = 0.25*guessStdev;
-                    psTrace("psLib.math", 6, "*** retry stdev is %f.\n", guessStdev);
+                    psTrace(TRACE, 6, "*** retry stdev is %f.\n", guessStdev);
                     continue;
                 }
 
                 psError(PS_ERR_UNKNOWN, false, "fit did not converge\n");
-                psTrace("psLib.math", 4, "---- %s(false) end  ----\n", __func__);
+                psTrace(TRACE, 4, "---- %s(false) end  ----\n", __func__);
                 return false;
             }
@@ -1449,7 +1461,7 @@
                 done = true;
             }
-            psTrace("psLib.math", 6, "Parabolic Lower fit results: %f + %f x + %f x^2\n", poly->coeff[0], poly->coeff[1], poly->coeff[2]);
-            psTrace("psLib.math", 6, "The lower mean  is %f.\n", guessMean);
-            psTrace("psLib.math", 6, "The lower stdev is %f.\n", guessStdev);
+            psTrace(TRACE, 6, "Parabolic Lower fit results: %f + %f x + %f x^2\n", poly->coeff[0], poly->coeff[1], poly->coeff[2]);
+            psTrace(TRACE, 6, "The lower mean  is %f.\n", guessMean);
+            psTrace(TRACE, 6, "The lower stdev is %f.\n", guessStdev);
 
             psFree(poly);
@@ -1467,6 +1479,6 @@
                 }
             }
-            psTrace("psLib.math", 6, "Lower bound for upper half: %f (%ld)\n", PS_BIN_MIDPOINT(histogram, binS), binS);
-            psTrace("psLib.math", 6, "Upper bound for upper half: %f (%ld)\n", PS_BIN_MIDPOINT(histogram, binE), binE);
+            psTrace(TRACE, 6, "Lower bound for upper half: %f (%ld)\n", PS_BIN_MIDPOINT(histogram, binS), binS);
+            psTrace(TRACE, 6, "Upper bound for upper half: %f (%ld)\n", PS_BIN_MIDPOINT(histogram, binE), binE);
 
             psVector *y = psVectorAllocEmpty(binE - binS, PS_TYPE_F32); // Vector of coordinates
@@ -1493,5 +1505,5 @@
                 psFree(histogram);
                 psFree(statsMinMax);
-                psTrace("psLib.math", 4, "---- %s(false) end  ----\n", __func__);
+                psTrace(TRACE, 4, "---- %s(false) end  ----\n", __func__);
                 return false;
             }
@@ -1501,7 +1513,7 @@
             float upperStdev = sqrt(-0.5/poly->coeff[2]);
             float upperMean = poly->coeff[1]*PS_SQR(upperStdev);
-            psTrace("psLib.math", 6, "Parabolic Upper fit results: %f + %f x + %f x^2\n", poly->coeff[0], poly->coeff[1], poly->coeff[2]);
-            psTrace("psLib.math", 6, "The upper mean  is %f.\n", upperMean);
-            psTrace("psLib.math", 6, "The upper stdev is %f.\n", upperStdev);
+            psTrace(TRACE, 6, "Parabolic Upper fit results: %f + %f x + %f x^2\n", poly->coeff[0], poly->coeff[1], poly->coeff[2]);
+            psTrace(TRACE, 6, "The upper mean  is %f.\n", upperMean);
+            psTrace(TRACE, 6, "The upper stdev is %f.\n", upperStdev);
 #endif
 
@@ -1516,9 +1528,9 @@
     // The fitted mean is the Gaussian mean.
     stats->fittedMean = guessMean;
-    psTrace("psLib.math", 6, "The fitted mean is %f.\n", stats->fittedMean);
+    psTrace(TRACE, 6, "The fitted mean is %f.\n", stats->fittedMean);
 
     // The fitted standard deviation
     stats->fittedStdev = guessStdev;
-    psTrace("psLib.math", 6, "The fitted stdev is %f.\n", stats->fittedStdev);
+    psTrace(TRACE, 6, "The fitted stdev is %f.\n", stats->fittedStdev);
 
     stats->results |= PS_STAT_FITTED_MEAN_V3;
@@ -1539,6 +1551,6 @@
                                    psF32 sigma)
 {
-    psTrace("psLib.math", 4, "---- %s() begin ----\n", __func__);
-    psTrace("psLib.math", 5, "(histogram->nums->n, sigma) is (%d, %.2f\n", (int) histogram->nums->n, sigma);
+    psTrace(TRACE, 4, "---- %s() begin ----\n", __func__);
+    psTrace(TRACE, 5, "(histogram->nums->n, sigma) is (%d, %.2f\n", (int) histogram->nums->n, sigma);
     PS_ASSERT_PTR_NON_NULL(histogram, NULL);
     PS_ASSERT_PTR_NON_NULL(histogram->bounds, NULL);
@@ -1627,5 +1639,5 @@
         PS_VECTOR_PRINT_F32(smooth);
     }
-    psTrace("psLib.math", 4, "---- %s() end ----\n", __func__);
+    psTrace(TRACE, 4, "---- %s() end ----\n", __func__);
     return(smooth);
 }
@@ -1648,5 +1660,5 @@
 psStats* psStatsAlloc(psStatsOptions options)
 {
-    psTrace("psLib.math", 3,"---- %s() begin  ----\n", __func__);
+    psTrace(TRACE, 3,"---- %s() begin  ----\n", __func__);
     psStats* newStruct = NULL;
 
@@ -1677,5 +1689,5 @@
     newStruct->options = options;
 
-    psTrace("psLib.math", 3, "---- %s() end  ----\n", __func__);
+    psTrace(TRACE, 3, "---- %s() end  ----\n", __func__);
     return (newStruct);
 }
@@ -1709,14 +1721,15 @@
                    psMaskType maskVal)
 {
-    psTrace("psLib.math", 3,"---- %s() begin  ----\n", __func__);
-    PS_ASSERT_PTR_NON_NULL(stats, NULL);
-    PS_ASSERT_VECTOR_NON_NULL(in, NULL);
+    psTrace(TRACE, 3,"---- %s() begin  ----\n", __func__);
+    PS_ASSERT_PTR_NON_NULL(stats, false);
+    PS_ASSERT_VECTOR_NON_NULL(in, false);
+    PS_ASSERT_VECTOR_NON_EMPTY(in, false);
     if (mask) {
-        PS_ASSERT_VECTORS_SIZE_EQUAL(mask, in, stats);
-        PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_U8, stats);
+        PS_ASSERT_VECTORS_SIZE_EQUAL(mask, in, false);
+        PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_U8, false);
     }
     if (errors) {
-        PS_ASSERT_VECTORS_SIZE_EQUAL(errors, in, stats);
-        PS_ASSERT_VECTOR_TYPE(errors, in->type.type, stats);
+        PS_ASSERT_VECTORS_SIZE_EQUAL(errors, in, false);
+        PS_ASSERT_VECTOR_TYPE(errors, in->type.type, false);
     }
 
@@ -1746,9 +1759,9 @@
 
     if ((stats->options & PS_STAT_USE_RANGE) && (stats->min >= stats->max)) {
-        PS_ASSERT_FLOAT_LARGER_THAN_OR_EQUAL(stats->max, stats->min, stats);
+        PS_ASSERT_FLOAT_LARGER_THAN_OR_EQUAL(stats->max, stats->min, false);
     }
 
     if ((stats->options & PS_STAT_USE_BINSIZE) && (stats->min >= stats->max)) {
-        PS_ASSERT_FLOAT_LARGER_THAN_OR_EQUAL(stats->binsize, 0.0, stats);
+        PS_ASSERT_FLOAT_LARGER_THAN_OR_EQUAL(stats->binsize, 0.0, false);
     }
 
@@ -1839,6 +1852,6 @@
     psFree(errorsF32);
     psFree(maskU8);
-    psTrace("psLib.math", 3,"---- %s() end  ----\n", __func__);
-    return (status);
+    psTrace(TRACE, 3,"---- %s() end  ----\n", __func__);
+    return status;
 }
 
@@ -1923,6 +1936,5 @@
         psStatsOptions option = psStatsOptionFromString(statString);
         if (option == 0) {
-            psWarning("Unable to interpret statistic option: %s --- ignored.\n",
-                     statString);
+            psWarning("Unable to interpret statistic option: %s --- ignored.\n", statString);
             continue;
         }
@@ -2054,6 +2066,6 @@
     )
 {
-    psTrace("psLib.math", 4, "---- %s() begin ----\n", __func__);
-    psTrace("psLib.math", 5, "binNum, yVal is (%d, %f)\n", binNum, yVal);
+    psTrace(TRACE, 4, "---- %s() begin ----\n", __func__);
+    psTrace(TRACE, 5, "binNum, yVal is (%d, %f)\n", binNum, yVal);
     if (psTraceGetLevel("psLib.math") >= 8) {
         PS_VECTOR_PRINT_F32(xVec);
@@ -2081,8 +2093,8 @@
         y->data.F64[1] = yVec->data.F32[binNum];
         y->data.F64[2] = yVec->data.F32[binNum + 1];
-        psTrace("psLib.math", 6, "x vec (orig) is (%f %f %f %f)\n", xVec->data.F32[binNum - 1],
+        psTrace(TRACE, 6, "x vec (orig) is (%f %f %f %f)\n", xVec->data.F32[binNum - 1],
                 xVec->data.F32[binNum], xVec->data.F32[binNum+1], xVec->data.F32[binNum+2]);
-        psTrace("psLib.math", 6, "x data is (%f %f %f)\n", x->data.F64[0], x->data.F64[1], x->data.F64[2]);
-        psTrace("psLib.math", 6, "y data is (%f %f %f)\n", y->data.F64[0], y->data.F64[1], y->data.F64[2]);
+        psTrace(TRACE, 6, "x data is (%f %f %f)\n", x->data.F64[0], x->data.F64[1], x->data.F64[2]);
+        psTrace(TRACE, 6, "y data is (%f %f %f)\n", y->data.F64[0], y->data.F64[1], y->data.F64[2]);
 
         //
@@ -2105,5 +2117,5 @@
             psFree(x);
             psFree(y);
-            psTrace("psLib.math", 5, "---- %s() end ----\n", __func__);
+            psTrace(TRACE, 5, "---- %s() end ----\n", __func__);
             return NAN;
         }
@@ -2116,16 +2128,16 @@
             psFree(x);
             psFree(y);
-            psTrace("psLib.math", 5, "---- %s(NAN) end ----\n", __func__);
+            psTrace(TRACE, 5, "---- %s(NAN) end ----\n", __func__);
             return NAN;
         }
-        psTrace("psLib.math", 6, "myPoly->coeff[0] is %f\n", myPoly->coeff[0]);
-        psTrace("psLib.math", 6, "myPoly->coeff[1] is %f\n", myPoly->coeff[1]);
-        psTrace("psLib.math", 6, "myPoly->coeff[2] is %f\n", myPoly->coeff[2]);
-        psTrace("psLib.math", 6, "Fitted y vec is (%f %f %f)\n",
+        psTrace(TRACE, 6, "myPoly->coeff[0] is %f\n", myPoly->coeff[0]);
+        psTrace(TRACE, 6, "myPoly->coeff[1] is %f\n", myPoly->coeff[1]);
+        psTrace(TRACE, 6, "myPoly->coeff[2] is %f\n", myPoly->coeff[2]);
+        psTrace(TRACE, 6, "Fitted y vec is (%f %f %f)\n",
                 (psF32) psPolynomial1DEval(myPoly, (psF64) x->data.F64[0]),
                 (psF32) psPolynomial1DEval(myPoly, (psF64) x->data.F64[1]),
                 (psF32) psPolynomial1DEval(myPoly, (psF64) x->data.F64[2]));
 
-        psTrace("psLib.math", 6, "We fit the polynomial, now find x such that f(x) equals %f\n", yVal);
+        psTrace(TRACE, 6, "We fit the polynomial, now find x such that f(x) equals %f\n", yVal);
         tmpFloat = QuadraticInverse(myPoly->coeff[2], myPoly->coeff[1], myPoly->coeff[0], yVal,
                                     x->data.F64[0], x->data.F64[2]);
@@ -2137,5 +2149,5 @@
             psFree(x);
             psFree(y);
-            psTrace("psLib.math", 5, "---- %s(NAN) end ----\n", __func__);
+            psTrace(TRACE, 5, "---- %s(NAN) end ----\n", __func__);
             return(NAN);
         }
@@ -2157,9 +2169,9 @@
     }
 
-    psTrace("psLib.math", 6, "FIT: return %f\n", tmpFloat);
+    psTrace(TRACE, 6, "FIT: return %f\n", tmpFloat);
     psFree(x);
     psFree(y);
 
-    psTrace("psLib.math", 5, "---- %s(%f) end ----\n", __func__, tmpFloat);
+    psTrace(TRACE, 5, "---- %s(%f) end ----\n", __func__, tmpFloat);
     return tmpFloat;
 }
@@ -2173,5 +2185,5 @@
     )
 {
-    psTrace("psLib.math", 4, "---- %s() begin ----\n", __func__);
+    psTrace(TRACE, 4, "---- %s() begin ----\n", __func__);
     PS_ASSERT_VECTOR_NON_NULL(params, NAN);
     PS_ASSERT_VECTOR_SIZE(params, (long)2, NAN);
@@ -2196,5 +2208,5 @@
 
 
-    psTrace("psLib.math", 4, "---- %s() end ----\n", __func__);
+    psTrace(TRACE, 4, "---- %s() end ----\n", __func__);
     return gauss;
 }
