aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/extent-sampling.sc5
-rw-r--r--src/macros/macros.sc14
2 files changed, 14 insertions, 5 deletions
diff --git a/src/extent-sampling.sc b/src/extent-sampling.sc
index 8d3693d..fb502a0 100644
--- a/src/extent-sampling.sc
+++ b/src/extent-sampling.sc
@@ -27,11 +27,6 @@
(pre-include "utils.h")
(pre-include "extent-sampling.h")
-(sc-define-syntax (with-rstats var body ...)
- (with-alloc var gsl-rstat-workspace*
- (gsl-rstat-alloc) gsl-rstat-free
- body ...))
-
(sc-define-syntax (with-integration-workspace var intervals body ...)
(with-alloc var gsl-integration-workspace*
(gsl-integration-workspace-alloc intervals)
diff --git a/src/macros/macros.sc b/src/macros/macros.sc
index cf6be15..8ff799b 100644
--- a/src/macros/macros.sc
+++ b/src/macros/macros.sc
@@ -53,3 +53,17 @@
(with-alloc var gsl-rng*
(gsl-rng-alloc gsl-rng-default) gsl-rng-free
body ...))
+
+(sc-define-syntax (with-rstats var body ...)
+ (with-alloc var gsl-rstat-workspace*
+ (gsl-rstat-alloc) gsl-rstat-free
+ body ...))
+
+(sc-define-syntax (with-rstats* var n body ...)
+ (begin
+ (declare var (array gsl-rstat-workspace* 3))
+ (for-i i n
+ (array-set var i (gsl-rstat-alloc)))
+ body ...
+ (for-i i n
+ (gsl-rstat-free (array-get var i)))))