Re: How do you get rid of for-loops with arrays [message #19342] |
Wed, 08 March 2000 00:00 |
John-David T. Smith
Messages: 384 Registered: January 2000
|
Senior Member |
|
|
Karri Kaksonen wrote:
>
> I have tried to understand how to use the arrays in IDL but
> there is still tons of techniques that I don't know...
>
> Is it possible to do this without for-loops?
>
> a = [[1,2,3],[4,5,6]]
> b = [2,2,3]
>
> for i=0,1 do a[*,i] = a[*,i] * b
a=a*rebin(b,3,2,/samp)
Redimensioning arrays in calculations is so important, it's in the FAQ:
http://www.ivsoftware.com:8000/FAQ/FMPro?-db=idl%5ffaq.fp3&a mp;-format=record%5fdetail.htm&-lay=entry%20layout&- max=2147483647&-recid=36&-findall=
JD
--
J.D. Smith |*| WORK: (607) 255-5842
Cornell University Dept. of Astronomy |*| (607) 255-6263
304 Space Sciences Bldg. |*| FAX: (607) 255-5875
Ithaca, NY 14853 |*|
|
|
|
Re: How do you get rid of for-loops with arrays [message #19344 is a reply to message #19342] |
Wed, 08 March 2000 00:00  |
Andy Loughe
Messages: 174 Registered: November 1995
|
Senior Member |
|
|
Karri Kaksonen wrote:
>
> I have tried to understand how to use the arrays in IDL but
> there is still tons of techniques that I don't know...
>
> Is it possible to do this without for-loops?
>
> a = [[1,2,3],[4,5,6]]
> b = [2,2,3]
>
> for i=0,1 do a[*,i] = a[*,i] * b
>
> --
> Thanks,
>
> Karri
a = ( b # replicate(1,2) ) * a
--------
Andrew F. Loughe email:loughe@fsl.noaa.gov phone:(303)497-6211
|
|
|