formatting pass.

This commit is contained in:
NunoSempere 2023-07-16 16:30:38 +02:00
parent 607554f22b
commit c487bdfaf5

View File

@ -1,9 +1,9 @@
#include <limits.h> // INT_MAX
#include <stdint.h>
#include <stdlib.h>
#include <float.h> // FLT_MAX, FLT_MIN #include <float.h> // FLT_MAX, FLT_MIN
#include <stdio.h> #include <limits.h> // INT_MAX
#include <math.h> // erf, sqrt #include <math.h> // erf, sqrt
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h> #include <time.h>
#define EXIT_ON_ERROR 0 #define EXIT_ON_ERROR 0
@ -178,7 +178,8 @@ float sampler_normal_0_1(uint32_t* seed)
#define STOP 1.0e-8 #define STOP 1.0e-8
#define TINY 1.0e-30 #define TINY 1.0e-30
struct box incbeta(float a, float b, float x) { struct box incbeta(float a, float b, float x)
{
// Descended from <https://github.com/codeplea/incbeta/blob/master/incbeta.c>, // Descended from <https://github.com/codeplea/incbeta/blob/master/incbeta.c>,
// but modified to return a box struct and floats instead of doubles. // but modified to return a box struct and floats instead of doubles.
// [x] to do: add attribution in README // [x] to do: add attribution in README
@ -256,11 +257,13 @@ struct box incbeta(float a, float b, float x) {
/*Do an iteration of Lentz's algorithm.*/ /*Do an iteration of Lentz's algorithm.*/
d = 1.0 + numerator * d; d = 1.0 + numerator * d;
if (fabs(d) < TINY) d = TINY; if (fabs(d) < TINY)
d = TINY;
d = 1.0 / d; d = 1.0 / d;
c = 1.0 + numerator / c; c = 1.0 + numerator / c;
if (fabs(c) < TINY) c = TINY; if (fabs(c) < TINY)
c = TINY;
const float cd = c * d; const float cd = c * d;
f *= cd; f *= cd;
@ -285,7 +288,8 @@ struct box incbeta(float a, float b, float x) {
} }
} }
struct box cdf_beta(float x){ struct box cdf_beta(float x)
{
if (x < 0) { if (x < 0) {
struct box result = { .empty = 0, .content = 0 }; struct box result = { .empty = 0, .content = 0 };
return result; return result;
@ -298,7 +302,8 @@ struct box cdf_beta(float x){
} }
} }
float cdf_dangerous_beta(float x){ float cdf_dangerous_beta(float x)
{
// So the thing is, this works // So the thing is, this works
// But it will propagate through the code // But it will propagate through the code
// So it doesn't feel like a great architectural choice; // So it doesn't feel like a great architectural choice;