From 1c7aaabffddeb10b2f43552ec8766d47a570464f Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Tue, 23 Feb 2021 16:33:28 +0530 Subject: Wrap extent oracles. * scm/extent-sampling/wrap.scm (make-extent-oracle, make-bernoulli-params, make-bernoulli-oracle, true-volume-procedure, bernoulli-true-volume, make-uniform-params, make-uniform-oracle, uniform-true-volume, make-beta-params, make-beta-oracle, beta-true-volume, make-cube-params, make-cube-oracle, cube-true-volume, make-spheroid-params, make-spheroid-oracle, spheroid-true-volume): New functions. --- scm/extent-sampling/wrap.scm | 70 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/scm/extent-sampling/wrap.scm b/scm/extent-sampling/wrap.scm index 0e32452..e22e299 100644 --- a/scm/extent-sampling/wrap.scm +++ b/scm/extent-sampling/wrap.scm @@ -220,3 +220,73 @@ (dynamic-func "shifted_gaussian_pdf" lib-extentsampling) (list double double double double unsigned-int '*)) theta (vector-norm2 mean) max-theta standard-deviation (vector-size mean) %integration-workspace)) + +;; oracles + +(define (make-extent-oracle oracle params) + (make-c-struct (list '* '*) + (list oracle params))) + +(define (make-bernoulli-params p r0 r1) + (make-c-struct (list double double double) + (list p r0 r1))) + +(define-public (make-bernoulli-oracle p r0 r1) + (make-extent-oracle (dynamic-func "bernoulli_extent_oracle" lib-extentsampling) + (make-bernoulli-params p r0 r1))) + +(define (true-volume-procedure name) + (pointer->procedure double + (dynamic-func name lib-extentsampling) + (list unsigned-int '*))) + +(define-public (bernoulli-true-volume p r0 r1 dimension) + ((true-volume-procedure "bernoulli_true_volume") + dimension (make-bernoulli-params p r0 r1))) + +(define (make-uniform-params a b) + (make-c-struct (list double double) + (list a b))) + +(define-public (make-uniform-oracle a b) + (make-extent-oracle (dynamic-func "uniform_extent_oracle" lib-extentsampling) + (make-uniform-params a b))) + +(define-public (uniform-true-volume a b dimension) + ((true-volume-procedure "uniform_true_volume") + dimension (make-uniform-params a b))) + +(define (make-beta-params alpha beta) + (make-c-struct (list double double) + (list alpha beta))) + +(define-public (make-beta-oracle alpha beta) + (make-extent-oracle (dynamic-func "beta_extent_oracle" lib-extentsampling) + (make-beta-params alpha beta))) + +(define-public (beta-true-volume alpha beta dimension) + ((true-volume-procedure "beta_true_volume") + dimension (make-beta-params alpha beta))) + +(define (make-cube-params edge) + (make-c-struct (list double) (list edge))) + +(define-public (make-cube-oracle edge) + (make-extent-oracle (dynamic-func "cube_extent_oracle" lib-extentsampling) + (make-cube-params edge))) + +(define-public (cube-true-volume edge dimension) + ((true-volume-procedure "cube_true_volume") + dimension (make-cube-params edge))) + +(define (make-spheroid-params eccentricity) + (make-c-struct (list double) (list eccentricity))) + +(define-public (make-spheroid-oracle eccentricity) + (make-extent-oracle (dynamic-func "spheroid_extent_oracle" lib-extentsampling) + (make-spheroid-params eccentricity))) + +(define-public (spheroid-true-volume eccentricity dimension) + ((true-volume-procedure "spheroid_true_volume") + dimension (make-spheroid-params eccentricity))) + -- cgit v1.2.3