BPU
A rational (usually integral) power of a single basis unit
Context
Introduction
#include <xo/unit/bpu.hpp>
A xo::qty::bpu (aka “basis power unit”) represents a rational (usually integer) power of a Basis Unit.
For example:
representation for cubic millimeters
representation for annual (365-day) volatility
bpu is intended as an implementation-level abstraction.
Application code will normally interact with the more-general scaled_unit
instead of bpu.
Class
-
template<typename Int>
class bpu represent product of a compile-time scale-factor with a rational power of a native unit
Member Variables
- group Bpu-instance-vars
Variables
-
struct basis_unit bu_
this
bpurepresent a power of basis unitbu.Public to avoid disqualifying
bpuas a ‘structural type’.
-
power_ratio_type power_ = {}
this unit represents basis dimension (bu) taken to this power
Public to avoid disqualifying
bpuas a ‘structural type’.
-
struct basis_unit bu_
Constructors
- group bpu constructors
Functions
-
constexpr bpu() = default
default constructor. creates dimensionless bpu, representing zero’th power of sentinel basis unit
-
inline constexpr bpu(const basis_unit &bu, const power_ratio_type &power)
construct
bpurepresenting exponentpowerof basis unitbu
-
inline constexpr bpu(dim native_dim, const scalefactor_ratio_type &scalefactor, const power_ratio_type &power)
construct
bpurepresenting exponentpowerofbasis_unit(native_dim,scalefactor)
-
static inline bpu<Int> unit_power(const basis_unit &bu)
construct bpu representing basis unit
bu, i.e. with unit exponent
-
constexpr bpu() = default
Access Methods
- group bpu access methods
Functions
-
inline const basis_unit &bu() const
report this bpu’s basis_unit, e.g.
detail::bu::minute
-
inline dimension native_dim() const
report this bpu’s dimension, e.g.
dimension::time
-
inline const scalefactor_ratio_type &scalefactor() const
report this bpu’s scale factor, e.g.
60/1fordetail::bu::minute
-
inline const power_ratio_type &power() const
report this bpu’s exponent, e.g.
3/1for bpu representing cubic meters
-
inline const basis_unit &bu() const
Other Methods
- group Bpu-methods
Functions
-
inline bpu_abbrev_type abbrev() const
abbreviation for this dimension
bpu<int64_t>(dim::time, scalefactor_ratio_type(60,1), power_ratio_type(-2,1)).abbrev() => "min^-2"
-
inline bpu_abbrev_type abbrev() const
Comparison
- group Bpu-comparison
Details
- group bpu abbrev helpers
Functions
-
power_abbrev_type flatstring_from_exponent(const power_ratio_type &power)
construct prefix string for unit exponent
Auxiliary function for bpu_abbrev
-
static bpu_abbrev_type bpu_abbrev(dim native_dim, const scalefactor_ratio_type &scalefactor, const power_ratio_type &power)
construct suffix abbreviation for a basis-power-unit
-
power_abbrev_type flatstring_from_exponent(const power_ratio_type &power)