From 2f871fc16e9f16957da6b7194703159bf85a61ef Mon Sep 17 00:00:00 2001 From: nicopietroni Date: Thu, 24 Apr 2014 16:07:13 +0000 Subject: [PATCH] corrected one bug in Add to insert the value in last bin since upper bound is +inf --- vcg/math/histogram.h | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/vcg/math/histogram.h b/vcg/math/histogram.h index f98fee45..9999a041 100644 --- a/vcg/math/histogram.h +++ b/vcg/math/histogram.h @@ -370,14 +370,11 @@ void Histogram::Add(ScalarType v, ScalarType increment) int pos=BinIndex(v); if(vmaxElem) maxElem=v; - if(pos>=0 && pos<=n) - { - - H[pos]+=increment; - cnt+=increment; - avg+=v*increment; - rms += (v*v)*increment; - } + assert((pos>=0)&&(pos<=n+1)); + H[pos]+=increment; + cnt+=increment; + avg+=v*increment; + rms += (v*v)*increment; } template