Particle Identification and Tracking
Public Member Functions | Protected Attributes | List of all members
utilities::Counted_vector Class Reference

A class for computing many averages in parallel. More...

#include <counted_vector.h>

+ Collaboration diagram for utilities::Counted_vector:

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...
 

Detailed Description

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.

Constructor & Destructor Documentation

Counted_vector::Counted_vector ( int  n_elements)

Constructor.

Member Function Documentation

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_.

bool utilities::Counted_vector::averaged ( ) const
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().

int utilities::Counted_vector::get_count ( int  j) const
inline

Returns the count in element j.

References count_array_.

int utilities::Counted_vector::get_length ( ) const
inline

Returns the number of elements.

References data_array_.

Referenced by tracking::Track_shelf::msd_corrected().

float utilities::Counted_vector::get_val ( int  j) const
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
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_.

Member Data Documentation

bool utilities::Counted_vector::averaged_
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().

std::vector<int> utilities::Counted_vector::count_array_
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().

std::vector<float> utilities::Counted_vector::data_array_
protected

The documentation for this class was generated from the following files: