32
32
;;; simultaneously of type (1) and (1m).
34
34
(defun $listarray (ary)
36
(cond ((mget ary 'hashar)
37
(mapcar #'(lambda (subs) ($arrayapply ary subs))
38
(cdddr (meval (list '($arrayinfo) ary)))))
39
((mget ary 'array) (listarray (mget ary 'array)))
41
((arrayp ary) (coerce ary 'list))
46
(declare (special vals tab))
47
(maphash #'(lambda (x &rest l)l (push (gethash x tab) vals)) ary )
50
(merror "Argument to LISTARRAY must be an array:~%~M" ary)))))
36
(cond ((mget ary 'hashar)
37
(mapcar #'(lambda (subs) ($arrayapply ary subs))
38
(cdddr (meval (list '($arrayinfo) ary)))))
39
((mget ary 'array) (listarray (mget ary 'array)))
41
((arrayp ary) (coerce ary 'list))
46
(declare (special vals tab))
47
(maphash #'(lambda (x &rest l)l (push (gethash x tab) vals)) ary )
50
(merror "Argument to `listarray' must be an array:~%~M" ary)))))
52
52
(defmfun $fillarray (ary1 ary2)
57
(and (arrayp ary1) ary1)
58
(merror "First argument to FILLARRAY must be a declared array:~%~M" ary1))))
61
(cond (($listp ary2) (cdr ary2))
62
((get (mget ary2 'array) 'array))
67
"Second argument to FILLARRAY must be an array or list:~%~M" ary2))))
70
;(defmacro $rearray (ar &rest dims)
71
; `(cond ($use_fast_arrays (setq ,ar (rearray-aux ',ar ,(safe-value ar) ,@ dims)))
72
; (t (rearray-aux ',ar (safe-value ,ar) ,@ dims))))
57
(and (arrayp ary1) ary1)
58
(merror "First argument to `fillarray' must be a declared array:~%~M" ary1))))
61
(cond (($listp ary2) (cdr ary2))
62
((get (mget ary2 'array) 'array))
67
"Second argument to `fillarray' must be an array or list:~%~M" ary2))))
70
;;(defmacro $rearray (ar &rest dims)
71
;; `(cond ($use_fast_arrays (setq ,ar (rearray-aux ',ar ,(safe-value ar) ,@ dims)))
72
;; (t (rearray-aux ',ar (safe-value ,ar) ,@ dims))))
74
74
(defun getvalue (sym)
75
75
(and (symbolp sym) (boundp sym) (symbol-value sym)))
76
(defmspec $rearray (l) (setq l (cdr l))
76
(defmspec $rearray (l)
77
78
(let ((ar (car l)) (dims (cdr l)))
78
(cond ($use_fast_arrays (set ar (rearray-aux ar (getvalue ar) dims )))
79
(t (rearray-aux ar (getvalue ar) dims)))))
79
(cond ($use_fast_arrays
80
(set ar (rearray-aux ar (getvalue ar) dims )))
82
(rearray-aux ar (getvalue ar) dims)))))
82
85
(defun rearray-aux (ar val dims &aux marray-sym)
86
89
(setf (symbol-array ar)
87
90
(apply 'lispm-rearray (symbol-array ar ) dims)))
88
91
((setq marray-sym (mget ar 'array))
89
(apply 'rearray-aux marray-sym nil dims ) ar)
92
;; Why apply? Why not directly call ourselves?
94
(apply 'rearray-aux marray-sym nil (list dims))
95
(rearray-aux marray-sym nil dims)
90
97
(t (error "unknown array ~A " ar))))
93
100
(defmspec $rearray (l) (setq l (cdr l))
94
101
(cond ((> (length l) 6)
95
(merror "Too many arguments to REARRAY:~%~M" l))
102
(merror "Too many arguments to `rearray':~%~M" l))
97
(merror "Too few arguments to REARRAY:~%~M" l)))
104
(merror "Too few arguments to `rearray':~%~M" l)))
98
105
(let ((name (car l))
99
106
(ary (cond ($use_fast_arrays
100
(symbol-value (car l)))
102
(cond ((mget (car l) 'array))
104
(merror "First argument to REARRAY must be a declared array:~%~M"
107
(symbol-value (car l)))
109
(cond ((mget (car l) 'array))
111
(merror "First argument to `rearray' must be a declared array:~%~M"
107
114
l (mapcar #'(lambda (x)
108
115
(setq x (meval x))
109
116
(cond ((not (eq (ml-typep x) 'fixnum))
111
"Non-integer dimension to REARRAY:~%~M"
118
"Non-integer dimension to `rearray':~%~M"
135
;(defmspec $rearray (l) (setq l (cdr l))
136
; (cond ((> (length l) 6)
137
; (merror "Too many arguments to REARRAY:~%~M" l))
139
; (merror "Too few arguments to REARRAY:~%~M" l)))
140
; (let ((name (car l))
141
; (ary (cond ($use_fast_arrays
142
; (symbol-value (car l)))
144
; (cond ((mget (car l) 'array))
146
; (merror "First argument to REARRAY must be a declared array:~%~M"
149
; l (mapcar #'(lambda (x)
151
; (cond ((not (eq (ml-typep x) 'fixnum))
153
; "Non-integer dimension to REARRAY:~%~M"
163
; (apply '*rearray (cons ary
164
; (cons (car (arraydims ary)) l)))))
165
; #+Franz(mputprop name new-array 'array)
169
; (cond ($use_fast_arrays
170
; (setq ary (apply 'lispm-rearray (cons ary l))))
171
; (t (setf (symbol-function ary) (apply 'lispm-rearray (cons (symbol-function ary) l)))))
172
; (cond ($use_fast_arrays (setq name ary))
173
; (t (mputprop name ary 'array))))
142
;;(defmspec $rearray (l) (setq l (cdr l))
143
;; (cond ((> (length l) 6)
144
;; (merror "Too many arguments to `rearray':~%~M" l))
146
;; (merror "Too few arguments to `rearray':~%~M" l)))
147
;; (let ((name (car l))
148
;; (ary (cond ($use_fast_arrays
149
;; (symbol-value (car l)))
151
;; (cond ((mget (car l) 'array))
153
;; (merror "First argument to `rearray' must be a declared array:~%~M"
156
;; l (mapcar #'(lambda (x)
157
;; (setq x (meval x))
158
;; (cond ((not (eq (ml-typep x) 'fixnum))
160
;; "Non-integer dimension to `rearray':~%~M"
170
;; (apply '*rearray (cons ary
171
;; (cons (car (arraydims ary)) l)))))
172
;; #+Franz(mputprop name new-array 'array)
176
;; (cond ($use_fast_arrays
177
;; (setq ary (apply 'lispm-rearray (cons ary l))))
178
;; (t (setf (symbol-function ary) (apply 'lispm-rearray (cons (symbol-function ary) l)))))
179
;; (cond ($use_fast_arrays (setq name ary))
180
;; (t (mputprop name ary 'array))))
177
;(defun lispm-rearray (ar &rest dims)
178
; ( make-array (mapcar '1+ (copy-list dims)) :element-type (array-element-type ar) :displaced-to ar ))
184
;;(defun lispm-rearray (ar &rest dims)
185
;; ( make-array (mapcar '1+ (copy-list dims)) :element-type (array-element-type ar) :displaced-to ar ))
181
188
(defun lispm-rearray (ar &rest dims)