Commit 1a4cb94f authored by Liam Healy's avatar Liam Healy
Browse files

Integrate marrays into grid

The GSLL marrays now function correctly as instances of grid:grid; for
example, (grid:transpose *m35*) works.  All previous tests pass in
SBCL.
parent 7b6dea21
;; A "marray" is an array in both GSL and CL
;; Liam Healy 2008-04-06 21:23:41EDT
;; Time-stamp: <2009-12-21 10:47:55EST marray.lisp>
;; Time-stamp: <2009-12-21 22:26:21EST marray.lisp>
(in-package :gsl)
......@@ -134,6 +134,15 @@
class-or-element-type))
keys))
(pushnew 'marray grid:*grid-data-superclasses*)
(defmethod grid:make-grid-data
((type (eql 'marray)) dimensions rest-spec
&key (initial-element nil initial-element-p))
(make-marray rest-spec
:dimensions dimensions
:initial-element initial-element))
;;; The reader macro #m will read a list of arguments, evaluating the
;;; contents, and construct a marray from it. If the symbol ^ occurs
;;; in the list, it indicates the object being made is a matrix, and
......
;; Foreign (C or C-compatible) arrays
;; Liam Healy 2008-12-28 10:44:22EST foreign-array.lisp
;; Time-stamp: <2009-12-21 19:04:46EST foreign-array.lisp>
;; Time-stamp: <2009-12-21 22:27:03EST foreign-array.lisp>
(in-package :c-array)
......@@ -47,6 +47,16 @@
(:documentation
"A superclass for arrays represented in C and CL."))
(defun foreign-array-specification (object dimensions)
"Create the grid specification for the object, with a possibly
different set of dimensions."
(let ((class
(or
(find-if (lambda (cl) (typep object cl))
grid:*grid-data-superclasses*)
(class-name (class-of object)))))
(list (cons class dimensions) (element-type object))))
;;; Allowable keys: :dimensions, :initial-contents, :initial-element.
(defmethod initialize-instance :after
((object foreign-array) &rest initargs
......@@ -61,7 +71,7 @@
total-size (array-total-size grid:data)
grid:rank (length dimensions)
grid:specification
(list (cons (class-of object) dimensions) (element-type object))
(foreign-array-specification object dimensions)
grid:affi (ignore-errors (affi:make-affi dimensions)))
#-native
(let ((cptr (cffi:foreign-alloc
......
;; Methods for grid functions
;; Liam Healy 2009-12-21 11:19:00EST methods.lisp
;; Time-stamp: <2009-12-21 13:48:59EST methods.lisp>
;; Time-stamp: <2009-12-21 21:56:38EST methods.lisp>
(in-package :c-array)
......@@ -13,7 +13,7 @@
(defmethod grid:make-grid-data
((type (eql 'foreign-array)) dimensions rest-spec
&key (initial-element nil initial-element-p))
;; Nothing to do here, because the data is inserted in
;; initialize-instance :after for foreign-array.
nil)
(make-instance 'foreign-array
:dimensions dimensions
:element-type rest-spec
:initial-element initial-element))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment