[pypy-svn] r15359 - in pypy/dist/pypy/translator/c: . src test

cfbolz at codespeak.net cfbolz at codespeak.net
Fri Jul 29 17:52:12 CEST 2005


Author: cfbolz
Date: Fri Jul 29 17:52:10 2005
New Revision: 15359

Modified:
   pypy/dist/pypy/translator/c/extfunc.py
   pypy/dist/pypy/translator/c/src/ll_math.h
   pypy/dist/pypy/translator/c/test/test_extfunc.py
Log:
added support for math.hypot


Modified: pypy/dist/pypy/translator/c/extfunc.py
==============================================================================
--- pypy/dist/pypy/translator/c/extfunc.py	(original)
+++ pypy/dist/pypy/translator/c/extfunc.py	Fri Jul 29 17:52:10 2005
@@ -23,6 +23,7 @@
     ll_math.ll_math_fmod : 'LL_math_fmod',
     ll_math.ll_math_ldexp: 'LL_math_ldexp',
     ll_math.ll_math_modf:  'LL_math_modf',
+    ll_math.ll_math_hypot: 'LL_math_hypot',
     }
 
 #______________________________________________________

Modified: pypy/dist/pypy/translator/c/src/ll_math.h
==============================================================================
--- pypy/dist/pypy/translator/c/src/ll_math.h	(original)
+++ pypy/dist/pypy/translator/c/src/ll_math.h	Fri Jul 29 17:52:10 2005
@@ -31,6 +31,10 @@
   return ldexp(x, (int) y);
 }
 
+double LL_math_hypot(double x, double y) {
+  return hypot(x, y);
+}
+
 
 RPyMODF_RESULT* LL_math_modf(double x) {
   double intpart;

Modified: pypy/dist/pypy/translator/c/test/test_extfunc.py
==============================================================================
--- pypy/dist/pypy/translator/c/test/test_extfunc.py	(original)
+++ pypy/dist/pypy/translator/c/test/test_extfunc.py	Fri Jul 29 17:52:10 2005
@@ -103,6 +103,13 @@
     f = compile(fn, [float])
     assert f(10.123) == modf(10.123)
 
+def test_math_hypot():
+    from math import hypot
+    def fn(x, y):
+        return hypot(x, y)
+    f = compile(fn, [float, float])
+    assert f(9812.231, 1234) == hypot(9812.231, 1234)
+
 simple_math_functions = [
     'acos', 'asin', 'atan', 'ceil', 'cos', 'cosh', 'exp', 'fabs',
     'floor', 'log', 'log10', 'sin', 'sinh', 'sqrt', 'tan', 'tanh'



More information about the Pypy-commit mailing list