ashinn / chibi-scheme

Official chibi-scheme repository
Other
1.21k stars 142 forks source link

SRFI 231: interval-projection problem? #925

Closed gambiteer closed 3 months ago

gambiteer commented 1 year ago

I'm testing chibi's SRFI 231 implementation, but I'm not really confident I'm doing it correctly. I'm trying

(test-values (values (make-interval '#())
                      (make-interval '#(1 1)))
              (interval-projections (make-interval '#(0 0) '#(1 1)) 2))

(I'm not sure this is correct, I'm following the "put the expected result first" principle.) I'm getting

    FAIL: ...(interval-projections (make-interval '#(0 0) '#(1 1)) 2)
        expected ({Interval #43 #() #()} {Interval #43 #(0 0) #(1 1)}) but got ({Interval #43 #(0 0) #(1 1)} {Interval #43 #() #()})
        on line 145 of file "/usr/local/chibi//share/chibi/chibi/test.scm"
        (call-with-values (lambda () (interval-projections (make-interval '#(0 0) '#(1 1)) 2)) (lambda results results))
gambiteer commented 1 year ago

It appears that this definition in base.scm:

(define (interval-projections iv rd)
  (values (make-interval (vector-copy (interval-lb iv) 0 rd)
                         (vector-copy (interval-ub iv) 0 rd))
          (make-interval (vector-copy (interval-lb iv) rd)
                         (vector-copy (interval-ub iv) rd))))

is incorrect, it puts rd dimensions into the first interval instead of the second. If you agree, I'll draw up a PR.

ashinn commented 3 months ago

Sorry, I lost track of these issues for a while and just got back to the SRFI 231 implementation. I believe this is working now, can you double check?

gambiteer commented 3 months ago

This works.