about summary refs log tree commit diff
path: root/scm
diff options
context:
space:
mode:
Diffstat (limited to 'scm')
-rw-r--r--scm/extent-sampling/wrap.scm20
1 files changed, 20 insertions, 0 deletions
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)))