aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorArun Isaac2021-02-23 16:21:51 +0530
committerArun Isaac2021-02-23 16:21:51 +0530
commit59c0f5d621d665a2ab48cc760b561a7b610ab5fd (patch)
tree71a71224b4d8061bd9abc1ea87ac24b2e454b883 /src
parentaa8f62acf46a3b9d05ca675044edac15213b7095 (diff)
downloadnsmc-59c0f5d621d665a2ab48cc760b561a7b610ab5fd.tar.gz
nsmc-59c0f5d621d665a2ab48cc760b561a7b610ab5fd.tar.lz
nsmc-59c0f5d621d665a2ab48cc760b561a7b610ab5fd.zip
Redefine integrand_t as a struct.
This change will make it easier for the scheme wrapper to curry integrands. * include/extent-sampling.h (integrand_t): Redefine type as struct. (integral): Pass pointer to integrand_t. * src/extent-sampling.sc (integral-per-direction, integral): Handle new integrand-t type. (invoke-integrand): New sc macro.
Diffstat (limited to 'src')
-rw-r--r--src/extent-sampling.sc9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/extent-sampling.sc b/src/extent-sampling.sc
index c91c46c..69ea0a7 100644
--- a/src/extent-sampling.sc
+++ b/src/extent-sampling.sc
@@ -71,13 +71,16 @@
(gsl-rstat-n stats))))
(return volume))
+(sc-define-syntax (invoke-integrand integrand r x)
+ ((: integrand integrand) r x (: integrand params)))
+
(pre-let* (INTEGRATION-INTERVALS 1000)
(define (integral-per-direction integrand direction r n radius rtol neval)
- (double integrand-t (const gsl-vector*) (const gsl-rng*) (unsigned int) double double int*)
+ (double integrand-t* (const gsl-vector*) (const gsl-rng*) (unsigned int) double double int*)
(define (f r params) (double double void*)
(set+ (pointer-get neval) 1)
(return (* (gsl-pow-uint r (- n 1))
- (integrand r direction))))
+ (invoke-integrand integrand r direction))))
(declare gsl-f (struct-variable gsl-function (function (address-of f)))
result double
error double)
@@ -97,7 +100,7 @@
(pre-let* (INTEGRAL-MINIMUM-SAMPLES 100)
(define (integral integrand extent-oracle true-integral r dimension rtol stats)
- (double integrand-t extent-oracle-t* double (const gsl-rng*) (unsigned int) double gsl-rstat-workspace*)
+ (double integrand-t* extent-oracle-t* double (const gsl-rng*) (unsigned int) double gsl-rstat-workspace*)
(declare integral double
error double)
(with-vector x dimension