This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// xoroshiro128+ | |
uint64_t rng_state[2]; | |
#if defined(_MSC_VER) | |
#define TO_FP32 (1.f/16777216.f) | |
#else | |
#define TO_FP32 0x1p-24f | |
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html><html><head><meta charset='utf-8'><title>Plot</title><script src='https://cdn.plot.ly/plotly-latest.min.js'></script><script type='text/javascript' src='https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script></head><body> | |
<style>body{margin:auto;padding:15px;text-align:justify;line-height:140%; -webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-size:14px;font-smoothing:antialiased;color:#222;font-family:Roboto, sans-serif;}</style><style>h1{border-bottom: 2px solid #666; color: #333; padding: 20px 0 8px }</style><style>h2{border-bottom: 1px solid #888; color: #555; padding: 20px 0 4px }</style></style><style>div.funclist{font-size: 12px}</style><h1>Example report using arctangent</h1> | |
This is overkill 'reporting' as demo. Actual intended use is to quickly visualize a small set of approximations over the domain. The script builds the HTML and can automatically open the results in a brower. A fair number of plot traces are so close they ove |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1 dep-chain (assuming state words in reg) to result. | |
// DON'T USE ME UNLESS YOUR PARINOID AND | |
// USING SOMETHING MORE EXPENSIVE (actually inferior | |
// to some other formulations...period is only 2^32-1) | |
// Zero is illegal for both state words. | |
typedef struct { uint32_t s[2]; } rng_state_t; | |
// smallcrush: passes | |
// crush: 1 systematic failure = 72 LinearComp, r = 29 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Public Domain under http://unlicense.org, see link for details. | |
#include <stdint.h> | |
#include <stdlib.h> | |
#include <stdio.h> | |
#include <math.h> | |
#include <string.h> | |
#include "xmmintrin.h" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SEE: https://lemire.me/blog/2019/03/19/the-fastest-conventional-random-number-generator-that-can-pass-big-crush/ | |
__uint128_t g_lehmer64_state; | |
uint64_t lehmer64() { | |
uint64_t r = (g_lehmer64_state >> 64); | |
g_lehmer64_state *= 0xda942042e4dd58b5; | |
return r; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* | |
Pi correctly rounded to 106 digits via sollya: | |
> display=dyadic!; | |
> round(Pi,106,RN); | |
63719069007931157819013617823235b-104 | |
*) | |
s = 63719069007931157819013617823235 | |
(* prime factors of 's' and nearby integers *) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* Mathematica source | |
same method as the previous gist for double. This validates that the constants giving here are optimal: | |
https://stackoverflow.com/questions/26692859/best-machine-optimized-polynomial-minimax-approximation-to-arctangent-on-1-1 | |
*) | |
(* round(Pi,48,RN) *) | |
s = 221069929750889 | |
(* prime factors of 's' and nearby integers *) | |
f0 = FactorInteger[s]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdint.h> | |
#include <stdlib.h> | |
#include <stdio.h> | |
#include <math.h> | |
#include <string.h> | |
inline uint32_t f32_to_bits(float x) | |
{ | |
uint32_t u; memcpy(&u, &x, 4); return u; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <inttypes.h> | |
#include <stdio.h> | |
#include <stdint.h> | |
#include "gdef.h" | |
#include "swrite.h" | |
#include "bbattery.h" | |
#include "scomp.h" | |
#include "swalk.h" | |
#include "svaria.h" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* -*- mode: c; -*- */ | |
// create primary range approximations of sin(pi x) and cos(pi x) for x on [-1/4,1/4] | |
// both for single and double precision | |
R = [0;1/4]; | |
T = floating; | |
E = relative; | |
B = [|24...|]; |