From e2bce25ab0f7eb0065812ebdc4f251206b86b446 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Tue, 23 Feb 2021 16:38:41 +0530 Subject: Wrap volume function. * scm/extent-sampling/wrap.scm (maybe-procedure->extent-oracle, maybe-procedure->integrand): New functions. --- scm/extent-sampling/wrap.scm | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/scm/extent-sampling/wrap.scm b/scm/extent-sampling/wrap.scm index 25b9970..6bf0972 100644 --- a/scm/extent-sampling/wrap.scm +++ b/scm/extent-sampling/wrap.scm @@ -311,3 +311,25 @@ (make-integrand (dynamic-func "x_coordinate_integrand" lib-extentsampling) %null-pointer)) +;; extent-sampling + +(define maybe-procedure->extent-oracle + (match-lambda + ((? procedure? proc) + (make-extent-oracle + (procedure->pointer double + (lambda (r x params) + (proc r x)) + (list '* '* '*)) + %null-pointer)) + (extent-oracle extent-oracle))) + +(define-public (volume extent-oracle true-volume dimension rtol) + (let ((stats (rstat-alloc))) + ((pointer->procedure double + (dynamic-func "volume" lib-extentsampling) + (list '* double '* unsigned-int double '*)) + (maybe-procedure->extent-oracle extent-oracle) + true-volume %gsl-random-state dimension rtol stats) + (rstat-n stats))) + -- cgit v1.2.3