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 
Return to the default flat view Create a new topic Submit Reply
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
[Message index]
 
Read Message
Read Message
Read Message
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 21:53:28 PDT 2025

Total time taken to generate the page: 0.88169 seconds