The International System of Units defines the system for physical quantities with the base quantities length, mass, time, electric current, thermodynamic temperature, amount of substance, luminous intensity. But this system is not necessary complete, we may want to use more base quantities such as angles, amount of data, currency, telephony offered load (Erlang) …
Here we present how the Units module implements a generic dimensional analysis for a system of units.
A dimensional system is derived from a set of base quantities \(\{ q_{i} \}_{1 \leq i \leq N}\). Any quantity can be written as:
That is a new quantity is derived by multiplying and/or dividing other quantities.
Note that a fractionnal power is possible, for example the square-root of a quantity is possible.
Here we implement \(\alpha_{i} \in \mathbb{Q}\), thus approximating a real number by a rational number.
Let \(\alpha_{i} = n_{i} / d_{i}\), with \(n_{i} \in \mathbb{Z}\), \(d_{i} \in \mathbb{N}^{*}\) and \(\gcd(n_{i}, d_{i}) = 1\), then
where \(m_{i} = n_{i} \prod_{j \neq i} d_{j} \in \mathbb{Z}\) and \(R = \prod_{i=1}^{N} d_{i} \in \mathbb{N}^{*}\).
To each base quantity \(q_{i}\) we associate an unique prime number \(p_{i}\). The quantity \(D\) can thus be represented as
where \(P/Q \in \mathbb{Q}\). Therefore, a dimension can be modelled as the root of a ratio and a set of three integers: \(\mathrm{Dim} \langle P, Q, R \rangle\).
The base quantities content of \(\mathrm{Dim} \langle P, Q, R \rangle\) can be recovered by performing a prime factor decompostion of \(P\) and \(Q\).
A dimension representation \(\mathrm{Dim} \langle P, Q, R \rangle\) is irreducible iff \(\gcd(P, Q) = 1\) and \(Q\) and \(P\) are not perfect \(R^{\mathrm{th}}\) powers (Wikipedia).
Two quantities are identical if they have the same irreducible dimension representation.
NB: This provides a compact and unique signature (given the correspondance \(q_{i} \mapsto p_{i}\) is well defined), that could be use in communication protocols to transfer data units.