35 #ifndef AIMS_HISTOGRAM_REGULARBINNEDHISTO_H
36 #define AIMS_HISTOGRAM_REGULARBINNEDHISTO_H
63 T mindataval, T maxdataval );
64 unsigned bins()
const {
return _bins; }
69 size_t abort_max = 0 )
const;
78 template<
typename T>
inline
80 :
Histogram<T>(), _bins( bins ), _minvalue( 0 ), _maxvalue( 0 )
85 template<
typename T>
inline
88 :
Histogram< T >( other ), _bins( other._bins ),
89 _minvalue( other._minvalue ), _maxvalue( other._maxvalue )
94 template<
typename T>
inline
102 template<
typename T >
inline
106 doit( thing, thing->min(), thing->max() );
110 template<
typename T >
inline
123 this->_data.fill( 0 );
124 double scl = (double) _bins / (
double) ( maxi - mini );
131 thing->getStrides(),
true );
132 for( ; !it.
ended(); ++it )
137 x = (double) ( (
double) (*iv) - mini ) * scl;
141 else if( y >= (
int) _bins )
143 if( x == (
int) _bins )
144 ++this->_data( _bins-1 );
153 template<
typename T >
inline
158 std::map<T, unsigned> vals;
165 thing->getStrides(),
true );
166 for( ; !it.
ended(); ++it )
175 if( n % 1000 == 0 && vals.size() >= abort_max )
176 throw std::runtime_error(
"too many values" );
181 std::vector<T> *res =
new std::vector<T>( vals.size() );
182 typename std::map<T, unsigned>::iterator im, e = vals.end();
183 typename std::vector<T>::iterator i = res->begin();
184 for( im=vals.begin(); im!=e; ++im, ++i )
Base class of histogram container class.
Histogram container class, with a specified number of regular bins.
std::vector< T > * unique(const carto::rc_ptr< carto::Volume< T > > &thing, size_t abort_max=0) const
RegularBinnedHistogram(unsigned bins=0)
void setBins(unsigned bins)
void doit(const carto::rc_ptr< carto::Volume< T > > &thing)
classical histogram computation function.
virtual ~RegularBinnedHistogram()
void inc_line_ptr(const T *&p) const