diff --git a/trng/lagfib2plus.hpp b/trng/lagfib2plus.hpp index 21a7489..35a904c 100644 --- a/trng/lagfib2plus.hpp +++ b/trng/lagfib2plus.hpp @@ -235,10 +235,10 @@ namespace trng { status_type S; void step() { + constexpr auto mask_B{int_math::mask(static_cast(B))}; ++S.index; - S.index &= int_math::mask(B); - S.r[S.index] = - S.r[(S.index - A) & int_math::mask(B)] + S.r[(S.index - B) & int_math::mask(B)]; + S.index &= mask_B; + S.r[S.index] = S.r[(S.index - A) & mask_B] + S.r[(S.index - B) & mask_B]; } }; diff --git a/trng/lagfib2xor.hpp b/trng/lagfib2xor.hpp index e1cba95..e2e87ca 100644 --- a/trng/lagfib2xor.hpp +++ b/trng/lagfib2xor.hpp @@ -237,10 +237,10 @@ namespace trng { status_type S; void step() { + constexpr auto mask_B{int_math::mask(static_cast(B))}; ++S.index; - S.index &= int_math::mask(B); - S.r[S.index] = - S.r[(S.index - A) & int_math::mask(B)] ^ S.r[(S.index - B) & int_math::mask(B)]; + S.index &= mask_B; + S.r[S.index] = S.r[(S.index - A) & mask_B] ^ S.r[(S.index - B) & mask_B]; } }; diff --git a/trng/lagfib4plus.hpp b/trng/lagfib4plus.hpp index f674080..4e7c815 100644 --- a/trng/lagfib4plus.hpp +++ b/trng/lagfib4plus.hpp @@ -237,11 +237,11 @@ namespace trng { status_type S; void step() { + constexpr auto mask_D{int_math::mask(static_cast(D))}; ++S.index; - S.index &= int_math::mask(D); - S.r[S.index] = - S.r[(S.index - A) & int_math::mask(D)] + S.r[(S.index - B) & int_math::mask(D)] + - S.r[(S.index - C) & int_math::mask(D)] + S.r[(S.index - D) & int_math::mask(D)]; + S.index &= mask_D; + S.r[S.index] = S.r[(S.index - A) & mask_D] + S.r[(S.index - B) & mask_D] + + S.r[(S.index - C) & mask_D] + S.r[(S.index - D) & mask_D]; } }; diff --git a/trng/lagfib4xor.hpp b/trng/lagfib4xor.hpp index f98b56e..0b9d10b 100644 --- a/trng/lagfib4xor.hpp +++ b/trng/lagfib4xor.hpp @@ -240,11 +240,11 @@ namespace trng { status_type S; void step() { + constexpr auto mask_D{int_math::mask(static_cast(D))}; ++S.index; - S.index &= int_math::mask(D); - S.r[S.index] = - S.r[(S.index - A) & int_math::mask(D)] ^ S.r[(S.index - B) & int_math::mask(D)] ^ - S.r[(S.index - C) & int_math::mask(D)] ^ S.r[(S.index - D) & int_math::mask(D)]; + S.index &= mask_D; + S.r[S.index] = S.r[(S.index - A) & mask_D] ^ S.r[(S.index - B) & mask_D] ^ + S.r[(S.index - C) & mask_D] ^ S.r[(S.index - D) & mask_D]; } };