![]() |
Shamrock 2025.10.0
Astrophysical Code
|
namespace containing the units library More...
Classes | |
| struct | Constants |
| Physical constants in a unit system. More... | |
| struct | NamedUnit |
| One registry entry: a unit and the two names it can be looked up by. More... | |
| struct | Dimension |
| Exponents of the seven SI base dimensions. More... | |
| struct | Unit |
| A unit: its dimension and its magnitude expressed in SI base units, in precision Tscal. More... | |
| class | UnitSystem |
| A unit system, defined by the SI value of its base units. More... | |
Functions | |
| template<class Tscal> | |
| void | to_json (nlohmann::json &j, const ::shamunits::UnitSystem< Tscal > &p) |
| Converts a UnitSystem object to a JSON object. | |
| template<class Tscal> | |
| void | from_json (const nlohmann::json &j, ::shamunits::UnitSystem< Tscal > &p) |
| Deserializes a UnitSystem object from a JSON object. | |
| constexpr Dimension | operator* (Dimension a, Dimension b) noexcept |
| Dimension of a product: exponents add. | |
| constexpr Dimension | operator/ (Dimension a, Dimension b) noexcept |
| Dimension of a quotient: exponents subtract. | |
| constexpr Dimension | dim_pow (Dimension d, int n) noexcept |
| Dimension raised to an integer power: exponents scale. | |
| template<class Tdst, class Tsrc> | |
| constexpr Unit< Tdst > | unit_cast (Unit< Tsrc > u) noexcept |
| Explicit precision conversion, e.g. unit_cast<float>(units::metre). | |
| template<class T> | |
| constexpr Unit< T > | operator* (Unit< T > a, Unit< T > b) noexcept |
| Product of two units: exponents add, factors multiply. | |
| template<class T> | |
| constexpr Unit< T > | operator/ (Unit< T > a, Unit< T > b) noexcept |
| Quotient of two units: exponents subtract, factors divide. | |
| template<class T> | |
| constexpr Unit< T > | operator* (T s, Unit< T > u) noexcept |
| Scale a unit, e.g. 149597870700. * metre. | |
| template<class T> | |
| constexpr Unit< T > | operator* (Unit< T > u, T s) noexcept |
| Scale a unit, e.g. metre * 1e3. | |
| template<class T> | |
| constexpr Unit< T > | operator/ (Unit< T > u, T s) noexcept |
| Divide a unit by a scalar, e.g. joule / 1e7. | |
| template<class T> | |
| constexpr Unit< T > | operator/ (T s, Unit< T > u) noexcept |
| Scalar over a unit, e.g. 1. / second: the dimension is inverted. | |
| template<class T> | |
| constexpr Unit< T > | upow (Unit< T > u, int n) noexcept |
| Integer power of a unit. | |
| template<class T = double> | |
| constexpr Unit< T > | base_unit (Dimension d) noexcept |
| A base unit of the given dimension with factor 1, e.g. base_unit({.metre = 1}). | |
| template<class T> | |
| constexpr Unit< T > | scale (T s) noexcept |
| A dimensionless scale factor, e.g. a prefix: scale(1e6) (precision of the argument). | |
Variables | |
| template<class T> | |
| constexpr T | pi = 3.141592653589793116 |
| Value of pi Usage : auto pi = shamunits::pi<T>;. | |
| template<class T> | |
| constexpr T | fine_structure = 0.0072973525693 |
| Fine structure constant. | |
| template<class T> | |
| constexpr T | proton_electron_ratio = 1836.1526734311 |
| Mass ration between the proton and electron. | |
| template<class T> | |
| constexpr T | electron_proton_ratio = 1 / proton_electron_ratio<T> |
| Mass ration between the electron and proton. | |
namespace containing the units library
|
inline |
Deserializes a UnitSystem object from a JSON object.
| j | The JSON object to deserialize from. |
| p | The UnitSystem object to populate. |
Definition at line 51 of file units_json.hpp.
|
constexprnoexcept |
|
inline |
Converts a UnitSystem object to a JSON object.
| j | The JSON object to be populated. |
| p | The UnitSystem object to be converted. |
Definition at line 33 of file units_json.hpp.
|
constexprnoexcept |
Explicit precision conversion, e.g. unit_cast<float>(units::metre).
Integer power of a unit.
Named upow rather than pow so argument-dependent lookup never competes with std::pow or sycl::pow. This is the only place in the unit algebra that can divide (for n < 0), and it folds at compile time whenever its argument is a constant expression.
Definition at line 147 of file Unit.hpp.
|
constexpr |
Mass ration between the electron and proton.
Definition at line 46 of file Constants.hpp.
|
constexpr |
Fine structure constant.
Definition at line 38 of file Constants.hpp.
|
constexpr |
Value of pi Usage : auto pi = shamunits::pi<T>;.
Definition at line 34 of file Constants.hpp.
|
constexpr |
Mass ration between the proton and electron.
Definition at line 42 of file Constants.hpp.