Prev: AUTHENTIC DESIGNER HANDBAGS & ACCESSORIES WWW.VOGUELANDE.COM CHANEL LOUIS VUITTON
Next: Re^2: slime errors in cmucl?
From: Norbert_Paul on 30 Mar 2010 14:20 I startet testing some matrix computation routines in slime using rt. (This was useful: Made me spot a bug) But then however I set up a test case using random dimensions and values and let it run 10000 times and sometimes the tests fails, even when the resulting matrix was correct. (I stored the fixture in global variables to inspect). All tests run fine in bare cmucl and bare sbcl (on my system sbcl doesn't work together with slime). In the slime sbcl-repl (which I took, brother, but there it didn't serve me well), however, the following sometimes fails: (dotimes (i 100000) (let* ((v1 (list (random 10d0)(random 10d0))) (v2 (list (random 10d0)(random 10d0))) (dot1 (reduce #'+ (mapcar #'* v1 v2))) (dot2 (reduce #'+ (mapcar #'* v1 v2)))) (if (/= dot1 dot2) (error "This REPL doesn't serve me well, brother.")))) I'm using Debian squeeze with GNU Emacs 23.1.1 (i486-pc-linux-gnu, GTK+ Version 2.18.2) of 2009-11-02 on raven, modified by Debian and slime version 1:2010022-1. Is that a known bug in slime or any other of aforementioned components? Norbert
From: vanekl on 30 Mar 2010 15:31 Norbert_Paul wrote: > (dotimes (i 100000) > (let* ((v1 (list (random 10d0)(random 10d0))) > (v2 (list (random 10d0)(random 10d0))) > (dot1 (reduce #'+ (mapcar #'* v1 v2))) > (dot2 (reduce #'+ (mapcar #'* v1 v2)))) > (if (/= dot1 dot2) > (error "This REPL doesn't serve me well, brother.")))) > > I'm using Debian squeeze with > GNU Emacs 23.1.1 (i486-pc-linux-gnu, GTK+ Version 2.18.2) of > 2009-11-02 on raven, modified by Debian and > slime version 1:2010022-1. > > Is that a known bug in slime or any other of aforementioned > components? > > Norbert no worries here, brothuh CL-USER> (dotimes (i 100000) (let* ((v1 (list (random 10d0)(random 10d0))) (v2 (list (random 10d0)(random 10d0))) (dot1 (reduce #'+ (mapcar #'* v1 v2))) (dot2 (reduce #'+ (mapcar #'* v1 v2)))) (if (/= dot1 dot2) (error "This REPL doesn't serve me well, brother.")))) NIL CL-USER> swank::*swank-wire-protocol-version* "2010-03-29" CL-USER> (swank-loader::slime-version-string) "2010-03-29" CL-USER> (lisp-implementation-version) "1.0.36.38" CL-USER> *features* (:SB-BSD-SOCKETS-ADDRINFO :ASDF :SBCL-HOOKS-REQUIRE :ANSI-CL :COMMON-LISP :SBCL :SB-DOC :SB-TEST :SB-LDB :SB-PACKAGE-LOCKS :SB-UNICODE :SB-EVAL :SB-SOURCE-LOCATIONS :IEEE-FLOATING-POINT :X86 :UNIX :ELF :LINUX :SB-THREAD :LARGEFILE :GENCGC :STACK-GROWS-DOWNWARD-NOT-UPWARD :C-STACK-IS-CONTROL-STACK :COMPARE-AND-SWAP-VOPS :UNWIND-TO-FRAME-AND-CALL-VOP :RAW-INSTANCE-INIT-VOPS :STACK-ALLOCATABLE-CLOSURES :STACK-ALLOCATABLE-VECTORS :STACK-ALLOCATABLE-LISTS :STACK-ALLOCATABLE-FIXED-OBJECTS :ALIEN-CALLBACKS :CYCLE-COUNTER :INLINE-CONSTANTS :LINKAGE-TABLE :OS-PROVIDES-DLOPEN :OS-PROVIDES-PUTWC :OS-PROVIDES-SUSECONDS-T) CL-USER> (SB-SYS:GET-MACHINE-VERSION ) "Intel(R) Pentium(R) 4 CPU 3.00GHz" >emacs-X11.exe --version GNU Emacs 23.1.1
From: Peter Keller on 30 Mar 2010 16:00 Norbert_Paul <norbertpauls_spambin(a)yahoo.com> wrote: > (dotimes (i 100000) > (let* ((v1 (list (random 10d0)(random 10d0))) > (v2 (list (random 10d0)(random 10d0))) > (dot1 (reduce #'+ (mapcar #'* v1 v2))) > (dot2 (reduce #'+ (mapcar #'* v1 v2)))) > (if (/= dot1 dot2) > (error "This REPL doesn't serve me well, brother.")))) I would think this code is suspect since you don't take into consideration numerical analysis techniques for comparing floating point numbers. I'd suppose the test should be: (when (> (abs (- dot1 dot2)) *tolerance*) (format t "Not equal!~%")) and *tolerance* would be something like 10e-8 or so. -pete
From: Norbert_Paul on 30 Mar 2010 16:22 Peter Keller wrote: > Norbert_Paul<norbertpauls_spambin(a)yahoo.com> wrote: >> (dotimes (i 100000) >> (let* ((v1 (list (random 10d0)(random 10d0))) >> (v2 (list (random 10d0)(random 10d0))) >> (dot1 (reduce #'+ (mapcar #'* v1 v2))) >> (dot2 (reduce #'+ (mapcar #'* v1 v2)))) >> (if (/= dot1 dot2) >> (error "This REPL doesn't serve me well, brother.")))) > > I would think this code is suspect since you don't take into consideration > numerical analysis techniques for comparing floating point numbers. No. I know about these errors, but note that the expressions to compute dot1 and dot2 are absolutely equal. Therefore they /must/ produce the same results (with the same errors). My initial version was dot1 = v1 . v2 and dot2 = v2 . v1, but later I suspected this might introduce such floating-point errors. Therefore I also tried the above. Also in my test cases where the error occured for the first time the differences between both values werde significant and not only by an error. These (0.0d0 12.230520293356577d0) (37.202197698216956d0 51.02715433387322d0) are some outputs of (dotimes (i 100000) (let* ((v1 (list (random 10d0)(random 10d0))) (v2 (list (random 10d0)(random 10d0))) (dot1 (reduce #'+ (mapcar #'* v1 v2))) (dot2 (reduce #'+ (mapcar #'* v1 v2)))) (when (/= dot1 dot2) (print `(,dot1 ,dot2))))) The error occurs extremely seldom. I had to run it several times to get such output. Norbert
From: Tim Bradshaw on 30 Mar 2010 16:23 On 2010-03-30 21:00:01 +0100, Peter Keller said: > I would think this code is suspect since you don't take into consideration > numerical analysis techniques for comparing floating point numbers. I don't think so. I think it should only fail if the same operations on bitwise-identical doubles can sometimes produce different answers (where the operations are multiplication and addition).
|
Next
|
Last
Pages: 1 2 3 4 5 6 Prev: AUTHENTIC DESIGNER HANDBAGS & ACCESSORIES WWW.VOGUELANDE.COM CHANEL LOUIS VUITTON Next: Re^2: slime errors in cmucl? |