[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: array manipulation problem
- Subject: Re: array manipulation problem
- From: Benno Puetz <puetz(at)mpipsykl.mpg.de>
- Date: Wed, 07 Jun 2000 15:44:53 +0200
- Newsgroups: comp.lang.idl-pvwave
- Organization: Max-Planck-Inst. f. Psychiatrie, NMR
- References: <393DF7F7.F7A34080@uni-freiburg.de>
- Xref: news.doit.wisc.edu comp.lang.idl-pvwave:19898
"Martin B. Schmidt" wrote:
> Hi,
>
> Given:
>
> n=500
> a=FltArr(n,n,n)
>
> How can I assign
> a[i,j,k] = i^2+j^2+k^2 for all i,j,k (i,j,k=0,1,2,..,n-1)
> without using any loop?
>
> Any idea?
>
> Martin
n=500
i = REBIN(REFORM(FINDGEN(n),n,1,1),n,n,n)^2 ; x^2
a = i + $ ; x^2
TRANSPOSE(i,[1,0,2]) + $ ; y^2
TRANSPOSE(i,[0,2,1]) ; z^2
should work if you have enough memory( I only tried n=5, though, since
this allocates two large arrays, not counting temporary allocations)
--
Benno Puetz
Kernspintomographie
Max-Planck-Institut f. Psychiatrie Tel.: +49-89-30622-413
Kraepelinstr. 10 Fax : +49-89-30622-520
80804 Muenchen, Germany