From 65589e3e26ee76d305524ca3f6e7d5d99a90281a Mon Sep 17 00:00:00 2001 From: Alex Shinn Date: Wed, 22 May 2024 21:59:11 +0900 Subject: [PATCH] Fix default coeffs for the degenerate dimension case. --- lib/srfi/231/base.scm | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/srfi/231/base.scm b/lib/srfi/231/base.scm index 9d5f62a8..73c883a7 100644 --- a/lib/srfi/231/base.scm +++ b/lib/srfi/231/base.scm @@ -416,16 +416,14 @@ (cond ((< i 0) res) - ((= (+ 1 (interval-lower-bound domain i)) - (interval-upper-bound domain i)) - ;; (vector-set! res (+ i 1) (if (< (+ i 1) dim) - ;; (interval-width domain (+ i 1)) - ;; 1)) - (lp (- i 1) scale)) (else - (let ((coeff (* scale (- (interval-upper-bound domain i) - (interval-lower-bound domain i))))) + (let* ((width (interval-width domain i)) + (coeff (* scale width))) + ;; The coefficient for stepping over each element is the + ;; volume (product of widths) of all higher dimensions. (vector-set! res (+ i 1) scale) + ;; Offset the constant bias by the lower bound of this + ;; dimension (typically but not necessarily 0). (vector-set! res 0 (- (vector-ref res 0) (* scale (interval-lower-bound domain i)))) (lp (- i 1) coeff)))))))