MCPcopy Create free account
hub / github.com/numpy/numpy / philox_next

Function philox_next

numpy/random/src/philox/philox.h:202–230  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

200} philox_state;
201
202static inline uint64_t philox_next(philox_state *state) {
203 uint64_t out;
204 int i;
205 philox4x64_ctr_t ct;
206
207 if (state->buffer_pos < PHILOX_BUFFER_SIZE) {
208 out = state->buffer[state->buffer_pos];
209 state->buffer_pos++;
210 return out;
211 }
212 /* generate 4 new uint64_t */
213 state->ctr->v[0]++;
214 /* Handle carry */
215 if (state->ctr->v[0] == 0) {
216 state->ctr->v[1]++;
217 if (state->ctr->v[1] == 0) {
218 state->ctr->v[2]++;
219 if (state->ctr->v[2] == 0) {
220 state->ctr->v[3]++;
221 }
222 }
223 }
224 ct = philox4x64_R(philox4x64_rounds, *state->ctr, *state->key);
225 for (i = 0; i < 4; i++) {
226 state->buffer[i] = ct.v[i];
227 }
228 state->buffer_pos = 1;
229 return state->buffer[0];
230}
231
232static inline uint64_t philox_next64(philox_state *state) {
233 return philox_next(state);

Callers 2

philox_next64Function · 0.85
philox_next32Function · 0.85

Calls 1

philox4x64_RFunction · 0.85

Tested by

no test coverage detected