List Info

Thread: reshare array




reshare array
country flaguser name
United States
2007-04-04 21:17:10
Hi,

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 

(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.

Thanks,

Tamas


PS. matlisp already has such a reshape, but only for
matrices.


Re: reshare array
country flaguser name
Netherlands
2007-04-05 07:13:32
Tamas K Papp wrote:

> 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?

Have a look at ADJUST-ARRAY.  Maybe it does what you need.

http://www.lispworks.com/documentation/HyperSp
ec/Body/f_adjust.htm

Arthur Lemmens



[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )