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

Home » Public Forums » archive » Arrays with complex index ?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Arrays with complex index ? [message #18128] Sat, 04 December 1999 00:00 Go to next message
Henrik E. Nilsen is currently offline  Henrik E. Nilsen
Messages: 3
Registered: November 1999
Junior Member
Hello all,

Annyone know if there's a way to reference a floating point array using a
complex number?

what I would like to do is something like:

cnum=complex(5,5) & cnum2=complex(2,3) & fnum=10.7
arr=fltarr(cnum)
arr[cnum2]=fnum

and not:

arr=fltarr(5,5)
arr[float(cnum),imaginary(cnum)]=fnum

I suspect that this is not possible. Does anyone know how time
consumining the 'float' and 'imaginary' commands are? (I'm using these
statments at the core of a loop structure, and so any savings in time are
important)

Thanks.
- Henrik

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Henrik E. Nilsen Chairman, The Maidanak Foundation
Graduate student, astrophysics http://www.maidanak.org
University of Bergen, Norway Welhavens gate 61
E-mail: Henrik.Nilsen@fi.uib.no N-5006 Bergen, Norway
Re: Arrays with complex index ? [message #18267 is a reply to message #18128] Mon, 06 December 1999 00:00 Go to previous message
wbiagiot is currently offline  wbiagiot
Messages: 59
Registered: January 1999
Member
In article <82bor4$o36$1@news.doit.wisc.edu>,

Henrik,

If you are interesting in looking at the timing of IDL routines (or
yours for that matter), IDL5.2 and upward has a pretty good execution
profiler (run->profile). This nifty feature gives you the exact
execution time and count for every one of your selected routines. This
will allow you to see where your program execution time is spent. Also,
IDL routines like 'COMPLEX' or 'FIX' are what I call "mini-routines"
and are so quick as to be inconsequental when looking at cumulative
execution time. Liam was correct in stating that if you can perform
your operations as array vectors that that is the best way to go by far.

Regards,

Bill B.

--
"They don't think it be like it is, but it do."

Oscar Gamble, NY Yankees


Sent via Deja.com http://www.deja.com/
Before you buy.
Re: Arrays with complex index ? [message #18276 is a reply to message #18128] Sat, 04 December 1999 00:00 Go to previous message
Liam Gumley is currently offline  Liam Gumley
Messages: 473
Registered: November 1994
Senior Member
Henrik E. Nilsen wrote:
> Annyone know if there's a way to reference a floating point array using a
> complex number?
>
> what I would like to do is something like:
>
> cnum=complex(5,5) & cnum2=complex(2,3) & fnum=10.7
> arr=fltarr(cnum)
> arr[cnum2]=fnum
>
> and not:
>
> arr=fltarr(5,5)
> arr[float(cnum),imaginary(cnum)]=fnum
>
> I suspect that this is not possible. Does anyone know how time
> consumining the 'float' and 'imaginary' commands are? (I'm using these
> statments at the core of a loop structure, and so any savings in time are
> important)

Regarding the use of a complex variable as an array subscript, here's what
the documentation says (Building IDL applications; Subscript Examples):

"Subscripts can be any type of vector or scalar expression. If a subscript
expression is not integer, a longword integer copy is made and used to
evaluate the subscript."

Thus the following statements are legal, but only the real part of the
complex number is used to form the subscript:

IDL> arr = indgen(10)
IDL> index = complex(1.0, 2.0)
IDL> help, long(index)
<Expression> LONG = 1
IDL> help, arr[index]
<Expression> INT = 1

The second example you gaev looks fine to me, e.g.

arr = fltarr(5,5)
arr[float(cnum),imaginary(cnum)] = fnum

I don't think there's any great time penalty incurred by using float() and
imaginary(). You'll gain much more speed by finding a way to express your
algorithm in array operations rather than loop operations.

Cheers,
Liam.
http://cimss.ssec.wisc.edu/~gumley
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: IDL 5.3 here
Next Topic: contour in polar coordinates

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

Current Time: Fri Oct 10 07:59:12 PDT 2025

Total time taken to generate the page: 0.08021 seconds