11 #ifndef __Pulsar_EvenlyWeighted_h
12 #define __Pulsar_EvenlyWeighted_h
14 #include "Pulsar/Divided.h"
20 class Integrate<C>::EvenlyWeighted :
public Integrate<C>::Divided
24 void initialize (Integrate*, C*);
27 unsigned get_nrange () {
return stop_indeces.size(); }
29 void get_range (
unsigned irange,
unsigned& start,
unsigned& stop);
32 virtual double get_weight (
const C*,
unsigned ielement) = 0;
37 std::vector<unsigned> stop_indeces;
48 unsigned container_size = this->get_size( container );
50 unsigned good_elements = 0;
53 for (
unsigned ielement=0; ielement < container_size; ielement++)
54 if (get_weight(container,ielement) != 0)
57 DEBUG(
"EvenlyWeighted::initialize good_elements=" << good_elements);
60 unsigned output_elements = 0;
62 this->divide (good_elements, output_elements, spacing);
64 stop_indeces.resize (output_elements);
67 unsigned ielement = 0;
68 for (
unsigned irange=0; irange < output_elements; irange++)
71 good_elements < spacing && ielement < container_size; ielement++)
72 if (get_weight(container,ielement) != 0)
75 DEBUG(
" stop[" << irange <<
"] = " << ielement);
77 stop_indeces[irange] = ielement;
88 if (irange >= stop_indeces.size())
89 throw Error (InvalidParam,
90 "Pulsar::Integrate::Divide::EvenlyWeighted::get_range",
91 "irange=%u >= output_elements=%u", irange, stop_indeces.size());
94 start = stop_indeces[irange-1];
98 stop = stop_indeces[irange];