[Gsll-devel] Problems with SVD through gsll on OS X 10.5 with SBCL

Nimalan Mahendran nimalan.mahendran at gmail.com
Fri Jun 19 04:54:53 UTC 2009


Hello everyone,

I'm trying to see whether I could use SBCL (or whatever CL
implementation) as an alternative for Matlab in machine learning
research. I have gsll running, but I saw that gsll's SVD,
(sv-decomposition u s v) is converging to the wrong answers for the
identity matrix.

>> M = [1 0 0; 0 1 0; 0 0 1]

but Matlab's SVD works fine.

Here's what happens in gsll/SBCL:

(setf M1
      (MAKE-MARRAY '(UNSIGNED-BYTE 32) :INITIAL-CONTENTS
                   '((1 0 0) (0 1 0) (0 0 1))))
(setf u (copy m1))
(setf s (make-marray 'vector-unsigned-byte-32 :dimensions 3))
(setf v (make-marray 'matrix-unsigned-byte-32 :dimensions '(3 3)))
(sv-decomposition u s v)

GSL> u
#<MATRIX-UNSIGNED-BYTE-32 #2A((0 0 0)
                              (2147483648 0 3220176896)
                              (0 2147483648 0))>
GSL> s
#<VECTOR-UNSIGNED-BYTE-32 #(268809831 296241371 268543215)>
GSL> v
#<MATRIX-UNSIGNED-BYTE-32 #2A((2083159301 2991920483 0)
                              (2147483648 0 1072693248)
                              (0 3220176896 0))>
GSL>

The answers are definitely not right.. I don't think the right memory
addresses are even being accessed.

I noticed in the definition of SV-decomposition in svd.lisp, the
:outputs parameter is (A S V), but according to the GSL documentation
at http://www.gnu.org/software/gsl/manual/html_node/Singular-Value-Decomposition.html,
maybe it should be (A V S)? I'm not sure how these parameters to
defmfun actually work or what they mean (although I am familiar with
cffi..). I was getting the same numbers even when I did SVD on this
matrix:

>> M = [1 0 0; 0 2 0; 0 0 3]

so a memory access error seems likely to me.

Would someone mind helping me fix this?

Thanks!
-- 
Nimalan Mahendran




More information about the gsll-devel mailing list