Added include assert.h and cast to ScalarType for a pow in SetRange() function.

This commit is contained in:
Paolo Cignoni 2005-06-10 14:59:39 +00:00
parent bebc58f9b1
commit c379550e2e
1 changed files with 5 additions and 2 deletions

View File

@ -24,6 +24,9 @@
History History
$Log: not supported by cvs2svn $ $Log: not supported by cvs2svn $
Revision 1.7 2005/06/09 14:19:55 cignoni
Added typedef Histogramf and Histogramd
Revision 1.6 2005/06/07 09:37:33 ponchio Revision 1.6 2005/06/07 09:37:33 ponchio
Added fabs() to variance, which can sometime be negative in case Added fabs() to variance, which can sometime be negative in case
of rounding errors (and sqrt chokes on it). of rounding errors (and sqrt chokes on it).
@ -50,7 +53,7 @@ Initial Release
#define __VCG_HISTOGRAM #define __VCG_HISTOGRAM
#include <vector> #include <vector>
#include <assert.h>
namespace vcg { namespace vcg {
/** /**
@ -118,7 +121,7 @@ void Histogram<ScalarType>::SetRange(ScalarType _minv, ScalarType _maxv, int _n,
R.resize(n+1); R.resize(n+1);
double dlt=(maxv-minv); double dlt=(maxv-minv);
for(int i=0;i<n+1;++i) for(int i=0;i<n+1;++i)
R[i]=minv+dlt*pow(double(i)/n,gamma); R[i]=minv+dlt*pow(ScalarType(i)/n,gamma);
} }
template <class ScalarType> template <class ScalarType>
int Histogram<ScalarType>::Interize(ScalarType val) int Histogram<ScalarType>::Interize(ScalarType val)