120 if (
hash == type->hash) {
124 if (generator ==
NULL) {
130 generator->type = type;
133 generator->data = type->initialize(in_region);
137 log_error(
"Param generator with hash %u not found", hash);
142 return generator->type->generate(generator->data);
146 generator->type->free(generator->data);
void log_error(const char *message,...)
General types associated with generators.
uint32_t generator_hash_t
The type of values used to indicate the subtype of generator to create. Must match the constants on t...
void() free_func(void *data)
How to free any data for the generator; all generator types use the same signature of free func.
accum() generate_param_func(void *generator)
How to generate values with a parameter generator.
void *() initialize_param_func(void **region)
How to initialise the param generator.
@ NORMAL
A parameter that is a normally-distributed random variable.
@ CONSTANT
A parameter that is a constant.
@ UNIFORM
A parameter that is a uniformly-distributed random variable.
@ EXPONENTIAL
A parameter that is an exponentially-distributed random variable.
@ N_PARAM_GENERATORS
The number of known generators.
@ NORMAL_CLIPPED
A parameter that is a clipped-normally-distributed random variable.
@ NORMAL_CLIPPED_BOUNDARY
A parameter that is a clamped-normally-distributed random variable.
@ EXPONENTIAL_CLIPPED
A parameter that is a clipped-exponentially-distributed random variable.
free_func * free
Free any data for the generator.
initialize_param_func * initialize
Initialise the generator.
void param_generator_free(param_generator_t generator)
Finish with a parameter generator.
static const struct param_generator_info param_generators[]
An Array of known generators.
generate_param_func * generate
Generate values with a parameter generator.
param_generator_t param_generator_init(uint32_t hash, void **in_region)
Initialise a specific parameter generator.
generator_hash_t hash
The hash of the generator.
accum param_generator_generate(param_generator_t generator)
Generate value with a parameter generator.
The data for a parameter generator.
A "class" for parameter generators.
Interface for parameter generator.
Constant value parameter generator implementation.
static void * param_generator_constant_initialize(void **region)
How to initialise the constant parameter generator.
static accum param_generator_constant_generate(void *generator)
How to generate values with the constant parameter generator.
static void param_generator_constant_free(void *generator)
How to free any data for the constant parameter generator.
Exponentially distributed random parameter generator implementation.
static accum param_generator_exponential_generate(void *generator)
How to generate values with the exponential RNG parameter generator.
static void param_generator_exponential_free(void *generator)
How to free any data for the exponential RNG parameter generator.
static void * param_generator_exponential_initialize(void **region)
How to initialise the exponential RNG parameter generator.
Exponentially distributed random parameter generator implementation.
static accum param_generator_exponential_clipped_generate(void *generator)
How to generate values with the exponential RNG parameter generator.
static void * param_generator_exponential_clipped_initialize(void **region)
How to initialise the exponential RNG parameter generator.
static void param_generator_exponential_clipped_free(void *generator)
How to free any data for the exponential RNG parameter generator.
Normally distributed random parameter generator implementation.
static void * param_generator_normal_initialize(void **region)
How to initialise the normal RNG parameter generator.
static void param_generator_normal_free(void *generator)
How to free any data for the normal RNG parameter generator.
static accum param_generator_normal_generate(void *generator)
How to generate values with the normal RNG parameter generator.
Normally distributed random, redrawn if out of boundary, parameter generator implementation.
static accum param_generator_normal_clipped_generate(void *generator)
How to generate values with the clipped normal RNG parameter generator.
static void param_generator_normal_clipped_free(void *generator)
How to free any data for the clipped normal RNG parameter generator.
static void * param_generator_normal_clipped_initialize(void **region)
How to initialise the clipped normal RNG parameter generator.
Normally distributed random set to boundary parameter generator implementation.
static void * param_generator_normal_clipped_boundary_initialize(void **region)
How to initialise the clamped normal RNG parameter generator.
static void param_generator_normal_clipped_boundary_free(void *generator)
How to free any data for the clamped normal RNG parameter generator.
static accum param_generator_normal_clipped_boundary_generate(void *generator)
How to generate values with the clamped normal RNG parameter generator.
void sark_free(void *ptr)