matlisp sbcl patch

Robbie Sedgewick <[email protected]> Thu, 13 Nov 2003 17:53:25 -0500
Newsgroups gmane.lisp.matlisp.user
Message-ID <[email protected]>
Hi everyone, 

I patched up matlisp to work with SBCL.  It should now run on x86 linux and 
Mac OS X using SBCL.

Included is a patch file against the CVS sources.  Since I changed 
configure.in, the configure script will has to be regenerated after the patch 
is applied.  Also I couldn't get diff to include the new files I had to 
create, so I've sent ffi-sbcl.lisp in a separate email.  It needs to go in the 
src directory.

(Aside:  is "cvs diff -c -N > ../patchfile" the best way to make a patch?)

Apologies for posting this to the users group, I am having trouble subscribing 
to matlisp-devel....

--Robbie
matlisp-sbcl.patch (text/x-diff, 37.6 KB)
? src/ffi-sbcl.lisp
Index: INSTALL
===================================================================
RCS file: /cvsroot/matlisp/matlisp/INSTALL,v
retrieving revision 1.5
diff -c -r1.5 INSTALL
*** INSTALL	19 Mar 2001 17:23:14 -0000	1.5
--- INSTALL	13 Nov 2003 21:50:26 -0000
***************
*** 1,8 ****
  -*- Mode: text -*-
  Requirements:
  =============
! Either CMUCL (version 18b) or Allegro CL (version 5.0 or later)
! is required.
  
  * Allegro CL: Matlisp should compile on Linux, Solaris, Windows.
                In particular, Matlisp relies on the foreign
--- 1,8 ----
  -*- Mode: text -*-
  Requirements:
  =============
! Either CMUCL (version 18b), SBCL (version 0.8.5) or 
! Allegro CL (version 5.0 or later) is required.
  
  * Allegro CL: Matlisp should compile on Linux, Solaris, Windows.
                In particular, Matlisp relies on the foreign
***************
*** 13,21 ****
            interface of CMU CL and the built-in type 
            kernel::complex-double-float.
  
  An immediate goal is to make Matlisp available for CLISP -- another 
  free Common Lisp implementation that is supported on a wider range of 
! platforms than CMUCL and AllegroCL. 
  
  
  Linux/Unix Installation:
--- 13,27 ----
            interface of CMU CL and the built-in type 
            kernel::complex-double-float.
  
+ * SBCL: Matlisp should compile on Linux and MacOS X
+         In particular, Matlisp relies on the foreign function
+         interface of SBCL.
+         
+         
+ 
  An immediate goal is to make Matlisp available for CLISP -- another 
  free Common Lisp implementation that is supported on a wider range of 
! platforms than CMUCL, SBCL and AllegroCL. 
  
  
  Linux/Unix Installation:
***************
*** 42,47 ****
--- 48,54 ----
  4. Configure the system.
     o If you're using Allegro CL, specify --with-lisp=acl.
     o If you're using CMU CL, specify --with-lisp=cmucl
+    o If you're using SBCL, specify --with-lisp=sbcl
     o Give the name of the Lisp executable via --with-lisp-exec=<name>
     o Run configure:
  
Index: configure.in
===================================================================
RCS file: /cvsroot/matlisp/matlisp/configure.in,v
retrieving revision 1.11
diff -c -r1.11 configure.in
*** configure.in	26 Oct 2001 13:51:46 -0000	1.11
--- configure.in	13 Nov 2003 21:50:26 -0000
***************
*** 109,115 ****
  dnl --with-lisp for the Lisp system we want to use.
  AC_ARG_WITH([lisp],
  [  --with-lisp=name        Which lisp system to use.  Currently supported
!                            systems are acl and cmucl.],
  [LISPSYS=$withval
  
  dnl Verify we got a supported system and figure out the command
--- 109,115 ----
  dnl --with-lisp for the Lisp system we want to use.
  AC_ARG_WITH([lisp],
  [  --with-lisp=name        Which lisp system to use.  Currently supported
!                            systems are acl, sbcl and cmucl.],
  [LISPSYS=$withval
  
  dnl Verify we got a supported system and figure out the command
***************
*** 126,133 ****
      LISPEVAL='-noinit -eval'
      LISPEXEC=lisp
      ;;
    *)
!      AC_MSG_ERROR([Unknown Lisp system:  $LISPSYS.  Supported systems are acl and cmucl])
       ;;
  esac
  ])
--- 126,138 ----
      LISPEVAL='-noinit -eval'
      LISPEXEC=lisp
      ;;
+   sbcl)
+     # Don't run the user's init function!
+     LISPEVAL='--sysinit /dev/null --userinit /dev/null --eval'
+     LISPEXEC=sbcl
+     ;;
    *)
!      AC_MSG_ERROR([Unknown Lisp system:  $LISPSYS.  Supported systems are acl, sbcl and cmucl])
       ;;
  esac
  ])
***************
*** 298,303 ****
--- 303,314 ----
    *-*-linux*)
  	SHARED_LIB_LDFLAGS="-shared"
    	;;
+   *-*-darwin*)
+         LD="ld"
+         FLIBS="-L/sw/lib -lf2c -lSystem -lcc_dynamic /usr/lib/bundle1.o"
+ #        SHARED_LIB_LDFLAGS="-dynamiclib -flat_namespace -undefined suppress"
+         SHARED_LIB_LDFLAGS="-bundle -flat_namespace -undefined suppress"
+         ;;
    *)
  	AC_MSG_WARN([Oops! Matlisp is tested on Solaris, SunOS or Linux])
  	AC_MSG_WARN([Matlisp may not compile on your system $host.])
Index: packages.lisp
===================================================================
RCS file: /cvsroot/matlisp/matlisp/packages.lisp,v
retrieving revision 1.18
diff -c -r1.18 packages.lisp
*** packages.lisp	25 Oct 2003 17:01:49 -0000	1.18
--- packages.lisp	13 Nov 2003 21:50:26 -0000
***************
*** 106,111 ****
--- 106,121 ----
     "INCF-SAP"
     "WITH-VECTOR-DATA-ADDRESSES"))
  
