23 #include "libmesh/parallel_histogram.h" 24 #include "libmesh/parallel.h" 25 #include "libmesh/parallel_conversion_utils.h" 26 #include "libmesh/parallel_hilbert.h" 34 template <
typename KeyType,
typename IdxType>
36 const std::vector<KeyType> & d) :
45 template <
typename KeyType,
typename IdxType>
50 libmesh_assert_less (min, max);
67 bin_bounds.resize (nbins+1);
68 bin_iters.resize (nbins+1, data.begin());
71 bin_iters[0] = data.begin();
75 for (IdxType b=1; b<nbins; ++b)
80 std::lower_bound (bin_iters[b-1], data.end(),
84 bin_iters[nbins] = data.end();
90 template <
typename KeyType,
typename IdxType>
94 std::vector<IdxType> local_hist (this->n_bins());
97 local_hist[b] = this->local_bin_size(b);
101 this->comm().sum(hist);
112 #ifdef LIBMESH_HAVE_LIBHILBERT The libMesh namespace provides an interface to certain functionality in the library.
void build_histogram()
Build the histogram across all processors and store the result in the input vector hist...
bool is_sorted(const std::vector< KeyType > &v)
const std::vector< KeyType > & data
Histogram(const Parallel::Communicator &comm, const std::vector< KeyType > &d)
Constructor.
void make_histogram(const IdxType nbins, KeyType max, KeyType min)
The actual function which sorts the data into nbins.
An object whose state is distributed along a set of processors.
static KeyType to_key_type(const double f)
Defines a histogram to be used in parallel in conjunction with a BinSorter.
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
double to_double(const KeyType &k)
A utility function which converts whatever KeyType is to a double for the histogram bounds...