37 template <
typename KeyType,
typename IdxType>
39 const std::vector<KeyType> & d) :
54 template <
typename KeyType,
typename IdxType>
59 libmesh_assert_less (
min,
max);
67 const std::vector<IdxType> & histogram =
75 IdxType local_data_size = cast_int<IdxType>(
data.size());
76 IdxType global_data_size = cast_int<IdxType>(local_data_size);
78 this->comm().sum(global_data_size);
80 std::vector<IdxType> target_bin_size (nbins, global_data_size / nbins);
83 for (IdxType i=0; i<(global_data_size % nbins); i++)
88 std::vector<double> bin_bounds (nbins+1);
89 bin_iters.resize (nbins+1,
data.begin());
92 bin_iters[0] =
data.begin();
96 IdxType current_histogram_bin = 0;
106 for (IdxType b=0; b<nbins; ++b)
110 int current_bin_size = 0;
114 while ((current_bin_size + histogram[current_histogram_bin] + delta) <= target_bin_size[b])
117 if ((current_histogram_bin+1) == phist.
n_bins())
120 current_bin_size += histogram[current_histogram_bin++];
123 delta += current_bin_size - target_bin_size[b];
126 bin_bounds[b+1] = phist.
upper_bound (current_histogram_bin);
128 std::lower_bound(bin_iters[b],
data.end(),
133 bin_iters[nbins] =
data.end();
146 #ifdef LIBMESH_HAVE_LIBHILBERT
BinSorter(const Parallel::Communicator &comm, const std::vector< KeyType > &d)
const std::vector< KeyType > & data
long double max(long double a, double b)
double upper_bound(const IdxType bin) const
bool is_sorted(const std::vector< KeyType > &v)
void make_histogram(const IdxType nbins, KeyType max, KeyType min)
Parallel bin sorting object.
An object whose state is distributed along a set of processors.
static KeyType to_key_type(const double f)
Used in conjunction with a BinSorter for parallel sorting.
long double min(long double a, double b)
double to_double(const KeyType &k)
void binsort(const IdxType nbins, KeyType max, KeyType min)
const std::vector< IdxType > & get_histogram() const