Re: Problem calling math.cos()

2006-04-23 Thread Alex Martelli
Thomas Bellman <[EMAIL PROTECTED]> wrote: > Alex Martelli <[EMAIL PROTECTED]> wrote: > > > C has no stand on complex numbers. > > If by that you mean that C does not have complex numbers, then > you are wrong. C99 defines the three types float _Complex, > double _Complex, and long double _Compl

Re: Problem calling math.cos()

2006-04-23 Thread Thomas Bellman
Alex Martelli <[EMAIL PROTECTED]> wrote: > C has no stand on complex numbers. If by that you mean that C does not have complex numbers, then you are wrong. C99 defines the three types float _Complex, double _Complex, and long double _Complex, and also the header . -- Thomas Bellman, Lysator

Re: Problem calling math.cos()

2006-04-22 Thread Robert Kern
Tim Peters wrote: > [Robert Kern] > >>... >>ph3 = math.atan( ac3.imag / ac3.real ) >>... > > Don't do that: atan2 is the correct way to compute the angle, because > the signs of both inputs are needed to determine the correct quadrant. > So do: > > ph3 = math.atan2(ac3.imag, ac3.real)

Re: Problem calling math.cos()

2006-04-22 Thread Sambo
Roy Smith wrote: > In article <[EMAIL PROTECTED]>, Sambo <[EMAIL PROTECTED]> > wrote: > > >>I have the following module: >>--- >>import math >> >>def ac_add_a_ph( amp1, ph1, amp2, ph2 ): >> >>amp3 = 0.0 >>ph3 = 0.0 >>ac1 = ( 0, 0j ) >>ac2 = ( 0, 0j )

Re: Problem calling math.cos()

2006-04-22 Thread Tim Peters
[Roy Smith] > I certainly agree about using atan2() instead of atan(), but I'm surprised > there's not an easier way to get the phase of a complex, just like abs() > gives you the modulus. I can see why you wouldn't want to pollute the > global namespace with another built-in just for this purpose

Re: Problem calling math.cos()

2006-04-22 Thread Roy Smith
In article <[EMAIL PROTECTED]>, "Tim Peters" <[EMAIL PROTECTED]> wrote: > [Robert Kern] > > ... > > ph3 = math.atan( ac3.imag / ac3.real ) > > ... > > Don't do that: atan2 is the correct way to compute the angle, because > the signs of both inputs are needed to determine the correct quadran

Re: Problem calling math.cos()

2006-04-22 Thread Tim Peters
[Robert Kern] > ... > ph3 = math.atan( ac3.imag / ac3.real ) > ... Don't do that: atan2 is the correct way to compute the angle, because the signs of both inputs are needed to determine the correct quadrant. So do: ph3 = math.atan2(ac3.imag, ac3.real) instead. -- http://mail.python.o

Re: Problem calling math.cos()

2006-04-22 Thread Felipe Almeida Lessa
Em Sáb, 2006-04-22 às 15:14 -0400, Sambo escreveu: > when I import it (electronics) in python.exe in windows2000 and > try to use it, it croaks. ??? $ python2.4 Python 2.4.3 (#2, Mar 30 2006, 21:52:26) [GCC 4.0.3 (Debian 4.0.3-1)] on linux2 Type "help", "copyright", "credits" or "license" for m

Re: Problem calling math.cos()

2006-04-22 Thread Robert Kern
Sambo wrote: > I have the following module: > --- > import math > > def ac_add_a_ph( amp1, ph1, amp2, ph2 ): > > amp3 = 0.0 > ph3 = 0.0 > ac1 = ( 0, 0j ) > ac2 = ( 0, 0j ) > ac3 = ( 0, 0j ) >

Re: Problem calling math.cos()

2006-04-22 Thread Alex Martelli
Sambo <[EMAIL PROTECTED]> wrote: > I have the following module: > --- > import math > > def ac_add_a_ph( amp1, ph1, amp2, ph2 ): > > amp3 = 0.0 > ph3 = 0.0 > ac1 = ( 0, 0j ) > ac2 = ( 0, 0j ) > ac3 = ( 0, 0j ) You're defining ac1, ac2, ac3 as tup

Re: Problem calling math.cos()

2006-04-22 Thread Roy Smith
In article <[EMAIL PROTECTED]>, Sambo <[EMAIL PROTECTED]> wrote: > I have the following module: > --- > import math > > def ac_add_a_ph( amp1, ph1, amp2, ph2 ): > > amp3 = 0.0 > ph3 = 0.0 > ac1 = ( 0, 0j ) > ac2 = ( 0, 0j )

Problem calling math.cos()

2006-04-22 Thread Sambo
I have the following module: --- import math def ac_add_a_ph( amp1, ph1, amp2, ph2 ): amp3 = 0.0 ph3 = 0.0 ac1 = ( 0, 0j ) ac2 = ( 0, 0j ) ac3 = ( 0, 0j ) ac1 = complex( amp1 * math.cos( mat