* Tamas K Papp <[EMAIL PROTECTED]> :
|
| I am a Lisp newbie, sorry if this question has a simple answer, I
| tried googling and found nothing.
|
| Consider an n-dimensional simple array, eg
|
| (setf a (make-array '(2 3 4) :element-type 'double-float))
|
| If I understand correctly, a simple boxed array is just a vector of
| numbers (in this case, 12 zeros), and information on the dimension (2
| 3 4).  Is it possible to "reshape" the array by changing only the
| latter?  Eg 

There are 24 elements in the array. Perhaps you can use a
displaced-array for your purpose

Try
(defparameter $b
  (make-array '(6 4) :displaced-to a :element-type 'double-float))


And read the common lisp hyperspec entry for MAKE-ARRAY which talks
about :dipsplaced-to and :displaced-index-offset for displaced arrays
and also 15.1.1.3.2.1


| (reshape a '(4 3))
|
| would give a 4x3 array with the same elements, etc.  A special case
| would be reshaping to a simple vector, or reshaping a simple vector to
| an array.
|
| Is there such a function already in CMUCL, or is it possible to write
| one without too much hassle?  Even a desctructive reshape! would be
| enough for my purposes.

--
Madhu


Reply via email to