dimension

namespace nin::inline units {
    struct dimension;
}

Represents the physical dimension of a quantity as a tuple of seven integer exponents, one for each SI base quantity.

Data members

α
β
γ
δ
ε
ζ
η

SI base dimension exponents

int8_t α = 0

Time (second)

int8_t β = 0

Length (metre)

int8_t γ = 0

Mass (kilogram)

int8_t δ = 0

Electric current (ampere)

int8_t ε = 0

Temperature (kelvin)

int8_t ζ = 0

Amount of substance (mole)

int8_t η = 0

Luminous intensity (candela)

All default-initialized to 0 (dimensionless).

Member functions

operator ==

equality comparison

bool operator ==(dimension rhs) const

(1)

Returns true if all seven exponents are equal. Defaulted.

operator *=
operator /=

dimension arithmetic assignment

dimension & operator *=(dimension rhs)

(1)

dimension & operator /=(dimension rhs)

(2)

  • (1) Adds the exponents of rhs to *this (dimension multiplication).

  • (2) Subtracts the exponents of rhs from *this (dimension division).

sqrt

square root of a dimension

dimension sqrt() const

(1)

Returns a dimension with all exponents halved. Throws std::domain_error if any exponent is odd.

is_sqrt_ok

check if square root is valid

bool is_sqrt_ok() const

(1)

Returns true if all exponents are even.

Non-member functions

operator *
operator /

dimension arithmetic

dimension operator *(dimension lhs, dimension rhs)

(1)

dimension operator /(dimension lhs, dimension rhs)

(2)

  • (1) Returns a dimension with exponents summed.

  • (2) Returns a dimension with exponents subtracted.