scratchpad formatting pass

This commit is contained in:
NunoSempere 2023-07-16 17:33:58 +02:00
parent 487de4a731
commit 65756a359b

View File

@ -235,12 +235,11 @@ struct box inverse_cdf_float(float cdf(float), float p)
}
if (convergence_condition) {
struct box result = {.empty = 0, .content = low};
struct box result = { .empty = 0, .content = low };
return result;
} else {
PROCESS_ERROR("Search process did not converge, in function inverse_cdf");
}
}
}
@ -261,12 +260,12 @@ struct box inverse_cdf_box(struct box cdf_box(float), float p)
// ^ Using FLT_MIN and FLT_MAX is overkill
// but it's also the *correct* thing to do.
struct box cdf_low = cdf_box(low);
if(cdf_low.empty){
if (cdf_low.empty) {
PROCESS_ERROR(cdf_low.error_msg);
}
struct box cdf_high=cdf_box(high);
if(cdf_high.empty){
struct box cdf_high = cdf_box(high);
if (cdf_high.empty) {
PROCESS_ERROR(cdf_low.error_msg);
}
@ -296,7 +295,7 @@ struct box inverse_cdf_box(struct box cdf_box(float), float p)
convergence_condition = 1;
} else {
struct box cdf_mid = cdf_box(mid);
if(cdf_mid.empty){
if (cdf_mid.empty) {
PROCESS_ERROR(cdf_mid.error_msg);
}
float mid_sign = cdf_mid.content - p;
@ -312,12 +311,11 @@ struct box inverse_cdf_box(struct box cdf_box(float), float p)
}
if (convergence_condition) {
struct box result = {.empty = 0, .content = low};
struct box result = { .empty = 0, .content = low };
return result;
} else {
PROCESS_ERROR("Search process did not converge, in function inverse_cdf");
}
}
}
@ -371,7 +369,8 @@ float sampler_normal_0_1(uint32_t* seed)
}
// Some testers
void test_inverse_cdf_float(char* cdf_name, float cdf_float(float)){
void test_inverse_cdf_float(char* cdf_name, float cdf_float(float))
{
struct box result = inverse_cdf_float(cdf_float, 0.5);
if (result.empty) {
printf("Inverse for %s not calculated\n", cdf_name);
@ -379,9 +378,9 @@ void test_inverse_cdf_float(char* cdf_name, float cdf_float(float)){
} else {
printf("Inverse of %s at %f is: %f\n", cdf_name, 0.5, result.content);
}
}
void test_inverse_cdf_box(char* cdf_name, struct box cdf_box(float)){
void test_inverse_cdf_box(char* cdf_name, struct box cdf_box(float))
{
struct box result = inverse_cdf_box(cdf_box, 0.5);
if (result.empty) {
printf("Inverse for %s not calculated\n", cdf_name);
@ -389,10 +388,10 @@ void test_inverse_cdf_box(char* cdf_name, struct box cdf_box(float)){
} else {
printf("Inverse of %s at %f is: %f\n", cdf_name, 0.5, result.content);
}
}
void test_and_time_sampler_float(char* cdf_name, float cdf_float(float), uint32_t* seed){
void test_and_time_sampler_float(char* cdf_name, float cdf_float(float), uint32_t* seed)
{
printf("\nGetting some samples from %s:\n", cdf_name);
clock_t begin = clock();
for (int i = 0; i < NUM_SAMPLES; i++) {
@ -408,7 +407,8 @@ void test_and_time_sampler_float(char* cdf_name, float cdf_float(float), uint32_
printf("Time spent: %f\n", time_spent);
}
void test_and_time_sampler_box(char* cdf_name, struct box cdf_box(float), uint32_t* seed){
void test_and_time_sampler_box(char* cdf_name, struct box cdf_box(float), uint32_t* seed)
{
printf("\nGetting some samples from %s:\n", cdf_name);
clock_t begin = clock();
for (int i = 0; i < NUM_SAMPLES; i++) {