Changeset 27553
- Timestamp:
- Apr 1, 2010, 12:52:06 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/math/psHistogram.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/math/psHistogram.c
r26892 r27553 58 58 psTrace("psLib.math", 3, "---- %s() begin ----\n", __func__); 59 59 psTrace("psLib.math", 5, "(lower, upper, n) is (%f, %f, %d)\n", lower, upper, n); 60 PS_ASSERT_INT_POSITIVE(n, NULL);61 PS_ASSERT_FLOAT_LARGER_THAN_OR_EQUAL(upper, lower, NULL);60 psAssert(n > 0, "Number of bins must be positive"); 61 psAssert(upper >= lower, "Bounds must be sensical"); 62 62 63 63 // Allocate memory for the new histogram structure. If there are N bins, then there are N+1 bounds to … … 287 287 double binSize = (out->bounds->data.F32[out->nums->n] - out->bounds->data.F32[0]) / (float) out->nums->n; // Histogram bin size 288 288 binNum = (inF32->data.F32[i] - out->bounds->data.F32[0]) / binSize; 289 binNum = PS_MAX (binNum, 0);290 binNum = PS_MIN (binNum, numBins - 1);291 292 // value is in bin 'i' if bound[i] <= value < bound[i]293 294 // we may slightly overshoot or undershoot. creep up or down on the true bin295 if (inF32->data.F32[i] < out->bounds->data.F32[binNum]) {296 psTrace("psLib.math", 6, "missed target bin, adjusting: %f vs %f to %f\n", inF32->data.F32[i], out->bounds->data.F32[binNum], out->bounds->data.F32[binNum+1]);297 while ((inF32->data.F32[i] < out->bounds->data.F32[binNum]) && (binNum > 0)) {298 binNum --;299 }300 301 }302 if (inF32->data.F32[i] >= out->bounds->data.F32[binNum+1]) {303 psTrace("psLib.math", 6, "missed target bin, adjusting: %f vs %f to %f\n", inF32->data.F32[i], out->bounds->data.F32[binNum], out->bounds->data.F32[binNum+1]);304 while ((inF32->data.F32[i] >= out->bounds->data.F32[binNum+1]) && (binNum < numBins - 1)) {305 binNum ++;306 }307 }289 binNum = PS_MAX (binNum, 0); 290 binNum = PS_MIN (binNum, numBins - 1); 291 292 // value is in bin 'i' if bound[i] <= value < bound[i] 293 294 // we may slightly overshoot or undershoot. creep up or down on the true bin 295 if (inF32->data.F32[i] < out->bounds->data.F32[binNum]) { 296 psTrace("psLib.math", 6, "missed target bin, adjusting: %f vs %f to %f\n", inF32->data.F32[i], out->bounds->data.F32[binNum], out->bounds->data.F32[binNum+1]); 297 while ((inF32->data.F32[i] < out->bounds->data.F32[binNum]) && (binNum > 0)) { 298 binNum --; 299 } 300 301 } 302 if (inF32->data.F32[i] >= out->bounds->data.F32[binNum+1]) { 303 psTrace("psLib.math", 6, "missed target bin, adjusting: %f vs %f to %f\n", inF32->data.F32[i], out->bounds->data.F32[binNum], out->bounds->data.F32[binNum+1]); 304 while ((inF32->data.F32[i] >= out->bounds->data.F32[binNum+1]) && (binNum < numBins - 1)) { 305 binNum ++; 306 } 307 } 308 308 309 309 if (errorsF32) { … … 326 326 // correct bin number requires a bit more work. 327 327 tmpScalar.data.F32 = inF32->data.F32[i]; 328 psVectorBinaryDisectResult result;328 psVectorBinaryDisectResult result; 329 329 binNum = psVectorBinaryDisect(&result, out->bounds, &tmpScalar); 330 if (result != PS_BINARY_DISECT_PASS) {331 continue;332 }333 if (errorsF32 != NULL) {334 if (!UpdateHistogramBins(binNum, out, inF32->data.F32[i], errors->data.F32[i])) {335 psLogMsg(__func__, PS_LOG_WARN, "WARNING: Failed to update the histogram "336 "bins with the errors vector.\n");337 }338 } else {339 out->nums->data.F32[binNum] += 1.0;340 }330 if (result != PS_BINARY_DISECT_PASS) { 331 continue; 332 } 333 if (errorsF32 != NULL) { 334 if (!UpdateHistogramBins(binNum, out, inF32->data.F32[i], errors->data.F32[i])) { 335 psLogMsg(__func__, PS_LOG_WARN, "WARNING: Failed to update the histogram " 336 "bins with the errors vector.\n"); 337 } 338 } else { 339 out->nums->data.F32[binNum] += 1.0; 340 } 341 341 } 342 342 }
Note:
See TracChangeset
for help on using the changeset viewer.