+ #+:sbcl
+ (defpackage "FORTRAN-FFI-ACCESSORS"
+   (:use "COMMON-LISP" "SB-ALIEN" "SB-C")
+   (:export
+    ;; Interface functions
+    "DEF-FORTRAN-ROUTINE"
+    "VECTOR-DATA-ADDRESS"
+    "INCF-SAP"
+    "WITH-VECTOR-DATA-ADDRESSES"))
+ 
  #+:allegro
  (defpackage "FORTRAN-FFI-ACCESSORS"
    (:use "COMMON-LISP" "FOREIGN-FUNCTIONS")
***************
*** 114,119 ****
--- 124,130 ----
  
  (defpackage "BLAS"
  #+:cmu  (:use "COMMON-LISP" "ALIEN" "C-CALL" "FORTRAN-FFI-ACCESSORS")
+ #+:sbcl  (:use "COMMON-LISP" "SB-ALIEN" "SB-C" "FORTRAN-FFI-ACCESSORS")
  #+:allegro  (:use "COMMON-LISP" "FOREIGN-FUNCTIONS" "FORTRAN-FFI-ACCESSORS")
    (:export
     "IDAMAX" "DASUM" "DDOT" "DNRM2"
***************
*** 127,132 ****
--- 138,144 ----
  
  (defpackage "LAPACK"
  #+:cmu  (:use "COMMON-LISP" "ALIEN" "C-CALL" "FORTRAN-FFI-ACCESSORS")
+ #+:sbcl  (:use "COMMON-LISP" "SB-ALIEN" "SB-C" "FORTRAN-FFI-ACCESSORS")
  #+:allegro  (:use "COMMON-LISP" "FOREIGN-FUNCTIONS" "FORTRAN-FFI-ACCESSORS")
    (:export
     "DGESV" "DGEEV" "DGETRF" "DGETRS" "DGESVD"
***************
*** 136,141 ****
--- 148,154 ----
  
  (defpackage "DFFTPACK"
  #+:cmu  (:use "COMMON-LISP" "ALIEN" "C-CALL" "FORTRAN-FFI-ACCESSORS")
+ #+:sbcl  (:use "COMMON-LISP" "SB-ALIEN" "SB-C" "FORTRAN-FFI-ACCESSORS")
  #+:allegro  (:use "COMMON-LISP" "FOREIGN-FUNCTIONS" "FORTRAN-FFI-ACCESSORS")
    (:export "ZFFTI" "ZFFTF" "ZFFTB"))
  
***************
*** 350,356 ****
       "M-BESSEL-SERIES-Y"))
  
  (defpackage "MATLISP-USER"
!   (:use "COMMON-LISP" "MATLISP" #+:allegro "EXCL" #+:cmu "EXT")
    (:shadowing-import-from "MATLISP" "REAL"))
  
  (in-package "MATLISP")
--- 363,373 ----
       "M-BESSEL-SERIES-Y"))
  
  (defpackage "MATLISP-USER"
!   (:use "COMMON-LISP"
!         "MATLISP"
!         #+:allegro "EXCL"
!         #+:cmu "EXT"
!         #+:sbcl "SB-EXT")
    (:shadowing-import-from "MATLISP" "REAL"))
  
  (in-package "MATLISP")
***************
*** 369,376 ****
  (eval-when (load eval compile)
  (defparameter *matlisp-version* "Pre 2.0")
  
! #-(or :cmu :allegro)
! (error "MATLISP version ~a requires CMUCL or ALLEGRO CL" 
         *matlisp-version*)
  
  (defun matlisp-version () *matlisp-version*)
--- 386,393 ----
  (eval-when (load eval compile)
  (defparameter *matlisp-version* "Pre 2.0")
  
! #-(or :cmu :allegro :sbcl)
! (error "MATLISP version ~a requires CMUCL, SBCL or ALLEGRO CL" 
         *matlisp-version*)
  
  (defun matlisp-version () *matlisp-version*)
Index: save.lisp
===================================================================
RCS file: /cvsroot/matlisp/matlisp/save.lisp,v
retrieving revision 1.5
diff -c -r1.5 save.lisp
*** save.lisp	8 Jan 2002 00:36:42 -0000	1.5
--- save.lisp	13 Nov 2003 21:50:26 -0000
***************
*** 109,114 ****
--- 109,171 ----
  	       (defparameter sys::*command-index* 0)
  	       (cl::%top-level))))))
  
