[vsipl++] [patch] histogram [signal.histo]
Jules Bergmann
jules at codesourcery.com
Mon Dec 5 23:41:28 UTC 2005
Don,
Looks good, a couple of minor suggestions below, please check it in. --
Jules
Don McCoy wrote:
> Please find the attached patch for the histogram class.
>
> Regards,
>
>
You could replace code like:
> + index_type n = num_bin_;
> + while ( n-- )
> + hist_.put(n, 0);
with this:
hist_ = 0;
Also, you might take the common code for computing the histogram index
and put it into a separate member function:
inline index_type
impl_bin(T value)
{
if (value < min_)
return 0;
else if (value >= max_)
return num_bin - 1;
else
return (index_type)((data(i) - min_) / delta_);
}
That would let you simplify the vector/matrix loops:
> +
> + for ( index_type i = 0; i < data.size(); ++i )
> + {
index_type n = impl_bin(data(i));
hist_(n) += 1;
> + }
This would also replace the multiple references to data(i) (which the
compiler might not be able to recognize as constant, esp if data is a
view of an expression block) with a single one.
More information about the vsipl++
mailing list