For bit widths on
k | size |
|
pop | runs | k (binary) |
---|---|---|---|---|---|
0000009e | 00000073 | 0.449219 | 5 | 2 | 1..1111. |
00000076 | 0000006f | 0.433594 | 5 | 2 | .111.11. |
00000016 | 0000006e | 0.429688 | 3 | 2 | ...1.11. |
// compile with whatever then run PractRand: | |
// ./test | RNG_test stdin64 -tlmin 256KB -tf 2 -tlmax 512GB -seed 0 | |
//**************************************************************************** | |
// verbatim from: https://prng.di.unimi.it/xoroshiro128plus.c | |
/* Written in 2016-2018 by David Blackman and Sebastiano Vigna (vigna@acm.org) | |
To the extent possible under law, the author has dedicated all copyright | |
and related and neighboring rights to this software to the public domain |
// Repeating Cecil Hastings atan approximations from 1955 using Sollya. | |
// Other than "amusement factor" these use Hasting's approximations | |
// to "seed" the sollya calls to 'fpminimax'. | |
// | |
// Current world usage could include using an initial approximation | |
// from some multiprecision or computer algebra system and then | |
// Sollya to refine the constants to hardware sized (half,single,double,etc) | |
// | |
// Additionally the wide choice of the range would cause Sollya to fail | |
// to converge if we didn't feed it an initial guess. |
// Public Domain under http://unlicense.org, see link for details. | |
// EXCEPT "CORE-MATH" marked section | |
// {gcc,clang} -O3 -march=native -Wall -Wextra -Wconversion -Wpedantic -Wno-unused-function -fno-math-errno -ffp-contract=off atan_spitball.c -o atan_spitball -lm | |
#include <stdint.h> | |
#include <stdlib.h> | |
#include <stdio.h> | |
#include <math.h> | |
#include <string.h> |
For bit widths on
k | size |
|
pop | runs | k (binary) |
---|---|---|---|---|---|
0000009e | 00000073 | 0.449219 | 5 | 2 | 1..1111. |
00000076 | 0000006f | 0.433594 | 5 | 2 | .111.11. |
00000016 | 0000006e | 0.429688 | 3 | 2 | ...1.11. |
// UNLICENSE or whatever other you want that doesn't hold me | |
// responsible for you choosing to use any of this. | |
// a sketch of a few niche things: | |
// 1) generate a random number with a given population count | |
// 2) perform a random bit permutation of the input | |
// 3) not quite random versions of (2) | |
// 4) use (2) or (3) to produce stateful variants of (1) | |
#include <stdint.h> |
/* -*- mode: c; -*- */ | |
// multiply by recip: 10 aren't correctly rounded | |
print("multiply by 1/255"); | |
for i from 0 to 255 do | |
{ | |
cr = HP(i/255); | |
r = HP(i*0x1.01p-8); |
// whatever return type | |
typedef struct { float h,l; } f32_pair_t; | |
f32_pair_t f32_quadratic_hq(float A, float B, float C) | |
{ | |
double a = (double)A; | |
double b = (double)B; | |
double c = (double)C; |
// if 'f' is the 64-bit input CRC32-C (with 'incoming' 32-bit value of zero) then | |
// there are 50 bijections (invertiable functions) which are a sum of f | |
// and a simple xorshift. So the follow two forms: | |
// | |
// f(x) ^ (x ^ (x << S)) | |
// f(x) ^ (x ^ (x >> S)) | |
// | |
// and 23 using a rotate instead of a shift: | |
// |
// Public Domain under http://unlicense.org, see link for details. | |
// except: | |
// * core-math function `cr_cbrtf` (see license below) | |
// * musl flavored fdlib function `fdlibm_cbrtf` (see license below) | |
// code and test driver for cube root and it's reciprocal based on: | |
// "Fast Calculation of Cube and Inverse Cube Roots Using | |
// a Magic Constant and Its Implementation on Microcontrollers" | |
// Moroz, Samotyy, Walczyk, Cieslinski, 2021 | |
// (PDF: https://www.mdpi.com/1996-1073/14/4/1058) |