+ #+:sbcl
+ (defmacro save-matlisp ()
+   "
+   Syntax
+   ======
+   (SAVE-MATLISP)
+ 
+   Purpose
+   =======
+   Dumps a Lisp core image to the file \"matlisp.core\" in 
+   the (EXT::DEFAULT-DIRECTORY), ie. the directory where 
+   you loaded matlisp, and also dumps the script file 
+   \"matlisp-sbcl\" which loads Matlisp with that core.
+ 
+   Notes
+   =====
+   The script file \"matlisp-sbcl\" will use the lisp executable 
+   that was used to dump the \"matlisp.core\" core image.
+ "
+   `(progn
+      (in-package "MATLISP")
+      (let ((core-name  "matlisp.core")
+ 	   (matlisp-name "matlisp-sbcl" )
+ 	   
+ 	   )
+ 
+        (format t "~&~% ** To start Matlisp after core dump \
+ execute the shell script")
+        (format t "~%     ~a" matlisp-name)
+        (format t "~% ** It may be necessary to:")
+        (format t "~%      chmod +x ~a" matlisp-name)   
+        (format t "~%~%")
+        (force-output)
+        
+        (with-open-file (f matlisp-name :DIRECTION :OUTPUT :if-exists :supersede)
+ 	 (format f "#!/bin/sh~%")
+          #+nil
+ 	 (let ((home-path (sb-ext:posix-getenv "SBCL_HOME")))
+ 	   (if home-path
+ 	       (format f "SBCL_HOME=~s~%" home-path)
+                (format f "SBCL_HOME=~%")))
+          (format f "export SBCL_HOME~%")
+ 	 (write-string (car sb-ext:*posix-argv*) f)
+ 	 (write-string " --core " f)
+ 	 (write-string core-name f)
+ 	 (write-string " $@" f)
+          (format f "~%"))
+        (sb-ext:save-lisp-and-die
+ 	   core-name
+ 	   :toplevel 
+ 	   #'(lambda () 
+ 	       (in-package "MATLISP-USER")
+ 	       (matlisp::load-blas-&-lapack-binaries)
+ 	       (format t "Loaded matlisp~%")
+ 	       (format t "~%")
+ 	       (sb-impl::toplevel-init))))))
+ 
  #+:allegro
  (defmacro save-matlisp ()
    "
Index: start.lisp
===================================================================
RCS file: /cvsroot/matlisp/matlisp/start.lisp,v
retrieving revision 1.9
diff -c -r1.9 start.lisp
*** start.lisp	27 Jun 2003 03:42:49 -0000	1.9
--- start.lisp	13 Nov 2003 21:50:26 -0000
***************
*** 104,110 ****
  "
    (flet ((default-dir ()
  	     #+:cmu (ext:default-directory)
! 	     #+:allegro (user::current-directory)))
      (flet ((load-pathname ()
  	     (merge-pathnames 
  	      (if *load-pathname* 
--- 104,111 ----
  "
    (flet ((default-dir ()
  	     #+:cmu (ext:default-directory)
! 	     #+:allegro (user::current-directory)
!              #+:sbcl *default-pathname-defaults*))
      (flet ((load-pathname ()
  	     (merge-pathnames 
  	      (if *load-pathname* 
***************
*** 135,141 ****
  	      "")
  	      (default-dir))))
  
!       #+:cmu
        (setf (logical-pathname-translations name)
  	(list 
  	 (list "**;*.*.*"  
--- 136,142 ----
  	      "")
  	      (default-dir))))
  
!       #+(or :cmu :sbcl)
        (setf (logical-pathname-translations name)
  	(list 
  	 (list "**;*.*.*"  
***************
*** 183,189 ****
  (mk::operate-on-system :matlisp
  		       :load
  		       :minimal-load t
! 		       :verbose nil
  		       :compile-during-load 
  		       #+:allegro-cl-lite nil
  		       #-:allegro-cl-lite t)
--- 184,190 ----
  (mk::operate-on-system :matlisp
  		       :load
  		       :minimal-load t
! 		       :verbose t
  		       :compile-during-load 
  		       #+:allegro-cl-lite nil
  		       #-:allegro-cl-lite t)
Index: system.dcl
===================================================================
RCS file: /cvsroot/matlisp/matlisp/system.dcl,v
retrieving revision 1.21
diff -c -r1.21 system.dcl
*** system.dcl	1 Jun 2003 15:21:59 -0000	1.21
--- system.dcl	13 Nov 2003 21:50:26 -0000
***************
*** 143,148 ****
--- 143,149 ----
  	:binary-pathname ""
  	:components ("f77-mangling"
  		     #+:cmu "ffi-cmu"
+ 		     #+:sbcl "ffi-sbcl"
  		     #+:allegro "ffi-acl"
  		     ))
         (:module "foreign-functions"
***************
*** 407,413 ****
  			  ((:file "cpoly")
  			   (:file "zeroin"
  				  :package "MATLISP-LIB")))
! 		 #+:cmu
  		 (:module "gnuplot"
  			  :source-extension "lisp"
  			  :binary-pathname ""
--- 408,414 ----
  			  ((:file "cpoly")
  			   (:file "zeroin"
  				  :package "MATLISP-LIB")))
! 		 #+(or :cmu :sbcl)
  		 (:module "gnuplot"
  			  :source-extension "lisp"
  			  :binary-pathname ""
Index: lib/lazy-loader.lisp.in
===================================================================
RCS file: /cvsroot/matlisp/matlisp/lib/lazy-loader.lisp.in,v
retrieving revision 1.11
diff -c -r1.11 lazy-loader.lisp.in
*** lib/lazy-loader.lisp.in	26 Apr 2001 13:42:57 -0000	1.11
--- lib/lazy-loader.lisp.in	13 Nov 2003 21:50:26 -0000
***************
*** 106,112 ****
  |#
  
  (eval-when (load eval compile)
! #+:cmu
  (defun tokenize-ld-args (s)
    (let ((token "")
  	(n (length s))
--- 106,112 ----
  |#
  
  (eval-when (load eval compile)
! #+(or :cmu :sbcl)
  (defun tokenize-ld-args (s)
    (let ((token "")
  	(n (length s))
***************
*** 148,153 ****
--- 148,158 ----
  			         "-lmatlisp"
  				 " "
  				 "@FLIBS@"))))
+ #+:sbcl
+ (defun load-blas-&-lapack-libraries ()
+   (sb-alien:load-1-foreign "matlisp:lib;libmatlisp.so"))
+ 
+ 
  
  #+:allegro
  (defun load-blas-&-lapack-libraries ()
***************
*** 164,170 ****
    #-:mswindows (load (translate-logical-pathname
  		      "matlisp:bin;dfftpack") :verbose nil))
  
! #+:cmu
  (defun unload-blas-&-lapack-libraries ()
    nil)
  
--- 169,175 ----
    #-:mswindows (load (translate-logical-pathname
  		      "matlisp:bin;dfftpack") :verbose nil))
  
! #+(or :cmu :sbcl)
  (defun unload-blas-&-lapack-libraries ()
    nil)
  
Index: lib-src/gnuplot/gnuplot.lisp
===================================================================
RCS file: /cvsroot/matlisp/matlisp/lib-src/gnuplot/gnuplot.lisp,v
retrieving revision 1.1
diff -c -r1.1 gnuplot.lisp
*** lib-src/gnuplot/gnuplot.lisp	21 Jul 2001 17:53:04 -0000	1.1
--- lib-src/gnuplot/gnuplot.lisp	13 Nov 2003 21:50:26 -0000
***************
*** 20,28 ****
      :accessor gnuplot-z-data)))
  
  (defun open-gnuplot-stream ()
!   (ext:run-program *gnuplot-binary* nil :input :stream :wait nil :output t))
  
! (defun gnuplot-plot (info &key (stream (ext:process-input *current-gnuplot-stream*)))
    (with-accessors ((title gnuplot-title)
  		   (x-label gnuplot-x-label)
  		   (y-label gnuplot-y-label)
--- 20,36 ----
      :accessor gnuplot-z-data)))
  
  (defun open-gnuplot-stream ()
!   (#-:sbcl
!    ext:run-program
!    #+:sbcl
!    sb-ext:run-program
!    *gnuplot-binary* nil :input :stream :wait nil :output t))
  
! (defun gnuplot-plot (info &key (stream (#-:sbcl
!                                         ext:process-input
!                                         #+:sbcl
!                                         sb-ext:process-input
!                                         *current-gnuplot-stream*)))
    (with-accessors ((title gnuplot-title)
  		   (x-label gnuplot-x-label)
  		   (y-label gnuplot-y-label)
Index: src/axpy.lisp
===================================================================
RCS file: /cvsroot/matlisp/matlisp/src/axpy.lisp,v
retrieving revision 1.6
diff -c -r1.6 axpy.lisp
*** src/axpy.lisp	14 Feb 2003 05:42:11 -0000	1.6
--- src/axpy.lisp	13 Nov 2003 21:50:26 -0000
***************
*** 179,184 ****
--- 179,185 ----
  
  
  (defmethod axpy ((alpha #+:cmu kernel::complex-double-float
+                         #+:sbcl sb-kernel::complex-double-float
  			#+:allegro complex) (x real-matrix) (y complex-matrix))
    (let* ((nxm (number-of-elements y))
  	 (n (nrows y))
***************
*** 201,211 ****
  
      result))
  
! #+:cmu
  (defmethod axpy ((alpha complex) (x real-matrix) (y complex-matrix))
    (axpy (complex-coerce alpha) x y))
  
  (defmethod axpy ((alpha #+:cmu kernel::complex-double-float
  			#+:allegro complex) (x complex-matrix) (y real-matrix))
    (let* ((nxm (number-of-elements y))
  	 (result (copy x))
--- 202,213 ----
  
      result))
  
! #+(or :cmu :sbcl)
  (defmethod axpy ((alpha complex) (x real-matrix) (y complex-matrix))
    (axpy (complex-coerce alpha) x y))
  
  (defmethod axpy ((alpha #+:cmu kernel::complex-double-float
+                         #+:sbcl sb-kernel::complex-double-float
  			#+:allegro complex) (x complex-matrix) (y real-matrix))
    (let* ((nxm (number-of-elements y))
  	 (result (copy x))
***************
*** 222,232 ****
      
      result))
  
! #+:cmu
  (defmethod axpy ((alpha complex) (x complex-matrix) (y real-matrix))
    (axpy (complex-coerce alpha) x y))
  
  (defmethod axpy ((alpha #+:cmu kernel::complex-double-float
  			#+:allegro complex) (x complex-matrix) (y complex-matrix))
    (let ((nxm (number-of-elements y))
  	(result (copy y)))
--- 224,235 ----
      
      result))
  
! #+(or :cmu :sbcl)
  (defmethod axpy ((alpha complex) (x complex-matrix) (y real-matrix))
    (axpy (complex-coerce alpha) x y))
  
  (defmethod axpy ((alpha #+:cmu kernel::complex-double-float
+                         #+:sbcl sb-kernel::complex-double-float
  			#+:allegro complex) (x complex-matrix) (y complex-matrix))
    (let ((nxm (number-of-elements y))
  	(result (copy y)))
***************
*** 240,246 ****
      (zaxpy nxm *1x1-complex-array* (store x) 1 (store result) 1)
      result))
  
! #+:cmu
  (defmethod axpy ((alpha complex) (x complex-matrix) (y complex-matrix))
    (axpy (complex-coerce alpha) x y))
  
--- 243,249 ----
      (zaxpy nxm *1x1-complex-array* (store x) 1 (store result) 1)
      result))
  
! #+(or :cmu :sbcl)
  (defmethod axpy ((alpha complex) (x complex-matrix) (y complex-matrix))
    (axpy (complex-coerce alpha) x y))
  
***************
*** 288,295 ****
  (defmethod axpy! ((alpha real) (x complex-matrix) (y complex-matrix))
    (axpy! (coerce alpha 'complex-matrix-element-type) x y))
  
! #+:cmu
! (defmethod axpy! ((alpha kernel::complex-double-float) (x real-matrix) (y complex-matrix))
    (let* ((nxm (number-of-elements y))
  	 (store-x (store x))
  	 (store-y (store y))
--- 291,301 ----
  (defmethod axpy! ((alpha real) (x complex-matrix) (y complex-matrix))
    (axpy! (coerce alpha 'complex-matrix-element-type) x y))
  
! #+(or :cmu :sbcl)
! (defmethod axpy! ((alpha #+:cmu kernel::complex-double-float
!                          #+:sbcl sb-kernel::complex-double-float)
!                   (x real-matrix)
!                   (y complex-matrix))
    (let* ((nxm (number-of-elements y))
  	 (store-x (store x))
  	 (store-y (store y))
***************
*** 308,314 ****
  
      y))
  
! #+:cmu
  (defmethod axpy! ((alpha complex) (x real-matrix) (y complex-matrix))
    (axpy! (complex-coerce alpha) x y))
  
--- 314,320 ----
  
      y))
  
! #+(or :cmu :sbcl)
  (defmethod axpy! ((alpha complex) (x real-matrix) (y complex-matrix))
    (axpy! (complex-coerce alpha) x y))
  
***************
*** 327,332 ****
--- 333,339 ----
      y))
  
  (defmethod axpy! ((alpha #+:cmu kernel::complex-double-float
+                          #+:sbcl sb-kernel::complex-double-float
  			 #+:allegro complex) (x complex-matrix) (y complex-matrix))
    (let ((nxm (number-of-elements y)))
      (declare (type fixnum nxm))
***************
*** 338,344 ****
      (zaxpy nxm *1x1-complex-array* (store x) 1 (store y) 1)
      y))
  
! #+:cmu
  (defmethod axpy! ((alpha complex) (x complex-matrix) (y complex-matrix))
    (axpy! (complex-coerce alpha) x y))
  
--- 345,351 ----
      (zaxpy nxm *1x1-complex-array* (store x) 1 (store y) 1)
      y))
  
! #+(or :cmu :sbcl)
  (defmethod axpy! ((alpha complex) (x complex-matrix) (y complex-matrix))
    (axpy! (complex-coerce alpha) x y))
  
Index: src/blas.lisp
===================================================================
RCS file: /cvsroot/matlisp/matlisp/src/blas.lisp,v
retrieving revision 1.5
diff -c -r1.5 blas.lisp
*** src/blas.lisp	21 Feb 2001 19:31:13 -0000	1.5
--- src/blas.lisp	13 Nov 2003 21:50:27 -0000
***************
*** 55,60 ****
--- 55,61 ----
  #+nil
  (defpackage "BLAS"
  #+:cmu  (:use "COMMON-LISP" "ALIEN" "C-CALL" "FORTRAN-FFI-ACCESSORS")
+ #+:sbcl  (:use "COMMON-LISP" "SB-ALIEN" "SB-C" "FORTRAN-FFI-ACCESSORS")
  #+:allegro  (:use "COMMON-LISP" "FOREIGN-FUNCTIONS" "FORTRAN-FFI-ACCESSORS")
    (:export
  "IDAMAX" "DASUM" "DDOT" "DNRM2"
Index: src/copy.lisp
===================================================================
RCS file: /cvsroot/matlisp/matlisp/src/copy.lisp,v
retrieving revision 1.7
diff -c -r1.7 copy.lisp
*** src/copy.lisp	14 Feb 2003 05:42:12 -0000	1.7
--- src/copy.lisp	13 Nov 2003 21:50:27 -0000
***************
*** 209,214 ****
--- 209,215 ----
  	 y))
  
  (defmethod copy! ((x #+:cmu kernel::complex-double-float
+                      #+:sbcl sb-kernel::complex-double-float
  		     #+:allegro complex) (y complex-matrix))
    (let ((nxm (number-of-elements y)))
  
Index: src/dfftpack.lisp
===================================================================
RCS file: /cvsroot/matlisp/matlisp/src/dfftpack.lisp,v
retrieving revision 1.4
diff -c -r1.4 dfftpack.lisp
*** src/dfftpack.lisp	11 Jul 2000 18:02:03 -0000	1.4
--- src/dfftpack.lisp	13 Nov 2003 21:50:27 -0000
***************
*** 52,57 ****
--- 52,58 ----
  #+nil
  (defpackage "DFFTPACK"
  #+:cmu  (:use "COMMON-LISP" "ALIEN" "C-CALL" "FORTRAN-FFI-ACCESSORS")
+ #+:sbcl  (:use "COMMON-LISP" "SB-ALIEN" "SB-C" "FORTRAN-FFI-ACCESSORS")
  #+:allegro  (:use "COMMON-LISP" "FOREIGN-FUNCTIONS" "FORTRAN-FFI-ACCESSORS")
    (:export "ZFFTI" "ZFFTF" "ZFFTB"))
  
Index: src/diag.lisp
===================================================================
RCS file: /cvsroot/matlisp/matlisp/src/diag.lisp,v
retrieving revision 1.6
diff -c -r1.6 diag.lisp
*** src/diag.lisp	29 Jul 2002 00:29:36 -0000	1.6
--- src/diag.lisp	13 Nov 2003 21:50:27 -0000
***************
*** 203,208 ****
--- 203,209 ----
      mat))
  
  (defmethod (setf diag) ((new-diag #+:cmu kernel::complex-double-float
+                                   #+:sbcl sb-kernel::complex-double-float
  				  #+:allegro complex) (mat complex-matrix))
    (let* ((n (nrows mat))
  	 (m (ncols mat))
Index: src/dot.lisp
===================================================================
RCS file: /cvsroot/matlisp/matlisp/src/dot.lisp,v
retrieving revision 1.5
diff -c -r1.5 dot.lisp
*** src/dot.lisp	28 Jul 2002 14:59:31 -0000	1.5
--- src/dot.lisp	13 Nov 2003 21:50:27 -0000
***************
*** 122,128 ****
      (declare (type fixnum nxm))
      (ddot nxm (store x) 1 (store y) 1)))
  
! #+:cmu
  (defmethod dot ((x real-matrix) (y complex-matrix) &optional conjugate-p)
    (declare (ignore conjugate-p))
    (let ((nxm (number-of-elements x))
--- 122,128 ----
      (declare (type fixnum nxm))
      (ddot nxm (store x) 1 (store y) 1)))
  
! #+(or :cmu :sbcl)
  (defmethod dot ((x real-matrix) (y complex-matrix) &optional conjugate-p)
    (declare (ignore conjugate-p))
    (let ((nxm (number-of-elements x))
***************
*** 175,181 ****
  	(complex realpart imagpart))
        )))
  
! #+:cmu
  (defmethod dot ((x complex-matrix) (y real-matrix) &optional (conjugate-p t))
    (let ((nxm (number-of-elements x))
  	(store-x (store x))
--- 175,181 ----
  	(complex realpart imagpart))
        )))
  
! #+(or :cmu :sbcl)
  (defmethod dot ((x complex-matrix) (y real-matrix) &optional (conjugate-p t))
    (let ((nxm (number-of-elements x))
  	(store-x (store x))
Index: src/fft.lisp
===================================================================
RCS file: /cvsroot/matlisp/matlisp/src/fft.lisp,v
retrieving revision 1.9
diff -c -r1.9 fft.lisp
*** src/fft.lisp	11 Feb 2003 13:52:04 -0000	1.9
--- src/fft.lisp	13 Nov 2003 21:50:27 -0000
***************
*** 213,219 ****
  		 (format t "Key = ~D, Val = ~A~%" key val))
  	     wsave-hash-table))))
  
! #+:cmu  
  (defmethod fft ((x standard-matrix) &optional n)
    (let* ((n (or n (if (row-or-col-vector-p x)
  		      (max (nrows x) (ncols x))
--- 213,219 ----
  		 (format t "Key = ~D, Val = ~A~%" key val))
  	     wsave-hash-table))))
  
! #+(or :cmu :sbcl)  
  (defmethod fft ((x standard-matrix) &optional n)
    (let* ((n (or n (if (row-or-col-vector-p x)
  		      (max (nrows x) (ncols x))
***************
*** 281,287 ****
        result))
  
  
! #+:cmu
  (defmethod ifft ((x standard-matrix) &optional n)
    (let* ((n (or n (if (row-or-col-vector-p x)
  		      (max (nrows x) (ncols x))
--- 281,287 ----
        result))
  
  
! #+(or :cmu :sbcl)
  (defmethod ifft ((x standard-matrix) &optional n)
    (let* ((n (or n (if (row-or-col-vector-p x)
  		      (max (nrows x) (ncols x))
***************
*** 365,371 ****
    (:documentation "See IFFT but note that the optional N is NOT permitted.
    Performs in place IFFT modifying X.  This will only work for a complex matrix."))
  
! #+:cmu  
  (defmethod fft! ((x complex-matrix))
    (let* ((n (if (row-or-col-vector-p x)
  		(max (nrows x) (ncols x))
--- 365,371 ----
    (:documentation "See IFFT but note that the optional N is NOT permitted.
    Performs in place IFFT modifying X.  This will only work for a complex matrix."))
  
! #+(or :cmu :sbcl)  
  (defmethod fft! ((x complex-matrix))
    (let* ((n (if (row-or-col-vector-p x)
  		(max (nrows x) (ncols x))
***************
*** 385,391 ****
  	    (dfftpack::fortran-zfftf n addr-x addr-wsave))))))
  
  
! #+:cmu
  (defmethod ifft! ((x complex-matrix))
    (let* ((n (if (row-or-col-vector-p x)
  		      (max (nrows x) (ncols x))
--- 385,391 ----
  	    (dfftpack::fortran-zfftf n addr-x addr-wsave))))))
  
  
! #+(or :cmu :sbcl)
  (defmethod ifft! ((x complex-matrix))
    (let* ((n (if (row-or-col-vector-p x)
  		      (max (nrows x) (ncols x))
Index: src/gemm.lisp
===================================================================
RCS file: /cvsroot/matlisp/matlisp/src/gemm.lisp,v
retrieving revision 1.6
diff -c -r1.6 gemm.lisp
*** src/gemm.lisp	22 Jun 2001 12:52:41 -0000	1.6
--- src/gemm.lisp	13 Nov 2003 21:50:27 -0000
***************
*** 225,234 ****
--- 225,236 ----
        (complex-beta (allocate-complex-store 1)))
  
  (defmethod gemm! ((alpha #+:cmu kernel::complex-double-float
+                          #+:sbcl sb-kernel::complex-double-float
  			 #+:allegro number) 
  		  (a complex-matrix) 
  		  (b complex-matrix)
  		  (beta #+:cmu kernel::complex-double-float
+                         #+:sbcl sb-kernel::complex-double-float
  			#+:allegro number) 
  		  (c complex-matrix) 
  		  &optional (job :nn))
***************
*** 275,281 ****
  	 c)))
  )
  
! #+:cmu
  (defmethod gemm! ((alpha number) 
  		  (a complex-matrix) 
  		  (b complex-matrix)
--- 277,283 ----
  	 c)))
  )
  
! #+(or :cmu :sbcl)
  (defmethod gemm! ((alpha number) 
  		  (a complex-matrix) 
  		  (b complex-matrix)
Index: src/help.lisp
===================================================================
RCS file: /cvsroot/matlisp/matlisp/src/help.lisp,v
retrieving revision 1.3
diff -c -r1.3 help.lisp
*** src/help.lisp	21 Feb 2001 19:38:01 -0000	1.3
--- src/help.lisp	13 Nov 2003 21:50:27 -0000
***************
*** 65,72 ****
    To provide a specialized manual for a function, class etc ...
    you may add a method to MAN.  See MAN.
  "
!   `(if ,item-p
!       (let ((item ',item))
  	(typecase item
  	  (symbol (man item))
  	  (list (if (eq (first item) 'quote)
--- 65,72 ----
    To provide a specialized manual for a function, class etc ...
    you may add a method to MAN.  See MAN.
  "
!   (if item-p
!       `(let ((item ',item))
  	(typecase item
  	  (symbol (man item))
  	  (list (if (eq (first item) 'quote)
***************
*** 76,82 ****
  	  (t (error "don't know how to help ~a" item)))
  	
  	(values))
!     (progn
         (format t "~&~%Help is available for the packages")
         (format t   "~%==================================")
         (dolist (p (list-all-packages))
--- 76,82 ----
  	  (t (error "don't know how to help ~a" item)))
  	
  	(values))
!     `(progn
         (format t "~&~%Help is available for the packages")
         (format t   "~%==================================")
         (dolist (p (list-all-packages))
Index: src/lapack.lisp
===================================================================
RCS file: /cvsroot/matlisp/matlisp/src/lapack.lisp,v
retrieving revision 1.10
diff -c -r1.10 lapack.lisp
*** src/lapack.lisp	31 May 2003 05:19:17 -0000	1.10
--- src/lapack.lisp	13 Nov 2003 21:50:27 -0000
***************
*** 76,81 ****
--- 76,82 ----
  #+nil
  (defpackage "LAPACK"
  #+:cmu  (:use "COMMON-LISP" "ALIEN" "C-CALL" "FORTRAN-FFI-ACCESSORS")
+ #+:sbcl  (:use "COMMON-LISP" "SB-ALIEN" "SB-C" "FORTRAN-FFI-ACCESSORS")
  #+:allegro  (:use "COMMON-LISP" "FOREIGN-FUNCTIONS" "FORTRAN-FFI-ACCESSORS")
    (:export
  "DGESV" "DGEEV" "DGETRF" "DGETRS" "DGESVD"
Index: src/matrix.lisp
===================================================================
RCS file: /cvsroot/matlisp/matlisp/src/matrix.lisp,v
retrieving revision 1.13
diff -c -r1.13 matrix.lisp
*** src/matrix.lisp	31 May 2003 22:20:26 -0000	1.13
--- src/matrix.lisp	13 Nov 2003 21:50:28 -0000
***************
*** 242,248 ****
  that way.
  "))
  
! #+(and cmu gerds-pcl)
  (declaim (ext:slots (slot-boundp real-matrix complex-matrix)
  		    (inline standard-matrix real-matrix complex-matrix)))
  
--- 242,248 ----
  that way.
  "))
  
! #+(and (or cmu sbcl) gerds-pcl)
  (declaim (ext:slots (slot-boundp real-matrix complex-matrix)
  		    (inline standard-matrix real-matrix complex-matrix)))
  
Index: src/mplus.lisp
===================================================================
RCS file: /cvsroot/matlisp/matlisp/src/mplus.lisp,v
retrieving revision 1.5
diff -c -r1.5 mplus.lisp
*** src/mplus.lisp	29 Jul 2002 01:06:59 -0000	1.5
--- src/mplus.lisp	13 Nov 2003 21:50:28 -0000
***************
*** 165,170 ****
--- 165,171 ----
    (m+ b (coerce a 'real-matrix-element-type)))
  
  (defmethod m+ ((a real-matrix) (b #+:cmu kernel::complex-double-float
+                                   #+:sbcl sb-kernel::complex-double-float
  				  #+:allegro complex))
    (let* ((n (nrows a))
  	 (m (ncols a))
***************
*** 174,188 ****
  
      (axpy! 1.0d0 a result)))
  
! #+:cmu
  (defmethod m+ ((a real-matrix) (b complex))
    (m+ a (complex-coerce b)))
  
  (defmethod m+ ((a #+:cmu kernel::complex-double-float
  		  #+:allegro complex) (b real-matrix))
    (m+ b a))
  
! #+:cmu
  (defmethod m+ ((a complex) (b real-matrix))
    (m+ b (complex-coerce a)))
  
--- 175,190 ----
  
      (axpy! 1.0d0 a result)))
  
! #+(or :cmu :sbcl)
  (defmethod m+ ((a real-matrix) (b complex))
    (m+ a (complex-coerce b)))
  
  (defmethod m+ ((a #+:cmu kernel::complex-double-float
+                   #+:sbcl sb-kernel::complex-double-float
  		  #+:allegro complex) (b real-matrix))
    (m+ b a))
  
! #+(or :cmu :sbcl)
  (defmethod m+ ((a complex) (b real-matrix))
    (m+ b (complex-coerce a)))
  
***************
*** 207,212 ****
--- 209,215 ----
    (m+ b (coerce a 'complex-matrix-element-type)))
  
  (defmethod m+ ((a complex-matrix) (b #+:cmu kernel::complex-double-float
+                                      #+:sbcl sb-kernel::complex-double-float
  				     #+:allegro complex))
    (let* ((n (nrows a))
  	 (m (ncols a))
***************
*** 216,230 ****
  
      (axpy! 1.0d0 a result)))
  
! #+:cmu
  (defmethod m+ ((a complex-matrix) (b complex))
    (m+ a (complex-coerce b)))
  
  (defmethod m+ ((a #+:cmu kernel::complex-double-float
  		  #+:allegro complex) (b complex-matrix))
    (m+ b a))
  
! #+:cmu
  (defmethod m+ ((a complex) (b complex-matrix))
    (m+ b (complex-coerce a)))
  
--- 219,234 ----
  
      (axpy! 1.0d0 a result)))
  
! #+(or :cmu :sbcl)
  (defmethod m+ ((a complex-matrix) (b complex))
    (m+ a (complex-coerce b)))
  
  (defmethod m+ ((a #+:cmu kernel::complex-double-float
+                   #+:sbcl sb-kernel::complex-double-float
  		  #+:allegro complex) (b complex-matrix))
    (m+ b a))
  
! #+(or :cmu :sbcl)
  (defmethod m+ ((a complex) (b complex-matrix))
    (m+ b (complex-coerce a)))
  
***************
*** 293,303 ****
--- 297,314 ----
  (defmethod m+! ((a real) (b complex-matrix))
    (m+! b (coerce a 'complex-matrix-element-type)))
  
+ #-:sbcl  ;; sbcl doesn't like constant arrays
  (defconstant *complex-unity-as-array* 
    (make-array 2 :element-type 'complex-matrix-element-type
  	      :initial-contents '(1.0d0 0.0d0)))
  
+ #+:sbcl
+ (defvar *complex-unity-as-array* 
+   (make-array 2 :element-type 'complex-matrix-element-type
+ 	      :initial-contents '(1.0d0 0.0d0)))
+ 
  (defmethod m+! ((a complex-matrix) (b #+:cmu kernel::complex-double-float
+                                       #+:sbcl sb-kernel::complex-double-float
  				      #+:allegro complex))
    (let* ((nxm (number-of-elements a)))
      (declare (type fixnum nxm))
***************
*** 309,323 ****
      (zaxpy nxm #c(1d0 0) b 0 (store a) 1)
      a))
  
! #+:cmu
  (defmethod m+! ((a complex-matrix) (b complex))
    (m+! a (complex-coerce b)))
  
  (defmethod m+! ((a #+:cmu kernel::complex-double-float
  		   #+:allegro complex) (b complex-matrix))
    (m+! b a))
  
! #+:cmu
  (defmethod m+! ((a complex) (b complex-matrix))
    (m+! b (complex-coerce a)))
  
--- 320,335 ----
      (zaxpy nxm #c(1d0 0) b 0 (store a) 1)
      a))
  
! #+(or :cmu :sbcl)
  (defmethod m+! ((a complex-matrix) (b complex))
    (m+! a (complex-coerce b)))
  
  (defmethod m+! ((a #+:cmu kernel::complex-double-float
+                    #+:sbcl sb-kernel::complex-double-float
  		   #+:allegro complex) (b complex-matrix))
    (m+! b a))
  
! #+(or :cmu :sbcl)
  (defmethod m+! ((a complex) (b complex-matrix))
    (m+! b (complex-coerce a)))
  
Index: src/norm.lisp
===================================================================
RCS file: /cvsroot/matlisp/matlisp/src/norm.lisp,v
retrieving revision 1.6
diff -c -r1.6 norm.lisp
*** src/norm.lisp	22 Jun 2001 12:52:41 -0000	1.6
--- src/norm.lisp	13 Nov 2003 21:50:28 -0000
***************
*** 117,123 ****
    (declare (ignore p))
    (abs a))
  
! #+:cmu
  (defmethod norm ((a real-matrix) &optional (p 2))
    (let ((n (nrows a))
  	(m (ncols a))
--- 117,123 ----
    (declare (ignore p))
    (abs a))
  
! #+(or :cmu :sbcl)
  (defmethod norm ((a real-matrix) &optional (p 2))
    (let ((n (nrows a))
  	(m (ncols a))
***************
*** 266,272 ****
  ;;
  ;; in either case, the doc for this function should be better defined.
  
! #+:cmu
  (defmethod norm ((a complex-matrix) &optional (p 2))
    (let ((n (nrows a))
  	(m (ncols a))
--- 266,272 ----
  ;;
  ;; in either case, the doc for this function should be better defined.
  
! #+(or :cmu :sbcl)
  (defmethod norm ((a complex-matrix) &optional (p 2))
    (let ((n (nrows a))
  	(m (ncols a))
Index: src/realimag.lisp
===================================================================
RCS file: /cvsroot/matlisp/matlisp/src/realimag.lisp,v
retrieving revision 1.5
diff -c -r1.5 realimag.lisp
*** src/realimag.lisp	22 Jun 2001 12:52:41 -0000	1.5
--- src/realimag.lisp	13 Nov 2003 21:50:28 -0000
***************
*** 128,134 ****
      (declare (type fixnum n m))
      (make-real-matrix-dim n m)))
  
! #+:cmu
  (defmethod imag ((mat complex-matrix))
    (let* ((n (nrows mat))
  	 (m (ncols mat))
--- 128,134 ----
      (declare (type fixnum n m))
      (make-real-matrix-dim n m)))
  
! #+(or :cmu :sbcl)
  (defmethod imag ((mat complex-matrix))
    (let* ((n (nrows mat))
  	 (m (ncols mat))
Index: src/ref.lisp
===================================================================
RCS file: /cvsroot/matlisp/matlisp/src/ref.lisp,v
retrieving revision 1.8
diff -c -r1.8 ref.lisp
*** src/ref.lisp	11 Oct 2003 01:49:24 -0000	1.8
--- src/ref.lisp	13 Nov 2003 21:50:28 -0000
***************
*** 1580,1585 ****
--- 1580,1586 ----
      (complex (aref store (fortran-complex-matrix-indexing i j n))
  	     (aref store (1+ (fortran-complex-matrix-indexing i j n))))))
  
+ 
  (defmethod matrix-ref-2d ((matrix complex-matrix) (i fixnum) (j list))
    (get-complex-matrix-slice-2d-seq matrix (list i) j))
  
***************
*** 2513,2518 ****
--- 2514,2520 ----
    
  #+nil
  (defmethod (setf matrix-ref) ((new #+:cmu kernel::complex-double-float
+                                    #+:sbcl sb-kernel::complex-double-float
  				   #+:allegro complex) 
  			      (matrix complex-matrix) i &optional (j nil j-p))
    (let* ((n (nrows matrix))
***************
*** 2601,2606 ****
--- 2603,2609 ----
  	  (t (error "don't know how to access element ~a of matrix" i)))))))
  
  (defmethod (setf matrix-ref-1d) ((new #+:cmu kernel::complex-double-float
+                                       #+:sbcl sb-kernel::complex-double-float
  				      #+:allegro complex) 
  				 (matrix complex-matrix) i)
    (let* ((n (nrows matrix))
***************
*** 2643,2648 ****
--- 2646,2652 ----
  	(t (error "don't know how to access element ~a of matrix" i))))))
  
  (defmethod (setf matrix-ref-2d) ((new #+:cmu kernel::complex-double-float
+                                       #+:sbcl sb-kernel::complex-double-float
  				      #+:allegro complex) 
  				 (matrix complex-matrix) i j)
    (let* ((n (nrows matrix))
Index: src/scal.lisp
===================================================================
RCS file: /cvsroot/matlisp/matlisp/src/scal.lisp,v
retrieving revision 1.4
diff -c -r1.4 scal.lisp
*** src/scal.lisp	11 Jul 2000 18:02:03 -0000	1.4
--- src/scal.lisp	13 Nov 2003 21:50:28 -0000
***************
*** 110,115 ****
--- 110,116 ----
    (scal (coerce alpha 'real-matrix-element-type) x))
  
  (defmethod scal ((alpha #+:cmu kernel::complex-double-float
+                         #+:sbcl sb-kernel::complex-double-float
  			#+:allegro complex) (x real-matrix))
    (let* ((nxm (number-of-elements x))
  	 (n (nrows x))
***************
*** 126,132 ****
  
      result))
  
! #+:cmu
  (defmethod scal ((alpha complex) (x real-matrix))
    (scal (complex-coerce alpha) x))
  
--- 127,133 ----
  
      result))
  
! #+(or :cmu :sbcl)
  (defmethod scal ((alpha complex) (x real-matrix))
    (scal (complex-coerce alpha) x))
  
***************
*** 142,147 ****
--- 143,149 ----
    (scal (coerce alpha 'real-matrix-element-type) x))
  
  (defmethod scal ((alpha #+:cmu kernel::complex-double-float
+                         #+:sbcl sb-kernel::complex-double-float
  			#+:allegro complex) (x complex-matrix))
    (let ((nxm (number-of-elements x))
  	(result (copy x)))
***************
*** 155,161 ****
  
      result))
  
! #+:cmu
  (defmethod scal ((alpha complex) (x complex-matrix))
    (scal (complex-coerce alpha) x))
  
--- 157,163 ----
  
      result))
  
! #+(or :cmu :sbcl)
  (defmethod scal ((alpha complex) (x complex-matrix))
    (scal (complex-coerce alpha) x))
  
***************
*** 189,194 ****
--- 191,197 ----
    (scal! (coerce alpha 'real-matrix-element-type) x))
  
  (defmethod scal! ((alpha #+:cmu kernel::complex-double-float
+                          #+:sbcl sb-kernel::complex-double-float
  			 #+:allegro complex) (x complex-matrix))
    (let ((nxm (number-of-elements x)))
      (declare (type fixnum nxm))
***************
*** 201,207 ****
  
      x))
  
! #+:cmu
  (defmethod scal! ((alpha complex) (x complex-matrix))
    (scal! (complex-coerce alpha) x))
  
--- 204,210 ----
  
      x))
  
! #+(or :cmu :sbcl)
  (defmethod scal! ((alpha complex) (x complex-matrix))
    (scal! (complex-coerce alpha) x))