#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "mcmc.h"
#include "mcmc_internal.h"
#include "debug.h"
#include "gsl_helper.h"
#include "histogram.h"
Defines |
#define | CIRCULAR_PARAMS 1,2 |
#define | DUMPONFAIL 1 |
#define | ASSERTDUMP(condition, text, a) |
#define | ASSERT(condition, text) ASSERTDUMP(condition, text, NULL) |
#define | ASSERTEQUALI(result, expected, text) |
#define | ASSERTEQUALD(result, expected, text) |
Functions |
int | count_tests () |
int | test_tests (void) |
int | test_hist (void) |
int | test_create (void) |
int | test_load (void) |
int | test_append (void) |
int | test_random (void) |
int | test_mod (void) |
int | test_write (void) |
int | test_write_prob (void) |
void | calc_prob (mcmc *m) |
void | calc_model (mcmc *m, const gsl_vector *old_values) |
void | calc_model_for (mcmc *m, const unsigned int index, const double old_value) |
Variables |
int(* | tests_registration [])(void) |
Define Documentation
#define ASSERT |
( |
|
condition, |
|
|
|
text |
|
) |
| ASSERTDUMP(condition, text, NULL) |
#define ASSERTDUMP |
( |
|
condition, |
|
|
|
text, |
|
|
|
a |
|
) |
| |
Value:{ \
if(!(condition)) { \
printf(" ASSERT FAILED: %s\n",text); \
if(DUMPONFAIL && a != NULL){ \
printf(" dump: \n"); \
dump_mcmc(a); \
} \
return 1; \
} else { \
printf(" subtest ok: %s\n",text); \
} \
}
#define ASSERTEQUALD |
( |
|
result, |
|
|
|
expected, |
|
|
|
text |
|
) |
| |
Value:{ \
if((expected) == (result) || \
abs_double((expected) - (result)) < abs_double((expected)+(result))*0.001 \
) { \
printf(" subtest ok: %s\n", text); \
} else { \
printf(" ASSERT EQUAL FAILED: expected: %e; got: %e; %s\n", expected, result, text); \
printf(" ASSERT CODE TERM: %s\n", #result); \
return 1; \
} \
}
Referenced by test_hist(), test_load(), test_mod(), and test_random().
#define ASSERTEQUALI |
( |
|
result, |
|
|
|
expected, |
|
|
|
text |
|
) |
| |
Value:{ \
if(expected != result) { \
printf(" ASSERT EQUAL FAILED: expected: %d; got: %d; %s\n", expected, result, text); \
printf(" ASSERT CODE: %s\n", #expected); \
return 1; \
} else { \
printf(" subtest ok: %s\n", text); \
} \
}
Referenced by test_append(), test_create(), test_hist(), test_load(), and test_write_prob().
#define CIRCULAR_PARAMS 1,2 |
Function Documentation
void calc_model |
( |
mcmc * |
m, |
|
|
const gsl_vector * |
old_values |
|
) |
| |
void calc_model_for |
( |
mcmc * |
m, |
|
|
const unsigned int |
i, |
|
|
const double |
old_value |
|
) |
| |
update the model as the new parameter value i changed and recalculate the probability for the model
- Parameters:
-
m | |
i | index of the parameter value that changed |
old_value | previous value of the parameter |
Referenced by main(), and markov_chain_step_for().
void calc_prob |
( |
mcmc * |
m | ) |
|
References ASSERT, ASSERTEQUALD, ASSERTEQUALI, mcmc::data, mcmc_free(), mcmc_load(), mcmc::n_par, mcmc::params, mcmc::params_descr, mcmc::params_max, mcmc::params_min, and mcmc::params_step.
int test_write_prob |
( |
void |
| ) |
|
References ASSERTEQUALI, countlines(), debug, mcmc_append_current_parameters(), mcmc_check(), mcmc_dump_flush(), mcmc_free(), mcmc_load(), mcmc_open_dump_files(), mcmc::params, mcmc::params_max, and require.
Variable Documentation