From 10d4a342fd02f79bdd848a87316c6f7dffc24019 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Thu, 11 Feb 2021 14:44:34 +0530 Subject: Change extent oracle and true volume prototypes. This change will make it easier for the scheme wrapper to curry extent oracles. * include/extent-sampling.h (extent_oracle_t): Define as a struct that bundles the parameters required by the actual extent oracle. * include/oracles.h (bernoulli_params, uniform_params, beta_params, cube_params, ellipsoid_params, spheroid_params): New types. (bernoulli_extent_generator, uniform_extent_generator, beta_extent_generator): Rename to bernoulli_extent_oracle, uniform_extent_oracle, beta_extent_oracle respectively and change to the new extent oracle prototype. (bernoulli_true_volume, uniform_true_volume, beta_true_volume, cube_extent_oracle, cube_extent_oracle_with_center, cube_true_volume, ellipsoid_extent_oracle, ellipsoid_true_volume, spheroid_extent_oracle, spheroid_true_volume): Change to new extent oracle and true volume prototypes. * src/oracles.sc: Likewise. * src/extent-sampling.sc (invoke-extent-oracle): New macro. (volume, volume-window, integral, volume-cone): Call using new extent oracle prototype. --- include/oracles.h | 51 ++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 38 insertions(+), 13 deletions(-) (limited to 'include/oracles.h') diff --git a/include/oracles.h b/include/oracles.h index b8421ed..c294b84 100644 --- a/include/oracles.h +++ b/include/oracles.h @@ -4,23 +4,48 @@ #include #include -double bernoulli_extent_generator (const gsl_rng* r, double p, double r0, double r1); -double bernoulli_true_volume (double p, double r0, double r1, unsigned int dimension); +typedef struct { + double p, r0, r1; +} bernoulli_params; -double uniform_extent_generator (const gsl_rng* r, double a, double b); -double uniform_true_volume (double a, double b, unsigned int dimension); +double bernoulli_extent_oracle (const gsl_rng *r, const gsl_vector *x, void *params); +double bernoulli_true_volume (unsigned int dimension, void *params); -double beta_extent_generator (const gsl_rng* r, double alpha, double beta); -double beta_true_volume (double alpha, double beta, unsigned int dimension); +typedef struct { + double a, b; +} uniform_params; -double cube_extent_oracle (const gsl_vector* x, double edge); -double cube_extent_oracle_with_center (const gsl_vector* x, const gsl_vector* center, double edge); -double cube_true_volume (double edge, unsigned int dimension); +double uniform_extent_oracle (const gsl_rng *r, const gsl_vector *x, void *params); +double uniform_true_volume (unsigned int dimension, void *params); -double ellipsoid_extent_oracle (const gsl_vector* x, const gsl_vector* axes); -double ellipsoid_true_volume (const gsl_vector* axes); +typedef struct { + double alpha, beta; +} beta_params; -double spheroid_extent_oracle (const gsl_vector* x, double eccentricity); -double spheroid_true_volume (double eccentricity, unsigned int dimension); +double beta_extent_oracle (const gsl_rng *r, const gsl_vector *x, void *params); +double beta_true_volume (unsigned int dimension, void *params); + +typedef struct { + double edge; + const gsl_vector* center; +} cube_params; + +double cube_extent_oracle (const gsl_rng *r, const gsl_vector *x, void *params); +double cube_extent_oracle_with_center (const gsl_rng *r, const gsl_vector *x, void *params); +double cube_true_volume (unsigned int dimension, void *params); + +typedef struct { + const gsl_vector* axes; +} ellipsoid_params; + +double ellipsoid_extent_oracle (const gsl_rng *r, const gsl_vector *x, void *params); +double ellipsoid_true_volume (unsigned int dimension, void *params); + +typedef struct { + double eccentricity; +} spheroid_params; + +double spheroid_extent_oracle (const gsl_rng *r, const gsl_vector *x, void *params); +double spheroid_true_volume (unsigned int dimension, void *params); #endif -- cgit v1.2.3