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

Home » Public Forums » archive » Re: complex arithmetic
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: complex arithmetic [message #1922 is a reply to message #1921] Wed, 06 April 1994 06:17 Go to previous messageGo to previous message
landers is currently offline  landers
Messages: 45
Registered: May 1993
Member
First, let me agree that there's no reason that this kind of thing should not be
supported. But...

Of course, you could do:

WAVE> x = complex( 0.,1.)
WAVE> print, exp( 3. * alog( x ) )
( 1.19249e-08, -1.00000)

Just a bit of residual error there in the real part....
This kind of technique will handle complex exponents, too.

It would be pretty easy to write a "pow.pro" around this - test for combo
of complex arg / non-int expo, and do the log thing.

(disclaimers - I use PV-WAVE - I tested this only lightly - YMMV - etc.)


function pow, arg, expo

on_error,2

if n_params() ne 2 then message, 'Usage: result = POW( argument, exponent )'

; argument sizes...
sa = size(arg)
se = size(expo)

; argument types...
ta = sa(sa(0)+1)
te = se(se(0)+1)

; test for structs/strings
if ta ge 7 or te ge 7 then message, 'Illegal data type.'

; check arg,expo combos - use hard way if complex^(float|double|complex)
; or anything^complex
if ( ta eq 6 and te ge 4) or te eq 6 then begin

ans = exp( expo * alog( arg ) )

endif else begin

ans = arg^expo

endelse

return, ans
end
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: IDL Map Projections ( PLATE CARREE )
Next Topic: JPEG routines for IDL

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

Current Time: Sat Oct 11 10:33:44 PDT 2025

Total time taken to generate the page: 0.96342 seconds