comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: array manipulation problem
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: array manipulation problem [message #20369 is a reply to message #20365] Wed, 07 June 2000 00:00 Go to previous message
Benno Puetz is currently offline  Benno Puetz
Messages: 16
Registered: March 2000
Junior Member
"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
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Curvefit on PV-Wave
Next Topic: reasons for truncated sav files

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 01:35:28 PDT 2025

Total time taken to generate the page: 0.64298 seconds