Skip to content
Snippets Groups Projects
Commit d1f1a4a7 authored by liam's avatar liam
Browse files

Swap first two arguments of with-data so that symbol is first. Make a

separate gsl-vector-c type.  #'subvector still gets "memory fault".


git-svn-id: svn+ssh://pop/opt/space/mathematics/gsl/trunk@3010 a3d8a0fb-c1db-0310-ace7-a616afeb9e30
parent 563e39b2
No related branches found
No related tags found
No related merge requests found
......@@ -3,7 +3,7 @@
; description: Using GSL storage.
; date: Sun Mar 26 2006 - 16:32
; author: Liam M. Healy
; modified: Mon Mar 27 2006 - 00:03
; modified: Wed Mar 29 2006 - 23:35
;********************************************************
;;; $Id: $
......@@ -82,7 +82,7 @@
(export 'with-data)
(defmacro with-data ((type symbol size &optional zero) &body body)
(defmacro with-data ((symbol type size &optional zero) &body body)
"Allocate GSL data, bind to pointer,
and then deallocated it when done. If zero is T, zero the
contents when allocating."
......
......@@ -3,7 +3,7 @@
; description: Vectors and matrices
; date: Sun Mar 26 2006 - 11:51
; author: Liam M. Healy
; modified: Wed Mar 29 2006 - 17:39
; modified: Wed Mar 29 2006 - 23:35
;********************************************************
;;; $Id: $
......@@ -52,7 +52,7 @@ deallocated with the vector.
;;; Allocation, freeing, reading and writing
(gsl-data-functions "vector")
(setf *wrap-types* (acons 'gsl-vector (lambda (x) `(pointer ,x)) *wrap-types*))
(setf *wrap-types* (acons 'gsl-vector-c (lambda (x) `(pointer ,x)) *wrap-types*))
;;;;****************************************************************************
;;;; Accessing elements
......@@ -116,22 +116,21 @@ deallocated with the vector.
;;;;****************************************************************************
(cffi:defcstruct gsl-vector-view
(vector gsl-vector))
(vector gsl-vector-c))
(setf *wrap-types*
(acons 'gsl-vector-view
(lambda (x)
x
;;x
#+no
`(cffi:foreign-slot-value ,x 'gsl-vector-view 'vector)
#+no
`(make-instance 'gsl-vector
:pointer
(cffi:foreign-slot-value ,x 'gsl-vector-view 'vector)))
*wrap-types*))
;;; improve documentation
(defun-gsl subvector ((vector gsl-vector) (offset :size) (size :size))
(defun-gsl subvector ((vector gsl-vector-c) (offset :size) (size :size))
"gsl_vector_subvector"
:c-return-value :return
:return (gsl-vector-view)
......@@ -166,7 +165,7 @@ elements.")
;;;;****************************************************************************
#|
(with-data (vector vec 3)
(with-data (vec vector 3)
(setf (gsl-aref vec 0) -3.21d0
(gsl-aref vec 1) 1.0d0
(gsl-aref vec 2) 12.8d0)
......@@ -174,7 +173,7 @@ elements.")
(print (gsl-aref vec 1))
(print (gsl-aref vec 0)))
(with-data (vector vec 3)
(with-data (vec vector 3)
(set-all vec 77.8d0)
(print (gsl-aref vec 2))
(print (gsl-aref vec 1))
......@@ -184,12 +183,12 @@ elements.")
(print (gsl-aref vec 1))
(print (gsl-aref vec 0)))
(with-data (vector vec 3) (set-basis vec 1)
(with-data (vec vector 3) (set-basis vec 1)
(format t "~&~a ~a ~a"
(gsl-aref vec 0) (gsl-aref vec 1) (gsl-aref vec 2)))
;;; broken
(with-data (vector vec 3)
(with-data (vec vector 3)
(setf (gsl-aref vec 0) -3.21d0
(gsl-aref vec 1) 1.0d0
(gsl-aref vec 2) 12.8d0)
......@@ -197,13 +196,26 @@ elements.")
(DEFUN SUBVECTOR (VECTOR OFFSET SIZE)
(FOREIGN-FUNCALL "gsl_vector_subvector"
GSL-VECTOR-c
(POINTER VECTOR)
:SIZE
OFFSET
:SIZE
SIZE
GSL-VECTOR-VIEW))
:pointer
(POINTER VECTOR)
:SIZE
OFFSET
:SIZE
SIZE
GSL-VECTOR-VIEW))
(with-data (vec vector 3)
(setf (gsl-aref vec 0) -3.21d0
(gsl-aref vec 1) 1.0d0
(gsl-aref vec 2) 12.8d0)
(FOREIGN-FUNCALL "gsl_vector_subvector"
:pointer
(POINTER VEC)
:SIZE
1
:SIZE
2
GSL-VECTOR-VIEW))
|#
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment