Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/src/physics0/pd0_rng.h # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / src / physics0 / pd0_rng.h` 58 lines ยท 2536 bytes Raw Blame History 1 /* SPDX-License-Identifier: Apache-2.0 2 * Copyright 2026 Drake Stapleton (AIEN / aien-dev) 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 /* PD-0 randomness (spec PD0_HIDDEN_EQUATION_BENCHMARK.md section 3). 18 * 19 * SplitMix64 with Vigna's published constants (increment 0x9E3779B97F4A7C15, 20 * mixers 0xBF58476D1CE4E5B9 and 0x94D049BB133111EB). The same constants are 21 * already in this repo at src/turing/history_selector.c:23-28 22 * (turing_splitmix64) and src/compiler/model/osc_model_gen.c:44; the test 23 * tests/physics0/test_pd0_world.c checks this stream against 24 * turing_splitmix64 symbol for symbol, which is the "record the check" 25 * the spec asks for (section 3, first bullet). 26 * 27 * stream(seed, tag) = SplitMix64 seeded with seed XOR fnv1a64(tag). 28 * uniform: next() % 1_000_001 (micro-units in [0, 1.0]). 29 * const draw in [lo, hi]: lo + ((hi - lo) * u) / 1_000_000. 30 * Irwin-Hall noise (four uniforms, sd of the sum 577_350 micro): 31 * e = ((u1+u2+u3+u4) - 2_000_000) * sigma / 577_350. 32 * Shared by the world (constants, noise, null) and the harness (scorer, 33 * planner seeds). Contains no generator knowledge. */ 34 #ifndef PD0_RNG_H 35 #define PD0_RNG_H 36 37 #include 38 39 #define PD0_MICRO 1000000LL 40 #define PD0_IH_SD 577350LL /* sd of the sum of four uniforms on [0, 1e6] */ 41 42 /* same pedantic-safe spelling as ty_math.h:30 (ty_u128) */ 43 __extension__ typedef __int128 pd0_i128; 44 45 typedef struct { uint64_t s; } pd0_rng; 46 47 uint64_t pd0_fnv1a64(const char *tag); 48 uint64_t pd0_splitmix64(uint64_t *s); 49 void pd0_stream(pd0_rng *r, uint64_t seed, const char *tag); 50 uint64_t pd0_next(pd0_rng *r); 51 int64_t pd0_uniform(pd0_rng *r); /* 0 .. 1_000_000 */ 52 int64_t pd0_const(pd0_rng *r, int64_t lo, int64_t hi); /* micro-units */ 53 int64_t pd0_noise(pd0_rng *r, int64_t sigma_micro); 54 /* product rescale: (a*b)/1e6 in 128-bit, truncating toward zero (spec 2.1) */ 55 int64_t pd0_mul(int64_t a, int64_t b); 56 int64_t pd0_div(int64_t a, int64_t b); /* truncating, b != 0 */ 57 58 #endif