[cl-gsl-cvs] CVS update: cl-gsl/ffi.lisp

Edgar Denny edenny at common-lisp.net
Tue Mar 15 03:15:22 UTC 2005


Update of /project/cl-gsl/cvsroot/cl-gsl
In directory common-lisp.net:/tmp/cvs-serv30766

Modified Files:
	ffi.lisp 
Log Message:
Changes needed for complex vectors.

Date: Tue Mar 15 04:15:21 2005
Author: edenny

Index: cl-gsl/ffi.lisp
diff -u cl-gsl/ffi.lisp:1.2 cl-gsl/ffi.lisp:1.3
--- cl-gsl/ffi.lisp:1.2	Fri Mar  4 02:52:38 2005
+++ cl-gsl/ffi.lisp	Tue Mar 15 04:15:20 2005
@@ -121,12 +121,12 @@
 
 (def-foreign-struct gsl-block-complex
     (size :unsigned-long)
-    (data (* gsl-complex)))
+    (data (* :double)))
 
 (def-foreign-struct gsl-vector-complex
     (size :unsigned-long)
     (stride :unsigned-long)
-    (data (* gsl-complex))
+    (data (* :double))
     (g-block (* gsl-block-complex))
     (owner :int))
 
@@ -137,12 +137,12 @@
 
 (def-foreign-struct gsl-block-complex-float
     (size :unsigned-long)
-    (data (* gsl-complex-float)))
+    (data (* :float)))
 
 (def-foreign-struct gsl-vector-complex-float
     (size :unsigned-long)
     (stride :unsigned-long)
-    (data (* gsl-complex-float))
+    (data (* :float))
     (g-block (* gsl-block-complex-float))
     (owner :int))
 
@@ -200,15 +200,15 @@
 
 ;; ----------------------------------------------------------------------
 
-(defun gsl-complex->complex (z)
-  (declare (gsl-complex-def z))
-  (let ((dat-array (uffi:get-slot-value z (:array :double) 'cl-gsl::dat)))
+(defun gsl-complex->complex (z-ptr)
+  ;; TODO: this seems to work with pointers and values
+;;  (declare (gsl-complex-def z))
+  (let ((dat-array (uffi:get-slot-value z-ptr '(:array :double) 'cl-gsl::dat)))
     (complex (uffi:deref-array dat-array :double 0)
              (uffi:deref-array dat-array :double 1))))
 
-(defun gsl-complex-float->complex (z)
-  (declare (gsl-complex-float-def z))
-  (let ((dat-array (uffi:get-slot-value z (:array :float) 'cl-gsl::dat)))
+(defun gsl-complex-float->complex (z-ptr)
+  (let ((dat-array (uffi:get-slot-value z-ptr '(:array :float) 'cl-gsl::dat)))
     (complex (uffi:deref-array dat-array :float 0)
              (uffi:deref-array dat-array :float 1))))
 
@@ -216,19 +216,19 @@
 ;; How do we free it?
 ;; Replace with a with-complex->gsl-complex macro that cleans up after
 ;; itself
-(defun complex->gsl-complex (z)
+(defun complex->gsl-complex-ptr (z)
   (let* ((z-ptr (uffi:allocate-foreign-object 'gsl-complex))
-         (dat-array (uffi:get-slot-value z-ptr (:array :float) 'cl-gsl::dat)))
+         (dat-array (uffi:get-slot-value z-ptr '(:array :double) 'cl-gsl::dat)))
     (setf (uffi:deref-array dat-array :double 0) (realpart z))
     (setf (uffi:deref-array dat-array :double 1) (imagpart z))
     z-ptr))
 
 ;; FIXME: see above
-(defun complex->gsl-complex-float (z)
+(defun complex->gsl-complex-float-ptr (z)
   (let* ((z-ptr (uffi:allocate-foreign-object 'gsl-complex-float))
-         (dat-array (uffi:get-slot-value z-ptr (:array :float) 'cl-gsl::dat)))
-    (setf (uffi:deref-array dat-array :double 0) (realpart z))
-    (setf (uffi:deref-array dat-array :double 1) (imagpart z))
+         (dat-array (uffi:get-slot-value z-ptr '(:array :float) 'cl-gsl::dat)))
+    (setf (uffi:deref-array dat-array :float 0) (realpart z))
+    (setf (uffi:deref-array dat-array :float 1) (imagpart z))
     z-ptr))
 
 




More information about the Cl-gsl-cvs mailing list