Particle Identification and Tracking
|
A class for computing many averages in parallel. More...
#include <counted_vector.h>
Public Member Functions | |
Counted_vector (int n_elements) | |
Constructor. More... | |
void | add_to_element (int t, float val) |
Adds val to the element t. More... | |
void | batch_add_to_element (int t, float val, int count) |
Adds val to the value and count to the count_array_. More... | |
void | output_to_wrapper (Generic_wrapper *out_wrapper, std::string &g_name, std::string &data_name, std::string &count_name, const Md_store *g_md_store) const |
Output data and count vectors to out_wrapper. More... | |
void | print () const |
Sensible output. More... | |
void | average_data () |
Averages by the count array. More... | |
void | unaverage_data () |
Un-averages by the count array. More... | |
int | get_length () const |
Returns the number of elements. More... | |
float | get_val (int j) const |
Returns the value in element j. More... | |
int | get_count (int j) const |
Returns the count in element j. More... | |
bool | averaged () const |
Return if the array is averaged. More... | |
Protected Attributes | |
std::vector< float > | data_array_ |
Array that contains the data. More... | |
std::vector< int > | count_array_ |
Array of identical size that counts how many times each bin is added to. More... | |
bool | averaged_ |
Flag for if the data is averaged. More... | |
A class for computing many averages in parallel.
The class has two vectors, one for a running total and the other the number of elements added to get running total. This is mostly used in msd related stuff.
Counted_vector::Counted_vector | ( | int | n_elements) |
Constructor.
void Counted_vector::add_to_element | ( | int | t, |
float | val | ||
) |
Adds val to the element t.
References averaged_, count_array_, and data_array_.
void Counted_vector::average_data | ( | ) |
Averages by the count array.
References averaged_, count_array_, and data_array_.
|
inline |
Return if the array is averaged.
References averaged_.
void Counted_vector::batch_add_to_element | ( | int | t, |
float | val, | ||
int | count | ||
) |
Adds val to the value and count to the count_array_.
References averaged_, count_array_, and data_array_.
Referenced by tracking::Track_shelf::msd_corrected().
|
inline |
Returns the count in element j.
References count_array_.
|
inline |
Returns the number of elements.
References data_array_.
Referenced by tracking::Track_shelf::msd_corrected().
|
inline |
Returns the value in element j.
References data_array_.
void Counted_vector::output_to_wrapper | ( | Generic_wrapper * | out_wrapper, |
std::string & | g_name, | ||
std::string & | data_name, | ||
std::string & | count_name, | ||
const Md_store * | g_md_store | ||
) | const |
Output data and count vectors to out_wrapper.
References utilities::Generic_wrapper::add_dset(), utilities::Generic_wrapper::add_meta_data(), utilities::Generic_wrapper::close_group(), utilities::Generic_wrapper::close_wrapper(), count_array_, data_array_, utilities::Generic_wrapper::is_open(), utilities::Generic_wrapper::open_group(), utilities::Generic_wrapper::open_wrapper(), utilities::V_FLOAT, and utilities::V_INT.
void Counted_vector::print | ( | ) | const |
Sensible output.
References count_array_, and data_array_.
void Counted_vector::unaverage_data | ( | ) |
Un-averages by the count array.
References averaged_, count_array_, and data_array_.
|
protected |
Flag for if the data is averaged.
This matters because the data is averaged in place, so once it in averaged, more data can't be added.
Referenced by add_to_element(), average_data(), averaged(), batch_add_to_element(), and unaverage_data().
|
protected |
Array of identical size that counts how many times each bin is added to.
Referenced by add_to_element(), average_data(), batch_add_to_element(), get_count(), output_to_wrapper(), print(), and unaverage_data().
|
protected |
Array that contains the data.
Referenced by add_to_element(), average_data(), batch_add_to_element(), get_length(), get_val(), output_to_wrapper(), print(), and unaverage_data().