Public Member Functions | List of all members
o2scl::table_units< vec_t > Class Template Reference

Data table class with units. More...

#include <table_units.h>

Detailed Description

template<class vec_t = std::vector<double>>
class o2scl::table_units< vec_t >

Idea for Future:
The unit conversion object is now always a pointer to the global conversion object. This could be modified, so that each table can have it's own, but this might require HDF output of unit conversion objects.
Idea for Future:
Make table methods virtual? (not necessary yet since delete_column() isn't referred to internally)

Definition at line 42 of file table_units.h.

Public Member Functions

 table_units (int cmaxlines=0)
 Create a new table_units with space for nlines<=cmaxlines.
 
Copy constructors
 table_units (const table_units &t)
 Copy with constructor from table_units.
 
 table_units (const table< vec_t > &t)
 Copy with constructor from table.
 
table_unitsoperator= (const table_units &t)
 Copy with operator= from table_units.
 
table_unitsoperator= (const table< vec_t > &t)
 Copy with operator= from table.
 
template<class vec2_t >
void copy_rows (std::string func, table_units< vec2_t > &dest)
 Copy all rows matching a particular condition to a new table. More...
 
Unit manipulation
std::string get_unit (std::string scol) const
 Get the unit for column scol.
 
void line_of_units (std::string unit_line)
 Specify the units as a string separated by spaces.
 
std::string get_unit (size_t i) const
 Get the unit for column with index i. More...
 
void remove_unit (std::string scol)
 Remove the unit for column scol.
 
void set_unit (std::string scol, std::string unit)
 Set the unit for column scol to unit.
 
int convert_to_unit (std::string scol, std::string unit, bool err_on_fail=true)
 Convert the units of column scol to unit.
 
size_t get_nunits ()
 Return the number of columns with units.
 

Virtual functions from \ref table

convert_units< double > * cup
 The pointer to the convert units object.
 
virtual void clear_table ()
 Clear the table and the column names and units (but leave constants)
 
virtual void delete_column (std::string scol)
 Delete column named scol.
 
virtual void rename_column (std::string src, std::string dest)
 Rename column named src to dest $ {\cal O}(C) $.
 
virtual void summary (std::ostream *out, size_t ncol=79) const
 Output a summary of the information stored.
 
virtual const char * type ()
 Return the type, "table_units".
 
virtual void copy_column (std::string src, std::string dest)
 Copy data from column named src to column named dest, creating a new column if necessary $ {\cal O}(R \log(C)) $. More...
 
virtual int read_generic (std::istream &fin, int verbose=0)
 Clear the current table and read from a generic data file.
 
template<class vec2_t >
void insert_table (table_units< vec2_t > &source, std::string src_index, bool allow_extrap=true, std::string dest_index="")
 Insert columns from a source table into the new table by interpolation (or extrapolation) More...
 
void o2scl_hdf::hdf_output (o2scl_hdf::hdf_file &hf, table_units<> &t, std::string name)
 
template<class vecf_t >
void o2scl_hdf::hdf_input (o2scl_hdf::hdf_file &hf, table_units< vecf_t > &t, std::string name)
 
void o2scl_hdf::hdf_output_data (o2scl_hdf::hdf_file &hf, table_units<> &t)
 
template<class vecf_t >
void o2scl_hdf::hdf_input_data (o2scl_hdf::hdf_file &hf, table_units< vecf_t > &t)
 

Unit map iterator types

typedef std::map< std::string, std::string, std::greater< std::string > >::iterator uiter
 
typedef std::map< std::string, std::string, std::greater< std::string > >::const_iterator uciter
 
std::map< std::string, std::string, std::greater< std::string > > utree
 Unit map.
 

Member Function Documentation

◆ copy_column()

template<class vec_t = std::vector<double>>
virtual void o2scl::table_units< vec_t >::copy_column ( std::string  src,
std::string  dest 
)
inlinevirtual

This function also sets the units of column dest to be the same as that in src, even if the column named dest already exists and previously had different units.

Definition at line 626 of file table_units.h.

◆ copy_rows()

template<class vec_t = std::vector<double>>
template<class vec2_t >
void o2scl::table_units< vec_t >::copy_rows ( std::string  func,
table_units< vec2_t > &  dest 
)
inline

This function begins by ensuring that all columns in the current table are present in dest, creating new columns (and copying their units) in dest if necessary. It then copies all rows where func evaluates to a number greater than 0.5 to table dest by adding rows at the end of the table.

Definition at line 312 of file table_units.h.

◆ get_unit()

template<class vec_t = std::vector<double>>
std::string o2scl::table_units< vec_t >::get_unit ( size_t  i) const
inline
Idea for Future:
Is there a way to make this function have O(1) time rather than searching?

Definition at line 381 of file table_units.h.

◆ insert_table()

template<class vec_t = std::vector<double>>
template<class vec2_t >
void o2scl::table_units< vec_t >::insert_table ( table_units< vec2_t > &  source,
std::string  src_index,
bool  allow_extrap = true,
std::string  dest_index = "" 
)
inline

This takes all of the columns in source, and adds them into the current table using interpolation, using the columns src_index and dest_index as the independent variable. The column named src_index is the column of the independent variable in source and the column named dest_index is the column of the independent variable in the current table. If dest_index is empty (the default) then the names in the two tables are taken to be the same.

If necessary, columns are created in the current table for the dependent variable columns in source. Columns in the current table which do not correspond to dependent variable columns in source are left unchanged.

If allow_extrap is false, then extrapolation is not allowed, and rows in the current table which have values of the independent variable which are outside the source table are unmodified.

If a column for a dependent variable in source has the same name as dest_index, then it is ignored and not inserted into the current table.

If the column named src_index cannot be found in source or the column names dest_index cannot be found in the current table, then the error handler is called.

If the allow_extrap is false and either the minimum or maximum values of the column named src_index in the source table are not finite, then the error handler is called.

Definition at line 828 of file table_units.h.


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

Documentation generated with Doxygen. Provided under the GNU Free Documentation License (see License Information).