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

Home » Public Forums » archive » Re: Imaginary is narrow minded
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
Re: Imaginary is narrow minded [message #9842] Wed, 03 September 1997 00:00
Christian Soeller is currently offline  Christian Soeller
Messages: 46
Registered: August 1996
Member
davidf@dfanning.com (David Fanning) writes:

>
> IF Type(thatThing) EQ 'COMPLEX' THEN thisThing=Imaginary(thatThing)$
> ELSE thisThing = 0
>

Wouldn't you want to make it return an array of zeroes when called
with an array?

Christian Soeller
Re: Imaginary is narrow minded [message #9844 is a reply to message #9842] Wed, 03 September 1997 00:00 Go to previous message
meron is currently offline  meron
Messages: 51
Registered: July 1995
Member
In article <jackel.140.20AC6E36@danlon.physics.uwo.ca>, jackel@danlon.physics.uwo.ca (Brian Jackel) writes:
> Greetings
>
> <Rant>
> I'm stuck with IDL 4.0, and was wondering if the snazzy new version
> still gives this stupid error
>
> % IMAGINARY: Operand must be of complex type:
>
> Alternatively, I'd love to know _why_ it can't just return a zero value.

I wrote my own function, M_IMAGINARY, which takes care of just this
problem, and I use it exclusively instead of the IDL IMAGINARY.

Mati Meron | "When you argue with a fool,
meron@cars.uchicago.edu | chances are he is doing just the same"
Re: Imaginary is narrow minded [message #9846 is a reply to message #9842] Tue, 02 September 1997 00:00 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Now I'm really brainstorming. Here is another
program for Brian Jackel:

FUNCTION IF_IMAGINARY, variable
types = ['UNDEFINED', 'BYTE', 'INTEGER', 'LONG', 'FLOAT', $
'DOUBLE', 'COMPLEX', 'STRING', 'STRUCTURE', $
'DCOMPLEX', 'POINTER', 'OBJECT']
s = Size(variable)
thisType = types(s(s(0) + 1))
IF thisType EQ 'COMPLEX' THEN RETURN, Imaginary(variable) $
ELSE RETURN, 0.0
END

Then, you can do this:

imaginaryPart = IF_IMAGINARY(variable)

Cheers,

David

-----------------------------------------------------------
David Fanning, Ph.D.
Fanning Software Consulting
Customizable IDL Programming Courses
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com
Re: Imaginary is narrow minded [message #9848 is a reply to message #9846] Tue, 02 September 1997 00:00 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Brian Jackel writes:

> <Rant>
> I'm stuck with IDL 4.0, and was wondering if the snazzy new version
> still gives this stupid error
>
> % IMAGINARY: Operand must be of complex type:
>
> Alternatively, I'd love to know _why_ it can't just return a zero value.
> Sometimes the argument is going to be real, and it irritates me to add
> the extra call to make sure the argument is complex. IDL functions are
> usually pretty clever about dealing with variable input types, but not here.
> </Rant>

Oh, dear, it's one of those days, apparently. Here, Brian, something to
cheer you up.

FUNCTION Type, variable
types = ['UNDEFINED', 'BYTE', 'INTEGER', 'LONG', 'FLOAT', $
'DOUBLE', 'COMPLEX', 'STRING', 'STRUCTURE', $
'DCOMPLEX', 'POINTER', 'OBJECT']
s = Size(variable)
RETURN, types(s(s(0) + 1))
END

IF Type(thatThing) EQ 'COMPLEX' THEN thisThing=Imaginary(thatThing)$
ELSE thisThing = 0

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting
Customizable IDL Programming Courses
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Size of variables in bytes?
Next Topic: IDL -> MPEG

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

Current Time: Wed Oct 08 15:37:54 PDT 2025

Total time taken to generate the page: 0.00878 seconds