diff options
author | Arun Isaac | 2021-02-23 16:39:14 +0530 |
---|---|---|
committer | Arun Isaac | 2021-02-23 16:39:14 +0530 |
commit | e50812c0a38f8583c5646c365a18acd42cfbe3a6 (patch) | |
tree | ccd6161402ac09c43f7d1a6c1290eb1eb26df632 | |
parent | e2bce25ab0f7eb0065812ebdc4f251206b86b446 (diff) | |
download | nsmc-e50812c0a38f8583c5646c365a18acd42cfbe3a6.tar.gz nsmc-e50812c0a38f8583c5646c365a18acd42cfbe3a6.tar.lz nsmc-e50812c0a38f8583c5646c365a18acd42cfbe3a6.zip |
Wrap integral function.
* scm/extent-sampling/wrap.scm (maybe-procedure->integrand, integral):
New functions.
-rw-r--r-- | scm/extent-sampling/wrap.scm | 20 |
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))) |