commit 4a24a6b93500e4b8f18f9bfd63124602dcfe2c0b
parent 65007a63040180ba7f84d7fbace5f11e51d7cb27
Author: NunoSempere <nuno.sempere@protonmail.com>
Date: Wed, 29 Nov 2023 20:04:41 +0000
clean scratchpad, start quickselect
Diffstat:
4 files changed, 13 insertions(+), 27 deletions(-)
diff --git a/scratchpad/core.c b/scratchpad/core.c
@@ -1,27 +0,0 @@
-
-uint64_t xorshift64(uint64_t* seed)
-{
- // Algorithm "xor" from p. 4 of Marsaglia, "Xorshift RNGs"
- // <https://en.wikipedia.org/wiki/Xorshift>
- uint64_t x = *seed;
- x ^= x << 13;
- x ^= x >> 7;
- x ^= x << 17;
- return *seed = x;
-}
-
-double sample_unit_uniform(uint64_t* seed)
-{
- // samples uniform from [0,1] interval.
- return ((double)xorshift64(seed)) / ((double)UINT64_MAX);
-}
-
-double sample_unit_normal(uint64_t* seed)
-{
- // // See: <https://en.wikipedia.org/wiki/Box%E2%80%93Muller_transform>
- double u1 = sample_unit_uniform(seed);
- double u2 = sample_unit_uniform(seed);
- double z = sqrtf(-2.0 * log(u1)) * sin(2 * PI * u2);
- return z;
-}
-
diff --git a/scratchpad/quickselect/makefile b/scratchpad/quickselect/makefile
@@ -0,0 +1,5 @@
+build:
+ gcc quickselect.c -lm -o quickselect
+
+run:
+ ./quickselect
diff --git a/scratchpad/quickselect/quickselect b/scratchpad/quickselect/quickselect
Binary files differ.
diff --git a/scratchpad/quickselect/quickselect.c b/scratchpad/quickselect/quickselect.c
@@ -0,0 +1,8 @@
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+int main(){
+ printf("Hello world!\n");
+ return 0;
+}