[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: array manipulation problem
- Subject: Re: array manipulation problem
- From: Paul Hick <pphick(at)ucsd.edu>
- Date: Wed, 07 Jun 2000 10:47:12 -0700
- Newsgroups: comp.lang.idl-pvwave
- Organization: Univ of Calif San Diego
- References: <393DF7F7.F7A34080@uni-freiburg.de>
- Xref: news.doit.wisc.edu comp.lang.idl-pvwave:19899
"Martin B. Schmidt" wrote:
> 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?
one = replicate(1.0, n)
index = findgen(n)^2
a = reform( reform( index#one, n*n)#one + reform( one#index, n*n)#one
+ reform( one#one, n*n)#index ,n,n,n)
Not particularly pretty, but it should work.
Cheers,
Paul
--
_________________________________________________________________
| Paul Hick (pphick@ucsd.edu) |
| Office : SERF Rm. 302 Smail : UCSD/CASS/0424 |
| Phone : (858) 534-8965 9500 Gilman Drive |
| Fax : (858) 534-0177 La Jolla CA 92093-0424 |
| WWW : http://casswww.ucsd.edu/personal/Plh.html |
|_________________________________________________________________|