![]() |
Google OR-Tools v9.12
a fast and portable software suite for combinatorial optimization
|
Division and modulus using uint32_t numerators and denominators. More...
#include <constant_divisor.h>
Public Types | |
using | value_type = uint32_t |
typedef uint32_t | value_type |
![]() | |
using | value_type |
Public Member Functions | |
ConstantDivisor (value_type denominator) | |
REQUIRES: denominator > 1. | |
value_type | div (value_type numerator) const |
ConstantDivisor (value_type denominator) | |
value_type | div (value_type n) const |
value_type | mod (value_type n) const |
![]() | |
ConstantDivisorBase (uint64_t magic, value_type denominator) | |
value_type | mod (value_type numerator) const |
value_type | denominator () const |
Friends | |
value_type | operator/ (value_type a, const ConstantDivisor &b) |
value_type | operator% (value_type a, const ConstantDivisor &b) |
Additional Inherited Members | |
![]() | |
using | MagicValueType |
![]() | |
uint64_t | magic_ |
Division and modulus using uint32_t numerators and denominators.
Definition at line 137 of file constant_divisor.h.
typedef uint32_t util::math::ConstantDivisor< uint32_t >::value_type |
Definition at line 59 of file constant_divisor.h.
using util::math::ConstantDivisor< uint32_t >::value_type = uint32_t |
Definition at line 141 of file constant_divisor.h.
|
explicit |
REQUIRES: denominator > 1.
If we hardcode shift_amount to 32, the 32-bit formula is: magic_number = 2 ^ 64 / d value / d = value * magic_number >> 64
One caveat is that for d == 1, magic_number takes 65 bits overflowing a uint64_t. So, we again disallow inputs with d == 1.
Definition at line 39 of file constant_divisor.cc.
|
inlineexplicit |
Definition at line 61 of file constant_divisor.h.
|
inline |
Definition at line 64 of file constant_divisor.h.
|
inline |
Definition at line 146 of file constant_divisor.h.
|
inline |
Definition at line 66 of file constant_divisor.h.
|
friend |
Definition at line 72 of file constant_divisor.h.
|
friend |
Definition at line 68 of file constant_divisor.h.