faunus
Public Types | Public Member Functions | Public Attributes | Protected Types | Protected Member Functions | Protected Attributes | List of all members
Faunus::Table2D< Tx, Ty > Class Template Reference

General class for handling 2D tables - xy data, for example. More...

#include <table_2d.h>

Collaboration diagram for Faunus::Table2D< Tx, Ty >:
Collaboration graph
[legend]

Public Types

enum  type { HISTOGRAM, XYDATA }
 

Public Member Functions

Ty sumy () const
 Sum of all y values (same as count())
 
 Table2D (Tx resolution=0.2, type key=XYDATA)
 Constructor. More...
 
std::map< std::string, std::vector< double > > to_map ()
 Convert to map.
 
void clear ()
 
void setResolution (Tx resolution)
 
void setResolution (std::vector< Tx > &resolution)
 
Ty & operator() (Tx x)
 Access operator - returns reference to y(x)
 
Ty & operator() (std::vector< Tx > &x)
 Access operator - returns reference to y(x)
 
Ty find (std::vector< Tx > &x)
 Find key and return corresponding value otherwise zero.
 
template<class T = double>
void save (const std::string &filename, T scale=1, T translate=0)
 Save table to disk.
 
template<class T = double>
void normSave (const std::string &filename)
 Save normalized table to disk.
 
template<class T = double>
void sumSave (std::string filename, T scale=1)
 Sums up all previous elements and saves table to disk.
 
const Tmap & getMap () const
 
Tmap & getMap ()
 
Tx getResolution ()
 
Tx mean ()
 
Tx std ()
 
Tmap::const_iterator min ()
 
Tmap::const_iterator max ()
 
Tx minx ()
 
Ty avg (const std::vector< Tx > &limits)
 
std::vector< double > hist2buf (int &size)
 Convert table2D to vector of floats.
 
void buf2hist (std::vector< double > &v)
 Convert vector of floats to table2D.
 
bool load (const std::string &filename)
 Load table from disk. More...
 
Eigen::MatrixXd tableToMatrix ()
 Convert table to matrix.
 

Public Attributes

type tabletype
 

Protected Types

typedef std::map< Tx, Ty > Tmap
 

Protected Member Functions

Ty count ()
 

Protected Attributes

Tx dx
 
Tmap map
 
std::string name
 

Detailed Description

template<typename Tx, typename Ty>
class Faunus::Table2D< Tx, Ty >

General class for handling 2D tables - xy data, for example.

Date
Lund 2011
Note
Tx is used as the std::map key and which may be problematic due to direct floating point comparison (== operator). We have not experienced any issues with this, though. This uses std::map and table lookup is of complexity logarithmic with N.

Constructor & Destructor Documentation

◆ Table2D()

template<typename Tx, typename Ty>
Faunus::Table2D< Tx, Ty >::Table2D ( Tx  resolution = 0.2,
type  key = XYDATA 
)
inline

Constructor.

Parameters
resolutionResolution of the x axis
keyTable type: HISTOGRAM or XYDATA

Member Function Documentation

◆ avg()

template<typename Tx, typename Ty>
Ty Faunus::Table2D< Tx, Ty >::avg ( const std::vector< Tx > &  limits)
inline

Returns average in interval

◆ load()

template<typename Tx, typename Ty>
bool Faunus::Table2D< Tx, Ty >::load ( const std::string &  filename)
inline

Load table from disk.

Note
The first line - used for comments - is ignored.
Todo:
Implement end bin compensation as in the save() function when loading HISTOGRAMs

◆ max()

template<typename Tx, typename Ty>
Tmap::const_iterator Faunus::Table2D< Tx, Ty >::max ( )
inline

Returns iterator of maximum y

◆ mean()

template<typename Tx, typename Ty>
Tx Faunus::Table2D< Tx, Ty >::mean ( )
inline

Returns average

◆ min()

template<typename Tx, typename Ty>
Tmap::const_iterator Faunus::Table2D< Tx, Ty >::min ( )
inline

Returns iterator of minumum y

◆ minx()

template<typename Tx, typename Ty>
Tx Faunus::Table2D< Tx, Ty >::minx ( )
inline

Returns x at minumum x

◆ std()

template<typename Tx, typename Ty>
Tx Faunus::Table2D< Tx, Ty >::std ( )
inline

Returns standard deviation


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