[pypy-svn] r15268 - in pypy/dist/pypy: module/math rpython rpython/module rpython/module/test

ale at codespeak.net ale at codespeak.net
Thu Jul 28 18:14:19 CEST 2005


Author: ale
Date: Thu Jul 28 18:14:17 2005
New Revision: 15268

Modified:
   pypy/dist/pypy/module/math/__init__.py
   pypy/dist/pypy/rpython/extfunctable.py
   pypy/dist/pypy/rpython/module/ll_math.py
   pypy/dist/pypy/rpython/module/test/test_ll_math.py
Log:
added math.sqrt, sin, cos, sinh, hypot (needed for lib-python)

Modified: pypy/dist/pypy/module/math/__init__.py
==============================================================================
--- pypy/dist/pypy/module/math/__init__.py	(original)
+++ pypy/dist/pypy/module/math/__init__.py	Thu Jul 28 18:14:17 2005
@@ -10,33 +10,36 @@
     #     is that we need to add support to
     #     extfunctable/translation
     interpleveldefs = {
-       'e'              : 'interp_math.get(space).w_e', 
-       'pi'             : 'interp_math.get(space).w_pi', 
-       #'pow'            : 'interp_math.pow',
-       #'cosh'           : 'interp_math.cosh',
-       'ldexp'          : 'interp_math.ldexp',
-       #'hypot'          : 'interp_math.hypot',
-       #'tan'            : 'interp_math.tan',
-       #'asin'           : 'interp_math.asin',
-       #'log'            : 'interp_math.log',
-       #'fabs'           : 'interp_math.fabs',
-       'floor'          : 'interp_math.floor',
-       #'sqrt'           : 'interp_math.sqrt',
-       'frexp'          : 'interp_math.frexp',
-       #'degrees'        : 'interp_math.degrees',
-       'log'             : 'interp_math.log',
-       'log10'          : 'interp_math.log10',
-       'fmod'           : 'interp_math.fmod',
-       #'atan'           : 'interp_math.atan',
-       'ceil'           : 'interp_math.ceil',
-       #'sinh'           : 'interp_math.sinh',
-       #'cos'            : 'interp_math.cos',
-       #'tanh'           : 'interp_math.tanh',
-       #'radians'        : 'interp_math.radians',
-       #'sin'            : 'interp_math.sin',
-       'atan2'          : 'interp_math.atan2',
-       'modf'           : 'interp_math.modf',
-       'exp'            : 'interp_math.exp',
-       #'acos'           : 'interp_math.acos',
+           'e'              : 'interp_math.get(space).w_e', 
+           'pi'             : 'interp_math.get(space).w_pi', 
+           #'pow'            : 'interp_math.pow',
+           #'cosh'           : 'interp_math.cosh',
+           'ldexp'          : 'interp_math.ldexp',
+           'hypot'          : 'interp_math.hypot',
+           #'tan'            : 'interp_math.tan',
+           #'asin'           : 'interp_math.asin',
+           #'log'            : 'interp_math.log',
+           #'fabs'           : 'interp_math.fabs',
+           'floor'          : 'interp_math.floor',
+           #'sqrt'           : 'interp_math.sqrt',
+           'frexp'          : 'interp_math.frexp',
+           #'degrees'        : 'interp_math.degrees',
+           'log'             : 'interp_math.log',
+           'log10'          : 'interp_math.log10',
+           'fmod'           : 'interp_math.fmod',
+           #'atan'           : 'interp_math.atan',
+           'ceil'           : 'interp_math.ceil',
+           'sinh'           : 'interp_math.sinh',
+           'acos'           : 'interp_math.acos',
+           'sin'            : 'interp_math.sin',
+           'sqrt'           : 'interp_math.sqrt',
+           'cos'            : 'interp_math.cos',
+           #'tanh'           : 'interp_math.tanh',
+           #'radians'        : 'interp_math.radians',
+           #'sin'            : 'interp_math.sin',
+           'atan2'          : 'interp_math.atan2',
+           'modf'           : 'interp_math.modf',
+           'exp'            : 'interp_math.exp',
+           'acos'           : 'interp_math.acos',
 
 }

Modified: pypy/dist/pypy/rpython/extfunctable.py
==============================================================================
--- pypy/dist/pypy/rpython/extfunctable.py	(original)
+++ pypy/dist/pypy/rpython/extfunctable.py	Thu Jul 28 18:14:17 2005
@@ -85,6 +85,12 @@
 declare(time.sleep  , noneannotation, 'll_time/sleep')
 declare(math.log10  , float         , 'll_math/log10')
 declare(math.log    , float         , 'll_math/log')
+declare(math.cos    , float         , 'll_math/cos')
+declare(math.sin    , float         , 'll_math/sin')
+declare(math.sinh   , float         , 'll_math/sinh')
+declare(math.acos   , float         , 'll_math/acos')
+declare(math.sqrt   , float         , 'll_math/sqrt')
+declare(math.hypot  , float         , 'll_math/hypot')
 declare(math.ceil   , float         , 'll_math/ceil')
 declare(math.frexp  , frexpannotation, 'll_math/frexp')
 declare(math.atan2  , float         , 'll_math/atan2')

Modified: pypy/dist/pypy/rpython/module/ll_math.py
==============================================================================
--- pypy/dist/pypy/rpython/module/ll_math.py	(original)
+++ pypy/dist/pypy/rpython/module/ll_math.py	Thu Jul 28 18:14:17 2005
@@ -2,6 +2,30 @@
 
 import math
 
+def ll_math_cos(x):
+    return math.cos(x)
+ll_math_cos.suggested_primitive = True
+
+def ll_math_sin(x):
+    return math.sin(x)
+ll_math_sin.suggested_primitive = True
+
+def ll_math_sinh(x):
+    return math.sinh(x)
+ll_math_sinh.suggested_primitive = True
+
+def ll_math_hypot(x, y):
+    return math.hypot(x, y)
+ll_math_hypot.suggested_primitive = True
+
+def ll_math_acos(x):
+    return math.acos(x)
+ll_math_acos.suggested_primitive = True
+
+def ll_math_sqrt(x):
+    return math.sqrt(x)
+ll_math_sqrt.suggested_primitive = True
+
 def ll_math_log(x):
     return math.log(x)
 ll_math_log.suggested_primitive = True

Modified: pypy/dist/pypy/rpython/module/test/test_ll_math.py
==============================================================================
--- pypy/dist/pypy/rpython/module/test/test_ll_math.py	(original)
+++ pypy/dist/pypy/rpython/module/test/test_ll_math.py	Thu Jul 28 18:14:17 2005
@@ -19,3 +19,17 @@
 def test_ll_log():
     assert ll_math_log(8943.790148912) == math.log(8943.790148912)
     assert ll_math_log10(8943.790148912) == math.log10(8943.790148912)
+
+def test_ll_cos_sin():
+    assert ll_math_cos(math.pi/3) == math.cos(math.pi/3)
+    assert ll_math_sin(math.pi/3) == math.sin(math.pi/3)
+    assert ll_math_acos(1./3) == math.acos(1./3)
+    assert ll_math_sinh(math.pi/3) == math.sinh(math.pi/3)
+    assert ll_math_cosh(math.pi/3) == math.cosh(math.pi/3)
+    
+def test_ll_math_sqrt():
+    assert ll_math_sqrt(10) == math.sqrt(10)
+    
+def test_ll_math_hypot():
+    assert ll_math_hypot(math.pi/3,3) == math.hypot(math.pi/3,3)
+    



More information about the Pypy-commit mailing list