diff options
author | Arun Isaac | 2021-02-11 14:44:34 +0530 |
---|---|---|
committer | Arun Isaac | 2021-02-11 14:44:34 +0530 |
commit | 10d4a342fd02f79bdd848a87316c6f7dffc24019 (patch) | |
tree | 8dcc44f5d22870b5e275e11f59b3a6b3e7d46d03 /include | |
parent | 6faadaad7c59896591a5a1a20b11cc00715eda19 (diff) | |
download | nsmc-10d4a342fd02f79bdd848a87316c6f7dffc24019.tar.gz nsmc-10d4a342fd02f79bdd848a87316c6f7dffc24019.tar.lz nsmc-10d4a342fd02f79bdd848a87316c6f7dffc24019.zip |
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.
Diffstat (limited to 'include')
-rw-r--r-- | include/extent-sampling.h | 6 | ||||
-rw-r--r-- | include/oracles.h | 51 |
2 files changed, 43 insertions, 14 deletions
diff --git a/include/extent-sampling.h b/include/extent-sampling.h index 8ed3fb2..fd11bc4 100644 --- a/include/extent-sampling.h +++ b/include/extent-sampling.h @@ -5,7 +5,11 @@ #include <gsl/gsl_rstat.h> #include <gsl/gsl_vector.h> -typedef double (*extent_oracle_t) (const gsl_vector*); +typedef struct { + double (*oracle) (const gsl_rng*, const gsl_vector*, void*); + void *params; +} extent_oracle_t; + typedef double (*integrand_t) (double, const gsl_vector*); void init_random (void); 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 <gsl/gsl_rng.h> #include <gsl/gsl_vector.h> -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 |