Commit 15147fea authored by liam's avatar liam

The selection of size or intial value will be different depending on

whether the object is a matrix or vector.


git-svn-id: svn+ssh://pop/opt/space/mathematics/gsl/trunk@3280 a3d8a0fb-c1db-0310-ace7-a616afeb9e30
parent 9a099f40
;; Using GSL storage.
;; Liam Healy, Sun Mar 26 2006 - 16:32
;; Time-stamp: <2008-02-02 23:15:39EST data.lisp>
;; Time-stamp: <2008-02-02 23:37:58EST data.lisp>
;; $Id: $
(in-package :gsl)
......@@ -103,17 +103,19 @@
;;(LONG-DOUBLE . "_long_double")
(COMPLEX . "_complex")))
(defmacro data-letm (type)
(defmacro data-letm (type size-spec-is-list)
"Define the letm function for data types."
`(defun-letm ,type (size-or-initial &optional zero)
(let ((argsymb (gensym "ARG")))
(list
`(make-data ',',type ,zero
(if (numberp ,argsymb) ,argsymb (length ,argsymb)))
'free
(lambda (symb)
`(unless (numberp ,argsymb) (setf (data ,symb) ,argsymb)))
(lambda () (list argsymb size-or-initial))))))
(let ((size-spec (if size-spec-is-list 'listp 'numberp))
(init-spec (if size-spec-is-list 'array-dimensions 'length)))
`(defun-letm ,type (size-or-initial &optional zero)
(let ((argsymb (gensym "ARG")))
(list
`(make-data ',',type ,zero
(if (,',size-spec ,argsymb) ,argsymb (,',init-spec ,argsymb)))
'free
(lambda (symb)
`(unless (,',size-spec ,argsymb) (setf (data ,symb) ,argsymb)))
(lambda () (list argsymb size-or-initial)))))))
(defmacro defdata
(c-string cl-symbol cl-base-type
......@@ -130,7 +132,7 @@
collect `((nth ,i (storage-size object)) :size)))
(object-name (make-symbol-from-strings *gsl-prefix* cl-symbol)))
`(progn
(data-letm ,cl-symbol)
(data-letm ,cl-symbol ,(eq superclass 'gsl-matrix))
(defclass ,object-name (,superclass)
((cl-base-type :initform ',cl-base-type :reader cl-base-type
:allocation :class)))
......
;; Matrices
;; Liam Healy, Sun Mar 26 2006 - 11:51
;; Time-stamp: <2008-01-28 22:19:38EST matrix.lisp>
;; Time-stamp: <2008-02-02 23:44:57EST matrix.lisp>
;; $Id: $
(in-package :gsl)
;;; Matrices are specified in a letm binding with
;;; (matrix-double size-or-initial &optional zero)
;;; (matrix-single size-or-initial &optional zero)
;;; (matrix-fixnum size-or-initial &optional zero)
;;; (matrix-complex size-or-initial &optional zero)
;;; where size-or-initial is a length-2 list of positive integers
;;; indicating the dimensions, and zero indicates that all elements should
;;; be set to zero, or, size-or-initial is a 2D array to which the
;;; vector should be initially set.
;;;;****************************************************************************
;;;; Matrix object definition, allocation, reading & writing
;;;;****************************************************************************
......
;; Vectors
;; Liam Healy, Sun Mar 26 2006 - 11:51
;; Time-stamp: <2008-02-02 23:13:54EST vector.lisp>
;; Time-stamp: <2008-02-02 23:45:19EST vector.lisp>
;; $Id: $
(in-package :gsl)
;;; Vectors are specified in a letm binding with
;;; (vector-double size-or-initial &optional zero)
;;; (vector-single size-or-initial &optional zero)
;;; (vector-fixnum size-or-initial &optional zero)
;;; (vector-complex size-or-initial &optional zero)
;;; where size-or-initial is a positive integer indicating the
;;; size, and zero indicates that all elements should be set to zero,
;;; or, size-or-initial is a sequence to which the vector
;;; should be initially set.
;;; No mechanism for C stream input/output yet.
;;; Generalize check-gsl-status to optionally signal errors, use here?
;;; Functions like write-binary etc. as a single function, selecting the C fn with typecase?
......
;; Utility definitions
;; Liam Healy, Sun Dec 3 2006 - 10:21
;; Time-stamp: <2008-02-02 22:48:23EST utility.lisp>
;; Time-stamp: <2008-02-02 23:22:56EST utility.lisp>
;; $Id: $
(in-package :gsl)
......@@ -59,6 +59,11 @@
;; No GSL objects in the bindings, just make an ordinary let
`(let* (,@bindings) ,@body))))
(defun not-for-users (form)
(unless *not-for-users*
(error "The form ~a should be placed in the binding of a letm."
form)))
;;; General definition for object creation
(defmacro defun-letm (symbol arglist &body body)
"Define a GSL object to be bound in a letm.
......@@ -75,9 +80,7 @@
(pushnew ',symbol *letm-expanded-object*)
(export ',symbol)
(defun ,symbol ,arglist
(unless *not-for-users*
(error "The form ~a should be placed in the binding of a letm."
',(cons symbol arglist)))
(not-for-users ',(cons symbol arglist))
,@body)))
;;; Specific, simple and common types of object creation
......
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