Skip to content

Commit d696560

Browse files
committed
QPR-12140 attempt to fix unit test on gcc / debian
1 parent 8078a49 commit d696560

2 files changed

Lines changed: 12 additions & 10 deletions

File tree

ql/math/randomnumbers/burley2020sobolrsg.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ namespace QuantLib {
4141
nextSequenceCounter_ = 0;
4242
}
4343

44-
const std::vector<std::uint_least32_t>& Burley2020SobolRsg::skipTo(std::uint32_t n) const {
44+
const std::vector<std::uint32_t>& Burley2020SobolRsg::skipTo(std::uint32_t n) const {
4545
reset();
4646
for (Size k = 0; k < n + 1; ++k) {
4747
nextInt32Sequence();
@@ -72,14 +72,16 @@ namespace QuantLib {
7272
15, 143, 79, 207, 47, 175, 111, 239, 31, 159, 95, 223, 63, 191, 127, 255};
7373

7474
std::uint32_t reverseBits(std::uint32_t x) {
75-
std::uint32_t y;
76-
unsigned char* p = (unsigned char*)(&x);
77-
unsigned char* q = (unsigned char*)(&y);
78-
q[3] = bitReverseTable[p[0]];
79-
q[2] = bitReverseTable[p[1]];
80-
q[1] = bitReverseTable[p[2]];
81-
q[0] = bitReverseTable[p[3]];
82-
return y;
75+
return (bitReverseTable[x & 0xff] << 24) | (bitReverseTable[(x >> 8) & 0xff] << 16) |
76+
(bitReverseTable[(x >> 16) & 0xff] << 8) | (bitReverseTable[(x >> 24) & 0xff]);
77+
// std::uint32_t y;
78+
// unsigned char* p = (unsigned char*)(&x);
79+
// unsigned char* q = (unsigned char*)(&y);
80+
// q[3] = bitReverseTable[p[0]];
81+
// q[2] = bitReverseTable[p[1]];
82+
// q[1] = bitReverseTable[p[2]];
83+
// q[0] = bitReverseTable[p[3]];
84+
// return y;
8385
}
8486

8587
std::uint32_t laine_karras_permutation(std::uint32_t x, std::uint32_t seed) {

ql/math/randomnumbers/burley2020sobolrsg.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ namespace QuantLib {
4040
unsigned long seed = 42,
4141
SobolRsg::DirectionIntegers directionIntegers = SobolRsg::Jaeckel,
4242
unsigned long scrambleSeed = 43);
43-
const std::vector<std::uint_least32_t>& skipTo(std::uint32_t n) const;
43+
const std::vector<std::uint32_t>& skipTo(std::uint32_t n) const;
4444
const std::vector<std::uint32_t>& nextInt32Sequence() const;
4545
const SobolRsg::sample_type& nextSequence() const;
4646
const sample_type& lastSequence() const { return sequence_; }

0 commit comments

Comments
 (0)