Skip to content

Commit 18d1f99

Browse files
authored
Add files via upload
trimmed useless free functions - tidy up.
1 parent 3c84aa1 commit 18d1f99

File tree

2 files changed

+16
-48
lines changed

2 files changed

+16
-48
lines changed

X128PP.hh

+8-24
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ public:
4141
static constexpr result_type max () { return result_max; }
4242

4343

44-
std::array<result_type, 4> state; // (128 bits)
44+
std::array<result_type, 4> state;
4545

4646
static constexpr auto clamp (result_type u) {
4747
return (u & result_max); }
4848

4949
static constexpr auto rol (result_type u, unsigned k) {
5050
u = clamp(u), k %= 32; // idiomatic rotate:
51-
return (k) ? clamp((u << k) | (u >> (32 - k))) : (u);
51+
return (k ? clamp((u << k) | (u >> (32 - k))) : (u));
5252
}
5353

5454
// xoshiro128++ generator function:
@@ -111,15 +111,7 @@ public:
111111
// X128PP jump function implementations:
112112

113113

114-
constexpr auto
115-
jump (const X128PP & prng) noexcept
116-
{
117-
auto jrng {prng}; jrng.jump(); return jrng;
118-
}
119-
120-
121-
constexpr void
122-
X128PP::jump () noexcept
114+
constexpr void X128PP::jump () noexcept
123115
{
124116
decltype(state) jbuf {};
125117

@@ -128,10 +120,10 @@ X128PP::jump () noexcept
128120

129121
for (auto j : jtab)
130122
{
131-
for (int b = 0; b < (32); operator () (), b++)
123+
for (int b = 0; b < 32; operator () (), b++)
132124
{
133125
if (j & (UINT32_C(1) << b))
134-
for (unsigned int i = 0; i < jbuf.size(); i++)
126+
for (unsigned i = 0; i < jbuf.size(); i++)
135127
jbuf[i] ^= state[i];
136128
}
137129
}
@@ -140,15 +132,7 @@ X128PP::jump () noexcept
140132
}
141133

142134

143-
constexpr auto
144-
long_jump (const X128PP & prng) noexcept
145-
{
146-
auto jrng {prng}; jrng.long_jump(); return jrng;
147-
}
148-
149-
150-
constexpr void
151-
X128PP::long_jump () noexcept
135+
constexpr void X128PP::long_jump () noexcept
152136
{
153137
decltype(state) jbuf {};
154138

@@ -157,10 +141,10 @@ X128PP::long_jump () noexcept
157141

158142
for (auto j : jtab)
159143
{
160-
for (int b = 0; b < (32); operator () (), b++)
144+
for (int b = 0; b < 32; operator () (), b++)
161145
{
162146
if (j & (UINT32_C(1) << b))
163-
for (unsigned int i = 0; i < jbuf.size(); i++)
147+
for (unsigned i = 0; i < jbuf.size(); i++)
164148
jbuf[i] ^= state[i];
165149
}
166150
}

X256PP.hh

+8-24
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ public:
4141
static constexpr result_type max () { return result_max; }
4242

4343

44-
std::array<result_type, 4> state; // (256 bits)
44+
std::array<result_type, 4> state;
4545

4646
static constexpr auto clamp (result_type u) {
4747
return (u & result_max); }
4848

4949
static constexpr auto rol (result_type u, unsigned k) {
5050
u = clamp(u), k %= 64; // idiomatic rotate:
51-
return (k) ? clamp((u << k) | (u >> (64 - k))) : (u);
51+
return (k ? clamp((u << k) | (u >> (64 - k))) : (u));
5252
}
5353

5454
// xoshiro256++ generator function:
@@ -112,15 +112,7 @@ public:
112112
// X256PP jump function implementations:
113113

114114

115-
constexpr auto
116-
jump (const X256PP & prng) noexcept
117-
{
118-
auto jrng {prng}; jrng.jump(); return jrng;
119-
}
120-
121-
122-
constexpr void
123-
X256PP::jump () noexcept
115+
constexpr void X256PP::jump () noexcept
124116
{
125117
decltype(state) jbuf {};
126118

@@ -131,10 +123,10 @@ X256PP::jump () noexcept
131123

132124
for (auto j : jtab)
133125
{
134-
for (int b = 0; b < (64); operator () (), b++)
126+
for (int b = 0; b < 64; operator () (), b++)
135127
{
136128
if (j & (UINT64_C(1) << b))
137-
for (unsigned int i = 0; i < jbuf.size(); i++)
129+
for (unsigned i = 0; i < jbuf.size(); i++)
138130
jbuf[i] ^= state[i];
139131
}
140132
}
@@ -143,15 +135,7 @@ X256PP::jump () noexcept
143135
}
144136

145137

146-
constexpr auto
147-
long_jump (const X256PP & prng) noexcept
148-
{
149-
auto jrng {prng}; jrng.long_jump(); return jrng;
150-
}
151-
152-
153-
constexpr void
154-
X256PP::long_jump () noexcept
138+
constexpr void X256PP::long_jump () noexcept
155139
{
156140
decltype(state) jbuf {};
157141

@@ -162,10 +146,10 @@ X256PP::long_jump () noexcept
162146

163147
for (auto j : jtab)
164148
{
165-
for (int b = 0; b < (64); operator () (), b++)
149+
for (int b = 0; b < 64; operator () (), b++)
166150
{
167151
if (j & (UINT64_C(1) << b))
168-
for (unsigned int i = 0; i < jbuf.size(); i++)
152+
for (unsigned i = 0; i < jbuf.size(); i++)
169153
jbuf[i] ^= state[i];
170154
}
171155
}

0 commit comments

Comments
 (0)