Class find_constants (o2scl)

O2scl : Class List

template<class fp_t = double>
class find_constants

A searchable database of constants with units.

Note

This class cannot handle conversions to F and C since those are more complicated than a simply multiplication or division.

Return values for find_nothrow()

static const int one_exact_match_unit_match = 0
static const int one_exact_match_unit_diff = 1
static const int exact_matches_no_unit = 2
static const int exact_matches_unit_match = 3
static const int exact_matches_unit_diff = 4
static const int one_pattern_match_unit_match = 5
static const int one_pattern_match_unit_diff = 6
static const int pattern_matches_no_unit = 7
static const int pattern_matches_unit_match = 8
static const int pattern_matches_unit_diff = 9
static const int no_matches = 10

Other possible values of the unit flag

static const int fc_unknown = 0
static const int fc_none = 3
static const int fc_other = 4

List of constants and unit match function [protected]

std::vector<const_entry> list

Database of constant values.

inline bool unit_match_logic(std::string unit, const const_entry &f) const

The function which decides if the requested unit matches the specified list entry.

Units match if

  • the unit is unspecified (string of length zero) or “none” and the flag is fc_none

  • the unit is equal to “any” (case-insensitive comparison)

  • the unit is equal to the list unit (case-insensitive comparison)

  • the unit is “mks” (case-insensitive comparison) and the unit flag is either o2scl_mks or fc_none

  • the unit is “cgs” (case-insensitive comparison) and the unit flag is either o2scl_cgs or fc_none

Functions to show or modify the constant list

inline void output_list(std::ostream &os) const

Output the full list of constants to os.

inline void output_list_full(std::ostream &os) const

Output the full list of constants to os.

inline void output_list_cout() const

Output the full list of constants to std::cout.

inline void output(const find_constants::const_entry &c, std::ostream &os) const

Output one entry from the constant database to os.

inline void add_constant(const const_entry &f, int verbose = 0)

Add a constant.

inline void del_constant(std::string &name, int verbose = 0)

Remove a constant.

Public Functions

inline find_constants()
class const_entry

Type for constant database (also used for list of matches)

Public Members

std::vector<std::string> names

List of names for the constant, with the preferred name first.

std::string unit

Unit.

int unit_flag

Flag (currently in the range 0 to 4)

fp_t val

Value.

std::string source

Source or reference for value.

int m

Power of length.

int k

Power of mass.

int s

Power of time.

int K

Power of temperature.

int A

Power of current.

int mol

Power of moles.

int cd

Power of luminous intensity.