A common problem is that the float arithmetic, here with double floats (regardless of the surrounding code, such as matrix multiplication), agrees.
Typically, the first thing to do with SBCL in such cases is:
Put the code in a file and compile it
The compiler then raises many optimization problems, given that one compiles for speed. Then you will need to study the notes and see what you can do.
Here, for example, the LOOP sum does not contain type information.
In fact, there is LOOP syntax for declaring a variable sum type. I do not know if SBCL uses the fact that:
(loop repeat 10 sum 1.0d0 of-type double-float)
SBCL 1.3.0 on 32-bit ARM for your code:
* (compile-file "/tmp/test.lisp") ; compiling file "/tmp/test.lisp" (written 13 DEC 2015 11:34:26 AM): ; compiling (DEFUN MATRIX-MUL ...) ; file: /tmp/test.lisp
1)
; in: DEFUN MATRIX-MUL ; (SETF (AREF DEST I) ; (LOOP FOR J BELOW COLS ; SUM (THE DOUBLE-FLOAT (*
2)
; (AREF MATRIX IJ) ; --> LET* ; ==> ; (SB-KERNEL:HAIRY-DATA-VECTOR-REF ARRAY SB-INT:INDEX) ; ; note: unable to ; avoid runtime dispatch on array element type ; due to type uncertainty: ; The first argument is a (ARRAY DOUBLE-FLOAT (* *)), not a SIMPLE-ARRAY.
3)
; (AREF VECTOR J) ; ==> ; (SB-KERNEL:HAIRY-DATA-VECTOR-REF ARRAY SB-INT:INDEX) ; ; note: unable to ; avoid runtime dispatch on array element type ; due to type uncertainty: ; The first argument is a (VECTOR DOUBLE-FLOAT), not a SIMPLE-ARRAY.
4)
; (LOOP FOR J BELOW COLS ; SUM (THE DOUBLE-FLOAT (* (AREF MATRIX IJ) (AREF VECTOR J)))) ; --> BLOCK LET SB-LOOP::WITH-SUM-COUNT LET SB-LOOP::LOOP-BODY TAGBODY SETQ THE ; ==> ; (+
5)
; --> BLOCK LET SB-LOOP::WITH-SUM-COUNT LET SB-LOOP::LOOP-BODY TAGBODY WHEN IF ; --> >= OR LET IF OR THE = IF ; ==> ; (= SB-C::X SB-C::Y) ; ; note: unable to open code because: The operands might not be the same type.
6)
7)
; (LOOP FOR J BELOW COLS ; SUM (THE DOUBLE-FLOAT (* (AREF MATRIX IJ) (AREF VECTOR J)))) ; --> BLOCK LET SB-LOOP::WITH-SUM-COUNT LET SB-LOOP::LOOP-BODY TAGBODY WHEN IF ; --> >= OR LET > IF ; ==> ; (> SB-C::X SB-C::Y) ; ; note: forced to do static-fun Two-arg-> (cost 53) ; unable to do inline fixnum comparison (cost 4) because: ; The second argument is a REAL, not a FIXNUM. ; unable to do inline (signed-byte 32) comparison (cost 6) because: ; The second argument is a REAL, not a (SIGNED-BYTE 32). ; etc.
eight)
; --> BLOCK LET SB-LOOP::WITH-SUM-COUNT LET SB-LOOP::LOOP-BODY TAGBODY SETQ THE ; ==> ; (+