Expand description
Physical dimensions as an abelian group of rational exponent vectors.
A dimension is what a quantity measures — length, mass, time, or a product/quotient of them (area = L², speed = L·T⁻¹, force = M·L·T⁻²). It is NOT a unit: metres and feet share the dimension Length. We model a dimension as a vector of rational exponents over the base dimensions, so dimensional algebra is exact vector arithmetic:
×adds exponent vectors (Length × Length = Length²),÷subtracts them (Area ÷ Length = Length),- integer powers scale them, and the
nth root divides them (so√(Length²) = Length).
Exponents are rational (not just integer) because real derived quantities need fractional
powers — noise density is V·Hz^(−1/2). The group’s identity is the dimensionless vector;
every dimension has an inverse (recip). Dimension is Copy + Eq + Hash, so it is a cheap
catalog key, rides inside the compiler’s type lattice, and tags a runtime quantity.
Structs§
- Dimension
- A physical dimension: a vector of rational exponents over
BaseDim. The group operation ismul(axiswise exponent addition); the identity isDimension::DIMENSIONLESS; the inverse isDimension::recip. - Exp
- A signed rational exponent in lowest terms with a strictly positive denominator — so equal
exponents share one representation (
Eq/Hashare structural). Admits fractional powers (L^(1/2)) while the common integer case is justden == 1.
Enums§
- BaseDim
- The base dimensions: the SI seven, plus the extensions Logos tracks end-to-end. Plane angle and solid angle are SI-dimensionless but tracked here to catch radian/steradian mix-ups; information (the bit) is tracked so data sizes are first-class. “Dimensionless” is the all-zero vector, not an axis.