23 #include "libmesh/libmesh_common.h" 
   24 #include "libmesh/parallel.h" 
   25 #include "libmesh/parallel_bin_sorter.h" 
   26 #include "libmesh/parallel_hilbert.h" 
   27 #include "libmesh/parallel_histogram.h" 
   28 #include "libmesh/parallel_conversion_utils.h" 
   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