units
Use physical dimensions at compile-time or run-time.
|
Least common denominator (LCD) and corresponding numerators for the comparison of a pair of rational numbers. More...
#include <common-denom.hpp>
Public Types | |
enum | { LCD_BITS = clamp64(DB1 + DB2), N1_BITS = clamp64(NB1 + DB2), N2_BITS = clamp64(NB2 + DB1), NMR_BITS = (N1_BITS > N2_BITS ? N1_BITS : N2_BITS) } |
Number of bits required for storage of various items. More... | |
using | lcd_t = typename int_types< LCD_BITS >::UF |
Type of LCD. More... | |
using | n1_t = typename int_types< N1_BITS >::SF |
Type of first numerator. More... | |
using | n2_t = typename int_types< N2_BITS >::SF |
Type of secnd numerator. More... | |
Static Public Member Functions | |
static constexpr unsigned | clamp64 (unsigned n) |
Clamp an unsigned number at the maximum value of 64. More... | |
Public Attributes | |
lcd_t const | lcd |
LCD. More... | |
n1_t const | n1 |
First numerator. More... | |
n2_t const | n2 |
Second numerator. More... | |
Private Types | |
using | rat1 = rational< NB1, DB1 > |
Type of first rational. More... | |
using | rat2 = rational< NB2, DB2 > |
Type of second rational. More... | |
Private Member Functions | |
constexpr | common_denom_params (lcd_t ll, n1_t nn1, n2_t nn2) |
Construct from list of initializers. More... | |
Friends | |
constexpr friend common_denom_params | common_denom (rat1 r1, rat2 r2) |
Allow common_denom() to call private constructor. More... | |
Least common denominator (LCD) and corresponding numerators for the comparison of a pair of rational numbers.
An instance of common_denom_params is returned by common_denom().
NB1 | Number of bits for numerator of first rational. |
DB1 | Number of bits for denominator of first rational. |
NB2 | Number of bits for numerator of second rational. |
DB2 | Number of bits for denominator of second rational. |
Definition at line 20 of file common-denom.hpp.
using vnix::rat::common_denom_params< NB1, DB1, NB2, DB2 >::lcd_t = typename int_types<LCD_BITS>::UF |
Type of LCD.
Definition at line 72 of file common-denom.hpp.
using vnix::rat::common_denom_params< NB1, DB1, NB2, DB2 >::n1_t = typename int_types<N1_BITS>::SF |
Type of first numerator.
Definition at line 73 of file common-denom.hpp.
using vnix::rat::common_denom_params< NB1, DB1, NB2, DB2 >::n2_t = typename int_types<N2_BITS>::SF |
Type of secnd numerator.
Definition at line 74 of file common-denom.hpp.
|
private |
Type of first rational.
Definition at line 81 of file common-denom.hpp.
|
private |
Type of second rational.
Definition at line 82 of file common-denom.hpp.
anonymous enum |
Number of bits required for storage of various items.
Enumerator | |
---|---|
LCD_BITS |
For storage of LCD. |
N1_BITS |
For storage of first numerator. |
N2_BITS |
For storage of second numerator. |
NMR_BITS |
For use by client for storage of sum of numerators. |
Definition at line 64 of file common-denom.hpp.
|
inlineprivate |
Construct from list of initializers.
ll | Least common denominator. |
nn1 | First numerator. |
nn2 | Second numerator. |
Definition at line 92 of file common-denom.hpp.
|
inlinestatic |
Clamp an unsigned number at the maximum value of 64.
n | Unsigned input. |
Definition at line 61 of file common-denom.hpp.
|
friend |
Allow common_denom() to call private constructor.
NB1 | Number of bits for numerator of first rational. |
DB1 | Number of bits for denominator of first rational. |
NB2 | Number of bits for numerator of second rational. |
DB2 | Number of bits for denominator of second rational. |
r1 | First input rational number. |
r2 | Second input rational number. |
Definition at line 35 of file common-denom.hpp.
lcd_t const vnix::rat::common_denom_params< NB1, DB1, NB2, DB2 >::lcd |
LCD.
Definition at line 76 of file common-denom.hpp.
n1_t const vnix::rat::common_denom_params< NB1, DB1, NB2, DB2 >::n1 |
First numerator.
Definition at line 77 of file common-denom.hpp.
n2_t const vnix::rat::common_denom_params< NB1, DB1, NB2, DB2 >::n2 |
Second numerator.
Definition at line 78 of file common-denom.hpp.