* Fills an array with cnt random npy_bool between off and off + rng * inclusive. */
| 408 | * inclusive. |
| 409 | */ |
| 410 | void rk_random_bool(npy_bool off, npy_bool rng, npy_intp cnt, npy_bool *out, |
| 411 | rk_state *state) { |
| 412 | npy_intp i; |
| 413 | npy_uint32 buf; |
| 414 | int bcnt = 0; |
| 415 | |
| 416 | if (rng == 0) { |
| 417 | for (i = 0; i < cnt; i++) { |
| 418 | out[i] = off; |
| 419 | } |
| 420 | return; |
| 421 | } |
| 422 | |
| 423 | /* If we reach here rng and mask are one and off is zero */ |
| 424 | assert(rng == 1 && off == 0); |
| 425 | for (i = 0; i < cnt; i++) { |
| 426 | if (!bcnt) { |
| 427 | buf = rk_uint32(state); |
| 428 | bcnt = 31; |
| 429 | } else { |
| 430 | buf >>= 1; |
| 431 | bcnt--; |
| 432 | } |
| 433 | out[i] = (buf & 0x00000001) != 0; |
| 434 | } |
| 435 | } |
| 436 | |
| 437 | long rk_long(rk_state *state) { return rk_ulong(state) >> 1; } |
| 438 |
nothing calls this directly
no test coverage detected