chibi-scheme icon indicating copy to clipboard operation
chibi-scheme copied to clipboard

SRFI 231: interval-projection problem?

Open gambiteer opened this issue 2 years ago • 1 comments

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 avatar Jun 23 '23 00:06 gambiteer

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.

gambiteer avatar Jun 23 '23 01:06 gambiteer

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?

ashinn avatar May 22 '24 14:05 ashinn

This works.

gambiteer avatar May 22 '24 19:05 gambiteer