corrected one bug in Add to insert the value in last bin since upper bound is +inf

This commit is contained in:
Nico Pietroni 2014-04-24 16:07:13 +00:00
parent cf1a476116
commit 2f871fc16e
1 changed files with 5 additions and 8 deletions

View File

@ -370,14 +370,11 @@ void Histogram<ScalarType>::Add(ScalarType v, ScalarType increment)
int pos=BinIndex(v); int pos=BinIndex(v);
if(v<minElem) minElem=v; if(v<minElem) minElem=v;
if(v>maxElem) maxElem=v; if(v>maxElem) maxElem=v;
if(pos>=0 && pos<=n) assert((pos>=0)&&(pos<=n+1));
{ H[pos]+=increment;
cnt+=increment;
H[pos]+=increment; avg+=v*increment;
cnt+=increment; rms += (v*v)*increment;
avg+=v*increment;
rms += (v*v)*increment;
}
} }
template <class ScalarType> template <class ScalarType>