[pypy-svn] r75873 - pypy/branch/fast-forward/lib_pypy
benjamin at codespeak.net
benjamin at codespeak.net
Tue Jul 6 01:39:35 CEST 2010
Author: benjamin
Date: Tue Jul 6 01:39:33 2010
New Revision: 75873
Modified:
pypy/branch/fast-forward/lib_pypy/cmath.py
Log:
simple new cmath functions
Modified: pypy/branch/fast-forward/lib_pypy/cmath.py
==============================================================================
--- pypy/branch/fast-forward/lib_pypy/cmath.py (original)
+++ pypy/branch/fast-forward/lib_pypy/cmath.py Tue Jul 6 01:39:33 2010
@@ -24,6 +24,23 @@
return complex(real, imag)
+def phase(x):
+ x = complex(x)
+ return math.atan2(x.imag, x.real)
+
+
+def polar(x):
+ x = complex(x)
+ phi = math.atan2(x.imag, x.real)
+ r = abs(x)
+ return r, phi
+
+
+def rect(r, phi):
+ r, phi = complex(r), complex(phi)
+ return complex(r * math.cos(phi), r * math.sin(phi))
+
+
def acos(x):
"""acos(x)
More information about the Pypy-commit
mailing list