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

Home » Public Forums » archive » Re: atan in IDL 5.5
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: atan in IDL 5.5 [message #31049] Tue, 04 June 2002 09:13
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
Zoe Dent <zoe@aurora.york.ac.uk> writes:

> --------------1F130981AB8092C521F2309C
> Content-Type: text/plain; charset=us-ascii
> Content-Transfer-Encoding: 7bit
>
> I'm having problems with the 'atan' function in IDL 5.5. I have a
> program which reads in an array of complex numbers, so an array of
> single numbers should be produced, but in fact another complex array os
> produced. At the command-line the atan of a set of complex numbers
> produces a single number. I have disabled the multi-threading option
> with no effect. I'd appreciate any advice on this matter.

Right, I used to rely on this too, but RSI made this change pretty
obvious in their release notes, as the others have pointed out. It's
a pity since the original ATAN behavior will be faster than the new
way to do it. That's why I use the following utility function,
ZCOMPARG. I set it and forget it.

Craig



function zcomparg, z

forward_function atan, real_part, imaginary
common zcomparg_common, atanver
if n_elements(atanver) EQ 0 then begin
if !version.release LT '5.5' then atanver = 1 $
else atanver = 2
endif

if atanver EQ 1 then return, atan(z) $
else return, atan(imaginary(z), real_part(z))

end

--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
Re: atan in IDL 5.5 [message #31052 is a reply to message #31049] Tue, 04 June 2002 08:08 Go to previous message
Randall Skelton is currently offline  Randall Skelton
Messages: 169
Registered: October 2000
Senior Member
Hi Zoe,

I am not sure I understand what you are trying to do. Can you please post
a snipit of code that demonstrates the problem you are having?

> I have a program which reads in an array of complex numbers, so an array
> of single numbers should be produced, but in fact another complex array os
> produced.

If you have complex numbers why are you expecting "an array of single
numbers" to be produced? What is your code doing?

> At the command-line the atan of a set of complex numbers
> produces a single number.

I disagree. If you give a complex value to atan, you will get a complex
number back.

IDL> a = complex(0.5,0.5)
IDL> help, a
A COMPLEX = ( 0.500000, 0.500000)
IDL> print, atan(a)
( 0.553574, 0.402359)

> I have disabled the multi-threading option with no effect.

This is a quantum leap... I have no idea what you are trying to do.

Cheers,
Randall

On Tue, 4 Jun 2002, Zoe Dent wrote:

> I'm having problems with the 'atan' function in IDL 5.5. I have a
> program which reads in an array of complex numbers, so an array of
> single numbers should be produced, but in fact another complex array os
> produced. At the command-line the atan of a set of complex numbers
> produces a single number. I have disabled the multi-threading option
> with no effect. I'd appreciate any advice on this matter.
>
> Many thanks,
>
> Zoe
Re: atan in IDL 5.5 [message #31054 is a reply to message #31052] Tue, 04 June 2002 07:17 Go to previous message
Richard Younger is currently offline  Richard Younger
Messages: 43
Registered: November 2000
Member
Zoe Dent wrote:
>
> I'm having problems with the 'atan' function in IDL 5.5. I have a
> program which reads in an array of complex numbers, so an array of
> single numbers should be produced, but in fact another complex array
> os produced. At the command-line the atan of a set of complex numbers
> produces a single number. I have disabled the multi-threading option
> with no effect. I'd appreciate any advice on this matter.

Zoe,

I think your problem is that RSI changed the behavior of ATAN in IDL
5.5. It used to be that IDL through 5.4 interpreted the arctangent of a
complex number as the the phase angle of that complex number, namely,
ArcTan(imag/real). when I switched to 5.5, I found a new "feature" in
the What's New that said something like 'Trigonometric functions now
handle complex values!' This means that you now have to explicitly
separate the complex and real parts to get the phase angle, which was a
bit of a nuisance to find and replace. E.G.:

a = complex(1.0, -0.5)
phase = ATAN(Imaginary(a),Real_Part(a))

I don't know about the command line producing different numbers. It
seems to work fine for me. At the command line, I get

IDL> print, !version
{ x86 Win32 Windows Microsoft Windows 5.5 Aug 28 2001 32 64}

IDL> a = complex(1.0, -0.5)
IDL> help, atan(a)
<Expression> COMPLEX = ( 0.847576, -0.238878)
IDL> help, ATAN(Imaginary(a),Real_Part(a))
<Expression> FLOAT = -0.463648

Best,
Rich

--
Richard Younger
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: atan in IDL 5.5
Next Topic: Re: Structure reforming

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

Current Time: Wed Oct 08 20:06:11 PDT 2025

Total time taken to generate the page: 0.20426 seconds