#include <parallel_histogram.h>
Histogram (const std::vector< KeyType > &d)
void make_histogram (const unsigned int nbins, KeyType max, KeyType min)
void build_histogram ()
const std::vector< unsigned int > & get_histogram () const
unsigned int n_bins () const
unsigned int local_bin_size (const unsigned int bin) const
unsigned int global_bin_size (const unsigned int bin) const
double lower_bound (const unsigned int bin) const
double upper_bound (const unsigned int bin) const
typedef std::vector< KeyType >::const_iterator IterType
const std::vector< KeyType > & data
std::vector< unsigned int > hist
std::vector< double > bin_bounds
std::vector< IterType > bin_iters
Definition at line 41 of file parallel_histogram.h.
Definition at line 44 of file parallel_histogram.h.
Definition at line 38 of file parallel_histogram.C.
References Parallel::Histogram< KeyType >::data, and Parallel::Utils::is_sorted().
:
data(d)
{
libmesh_assert (Parallel::Utils::is_sorted (data));
}
Definition at line 91 of file parallel_histogram.C.
Referenced by Parallel::BinSorter< KeyType >::binsort().
{
// Build a local histogram
std::vector<unsigned int> local_hist (this->n_bins());
for (unsigned int b=0; b<this->n_bins(); b++)
local_hist[b] = this->local_bin_size(b);
// Add all the local histograms to get the global histogram
hist = local_hist;
Parallel::sum(hist);
// All done!
}
Definition at line 98 of file parallel_histogram.h.
Referenced by Parallel::BinSorter< KeyType >::binsort().
{
return hist;
}
Definition at line 131 of file parallel_histogram.h.
{
libmesh_assert (bin < hist.size());
// The number of entries in the bin (globally)
return hist[bin];
}
Definition at line 119 of file parallel_histogram.h.
{
libmesh_assert ((bin+1) < bin_iters.size());
// The number of entries in the bin (locally)
return std::distance (bin_iters[bin], bin_iters[bin+1]);
}
Definition at line 143 of file parallel_histogram.h.
{
libmesh_assert ((bin+1) < bin_bounds.size());
return bin_bounds[bin];
}
Definition at line 47 of file parallel_histogram.C.
References Parallel::Utils::to_double().
Referenced by Parallel::BinSorter< KeyType >::binsort().
{
libmesh_assert (min < max);
// The width of each bin. Store this as a floating point value
double bin_width = (Parallel::Utils::to_double(max)-
Parallel::Utils::to_double(min))/static_cast<double>(nbins);
// The idea for 4 bins of size d is this:
//
// 0 1 2 3 4
// |----------|----------|-----------|----------|
// min 0 min+d 1 min+2d 2 min+3d 3 max
// Set the iterators corresponding to the boundaries
// as defined above. This takes nbins * O(log N) time.
bin_bounds.resize (nbins+1);
bin_iters.resize (nbins+1, data.begin());
// Set the minimum bin boundary iterator
bin_iters[0] = data.begin();
bin_bounds[0] = Parallel::Utils::to_double(min);
// Set the internal bin boundary iterators
for (unsigned int b=1; b<nbins; ++b)
{
bin_bounds[b] = Parallel::Utils::to_double(min) + bin_width * b;
bin_iters[b] = std::lower_bound (bin_iters[b-1], data.end(),
Parallel::Utils::to_key_type<KeyType>(bin_bounds[b]));
}
bin_iters[nbins] = data.end();
bin_bounds[nbins] = Parallel::Utils::to_double(max);
}
Definition at line 107 of file parallel_histogram.h.
Referenced by Parallel::BinSorter< KeyType >::binsort().
{
if (bin_iters.empty())
return 0;
return (bin_iters.size()-1);
}
Definition at line 154 of file parallel_histogram.h.
Referenced by Parallel::BinSorter< KeyType >::binsort().
{
libmesh_assert ((bin+1) < bin_bounds.size());
return bin_bounds[bin+1];
}
Definition at line 87 of file parallel_histogram.h.
Definition at line 88 of file parallel_histogram.h.
Definition at line 85 of file parallel_histogram.h.
Referenced by Parallel::Histogram< KeyType >::Histogram().
Definition at line 86 of file parallel_histogram.h.
Generated automatically by Doxygen for libMesh from the source code.