commit bebb7c6d4637e97c310d7ba8c922c591d839fba0
parent 6247fbfb7bcc3d396f7a29a96b8d6e90ed057849
Author: NunoSempere <nuno.sempere@protonmail.com>
Date: Sun, 16 Jul 2023 22:59:47 +0200
format squiggle.c
Diffstat:
1 file changed, 11 insertions(+), 13 deletions(-)
diff --git a/squiggle.c b/squiggle.c
@@ -10,11 +10,9 @@
#define EXIT_ON_ERROR 0
#define PROCESS_ERROR(error_msg) process_error(error_msg, EXIT_ON_ERROR, __FILE__, __LINE__)
-// PI constant
const float PI = 3.14159265358979323846; // M_PI in gcc gnu99
// Pseudo Random number generator
-
uint32_t xorshift32(uint32_t* seed)
{
// Algorithm "xor" from p. 4 of Marsaglia, "Xorshift RNGs"
@@ -30,7 +28,6 @@ uint32_t xorshift32(uint32_t* seed)
}
// Distribution & sampling functions
-
float rand_0_to_1(uint32_t* seed)
{
return ((float)xorshift32(seed)) / ((float)UINT32_MAX);
@@ -128,16 +125,17 @@ struct box {
char* error_msg;
};
-struct box process_error(const char* error_msg, int should_exit, char* file, int line){
- if(should_exit){
- printf("@, in %s (%d)", file, line);
- exit(1);
- }else{
- char error_msg[MAX_ERROR_LENGTH];
- snprintf(error_msg, MAX_ERROR_LENGTH, "@, in %s (%d)", file, line);
- struct box error = { .empty = 1, .error_msg = error_msg };
- return error;
- }
+struct box process_error(const char* error_msg, int should_exit, char* file, int line)
+{
+ if (should_exit) {
+ printf("@, in %s (%d)", file, line);
+ exit(1);
+ } else {
+ char error_msg[MAX_ERROR_LENGTH];
+ snprintf(error_msg, MAX_ERROR_LENGTH, "@, in %s (%d)", file, line);
+ struct box error = { .empty = 1, .error_msg = error_msg };
+ return error;
+ }
}
// Inverse cdf at point