From e50812c0a38f8583c5646c365a18acd42cfbe3a6 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Tue, 23 Feb 2021 16:39:14 +0530 Subject: Wrap integral function. * scm/extent-sampling/wrap.scm (maybe-procedure->integrand, integral): New functions. --- scm/extent-sampling/wrap.scm | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'scm/extent-sampling') diff --git a/scm/extent-sampling/wrap.scm b/scm/extent-sampling/wrap.scm index 6bf0972..439a57d 100644 --- a/scm/extent-sampling/wrap.scm +++ b/scm/extent-sampling/wrap.scm @@ -324,6 +324,17 @@ %null-pointer)) (extent-oracle extent-oracle))) +(define maybe-procedure->integrand + (match-lambda + ((? procedure? integrand) + (make-integrand + (procedure->pointer double + (lambda (r x params) + (integrand r x)) + (list double '* '*)) + %null-pointer)) + (integrand integrand))) + (define-public (volume extent-oracle true-volume dimension rtol) (let ((stats (rstat-alloc))) ((pointer->procedure double @@ -333,3 +344,12 @@ true-volume %gsl-random-state dimension rtol stats) (rstat-n stats))) +(define-public (integral integrand extent-oracle true-integral dimension rtol) + (let ((stats (rstat-alloc))) + ((pointer->procedure double + (dynamic-func "integral" lib-extentsampling) + (list '* '* double '* unsigned-int double '*)) + (maybe-procedure->integrand integrand) + (maybe-procedure->extent-oracle extent-oracle) + true-integral %gsl-random-state dimension rtol stats) + (rstat-n stats))) -- cgit v1.2.3