some minor tweaks to some mpl files and color filter updates
[quplot.git] / ran.h
blobd76aa53d6bb54b1eb28b513932c72e0d6ad520a4
1 #ifndef RAN_H
2 #define RAN_H
4 #include "qp3.h"
6 struct Ran {
7 Ullong u,v,w;
8 Ran(Ullong j) : v(4101842887655102017LL), w(1) {
9 // Constructor. Call with any integer seed (except value of v above).
10 u = j ^ v; int64();
11 v = u; int64();
12 w = v; int64();
14 inline Ullong int64() {
15 // Return 64-bit random integer.
16 u = u * 2862933555777941757LL + 7046029254386353087LL;
17 v ^= v >> 17; v ^= v << 31; v ^= v >> 8;
18 w = 4294957665U*(w & 0xffffffff) + (w >> 32);
19 Ullong x = u ^ (u << 21); x ^= x >> 35; x ^= x << 4;
20 return (x + v) ^ w;
22 inline Doub doub() { return 5.42101086242752217E-20 * int64(); }
23 // Return random double-precision floating value in the range 0. to 1.
24 inline Uint int32() { return (Uint)int64(); }
25 // Return 32-bit random integer.
28 struct Ranq1 {
29 Ullong v;
30 Ranq1(Ullong j) : v(4101842887655102017LL) {
31 v ^= j;
32 v = int64();
34 inline Ullong int64() {
35 v ^= v >> 21; v ^= v << 35; v ^= v >> 4;
36 return v * 2685821657736338717LL;
38 inline Doub doub() { return 5.42101086242752217E-20 * int64(); }
39 inline Uint int32() { return (Uint)int64(); }
42 struct Ranq2 {
43 Ullong v,w;
44 Ranq2(Ullong j) : v(4101842887655102017LL), w(1) {
45 v ^= j;
46 w = int64();
47 v = int64();
49 inline Ullong int64() {
50 v ^= v >> 17; v ^= v << 31; v ^= v >> 8;
51 w = 4294957665U*(w & 0xffffffff) + (w >> 32);
52 return v ^ w;
54 inline Doub doub() { return 5.42101086242752217E-20 * int64(); }
55 inline Uint int32() { return (Uint)int64(); }
58 #endif // RAN_H