Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
Loading...
Searching...
No Matches
Series< T > Class Template Reference

Generic one-dimensional container of values with optional string index. More...

#include <Series.h>

Public Member Functions

 Series ()
 Default constructor.
 
 Series (const std::string &colName)
 Constructs a Series with a given column name.
 
void add (const T &value)
 Appends a value at the end of the series (without index).
 
void add (const T &value, const std::string &idx)
 Appends a value with an associated index label.
 
T iat (size_t idx) const
 Positional access to the i-th element.
 
T at (const std::string &idx) const
 Label-based access to a value.
 
size_t size () const
 Returns the number of elements stored in the series.
 
const std::string & getName () const
 Returns the series name.
 
void print () const
 Prints all stored values to std::cout.
 
T min () const
 Returns the minimum value in the series.
 
T max () const
 Returns the maximum value in the series.
 
double mean () const
 Computes the arithmetic mean of the series.
 
double stddev () const
 Computes the (population) standard deviation of the series.
 
std::vector< Tquartiles () const
 Returns the first, second (median), and third quartiles.
 
const std::shared_ptr< std::vector< std::string > > & getIndex () const
 Accessor to the shared index vector.
 
std::vector< Tto_vec ()
 Returns a copy of the underlying data as a std::vector.
 
std::vector< std::string > to_string_vec ()
 Returns a vector of stringified values.
 

Detailed Description

template<typename T>
class Series< T >

Generic one-dimensional container of values with optional string index.

The Series<T> class is intended as a lightweight helper for handling small numerical (or generic) datasets. It supports:

  • positional access via iat(),
  • label-based access via at() when an index is provided,
  • descriptive statistics: min, max, mean, standard deviation, and quartiles.

The index is shared via a std::shared_ptr so that multiple Series can share the same labels if needed.

Template Parameters
TValue type (typically arithmetic, but not strictly required for all operations except statistics).

Definition at line 41 of file Series.h.

Constructor & Destructor Documentation

◆ Series() [1/2]

template<typename T >
Series< T >::Series ( )
inline

Default constructor.

Constructs an empty series with an empty shared index.

Definition at line 52 of file Series.h.

◆ Series() [2/2]

template<typename T >
Series< T >::Series ( const std::string &  colName)

Constructs a Series with a given column name.

Parameters
colNameHuman-readable name of the series (e.g. "mass", "q2").

Member Function Documentation

◆ add() [1/2]

template<typename T >
void Series< T >::add ( const T value)

Appends a value at the end of the series (without index).

The associated index entry, if any, is not modified. This is mainly useful for purely positional series.

Parameters
valueValue to append.

◆ add() [2/2]

template<typename T >
void Series< T >::add ( const T value,
const std::string &  idx 
)
inline

Appends a value with an associated index label.

Both the data vector and the shared index are extended.

Parameters
valueValue to append.
idxIndex label for this value.

Definition at line 79 of file Series.h.

◆ at()

template<typename T >
T Series< T >::at ( const std::string &  idx) const

Label-based access to a value.

Searches the index for the given label and returns the corresponding data value.

Parameters
idxIndex label (string).
Returns
Value at the matching index position.
Exceptions
std::invalid_argumentif the index label is not found.

◆ getIndex()

template<typename T >
const std::shared_ptr< std::vector< std::string > > & Series< T >::getIndex ( ) const
inline

Accessor to the shared index vector.

Returns
Shared pointer to the index storage.

Definition at line 182 of file Series.h.

◆ getName()

template<typename T >
const std::string & Series< T >::getName ( ) const

Returns the series name.

Returns
Reference to the internal name string.

◆ iat()

template<typename T >
T Series< T >::iat ( size_t  idx) const

Positional access to the i-th element.

Parameters
idxZero-based position in the series.
Returns
Value at the requested position.
Exceptions
std::out_of_rangeif idx >= size().

◆ max()

template<typename T >
T Series< T >::max ( ) const

Returns the maximum value in the series.

Returns
Maximum element.
Exceptions
std::runtime_errorif the series is empty.

◆ mean()

template<typename T >
double Series< T >::mean ( ) const

Computes the arithmetic mean of the series.

Returns
Mean value as a double.
Exceptions
std::runtime_errorif the series is empty.

◆ min()

template<typename T >
T Series< T >::min ( ) const

Returns the minimum value in the series.

Returns
Minimum element.
Exceptions
std::runtime_errorif the series is empty.

◆ print()

template<typename T >
void Series< T >::print ( ) const

Prints all stored values to std::cout.

This is mainly intended for debugging or quick inspection.

◆ quartiles()

template<typename T >
std::vector< T > Series< T >::quartiles ( ) const

Returns the first, second (median), and third quartiles.

The method sorts a copy of the data and picks elements at 25%, 50% and 75% of the size.

Returns
Vector {Q1, Q2, Q3}.
Exceptions
std::runtime_errorif the series is empty.

◆ size()

template<typename T >
size_t Series< T >::size ( ) const

Returns the number of elements stored in the series.

◆ stddev()

template<typename T >
double Series< T >::stddev ( ) const

Computes the (population) standard deviation of the series.

The variance is computed as: var = (1/N) * sum_i (x_i - mean)^2

Returns
Standard deviation as a double.
Exceptions
std::runtime_errorif the series is empty.

◆ to_string_vec()

template<typename T >
std::vector< std::string > Series< T >::to_string_vec ( )
inline

Returns a vector of stringified values.

Each element is converted to std::string via std::to_string. Intended for simple export/inspection use cases.

Definition at line 199 of file Series.h.

◆ to_vec()

template<typename T >
std::vector< T > Series< T >::to_vec ( )
inline

Returns a copy of the underlying data as a std::vector.

Definition at line 189 of file Series.h.


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