You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1246 lines
37 KiB

30 years ago
30 years ago
30 years ago
30 years ago
30 years ago
30 years ago
30 years ago
Merged revisions 62386-62387,62389-62393,62396,62400-62402,62407,62409-62410,62412-62414,62418-62419 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r62386 | christian.heimes | 2008-04-19 04:23:57 +0200 (Sat, 19 Apr 2008) | 2 lines Added kill, terminate and send_signal to subprocess.Popen The bits and pieces for the Windows side were already in place. The POSIX side is trivial (as usual) and uses os.kill(). ........ r62387 | georg.brandl | 2008-04-19 10:23:59 +0200 (Sat, 19 Apr 2008) | 2 lines Fix-up docs for revision 62386. ........ r62389 | georg.brandl | 2008-04-19 18:57:43 +0200 (Sat, 19 Apr 2008) | 2 lines #2369: clarify that copyfile() doesn't take a target directory. ........ r62390 | georg.brandl | 2008-04-19 18:58:28 +0200 (Sat, 19 Apr 2008) | 2 lines #2634: clarify meaning of env parameter to spawn/exec*e. ........ r62391 | georg.brandl | 2008-04-19 18:58:49 +0200 (Sat, 19 Apr 2008) | 2 lines #2633: clarify meaning of env parameter. ........ r62392 | georg.brandl | 2008-04-19 18:59:16 +0200 (Sat, 19 Apr 2008) | 2 lines #2631: clarify IMPORT_NAME semantics. ........ r62393 | georg.brandl | 2008-04-19 19:00:14 +0200 (Sat, 19 Apr 2008) | 2 lines :func: et al. should *not* include the parens. ........ r62396 | mark.dickinson | 2008-04-19 20:51:48 +0200 (Sat, 19 Apr 2008) | 5 lines Additional tests for math.pow, and extra special-case handling code in math.pow, in the hope of making all tests pass on the alpha Tru64 buildbot. ........ r62400 | mark.dickinson | 2008-04-19 21:41:52 +0200 (Sat, 19 Apr 2008) | 3 lines Additional special-case handling for math.pow. Windows/VS2008 doesn't like (-1)**(+-inf). ........ r62401 | benjamin.peterson | 2008-04-19 21:47:34 +0200 (Sat, 19 Apr 2008) | 2 lines Complete documentation for errors argument of io's open and TextIOWrapper ........ r62402 | mark.dickinson | 2008-04-19 22:31:16 +0200 (Sat, 19 Apr 2008) | 2 lines Document updates to math and cmath modules. ........ r62407 | georg.brandl | 2008-04-19 23:28:38 +0200 (Sat, 19 Apr 2008) | 2 lines Update template for newest Sphinx. ........ r62409 | mark.dickinson | 2008-04-19 23:35:35 +0200 (Sat, 19 Apr 2008) | 5 lines Correct documentation for math.pow; 0**nan is nan, not 0. (But nan**0 and 1**nan are 1.) Also fix minor typo: 'quite NaN' -> 'quiet NaN' ........ r62410 | mark.dickinson | 2008-04-19 23:49:22 +0200 (Sat, 19 Apr 2008) | 4 lines Move asinh documentation to the proper place. Remove meaningless 'in radians' from inverse hyperbolic functions. ........ r62412 | mark.dickinson | 2008-04-20 03:22:30 +0200 (Sun, 20 Apr 2008) | 5 lines Report additional diagnostic information in test_math, to help track down debian-alpha buildbot failure. ........ r62413 | mark.dickinson | 2008-04-20 03:39:24 +0200 (Sun, 20 Apr 2008) | 3 lines FreeBSD doesn't follow C99 for modf(inf); so add explicit special-value handling to math.modf code. ........ r62414 | mark.dickinson | 2008-04-20 06:13:13 +0200 (Sun, 20 Apr 2008) | 5 lines Yet more explicit special case handling to make math.pow behave on alpha Tru64. All IEEE 754 special values are now handled directly; only the finite**finite case is handled by libm. ........ r62418 | mark.dickinson | 2008-04-20 18:13:17 +0200 (Sun, 20 Apr 2008) | 7 lines Issue 2662: Initialize special value tables dynamically (i.e. when cmath module is loaded) instead of statically. This fixes compile-time problems on platforms where HUGE_VAL is an extern variable rather than a constant. Thanks Hirokazu Yamamoto for the patch. ........ r62419 | andrew.kuchling | 2008-04-20 18:54:02 +0200 (Sun, 20 Apr 2008) | 1 line Move description of math module changes; various edits to description of cmath changes ........
18 years ago
Merged revisions 62386-62387,62389-62393,62396,62400-62402,62407,62409-62410,62412-62414,62418-62419 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r62386 | christian.heimes | 2008-04-19 04:23:57 +0200 (Sat, 19 Apr 2008) | 2 lines Added kill, terminate and send_signal to subprocess.Popen The bits and pieces for the Windows side were already in place. The POSIX side is trivial (as usual) and uses os.kill(). ........ r62387 | georg.brandl | 2008-04-19 10:23:59 +0200 (Sat, 19 Apr 2008) | 2 lines Fix-up docs for revision 62386. ........ r62389 | georg.brandl | 2008-04-19 18:57:43 +0200 (Sat, 19 Apr 2008) | 2 lines #2369: clarify that copyfile() doesn't take a target directory. ........ r62390 | georg.brandl | 2008-04-19 18:58:28 +0200 (Sat, 19 Apr 2008) | 2 lines #2634: clarify meaning of env parameter to spawn/exec*e. ........ r62391 | georg.brandl | 2008-04-19 18:58:49 +0200 (Sat, 19 Apr 2008) | 2 lines #2633: clarify meaning of env parameter. ........ r62392 | georg.brandl | 2008-04-19 18:59:16 +0200 (Sat, 19 Apr 2008) | 2 lines #2631: clarify IMPORT_NAME semantics. ........ r62393 | georg.brandl | 2008-04-19 19:00:14 +0200 (Sat, 19 Apr 2008) | 2 lines :func: et al. should *not* include the parens. ........ r62396 | mark.dickinson | 2008-04-19 20:51:48 +0200 (Sat, 19 Apr 2008) | 5 lines Additional tests for math.pow, and extra special-case handling code in math.pow, in the hope of making all tests pass on the alpha Tru64 buildbot. ........ r62400 | mark.dickinson | 2008-04-19 21:41:52 +0200 (Sat, 19 Apr 2008) | 3 lines Additional special-case handling for math.pow. Windows/VS2008 doesn't like (-1)**(+-inf). ........ r62401 | benjamin.peterson | 2008-04-19 21:47:34 +0200 (Sat, 19 Apr 2008) | 2 lines Complete documentation for errors argument of io's open and TextIOWrapper ........ r62402 | mark.dickinson | 2008-04-19 22:31:16 +0200 (Sat, 19 Apr 2008) | 2 lines Document updates to math and cmath modules. ........ r62407 | georg.brandl | 2008-04-19 23:28:38 +0200 (Sat, 19 Apr 2008) | 2 lines Update template for newest Sphinx. ........ r62409 | mark.dickinson | 2008-04-19 23:35:35 +0200 (Sat, 19 Apr 2008) | 5 lines Correct documentation for math.pow; 0**nan is nan, not 0. (But nan**0 and 1**nan are 1.) Also fix minor typo: 'quite NaN' -> 'quiet NaN' ........ r62410 | mark.dickinson | 2008-04-19 23:49:22 +0200 (Sat, 19 Apr 2008) | 4 lines Move asinh documentation to the proper place. Remove meaningless 'in radians' from inverse hyperbolic functions. ........ r62412 | mark.dickinson | 2008-04-20 03:22:30 +0200 (Sun, 20 Apr 2008) | 5 lines Report additional diagnostic information in test_math, to help track down debian-alpha buildbot failure. ........ r62413 | mark.dickinson | 2008-04-20 03:39:24 +0200 (Sun, 20 Apr 2008) | 3 lines FreeBSD doesn't follow C99 for modf(inf); so add explicit special-value handling to math.modf code. ........ r62414 | mark.dickinson | 2008-04-20 06:13:13 +0200 (Sun, 20 Apr 2008) | 5 lines Yet more explicit special case handling to make math.pow behave on alpha Tru64. All IEEE 754 special values are now handled directly; only the finite**finite case is handled by libm. ........ r62418 | mark.dickinson | 2008-04-20 18:13:17 +0200 (Sun, 20 Apr 2008) | 7 lines Issue 2662: Initialize special value tables dynamically (i.e. when cmath module is loaded) instead of statically. This fixes compile-time problems on platforms where HUGE_VAL is an extern variable rather than a constant. Thanks Hirokazu Yamamoto for the patch. ........ r62419 | andrew.kuchling | 2008-04-20 18:54:02 +0200 (Sun, 20 Apr 2008) | 1 line Move description of math module changes; various edits to description of cmath changes ........
18 years ago
30 years ago
30 years ago
30 years ago
Merged revisions 62386-62387,62389-62393,62396,62400-62402,62407,62409-62410,62412-62414,62418-62419 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r62386 | christian.heimes | 2008-04-19 04:23:57 +0200 (Sat, 19 Apr 2008) | 2 lines Added kill, terminate and send_signal to subprocess.Popen The bits and pieces for the Windows side were already in place. The POSIX side is trivial (as usual) and uses os.kill(). ........ r62387 | georg.brandl | 2008-04-19 10:23:59 +0200 (Sat, 19 Apr 2008) | 2 lines Fix-up docs for revision 62386. ........ r62389 | georg.brandl | 2008-04-19 18:57:43 +0200 (Sat, 19 Apr 2008) | 2 lines #2369: clarify that copyfile() doesn't take a target directory. ........ r62390 | georg.brandl | 2008-04-19 18:58:28 +0200 (Sat, 19 Apr 2008) | 2 lines #2634: clarify meaning of env parameter to spawn/exec*e. ........ r62391 | georg.brandl | 2008-04-19 18:58:49 +0200 (Sat, 19 Apr 2008) | 2 lines #2633: clarify meaning of env parameter. ........ r62392 | georg.brandl | 2008-04-19 18:59:16 +0200 (Sat, 19 Apr 2008) | 2 lines #2631: clarify IMPORT_NAME semantics. ........ r62393 | georg.brandl | 2008-04-19 19:00:14 +0200 (Sat, 19 Apr 2008) | 2 lines :func: et al. should *not* include the parens. ........ r62396 | mark.dickinson | 2008-04-19 20:51:48 +0200 (Sat, 19 Apr 2008) | 5 lines Additional tests for math.pow, and extra special-case handling code in math.pow, in the hope of making all tests pass on the alpha Tru64 buildbot. ........ r62400 | mark.dickinson | 2008-04-19 21:41:52 +0200 (Sat, 19 Apr 2008) | 3 lines Additional special-case handling for math.pow. Windows/VS2008 doesn't like (-1)**(+-inf). ........ r62401 | benjamin.peterson | 2008-04-19 21:47:34 +0200 (Sat, 19 Apr 2008) | 2 lines Complete documentation for errors argument of io's open and TextIOWrapper ........ r62402 | mark.dickinson | 2008-04-19 22:31:16 +0200 (Sat, 19 Apr 2008) | 2 lines Document updates to math and cmath modules. ........ r62407 | georg.brandl | 2008-04-19 23:28:38 +0200 (Sat, 19 Apr 2008) | 2 lines Update template for newest Sphinx. ........ r62409 | mark.dickinson | 2008-04-19 23:35:35 +0200 (Sat, 19 Apr 2008) | 5 lines Correct documentation for math.pow; 0**nan is nan, not 0. (But nan**0 and 1**nan are 1.) Also fix minor typo: 'quite NaN' -> 'quiet NaN' ........ r62410 | mark.dickinson | 2008-04-19 23:49:22 +0200 (Sat, 19 Apr 2008) | 4 lines Move asinh documentation to the proper place. Remove meaningless 'in radians' from inverse hyperbolic functions. ........ r62412 | mark.dickinson | 2008-04-20 03:22:30 +0200 (Sun, 20 Apr 2008) | 5 lines Report additional diagnostic information in test_math, to help track down debian-alpha buildbot failure. ........ r62413 | mark.dickinson | 2008-04-20 03:39:24 +0200 (Sun, 20 Apr 2008) | 3 lines FreeBSD doesn't follow C99 for modf(inf); so add explicit special-value handling to math.modf code. ........ r62414 | mark.dickinson | 2008-04-20 06:13:13 +0200 (Sun, 20 Apr 2008) | 5 lines Yet more explicit special case handling to make math.pow behave on alpha Tru64. All IEEE 754 special values are now handled directly; only the finite**finite case is handled by libm. ........ r62418 | mark.dickinson | 2008-04-20 18:13:17 +0200 (Sun, 20 Apr 2008) | 7 lines Issue 2662: Initialize special value tables dynamically (i.e. when cmath module is loaded) instead of statically. This fixes compile-time problems on platforms where HUGE_VAL is an extern variable rather than a constant. Thanks Hirokazu Yamamoto for the patch. ........ r62419 | andrew.kuchling | 2008-04-20 18:54:02 +0200 (Sun, 20 Apr 2008) | 1 line Move description of math module changes; various edits to description of cmath changes ........
18 years ago
30 years ago
30 years ago
30 years ago
30 years ago
Merged revisions 62386-62387,62389-62393,62396,62400-62402,62407,62409-62410,62412-62414,62418-62419 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r62386 | christian.heimes | 2008-04-19 04:23:57 +0200 (Sat, 19 Apr 2008) | 2 lines Added kill, terminate and send_signal to subprocess.Popen The bits and pieces for the Windows side were already in place. The POSIX side is trivial (as usual) and uses os.kill(). ........ r62387 | georg.brandl | 2008-04-19 10:23:59 +0200 (Sat, 19 Apr 2008) | 2 lines Fix-up docs for revision 62386. ........ r62389 | georg.brandl | 2008-04-19 18:57:43 +0200 (Sat, 19 Apr 2008) | 2 lines #2369: clarify that copyfile() doesn't take a target directory. ........ r62390 | georg.brandl | 2008-04-19 18:58:28 +0200 (Sat, 19 Apr 2008) | 2 lines #2634: clarify meaning of env parameter to spawn/exec*e. ........ r62391 | georg.brandl | 2008-04-19 18:58:49 +0200 (Sat, 19 Apr 2008) | 2 lines #2633: clarify meaning of env parameter. ........ r62392 | georg.brandl | 2008-04-19 18:59:16 +0200 (Sat, 19 Apr 2008) | 2 lines #2631: clarify IMPORT_NAME semantics. ........ r62393 | georg.brandl | 2008-04-19 19:00:14 +0200 (Sat, 19 Apr 2008) | 2 lines :func: et al. should *not* include the parens. ........ r62396 | mark.dickinson | 2008-04-19 20:51:48 +0200 (Sat, 19 Apr 2008) | 5 lines Additional tests for math.pow, and extra special-case handling code in math.pow, in the hope of making all tests pass on the alpha Tru64 buildbot. ........ r62400 | mark.dickinson | 2008-04-19 21:41:52 +0200 (Sat, 19 Apr 2008) | 3 lines Additional special-case handling for math.pow. Windows/VS2008 doesn't like (-1)**(+-inf). ........ r62401 | benjamin.peterson | 2008-04-19 21:47:34 +0200 (Sat, 19 Apr 2008) | 2 lines Complete documentation for errors argument of io's open and TextIOWrapper ........ r62402 | mark.dickinson | 2008-04-19 22:31:16 +0200 (Sat, 19 Apr 2008) | 2 lines Document updates to math and cmath modules. ........ r62407 | georg.brandl | 2008-04-19 23:28:38 +0200 (Sat, 19 Apr 2008) | 2 lines Update template for newest Sphinx. ........ r62409 | mark.dickinson | 2008-04-19 23:35:35 +0200 (Sat, 19 Apr 2008) | 5 lines Correct documentation for math.pow; 0**nan is nan, not 0. (But nan**0 and 1**nan are 1.) Also fix minor typo: 'quite NaN' -> 'quiet NaN' ........ r62410 | mark.dickinson | 2008-04-19 23:49:22 +0200 (Sat, 19 Apr 2008) | 4 lines Move asinh documentation to the proper place. Remove meaningless 'in radians' from inverse hyperbolic functions. ........ r62412 | mark.dickinson | 2008-04-20 03:22:30 +0200 (Sun, 20 Apr 2008) | 5 lines Report additional diagnostic information in test_math, to help track down debian-alpha buildbot failure. ........ r62413 | mark.dickinson | 2008-04-20 03:39:24 +0200 (Sun, 20 Apr 2008) | 3 lines FreeBSD doesn't follow C99 for modf(inf); so add explicit special-value handling to math.modf code. ........ r62414 | mark.dickinson | 2008-04-20 06:13:13 +0200 (Sun, 20 Apr 2008) | 5 lines Yet more explicit special case handling to make math.pow behave on alpha Tru64. All IEEE 754 special values are now handled directly; only the finite**finite case is handled by libm. ........ r62418 | mark.dickinson | 2008-04-20 18:13:17 +0200 (Sun, 20 Apr 2008) | 7 lines Issue 2662: Initialize special value tables dynamically (i.e. when cmath module is loaded) instead of statically. This fixes compile-time problems on platforms where HUGE_VAL is an extern variable rather than a constant. Thanks Hirokazu Yamamoto for the patch. ........ r62419 | andrew.kuchling | 2008-04-20 18:54:02 +0200 (Sun, 20 Apr 2008) | 1 line Move description of math module changes; various edits to description of cmath changes ........
18 years ago
30 years ago
30 years ago
30 years ago
30 years ago
Merged revisions 62386-62387,62389-62393,62396,62400-62402,62407,62409-62410,62412-62414,62418-62419 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r62386 | christian.heimes | 2008-04-19 04:23:57 +0200 (Sat, 19 Apr 2008) | 2 lines Added kill, terminate and send_signal to subprocess.Popen The bits and pieces for the Windows side were already in place. The POSIX side is trivial (as usual) and uses os.kill(). ........ r62387 | georg.brandl | 2008-04-19 10:23:59 +0200 (Sat, 19 Apr 2008) | 2 lines Fix-up docs for revision 62386. ........ r62389 | georg.brandl | 2008-04-19 18:57:43 +0200 (Sat, 19 Apr 2008) | 2 lines #2369: clarify that copyfile() doesn't take a target directory. ........ r62390 | georg.brandl | 2008-04-19 18:58:28 +0200 (Sat, 19 Apr 2008) | 2 lines #2634: clarify meaning of env parameter to spawn/exec*e. ........ r62391 | georg.brandl | 2008-04-19 18:58:49 +0200 (Sat, 19 Apr 2008) | 2 lines #2633: clarify meaning of env parameter. ........ r62392 | georg.brandl | 2008-04-19 18:59:16 +0200 (Sat, 19 Apr 2008) | 2 lines #2631: clarify IMPORT_NAME semantics. ........ r62393 | georg.brandl | 2008-04-19 19:00:14 +0200 (Sat, 19 Apr 2008) | 2 lines :func: et al. should *not* include the parens. ........ r62396 | mark.dickinson | 2008-04-19 20:51:48 +0200 (Sat, 19 Apr 2008) | 5 lines Additional tests for math.pow, and extra special-case handling code in math.pow, in the hope of making all tests pass on the alpha Tru64 buildbot. ........ r62400 | mark.dickinson | 2008-04-19 21:41:52 +0200 (Sat, 19 Apr 2008) | 3 lines Additional special-case handling for math.pow. Windows/VS2008 doesn't like (-1)**(+-inf). ........ r62401 | benjamin.peterson | 2008-04-19 21:47:34 +0200 (Sat, 19 Apr 2008) | 2 lines Complete documentation for errors argument of io's open and TextIOWrapper ........ r62402 | mark.dickinson | 2008-04-19 22:31:16 +0200 (Sat, 19 Apr 2008) | 2 lines Document updates to math and cmath modules. ........ r62407 | georg.brandl | 2008-04-19 23:28:38 +0200 (Sat, 19 Apr 2008) | 2 lines Update template for newest Sphinx. ........ r62409 | mark.dickinson | 2008-04-19 23:35:35 +0200 (Sat, 19 Apr 2008) | 5 lines Correct documentation for math.pow; 0**nan is nan, not 0. (But nan**0 and 1**nan are 1.) Also fix minor typo: 'quite NaN' -> 'quiet NaN' ........ r62410 | mark.dickinson | 2008-04-19 23:49:22 +0200 (Sat, 19 Apr 2008) | 4 lines Move asinh documentation to the proper place. Remove meaningless 'in radians' from inverse hyperbolic functions. ........ r62412 | mark.dickinson | 2008-04-20 03:22:30 +0200 (Sun, 20 Apr 2008) | 5 lines Report additional diagnostic information in test_math, to help track down debian-alpha buildbot failure. ........ r62413 | mark.dickinson | 2008-04-20 03:39:24 +0200 (Sun, 20 Apr 2008) | 3 lines FreeBSD doesn't follow C99 for modf(inf); so add explicit special-value handling to math.modf code. ........ r62414 | mark.dickinson | 2008-04-20 06:13:13 +0200 (Sun, 20 Apr 2008) | 5 lines Yet more explicit special case handling to make math.pow behave on alpha Tru64. All IEEE 754 special values are now handled directly; only the finite**finite case is handled by libm. ........ r62418 | mark.dickinson | 2008-04-20 18:13:17 +0200 (Sun, 20 Apr 2008) | 7 lines Issue 2662: Initialize special value tables dynamically (i.e. when cmath module is loaded) instead of statically. This fixes compile-time problems on platforms where HUGE_VAL is an extern variable rather than a constant. Thanks Hirokazu Yamamoto for the patch. ........ r62419 | andrew.kuchling | 2008-04-20 18:54:02 +0200 (Sun, 20 Apr 2008) | 1 line Move description of math module changes; various edits to description of cmath changes ........
18 years ago
30 years ago
30 years ago
30 years ago
30 years ago
Merged revisions 62386-62387,62389-62393,62396,62400-62402,62407,62409-62410,62412-62414,62418-62419 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r62386 | christian.heimes | 2008-04-19 04:23:57 +0200 (Sat, 19 Apr 2008) | 2 lines Added kill, terminate and send_signal to subprocess.Popen The bits and pieces for the Windows side were already in place. The POSIX side is trivial (as usual) and uses os.kill(). ........ r62387 | georg.brandl | 2008-04-19 10:23:59 +0200 (Sat, 19 Apr 2008) | 2 lines Fix-up docs for revision 62386. ........ r62389 | georg.brandl | 2008-04-19 18:57:43 +0200 (Sat, 19 Apr 2008) | 2 lines #2369: clarify that copyfile() doesn't take a target directory. ........ r62390 | georg.brandl | 2008-04-19 18:58:28 +0200 (Sat, 19 Apr 2008) | 2 lines #2634: clarify meaning of env parameter to spawn/exec*e. ........ r62391 | georg.brandl | 2008-04-19 18:58:49 +0200 (Sat, 19 Apr 2008) | 2 lines #2633: clarify meaning of env parameter. ........ r62392 | georg.brandl | 2008-04-19 18:59:16 +0200 (Sat, 19 Apr 2008) | 2 lines #2631: clarify IMPORT_NAME semantics. ........ r62393 | georg.brandl | 2008-04-19 19:00:14 +0200 (Sat, 19 Apr 2008) | 2 lines :func: et al. should *not* include the parens. ........ r62396 | mark.dickinson | 2008-04-19 20:51:48 +0200 (Sat, 19 Apr 2008) | 5 lines Additional tests for math.pow, and extra special-case handling code in math.pow, in the hope of making all tests pass on the alpha Tru64 buildbot. ........ r62400 | mark.dickinson | 2008-04-19 21:41:52 +0200 (Sat, 19 Apr 2008) | 3 lines Additional special-case handling for math.pow. Windows/VS2008 doesn't like (-1)**(+-inf). ........ r62401 | benjamin.peterson | 2008-04-19 21:47:34 +0200 (Sat, 19 Apr 2008) | 2 lines Complete documentation for errors argument of io's open and TextIOWrapper ........ r62402 | mark.dickinson | 2008-04-19 22:31:16 +0200 (Sat, 19 Apr 2008) | 2 lines Document updates to math and cmath modules. ........ r62407 | georg.brandl | 2008-04-19 23:28:38 +0200 (Sat, 19 Apr 2008) | 2 lines Update template for newest Sphinx. ........ r62409 | mark.dickinson | 2008-04-19 23:35:35 +0200 (Sat, 19 Apr 2008) | 5 lines Correct documentation for math.pow; 0**nan is nan, not 0. (But nan**0 and 1**nan are 1.) Also fix minor typo: 'quite NaN' -> 'quiet NaN' ........ r62410 | mark.dickinson | 2008-04-19 23:49:22 +0200 (Sat, 19 Apr 2008) | 4 lines Move asinh documentation to the proper place. Remove meaningless 'in radians' from inverse hyperbolic functions. ........ r62412 | mark.dickinson | 2008-04-20 03:22:30 +0200 (Sun, 20 Apr 2008) | 5 lines Report additional diagnostic information in test_math, to help track down debian-alpha buildbot failure. ........ r62413 | mark.dickinson | 2008-04-20 03:39:24 +0200 (Sun, 20 Apr 2008) | 3 lines FreeBSD doesn't follow C99 for modf(inf); so add explicit special-value handling to math.modf code. ........ r62414 | mark.dickinson | 2008-04-20 06:13:13 +0200 (Sun, 20 Apr 2008) | 5 lines Yet more explicit special case handling to make math.pow behave on alpha Tru64. All IEEE 754 special values are now handled directly; only the finite**finite case is handled by libm. ........ r62418 | mark.dickinson | 2008-04-20 18:13:17 +0200 (Sun, 20 Apr 2008) | 7 lines Issue 2662: Initialize special value tables dynamically (i.e. when cmath module is loaded) instead of statically. This fixes compile-time problems on platforms where HUGE_VAL is an extern variable rather than a constant. Thanks Hirokazu Yamamoto for the patch. ........ r62419 | andrew.kuchling | 2008-04-20 18:54:02 +0200 (Sun, 20 Apr 2008) | 1 line Move description of math module changes; various edits to description of cmath changes ........
18 years ago
30 years ago
30 years ago
Merged revisions 62386-62387,62389-62393,62396,62400-62402,62407,62409-62410,62412-62414,62418-62419 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r62386 | christian.heimes | 2008-04-19 04:23:57 +0200 (Sat, 19 Apr 2008) | 2 lines Added kill, terminate and send_signal to subprocess.Popen The bits and pieces for the Windows side were already in place. The POSIX side is trivial (as usual) and uses os.kill(). ........ r62387 | georg.brandl | 2008-04-19 10:23:59 +0200 (Sat, 19 Apr 2008) | 2 lines Fix-up docs for revision 62386. ........ r62389 | georg.brandl | 2008-04-19 18:57:43 +0200 (Sat, 19 Apr 2008) | 2 lines #2369: clarify that copyfile() doesn't take a target directory. ........ r62390 | georg.brandl | 2008-04-19 18:58:28 +0200 (Sat, 19 Apr 2008) | 2 lines #2634: clarify meaning of env parameter to spawn/exec*e. ........ r62391 | georg.brandl | 2008-04-19 18:58:49 +0200 (Sat, 19 Apr 2008) | 2 lines #2633: clarify meaning of env parameter. ........ r62392 | georg.brandl | 2008-04-19 18:59:16 +0200 (Sat, 19 Apr 2008) | 2 lines #2631: clarify IMPORT_NAME semantics. ........ r62393 | georg.brandl | 2008-04-19 19:00:14 +0200 (Sat, 19 Apr 2008) | 2 lines :func: et al. should *not* include the parens. ........ r62396 | mark.dickinson | 2008-04-19 20:51:48 +0200 (Sat, 19 Apr 2008) | 5 lines Additional tests for math.pow, and extra special-case handling code in math.pow, in the hope of making all tests pass on the alpha Tru64 buildbot. ........ r62400 | mark.dickinson | 2008-04-19 21:41:52 +0200 (Sat, 19 Apr 2008) | 3 lines Additional special-case handling for math.pow. Windows/VS2008 doesn't like (-1)**(+-inf). ........ r62401 | benjamin.peterson | 2008-04-19 21:47:34 +0200 (Sat, 19 Apr 2008) | 2 lines Complete documentation for errors argument of io's open and TextIOWrapper ........ r62402 | mark.dickinson | 2008-04-19 22:31:16 +0200 (Sat, 19 Apr 2008) | 2 lines Document updates to math and cmath modules. ........ r62407 | georg.brandl | 2008-04-19 23:28:38 +0200 (Sat, 19 Apr 2008) | 2 lines Update template for newest Sphinx. ........ r62409 | mark.dickinson | 2008-04-19 23:35:35 +0200 (Sat, 19 Apr 2008) | 5 lines Correct documentation for math.pow; 0**nan is nan, not 0. (But nan**0 and 1**nan are 1.) Also fix minor typo: 'quite NaN' -> 'quiet NaN' ........ r62410 | mark.dickinson | 2008-04-19 23:49:22 +0200 (Sat, 19 Apr 2008) | 4 lines Move asinh documentation to the proper place. Remove meaningless 'in radians' from inverse hyperbolic functions. ........ r62412 | mark.dickinson | 2008-04-20 03:22:30 +0200 (Sun, 20 Apr 2008) | 5 lines Report additional diagnostic information in test_math, to help track down debian-alpha buildbot failure. ........ r62413 | mark.dickinson | 2008-04-20 03:39:24 +0200 (Sun, 20 Apr 2008) | 3 lines FreeBSD doesn't follow C99 for modf(inf); so add explicit special-value handling to math.modf code. ........ r62414 | mark.dickinson | 2008-04-20 06:13:13 +0200 (Sun, 20 Apr 2008) | 5 lines Yet more explicit special case handling to make math.pow behave on alpha Tru64. All IEEE 754 special values are now handled directly; only the finite**finite case is handled by libm. ........ r62418 | mark.dickinson | 2008-04-20 18:13:17 +0200 (Sun, 20 Apr 2008) | 7 lines Issue 2662: Initialize special value tables dynamically (i.e. when cmath module is loaded) instead of statically. This fixes compile-time problems on platforms where HUGE_VAL is an extern variable rather than a constant. Thanks Hirokazu Yamamoto for the patch. ........ r62419 | andrew.kuchling | 2008-04-20 18:54:02 +0200 (Sun, 20 Apr 2008) | 1 line Move description of math module changes; various edits to description of cmath changes ........
18 years ago
30 years ago
30 years ago
Merged revisions 62386-62387,62389-62393,62396,62400-62402,62407,62409-62410,62412-62414,62418-62419 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r62386 | christian.heimes | 2008-04-19 04:23:57 +0200 (Sat, 19 Apr 2008) | 2 lines Added kill, terminate and send_signal to subprocess.Popen The bits and pieces for the Windows side were already in place. The POSIX side is trivial (as usual) and uses os.kill(). ........ r62387 | georg.brandl | 2008-04-19 10:23:59 +0200 (Sat, 19 Apr 2008) | 2 lines Fix-up docs for revision 62386. ........ r62389 | georg.brandl | 2008-04-19 18:57:43 +0200 (Sat, 19 Apr 2008) | 2 lines #2369: clarify that copyfile() doesn't take a target directory. ........ r62390 | georg.brandl | 2008-04-19 18:58:28 +0200 (Sat, 19 Apr 2008) | 2 lines #2634: clarify meaning of env parameter to spawn/exec*e. ........ r62391 | georg.brandl | 2008-04-19 18:58:49 +0200 (Sat, 19 Apr 2008) | 2 lines #2633: clarify meaning of env parameter. ........ r62392 | georg.brandl | 2008-04-19 18:59:16 +0200 (Sat, 19 Apr 2008) | 2 lines #2631: clarify IMPORT_NAME semantics. ........ r62393 | georg.brandl | 2008-04-19 19:00:14 +0200 (Sat, 19 Apr 2008) | 2 lines :func: et al. should *not* include the parens. ........ r62396 | mark.dickinson | 2008-04-19 20:51:48 +0200 (Sat, 19 Apr 2008) | 5 lines Additional tests for math.pow, and extra special-case handling code in math.pow, in the hope of making all tests pass on the alpha Tru64 buildbot. ........ r62400 | mark.dickinson | 2008-04-19 21:41:52 +0200 (Sat, 19 Apr 2008) | 3 lines Additional special-case handling for math.pow. Windows/VS2008 doesn't like (-1)**(+-inf). ........ r62401 | benjamin.peterson | 2008-04-19 21:47:34 +0200 (Sat, 19 Apr 2008) | 2 lines Complete documentation for errors argument of io's open and TextIOWrapper ........ r62402 | mark.dickinson | 2008-04-19 22:31:16 +0200 (Sat, 19 Apr 2008) | 2 lines Document updates to math and cmath modules. ........ r62407 | georg.brandl | 2008-04-19 23:28:38 +0200 (Sat, 19 Apr 2008) | 2 lines Update template for newest Sphinx. ........ r62409 | mark.dickinson | 2008-04-19 23:35:35 +0200 (Sat, 19 Apr 2008) | 5 lines Correct documentation for math.pow; 0**nan is nan, not 0. (But nan**0 and 1**nan are 1.) Also fix minor typo: 'quite NaN' -> 'quiet NaN' ........ r62410 | mark.dickinson | 2008-04-19 23:49:22 +0200 (Sat, 19 Apr 2008) | 4 lines Move asinh documentation to the proper place. Remove meaningless 'in radians' from inverse hyperbolic functions. ........ r62412 | mark.dickinson | 2008-04-20 03:22:30 +0200 (Sun, 20 Apr 2008) | 5 lines Report additional diagnostic information in test_math, to help track down debian-alpha buildbot failure. ........ r62413 | mark.dickinson | 2008-04-20 03:39:24 +0200 (Sun, 20 Apr 2008) | 3 lines FreeBSD doesn't follow C99 for modf(inf); so add explicit special-value handling to math.modf code. ........ r62414 | mark.dickinson | 2008-04-20 06:13:13 +0200 (Sun, 20 Apr 2008) | 5 lines Yet more explicit special case handling to make math.pow behave on alpha Tru64. All IEEE 754 special values are now handled directly; only the finite**finite case is handled by libm. ........ r62418 | mark.dickinson | 2008-04-20 18:13:17 +0200 (Sun, 20 Apr 2008) | 7 lines Issue 2662: Initialize special value tables dynamically (i.e. when cmath module is loaded) instead of statically. This fixes compile-time problems on platforms where HUGE_VAL is an extern variable rather than a constant. Thanks Hirokazu Yamamoto for the patch. ........ r62419 | andrew.kuchling | 2008-04-20 18:54:02 +0200 (Sun, 20 Apr 2008) | 1 line Move description of math module changes; various edits to description of cmath changes ........
18 years ago
30 years ago
30 years ago
30 years ago
30 years ago
30 years ago
30 years ago
Merged revisions 62386-62387,62389-62393,62396,62400-62402,62407,62409-62410,62412-62414,62418-62419 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r62386 | christian.heimes | 2008-04-19 04:23:57 +0200 (Sat, 19 Apr 2008) | 2 lines Added kill, terminate and send_signal to subprocess.Popen The bits and pieces for the Windows side were already in place. The POSIX side is trivial (as usual) and uses os.kill(). ........ r62387 | georg.brandl | 2008-04-19 10:23:59 +0200 (Sat, 19 Apr 2008) | 2 lines Fix-up docs for revision 62386. ........ r62389 | georg.brandl | 2008-04-19 18:57:43 +0200 (Sat, 19 Apr 2008) | 2 lines #2369: clarify that copyfile() doesn't take a target directory. ........ r62390 | georg.brandl | 2008-04-19 18:58:28 +0200 (Sat, 19 Apr 2008) | 2 lines #2634: clarify meaning of env parameter to spawn/exec*e. ........ r62391 | georg.brandl | 2008-04-19 18:58:49 +0200 (Sat, 19 Apr 2008) | 2 lines #2633: clarify meaning of env parameter. ........ r62392 | georg.brandl | 2008-04-19 18:59:16 +0200 (Sat, 19 Apr 2008) | 2 lines #2631: clarify IMPORT_NAME semantics. ........ r62393 | georg.brandl | 2008-04-19 19:00:14 +0200 (Sat, 19 Apr 2008) | 2 lines :func: et al. should *not* include the parens. ........ r62396 | mark.dickinson | 2008-04-19 20:51:48 +0200 (Sat, 19 Apr 2008) | 5 lines Additional tests for math.pow, and extra special-case handling code in math.pow, in the hope of making all tests pass on the alpha Tru64 buildbot. ........ r62400 | mark.dickinson | 2008-04-19 21:41:52 +0200 (Sat, 19 Apr 2008) | 3 lines Additional special-case handling for math.pow. Windows/VS2008 doesn't like (-1)**(+-inf). ........ r62401 | benjamin.peterson | 2008-04-19 21:47:34 +0200 (Sat, 19 Apr 2008) | 2 lines Complete documentation for errors argument of io's open and TextIOWrapper ........ r62402 | mark.dickinson | 2008-04-19 22:31:16 +0200 (Sat, 19 Apr 2008) | 2 lines Document updates to math and cmath modules. ........ r62407 | georg.brandl | 2008-04-19 23:28:38 +0200 (Sat, 19 Apr 2008) | 2 lines Update template for newest Sphinx. ........ r62409 | mark.dickinson | 2008-04-19 23:35:35 +0200 (Sat, 19 Apr 2008) | 5 lines Correct documentation for math.pow; 0**nan is nan, not 0. (But nan**0 and 1**nan are 1.) Also fix minor typo: 'quite NaN' -> 'quiet NaN' ........ r62410 | mark.dickinson | 2008-04-19 23:49:22 +0200 (Sat, 19 Apr 2008) | 4 lines Move asinh documentation to the proper place. Remove meaningless 'in radians' from inverse hyperbolic functions. ........ r62412 | mark.dickinson | 2008-04-20 03:22:30 +0200 (Sun, 20 Apr 2008) | 5 lines Report additional diagnostic information in test_math, to help track down debian-alpha buildbot failure. ........ r62413 | mark.dickinson | 2008-04-20 03:39:24 +0200 (Sun, 20 Apr 2008) | 3 lines FreeBSD doesn't follow C99 for modf(inf); so add explicit special-value handling to math.modf code. ........ r62414 | mark.dickinson | 2008-04-20 06:13:13 +0200 (Sun, 20 Apr 2008) | 5 lines Yet more explicit special case handling to make math.pow behave on alpha Tru64. All IEEE 754 special values are now handled directly; only the finite**finite case is handled by libm. ........ r62418 | mark.dickinson | 2008-04-20 18:13:17 +0200 (Sun, 20 Apr 2008) | 7 lines Issue 2662: Initialize special value tables dynamically (i.e. when cmath module is loaded) instead of statically. This fixes compile-time problems on platforms where HUGE_VAL is an extern variable rather than a constant. Thanks Hirokazu Yamamoto for the patch. ........ r62419 | andrew.kuchling | 2008-04-20 18:54:02 +0200 (Sun, 20 Apr 2008) | 1 line Move description of math module changes; various edits to description of cmath changes ........
18 years ago
30 years ago
30 years ago
Merged revisions 62386-62387,62389-62393,62396,62400-62402,62407,62409-62410,62412-62414,62418-62419 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r62386 | christian.heimes | 2008-04-19 04:23:57 +0200 (Sat, 19 Apr 2008) | 2 lines Added kill, terminate and send_signal to subprocess.Popen The bits and pieces for the Windows side were already in place. The POSIX side is trivial (as usual) and uses os.kill(). ........ r62387 | georg.brandl | 2008-04-19 10:23:59 +0200 (Sat, 19 Apr 2008) | 2 lines Fix-up docs for revision 62386. ........ r62389 | georg.brandl | 2008-04-19 18:57:43 +0200 (Sat, 19 Apr 2008) | 2 lines #2369: clarify that copyfile() doesn't take a target directory. ........ r62390 | georg.brandl | 2008-04-19 18:58:28 +0200 (Sat, 19 Apr 2008) | 2 lines #2634: clarify meaning of env parameter to spawn/exec*e. ........ r62391 | georg.brandl | 2008-04-19 18:58:49 +0200 (Sat, 19 Apr 2008) | 2 lines #2633: clarify meaning of env parameter. ........ r62392 | georg.brandl | 2008-04-19 18:59:16 +0200 (Sat, 19 Apr 2008) | 2 lines #2631: clarify IMPORT_NAME semantics. ........ r62393 | georg.brandl | 2008-04-19 19:00:14 +0200 (Sat, 19 Apr 2008) | 2 lines :func: et al. should *not* include the parens. ........ r62396 | mark.dickinson | 2008-04-19 20:51:48 +0200 (Sat, 19 Apr 2008) | 5 lines Additional tests for math.pow, and extra special-case handling code in math.pow, in the hope of making all tests pass on the alpha Tru64 buildbot. ........ r62400 | mark.dickinson | 2008-04-19 21:41:52 +0200 (Sat, 19 Apr 2008) | 3 lines Additional special-case handling for math.pow. Windows/VS2008 doesn't like (-1)**(+-inf). ........ r62401 | benjamin.peterson | 2008-04-19 21:47:34 +0200 (Sat, 19 Apr 2008) | 2 lines Complete documentation for errors argument of io's open and TextIOWrapper ........ r62402 | mark.dickinson | 2008-04-19 22:31:16 +0200 (Sat, 19 Apr 2008) | 2 lines Document updates to math and cmath modules. ........ r62407 | georg.brandl | 2008-04-19 23:28:38 +0200 (Sat, 19 Apr 2008) | 2 lines Update template for newest Sphinx. ........ r62409 | mark.dickinson | 2008-04-19 23:35:35 +0200 (Sat, 19 Apr 2008) | 5 lines Correct documentation for math.pow; 0**nan is nan, not 0. (But nan**0 and 1**nan are 1.) Also fix minor typo: 'quite NaN' -> 'quiet NaN' ........ r62410 | mark.dickinson | 2008-04-19 23:49:22 +0200 (Sat, 19 Apr 2008) | 4 lines Move asinh documentation to the proper place. Remove meaningless 'in radians' from inverse hyperbolic functions. ........ r62412 | mark.dickinson | 2008-04-20 03:22:30 +0200 (Sun, 20 Apr 2008) | 5 lines Report additional diagnostic information in test_math, to help track down debian-alpha buildbot failure. ........ r62413 | mark.dickinson | 2008-04-20 03:39:24 +0200 (Sun, 20 Apr 2008) | 3 lines FreeBSD doesn't follow C99 for modf(inf); so add explicit special-value handling to math.modf code. ........ r62414 | mark.dickinson | 2008-04-20 06:13:13 +0200 (Sun, 20 Apr 2008) | 5 lines Yet more explicit special case handling to make math.pow behave on alpha Tru64. All IEEE 754 special values are now handled directly; only the finite**finite case is handled by libm. ........ r62418 | mark.dickinson | 2008-04-20 18:13:17 +0200 (Sun, 20 Apr 2008) | 7 lines Issue 2662: Initialize special value tables dynamically (i.e. when cmath module is loaded) instead of statically. This fixes compile-time problems on platforms where HUGE_VAL is an extern variable rather than a constant. Thanks Hirokazu Yamamoto for the patch. ........ r62419 | andrew.kuchling | 2008-04-20 18:54:02 +0200 (Sun, 20 Apr 2008) | 1 line Move description of math module changes; various edits to description of cmath changes ........
18 years ago
30 years ago
30 years ago
30 years ago
30 years ago
Merged revisions 62386-62387,62389-62393,62396,62400-62402,62407,62409-62410,62412-62414,62418-62419 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r62386 | christian.heimes | 2008-04-19 04:23:57 +0200 (Sat, 19 Apr 2008) | 2 lines Added kill, terminate and send_signal to subprocess.Popen The bits and pieces for the Windows side were already in place. The POSIX side is trivial (as usual) and uses os.kill(). ........ r62387 | georg.brandl | 2008-04-19 10:23:59 +0200 (Sat, 19 Apr 2008) | 2 lines Fix-up docs for revision 62386. ........ r62389 | georg.brandl | 2008-04-19 18:57:43 +0200 (Sat, 19 Apr 2008) | 2 lines #2369: clarify that copyfile() doesn't take a target directory. ........ r62390 | georg.brandl | 2008-04-19 18:58:28 +0200 (Sat, 19 Apr 2008) | 2 lines #2634: clarify meaning of env parameter to spawn/exec*e. ........ r62391 | georg.brandl | 2008-04-19 18:58:49 +0200 (Sat, 19 Apr 2008) | 2 lines #2633: clarify meaning of env parameter. ........ r62392 | georg.brandl | 2008-04-19 18:59:16 +0200 (Sat, 19 Apr 2008) | 2 lines #2631: clarify IMPORT_NAME semantics. ........ r62393 | georg.brandl | 2008-04-19 19:00:14 +0200 (Sat, 19 Apr 2008) | 2 lines :func: et al. should *not* include the parens. ........ r62396 | mark.dickinson | 2008-04-19 20:51:48 +0200 (Sat, 19 Apr 2008) | 5 lines Additional tests for math.pow, and extra special-case handling code in math.pow, in the hope of making all tests pass on the alpha Tru64 buildbot. ........ r62400 | mark.dickinson | 2008-04-19 21:41:52 +0200 (Sat, 19 Apr 2008) | 3 lines Additional special-case handling for math.pow. Windows/VS2008 doesn't like (-1)**(+-inf). ........ r62401 | benjamin.peterson | 2008-04-19 21:47:34 +0200 (Sat, 19 Apr 2008) | 2 lines Complete documentation for errors argument of io's open and TextIOWrapper ........ r62402 | mark.dickinson | 2008-04-19 22:31:16 +0200 (Sat, 19 Apr 2008) | 2 lines Document updates to math and cmath modules. ........ r62407 | georg.brandl | 2008-04-19 23:28:38 +0200 (Sat, 19 Apr 2008) | 2 lines Update template for newest Sphinx. ........ r62409 | mark.dickinson | 2008-04-19 23:35:35 +0200 (Sat, 19 Apr 2008) | 5 lines Correct documentation for math.pow; 0**nan is nan, not 0. (But nan**0 and 1**nan are 1.) Also fix minor typo: 'quite NaN' -> 'quiet NaN' ........ r62410 | mark.dickinson | 2008-04-19 23:49:22 +0200 (Sat, 19 Apr 2008) | 4 lines Move asinh documentation to the proper place. Remove meaningless 'in radians' from inverse hyperbolic functions. ........ r62412 | mark.dickinson | 2008-04-20 03:22:30 +0200 (Sun, 20 Apr 2008) | 5 lines Report additional diagnostic information in test_math, to help track down debian-alpha buildbot failure. ........ r62413 | mark.dickinson | 2008-04-20 03:39:24 +0200 (Sun, 20 Apr 2008) | 3 lines FreeBSD doesn't follow C99 for modf(inf); so add explicit special-value handling to math.modf code. ........ r62414 | mark.dickinson | 2008-04-20 06:13:13 +0200 (Sun, 20 Apr 2008) | 5 lines Yet more explicit special case handling to make math.pow behave on alpha Tru64. All IEEE 754 special values are now handled directly; only the finite**finite case is handled by libm. ........ r62418 | mark.dickinson | 2008-04-20 18:13:17 +0200 (Sun, 20 Apr 2008) | 7 lines Issue 2662: Initialize special value tables dynamically (i.e. when cmath module is loaded) instead of statically. This fixes compile-time problems on platforms where HUGE_VAL is an extern variable rather than a constant. Thanks Hirokazu Yamamoto for the patch. ........ r62419 | andrew.kuchling | 2008-04-20 18:54:02 +0200 (Sun, 20 Apr 2008) | 1 line Move description of math module changes; various edits to description of cmath changes ........
18 years ago
30 years ago
30 years ago
30 years ago
30 years ago
30 years ago
30 years ago
30 years ago
26 years ago
30 years ago
30 years ago
30 years ago
Merged revisions 62386-62387,62389-62393,62396,62400-62402,62407,62409-62410,62412-62414,62418-62419 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r62386 | christian.heimes | 2008-04-19 04:23:57 +0200 (Sat, 19 Apr 2008) | 2 lines Added kill, terminate and send_signal to subprocess.Popen The bits and pieces for the Windows side were already in place. The POSIX side is trivial (as usual) and uses os.kill(). ........ r62387 | georg.brandl | 2008-04-19 10:23:59 +0200 (Sat, 19 Apr 2008) | 2 lines Fix-up docs for revision 62386. ........ r62389 | georg.brandl | 2008-04-19 18:57:43 +0200 (Sat, 19 Apr 2008) | 2 lines #2369: clarify that copyfile() doesn't take a target directory. ........ r62390 | georg.brandl | 2008-04-19 18:58:28 +0200 (Sat, 19 Apr 2008) | 2 lines #2634: clarify meaning of env parameter to spawn/exec*e. ........ r62391 | georg.brandl | 2008-04-19 18:58:49 +0200 (Sat, 19 Apr 2008) | 2 lines #2633: clarify meaning of env parameter. ........ r62392 | georg.brandl | 2008-04-19 18:59:16 +0200 (Sat, 19 Apr 2008) | 2 lines #2631: clarify IMPORT_NAME semantics. ........ r62393 | georg.brandl | 2008-04-19 19:00:14 +0200 (Sat, 19 Apr 2008) | 2 lines :func: et al. should *not* include the parens. ........ r62396 | mark.dickinson | 2008-04-19 20:51:48 +0200 (Sat, 19 Apr 2008) | 5 lines Additional tests for math.pow, and extra special-case handling code in math.pow, in the hope of making all tests pass on the alpha Tru64 buildbot. ........ r62400 | mark.dickinson | 2008-04-19 21:41:52 +0200 (Sat, 19 Apr 2008) | 3 lines Additional special-case handling for math.pow. Windows/VS2008 doesn't like (-1)**(+-inf). ........ r62401 | benjamin.peterson | 2008-04-19 21:47:34 +0200 (Sat, 19 Apr 2008) | 2 lines Complete documentation for errors argument of io's open and TextIOWrapper ........ r62402 | mark.dickinson | 2008-04-19 22:31:16 +0200 (Sat, 19 Apr 2008) | 2 lines Document updates to math and cmath modules. ........ r62407 | georg.brandl | 2008-04-19 23:28:38 +0200 (Sat, 19 Apr 2008) | 2 lines Update template for newest Sphinx. ........ r62409 | mark.dickinson | 2008-04-19 23:35:35 +0200 (Sat, 19 Apr 2008) | 5 lines Correct documentation for math.pow; 0**nan is nan, not 0. (But nan**0 and 1**nan are 1.) Also fix minor typo: 'quite NaN' -> 'quiet NaN' ........ r62410 | mark.dickinson | 2008-04-19 23:49:22 +0200 (Sat, 19 Apr 2008) | 4 lines Move asinh documentation to the proper place. Remove meaningless 'in radians' from inverse hyperbolic functions. ........ r62412 | mark.dickinson | 2008-04-20 03:22:30 +0200 (Sun, 20 Apr 2008) | 5 lines Report additional diagnostic information in test_math, to help track down debian-alpha buildbot failure. ........ r62413 | mark.dickinson | 2008-04-20 03:39:24 +0200 (Sun, 20 Apr 2008) | 3 lines FreeBSD doesn't follow C99 for modf(inf); so add explicit special-value handling to math.modf code. ........ r62414 | mark.dickinson | 2008-04-20 06:13:13 +0200 (Sun, 20 Apr 2008) | 5 lines Yet more explicit special case handling to make math.pow behave on alpha Tru64. All IEEE 754 special values are now handled directly; only the finite**finite case is handled by libm. ........ r62418 | mark.dickinson | 2008-04-20 18:13:17 +0200 (Sun, 20 Apr 2008) | 7 lines Issue 2662: Initialize special value tables dynamically (i.e. when cmath module is loaded) instead of statically. This fixes compile-time problems on platforms where HUGE_VAL is an extern variable rather than a constant. Thanks Hirokazu Yamamoto for the patch. ........ r62419 | andrew.kuchling | 2008-04-20 18:54:02 +0200 (Sun, 20 Apr 2008) | 1 line Move description of math module changes; various edits to description of cmath changes ........
18 years ago
30 years ago
30 years ago
30 years ago
30 years ago
Merged revisions 62386-62387,62389-62393,62396,62400-62402,62407,62409-62410,62412-62414,62418-62419 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r62386 | christian.heimes | 2008-04-19 04:23:57 +0200 (Sat, 19 Apr 2008) | 2 lines Added kill, terminate and send_signal to subprocess.Popen The bits and pieces for the Windows side were already in place. The POSIX side is trivial (as usual) and uses os.kill(). ........ r62387 | georg.brandl | 2008-04-19 10:23:59 +0200 (Sat, 19 Apr 2008) | 2 lines Fix-up docs for revision 62386. ........ r62389 | georg.brandl | 2008-04-19 18:57:43 +0200 (Sat, 19 Apr 2008) | 2 lines #2369: clarify that copyfile() doesn't take a target directory. ........ r62390 | georg.brandl | 2008-04-19 18:58:28 +0200 (Sat, 19 Apr 2008) | 2 lines #2634: clarify meaning of env parameter to spawn/exec*e. ........ r62391 | georg.brandl | 2008-04-19 18:58:49 +0200 (Sat, 19 Apr 2008) | 2 lines #2633: clarify meaning of env parameter. ........ r62392 | georg.brandl | 2008-04-19 18:59:16 +0200 (Sat, 19 Apr 2008) | 2 lines #2631: clarify IMPORT_NAME semantics. ........ r62393 | georg.brandl | 2008-04-19 19:00:14 +0200 (Sat, 19 Apr 2008) | 2 lines :func: et al. should *not* include the parens. ........ r62396 | mark.dickinson | 2008-04-19 20:51:48 +0200 (Sat, 19 Apr 2008) | 5 lines Additional tests for math.pow, and extra special-case handling code in math.pow, in the hope of making all tests pass on the alpha Tru64 buildbot. ........ r62400 | mark.dickinson | 2008-04-19 21:41:52 +0200 (Sat, 19 Apr 2008) | 3 lines Additional special-case handling for math.pow. Windows/VS2008 doesn't like (-1)**(+-inf). ........ r62401 | benjamin.peterson | 2008-04-19 21:47:34 +0200 (Sat, 19 Apr 2008) | 2 lines Complete documentation for errors argument of io's open and TextIOWrapper ........ r62402 | mark.dickinson | 2008-04-19 22:31:16 +0200 (Sat, 19 Apr 2008) | 2 lines Document updates to math and cmath modules. ........ r62407 | georg.brandl | 2008-04-19 23:28:38 +0200 (Sat, 19 Apr 2008) | 2 lines Update template for newest Sphinx. ........ r62409 | mark.dickinson | 2008-04-19 23:35:35 +0200 (Sat, 19 Apr 2008) | 5 lines Correct documentation for math.pow; 0**nan is nan, not 0. (But nan**0 and 1**nan are 1.) Also fix minor typo: 'quite NaN' -> 'quiet NaN' ........ r62410 | mark.dickinson | 2008-04-19 23:49:22 +0200 (Sat, 19 Apr 2008) | 4 lines Move asinh documentation to the proper place. Remove meaningless 'in radians' from inverse hyperbolic functions. ........ r62412 | mark.dickinson | 2008-04-20 03:22:30 +0200 (Sun, 20 Apr 2008) | 5 lines Report additional diagnostic information in test_math, to help track down debian-alpha buildbot failure. ........ r62413 | mark.dickinson | 2008-04-20 03:39:24 +0200 (Sun, 20 Apr 2008) | 3 lines FreeBSD doesn't follow C99 for modf(inf); so add explicit special-value handling to math.modf code. ........ r62414 | mark.dickinson | 2008-04-20 06:13:13 +0200 (Sun, 20 Apr 2008) | 5 lines Yet more explicit special case handling to make math.pow behave on alpha Tru64. All IEEE 754 special values are now handled directly; only the finite**finite case is handled by libm. ........ r62418 | mark.dickinson | 2008-04-20 18:13:17 +0200 (Sun, 20 Apr 2008) | 7 lines Issue 2662: Initialize special value tables dynamically (i.e. when cmath module is loaded) instead of statically. This fixes compile-time problems on platforms where HUGE_VAL is an extern variable rather than a constant. Thanks Hirokazu Yamamoto for the patch. ........ r62419 | andrew.kuchling | 2008-04-20 18:54:02 +0200 (Sun, 20 Apr 2008) | 1 line Move description of math module changes; various edits to description of cmath changes ........
18 years ago
Merged revisions 62386-62387,62389-62393,62396,62400-62402,62407,62409-62410,62412-62414,62418-62419 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r62386 | christian.heimes | 2008-04-19 04:23:57 +0200 (Sat, 19 Apr 2008) | 2 lines Added kill, terminate and send_signal to subprocess.Popen The bits and pieces for the Windows side were already in place. The POSIX side is trivial (as usual) and uses os.kill(). ........ r62387 | georg.brandl | 2008-04-19 10:23:59 +0200 (Sat, 19 Apr 2008) | 2 lines Fix-up docs for revision 62386. ........ r62389 | georg.brandl | 2008-04-19 18:57:43 +0200 (Sat, 19 Apr 2008) | 2 lines #2369: clarify that copyfile() doesn't take a target directory. ........ r62390 | georg.brandl | 2008-04-19 18:58:28 +0200 (Sat, 19 Apr 2008) | 2 lines #2634: clarify meaning of env parameter to spawn/exec*e. ........ r62391 | georg.brandl | 2008-04-19 18:58:49 +0200 (Sat, 19 Apr 2008) | 2 lines #2633: clarify meaning of env parameter. ........ r62392 | georg.brandl | 2008-04-19 18:59:16 +0200 (Sat, 19 Apr 2008) | 2 lines #2631: clarify IMPORT_NAME semantics. ........ r62393 | georg.brandl | 2008-04-19 19:00:14 +0200 (Sat, 19 Apr 2008) | 2 lines :func: et al. should *not* include the parens. ........ r62396 | mark.dickinson | 2008-04-19 20:51:48 +0200 (Sat, 19 Apr 2008) | 5 lines Additional tests for math.pow, and extra special-case handling code in math.pow, in the hope of making all tests pass on the alpha Tru64 buildbot. ........ r62400 | mark.dickinson | 2008-04-19 21:41:52 +0200 (Sat, 19 Apr 2008) | 3 lines Additional special-case handling for math.pow. Windows/VS2008 doesn't like (-1)**(+-inf). ........ r62401 | benjamin.peterson | 2008-04-19 21:47:34 +0200 (Sat, 19 Apr 2008) | 2 lines Complete documentation for errors argument of io's open and TextIOWrapper ........ r62402 | mark.dickinson | 2008-04-19 22:31:16 +0200 (Sat, 19 Apr 2008) | 2 lines Document updates to math and cmath modules. ........ r62407 | georg.brandl | 2008-04-19 23:28:38 +0200 (Sat, 19 Apr 2008) | 2 lines Update template for newest Sphinx. ........ r62409 | mark.dickinson | 2008-04-19 23:35:35 +0200 (Sat, 19 Apr 2008) | 5 lines Correct documentation for math.pow; 0**nan is nan, not 0. (But nan**0 and 1**nan are 1.) Also fix minor typo: 'quite NaN' -> 'quiet NaN' ........ r62410 | mark.dickinson | 2008-04-19 23:49:22 +0200 (Sat, 19 Apr 2008) | 4 lines Move asinh documentation to the proper place. Remove meaningless 'in radians' from inverse hyperbolic functions. ........ r62412 | mark.dickinson | 2008-04-20 03:22:30 +0200 (Sun, 20 Apr 2008) | 5 lines Report additional diagnostic information in test_math, to help track down debian-alpha buildbot failure. ........ r62413 | mark.dickinson | 2008-04-20 03:39:24 +0200 (Sun, 20 Apr 2008) | 3 lines FreeBSD doesn't follow C99 for modf(inf); so add explicit special-value handling to math.modf code. ........ r62414 | mark.dickinson | 2008-04-20 06:13:13 +0200 (Sun, 20 Apr 2008) | 5 lines Yet more explicit special case handling to make math.pow behave on alpha Tru64. All IEEE 754 special values are now handled directly; only the finite**finite case is handled by libm. ........ r62418 | mark.dickinson | 2008-04-20 18:13:17 +0200 (Sun, 20 Apr 2008) | 7 lines Issue 2662: Initialize special value tables dynamically (i.e. when cmath module is loaded) instead of statically. This fixes compile-time problems on platforms where HUGE_VAL is an extern variable rather than a constant. Thanks Hirokazu Yamamoto for the patch. ........ r62419 | andrew.kuchling | 2008-04-20 18:54:02 +0200 (Sun, 20 Apr 2008) | 1 line Move description of math module changes; various edits to description of cmath changes ........
18 years ago
30 years ago
  1. /* Complex math module */
  2. /* much code borrowed from mathmodule.c */
  3. #include "Python.h"
  4. #include "_math.h"
  5. /* we need DBL_MAX, DBL_MIN, DBL_EPSILON, DBL_MANT_DIG and FLT_RADIX from
  6. float.h. We assume that FLT_RADIX is either 2 or 16. */
  7. #include <float.h>
  8. #if (FLT_RADIX != 2 && FLT_RADIX != 16)
  9. #error "Modules/cmathmodule.c expects FLT_RADIX to be 2 or 16"
  10. #endif
  11. #ifndef M_LN2
  12. #define M_LN2 (0.6931471805599453094) /* natural log of 2 */
  13. #endif
  14. #ifndef M_LN10
  15. #define M_LN10 (2.302585092994045684) /* natural log of 10 */
  16. #endif
  17. /*
  18. CM_LARGE_DOUBLE is used to avoid spurious overflow in the sqrt, log,
  19. inverse trig and inverse hyperbolic trig functions. Its log is used in the
  20. evaluation of exp, cos, cosh, sin, sinh, tan, and tanh to avoid unnecessary
  21. overflow.
  22. */
  23. #define CM_LARGE_DOUBLE (DBL_MAX/4.)
  24. #define CM_SQRT_LARGE_DOUBLE (sqrt(CM_LARGE_DOUBLE))
  25. #define CM_LOG_LARGE_DOUBLE (log(CM_LARGE_DOUBLE))
  26. #define CM_SQRT_DBL_MIN (sqrt(DBL_MIN))
  27. /*
  28. CM_SCALE_UP is an odd integer chosen such that multiplication by
  29. 2**CM_SCALE_UP is sufficient to turn a subnormal into a normal.
  30. CM_SCALE_DOWN is (-(CM_SCALE_UP+1)/2). These scalings are used to compute
  31. square roots accurately when the real and imaginary parts of the argument
  32. are subnormal.
  33. */
  34. #if FLT_RADIX==2
  35. #define CM_SCALE_UP (2*(DBL_MANT_DIG/2) + 1)
  36. #elif FLT_RADIX==16
  37. #define CM_SCALE_UP (4*DBL_MANT_DIG+1)
  38. #endif
  39. #define CM_SCALE_DOWN (-(CM_SCALE_UP+1)/2)
  40. /* forward declarations */
  41. static Py_complex c_asinh(Py_complex);
  42. static Py_complex c_atanh(Py_complex);
  43. static Py_complex c_cosh(Py_complex);
  44. static Py_complex c_sinh(Py_complex);
  45. static Py_complex c_sqrt(Py_complex);
  46. static Py_complex c_tanh(Py_complex);
  47. static PyObject * math_error(void);
  48. /* Code to deal with special values (infinities, NaNs, etc.). */
  49. /* special_type takes a double and returns an integer code indicating
  50. the type of the double as follows:
  51. */
  52. enum special_types {
  53. ST_NINF, /* 0, negative infinity */
  54. ST_NEG, /* 1, negative finite number (nonzero) */
  55. ST_NZERO, /* 2, -0. */
  56. ST_PZERO, /* 3, +0. */
  57. ST_POS, /* 4, positive finite number (nonzero) */
  58. ST_PINF, /* 5, positive infinity */
  59. ST_NAN /* 6, Not a Number */
  60. };
  61. static enum special_types
  62. special_type(double d)
  63. {
  64. if (Py_IS_FINITE(d)) {
  65. if (d != 0) {
  66. if (copysign(1., d) == 1.)
  67. return ST_POS;
  68. else
  69. return ST_NEG;
  70. }
  71. else {
  72. if (copysign(1., d) == 1.)
  73. return ST_PZERO;
  74. else
  75. return ST_NZERO;
  76. }
  77. }
  78. if (Py_IS_NAN(d))
  79. return ST_NAN;
  80. if (copysign(1., d) == 1.)
  81. return ST_PINF;
  82. else
  83. return ST_NINF;
  84. }
  85. #define SPECIAL_VALUE(z, table) \
  86. if (!Py_IS_FINITE((z).real) || !Py_IS_FINITE((z).imag)) { \
  87. errno = 0; \
  88. return table[special_type((z).real)] \
  89. [special_type((z).imag)]; \
  90. }
  91. #define P Py_MATH_PI
  92. #define P14 0.25*Py_MATH_PI
  93. #define P12 0.5*Py_MATH_PI
  94. #define P34 0.75*Py_MATH_PI
  95. #define INF Py_HUGE_VAL
  96. #define N Py_NAN
  97. #define U -9.5426319407711027e33 /* unlikely value, used as placeholder */
  98. /* First, the C functions that do the real work. Each of the c_*
  99. functions computes and returns the C99 Annex G recommended result
  100. and also sets errno as follows: errno = 0 if no floating-point
  101. exception is associated with the result; errno = EDOM if C99 Annex
  102. G recommends raising divide-by-zero or invalid for this result; and
  103. errno = ERANGE where the overflow floating-point signal should be
  104. raised.
  105. */
  106. static Py_complex acos_special_values[7][7];
  107. static Py_complex
  108. c_acos(Py_complex z)
  109. {
  110. Py_complex s1, s2, r;
  111. SPECIAL_VALUE(z, acos_special_values);
  112. if (fabs(z.real) > CM_LARGE_DOUBLE || fabs(z.imag) > CM_LARGE_DOUBLE) {
  113. /* avoid unnecessary overflow for large arguments */
  114. r.real = atan2(fabs(z.imag), z.real);
  115. /* split into cases to make sure that the branch cut has the
  116. correct continuity on systems with unsigned zeros */
  117. if (z.real < 0.) {
  118. r.imag = -copysign(log(hypot(z.real/2., z.imag/2.)) +
  119. M_LN2*2., z.imag);
  120. } else {
  121. r.imag = copysign(log(hypot(z.real/2., z.imag/2.)) +
  122. M_LN2*2., -z.imag);
  123. }
  124. } else {
  125. s1.real = 1.-z.real;
  126. s1.imag = -z.imag;
  127. s1 = c_sqrt(s1);
  128. s2.real = 1.+z.real;
  129. s2.imag = z.imag;
  130. s2 = c_sqrt(s2);
  131. r.real = 2.*atan2(s1.real, s2.real);
  132. r.imag = m_asinh(s2.real*s1.imag - s2.imag*s1.real);
  133. }
  134. errno = 0;
  135. return r;
  136. }
  137. PyDoc_STRVAR(c_acos_doc,
  138. "acos(x)\n"
  139. "\n"
  140. "Return the arc cosine of x.");
  141. static Py_complex acosh_special_values[7][7];
  142. static Py_complex
  143. c_acosh(Py_complex z)
  144. {
  145. Py_complex s1, s2, r;
  146. SPECIAL_VALUE(z, acosh_special_values);
  147. if (fabs(z.real) > CM_LARGE_DOUBLE || fabs(z.imag) > CM_LARGE_DOUBLE) {
  148. /* avoid unnecessary overflow for large arguments */
  149. r.real = log(hypot(z.real/2., z.imag/2.)) + M_LN2*2.;
  150. r.imag = atan2(z.imag, z.real);
  151. } else {
  152. s1.real = z.real - 1.;
  153. s1.imag = z.imag;
  154. s1 = c_sqrt(s1);
  155. s2.real = z.real + 1.;
  156. s2.imag = z.imag;
  157. s2 = c_sqrt(s2);
  158. r.real = m_asinh(s1.real*s2.real + s1.imag*s2.imag);
  159. r.imag = 2.*atan2(s1.imag, s2.real);
  160. }
  161. errno = 0;
  162. return r;
  163. }
  164. PyDoc_STRVAR(c_acosh_doc,
  165. "acosh(x)\n"
  166. "\n"
  167. "Return the inverse hyperbolic cosine of x.");
  168. static Py_complex
  169. c_asin(Py_complex z)
  170. {
  171. /* asin(z) = -i asinh(iz) */
  172. Py_complex s, r;
  173. s.real = -z.imag;
  174. s.imag = z.real;
  175. s = c_asinh(s);
  176. r.real = s.imag;
  177. r.imag = -s.real;
  178. return r;
  179. }
  180. PyDoc_STRVAR(c_asin_doc,
  181. "asin(x)\n"
  182. "\n"
  183. "Return the arc sine of x.");
  184. static Py_complex asinh_special_values[7][7];
  185. static Py_complex
  186. c_asinh(Py_complex z)
  187. {
  188. Py_complex s1, s2, r;
  189. SPECIAL_VALUE(z, asinh_special_values);
  190. if (fabs(z.real) > CM_LARGE_DOUBLE || fabs(z.imag) > CM_LARGE_DOUBLE) {
  191. if (z.imag >= 0.) {
  192. r.real = copysign(log(hypot(z.real/2., z.imag/2.)) +
  193. M_LN2*2., z.real);
  194. } else {
  195. r.real = -copysign(log(hypot(z.real/2., z.imag/2.)) +
  196. M_LN2*2., -z.real);
  197. }
  198. r.imag = atan2(z.imag, fabs(z.real));
  199. } else {
  200. s1.real = 1.+z.imag;
  201. s1.imag = -z.real;
  202. s1 = c_sqrt(s1);
  203. s2.real = 1.-z.imag;
  204. s2.imag = z.real;
  205. s2 = c_sqrt(s2);
  206. r.real = m_asinh(s1.real*s2.imag-s2.real*s1.imag);
  207. r.imag = atan2(z.imag, s1.real*s2.real-s1.imag*s2.imag);
  208. }
  209. errno = 0;
  210. return r;
  211. }
  212. PyDoc_STRVAR(c_asinh_doc,
  213. "asinh(x)\n"
  214. "\n"
  215. "Return the inverse hyperbolic sine of x.");
  216. static Py_complex
  217. c_atan(Py_complex z)
  218. {
  219. /* atan(z) = -i atanh(iz) */
  220. Py_complex s, r;
  221. s.real = -z.imag;
  222. s.imag = z.real;
  223. s = c_atanh(s);
  224. r.real = s.imag;
  225. r.imag = -s.real;
  226. return r;
  227. }
  228. /* Windows screws up atan2 for inf and nan, and alpha Tru64 5.1 doesn't follow
  229. C99 for atan2(0., 0.). */
  230. static double
  231. c_atan2(Py_complex z)
  232. {
  233. if (Py_IS_NAN(z.real) || Py_IS_NAN(z.imag))
  234. return Py_NAN;
  235. if (Py_IS_INFINITY(z.imag)) {
  236. if (Py_IS_INFINITY(z.real)) {
  237. if (copysign(1., z.real) == 1.)
  238. /* atan2(+-inf, +inf) == +-pi/4 */
  239. return copysign(0.25*Py_MATH_PI, z.imag);
  240. else
  241. /* atan2(+-inf, -inf) == +-pi*3/4 */
  242. return copysign(0.75*Py_MATH_PI, z.imag);
  243. }
  244. /* atan2(+-inf, x) == +-pi/2 for finite x */
  245. return copysign(0.5*Py_MATH_PI, z.imag);
  246. }
  247. if (Py_IS_INFINITY(z.real) || z.imag == 0.) {
  248. if (copysign(1., z.real) == 1.)
  249. /* atan2(+-y, +inf) = atan2(+-0, +x) = +-0. */
  250. return copysign(0., z.imag);
  251. else
  252. /* atan2(+-y, -inf) = atan2(+-0., -x) = +-pi. */
  253. return copysign(Py_MATH_PI, z.imag);
  254. }
  255. return atan2(z.imag, z.real);
  256. }
  257. PyDoc_STRVAR(c_atan_doc,
  258. "atan(x)\n"
  259. "\n"
  260. "Return the arc tangent of x.");
  261. static Py_complex atanh_special_values[7][7];
  262. static Py_complex
  263. c_atanh(Py_complex z)
  264. {
  265. Py_complex r;
  266. double ay, h;
  267. SPECIAL_VALUE(z, atanh_special_values);
  268. /* Reduce to case where z.real >= 0., using atanh(z) = -atanh(-z). */
  269. if (z.real < 0.) {
  270. return c_neg(c_atanh(c_neg(z)));
  271. }
  272. ay = fabs(z.imag);
  273. if (z.real > CM_SQRT_LARGE_DOUBLE || ay > CM_SQRT_LARGE_DOUBLE) {
  274. /*
  275. if abs(z) is large then we use the approximation
  276. atanh(z) ~ 1/z +/- i*pi/2 (+/- depending on the sign
  277. of z.imag)
  278. */
  279. h = hypot(z.real/2., z.imag/2.); /* safe from overflow */
  280. r.real = z.real/4./h/h;
  281. /* the two negations in the next line cancel each other out
  282. except when working with unsigned zeros: they're there to
  283. ensure that the branch cut has the correct continuity on
  284. systems that don't support signed zeros */
  285. r.imag = -copysign(Py_MATH_PI/2., -z.imag);
  286. errno = 0;
  287. } else if (z.real == 1. && ay < CM_SQRT_DBL_MIN) {
  288. /* C99 standard says: atanh(1+/-0.) should be inf +/- 0i */
  289. if (ay == 0.) {
  290. r.real = INF;
  291. r.imag = z.imag;
  292. errno = EDOM;
  293. } else {
  294. r.real = -log(sqrt(ay)/sqrt(hypot(ay, 2.)));
  295. r.imag = copysign(atan2(2., -ay)/2, z.imag);
  296. errno = 0;
  297. }
  298. } else {
  299. r.real = m_log1p(4.*z.real/((1-z.real)*(1-z.real) + ay*ay))/4.;
  300. r.imag = -atan2(-2.*z.imag, (1-z.real)*(1+z.real) - ay*ay)/2.;
  301. errno = 0;
  302. }
  303. return r;
  304. }
  305. PyDoc_STRVAR(c_atanh_doc,
  306. "atanh(x)\n"
  307. "\n"
  308. "Return the inverse hyperbolic tangent of x.");
  309. static Py_complex
  310. c_cos(Py_complex z)
  311. {
  312. /* cos(z) = cosh(iz) */
  313. Py_complex r;
  314. r.real = -z.imag;
  315. r.imag = z.real;
  316. r = c_cosh(r);
  317. return r;
  318. }
  319. PyDoc_STRVAR(c_cos_doc,
  320. "cos(x)\n"
  321. "\n"
  322. "Return the cosine of x.");
  323. /* cosh(infinity + i*y) needs to be dealt with specially */
  324. static Py_complex cosh_special_values[7][7];
  325. static Py_complex
  326. c_cosh(Py_complex z)
  327. {
  328. Py_complex r;
  329. double x_minus_one;
  330. /* special treatment for cosh(+/-inf + iy) if y is not a NaN */
  331. if (!Py_IS_FINITE(z.real) || !Py_IS_FINITE(z.imag)) {
  332. if (Py_IS_INFINITY(z.real) && Py_IS_FINITE(z.imag) &&
  333. (z.imag != 0.)) {
  334. if (z.real > 0) {
  335. r.real = copysign(INF, cos(z.imag));
  336. r.imag = copysign(INF, sin(z.imag));
  337. }
  338. else {
  339. r.real = copysign(INF, cos(z.imag));
  340. r.imag = -copysign(INF, sin(z.imag));
  341. }
  342. }
  343. else {
  344. r = cosh_special_values[special_type(z.real)]
  345. [special_type(z.imag)];
  346. }
  347. /* need to set errno = EDOM if y is +/- infinity and x is not
  348. a NaN */
  349. if (Py_IS_INFINITY(z.imag) && !Py_IS_NAN(z.real))
  350. errno = EDOM;
  351. else
  352. errno = 0;
  353. return r;
  354. }
  355. if (fabs(z.real) > CM_LOG_LARGE_DOUBLE) {
  356. /* deal correctly with cases where cosh(z.real) overflows but
  357. cosh(z) does not. */
  358. x_minus_one = z.real - copysign(1., z.real);
  359. r.real = cos(z.imag) * cosh(x_minus_one) * Py_MATH_E;
  360. r.imag = sin(z.imag) * sinh(x_minus_one) * Py_MATH_E;
  361. } else {
  362. r.real = cos(z.imag) * cosh(z.real);
  363. r.imag = sin(z.imag) * sinh(z.real);
  364. }
  365. /* detect overflow, and set errno accordingly */
  366. if (Py_IS_INFINITY(r.real) || Py_IS_INFINITY(r.imag))
  367. errno = ERANGE;
  368. else
  369. errno = 0;
  370. return r;
  371. }
  372. PyDoc_STRVAR(c_cosh_doc,
  373. "cosh(x)\n"
  374. "\n"
  375. "Return the hyperbolic cosine of x.");
  376. /* exp(infinity + i*y) and exp(-infinity + i*y) need special treatment for
  377. finite y */
  378. static Py_complex exp_special_values[7][7];
  379. static Py_complex
  380. c_exp(Py_complex z)
  381. {
  382. Py_complex r;
  383. double l;
  384. if (!Py_IS_FINITE(z.real) || !Py_IS_FINITE(z.imag)) {
  385. if (Py_IS_INFINITY(z.real) && Py_IS_FINITE(z.imag)
  386. && (z.imag != 0.)) {
  387. if (z.real > 0) {
  388. r.real = copysign(INF, cos(z.imag));
  389. r.imag = copysign(INF, sin(z.imag));
  390. }
  391. else {
  392. r.real = copysign(0., cos(z.imag));
  393. r.imag = copysign(0., sin(z.imag));
  394. }
  395. }
  396. else {
  397. r = exp_special_values[special_type(z.real)]
  398. [special_type(z.imag)];
  399. }
  400. /* need to set errno = EDOM if y is +/- infinity and x is not
  401. a NaN and not -infinity */
  402. if (Py_IS_INFINITY(z.imag) &&
  403. (Py_IS_FINITE(z.real) ||
  404. (Py_IS_INFINITY(z.real) && z.real > 0)))
  405. errno = EDOM;
  406. else
  407. errno = 0;
  408. return r;
  409. }
  410. if (z.real > CM_LOG_LARGE_DOUBLE) {
  411. l = exp(z.real-1.);
  412. r.real = l*cos(z.imag)*Py_MATH_E;
  413. r.imag = l*sin(z.imag)*Py_MATH_E;
  414. } else {
  415. l = exp(z.real);
  416. r.real = l*cos(z.imag);
  417. r.imag = l*sin(z.imag);
  418. }
  419. /* detect overflow, and set errno accordingly */
  420. if (Py_IS_INFINITY(r.real) || Py_IS_INFINITY(r.imag))
  421. errno = ERANGE;
  422. else
  423. errno = 0;
  424. return r;
  425. }
  426. PyDoc_STRVAR(c_exp_doc,
  427. "exp(x)\n"
  428. "\n"
  429. "Return the exponential value e**x.");
  430. static Py_complex log_special_values[7][7];
  431. static Py_complex
  432. c_log(Py_complex z)
  433. {
  434. /*
  435. The usual formula for the real part is log(hypot(z.real, z.imag)).
  436. There are four situations where this formula is potentially
  437. problematic:
  438. (1) the absolute value of z is subnormal. Then hypot is subnormal,
  439. so has fewer than the usual number of bits of accuracy, hence may
  440. have large relative error. This then gives a large absolute error
  441. in the log. This can be solved by rescaling z by a suitable power
  442. of 2.
  443. (2) the absolute value of z is greater than DBL_MAX (e.g. when both
  444. z.real and z.imag are within a factor of 1/sqrt(2) of DBL_MAX)
  445. Again, rescaling solves this.
  446. (3) the absolute value of z is close to 1. In this case it's
  447. difficult to achieve good accuracy, at least in part because a
  448. change of 1ulp in the real or imaginary part of z can result in a
  449. change of billions of ulps in the correctly rounded answer.
  450. (4) z = 0. The simplest thing to do here is to call the
  451. floating-point log with an argument of 0, and let its behaviour
  452. (returning -infinity, signaling a floating-point exception, setting
  453. errno, or whatever) determine that of c_log. So the usual formula
  454. is fine here.
  455. */
  456. Py_complex r;
  457. double ax, ay, am, an, h;
  458. SPECIAL_VALUE(z, log_special_values);
  459. ax = fabs(z.real);
  460. ay = fabs(z.imag);
  461. if (ax > CM_LARGE_DOUBLE || ay > CM_LARGE_DOUBLE) {
  462. r.real = log(hypot(ax/2., ay/2.)) + M_LN2;
  463. } else if (ax < DBL_MIN && ay < DBL_MIN) {
  464. if (ax > 0. || ay > 0.) {
  465. /* catch cases where hypot(ax, ay) is subnormal */
  466. r.real = log(hypot(ldexp(ax, DBL_MANT_DIG),
  467. ldexp(ay, DBL_MANT_DIG))) - DBL_MANT_DIG*M_LN2;
  468. }
  469. else {
  470. /* log(+/-0. +/- 0i) */
  471. r.real = -INF;
  472. r.imag = atan2(z.imag, z.real);
  473. errno = EDOM;
  474. return r;
  475. }
  476. } else {
  477. h = hypot(ax, ay);
  478. if (0.71 <= h && h <= 1.73) {
  479. am = ax > ay ? ax : ay; /* max(ax, ay) */
  480. an = ax > ay ? ay : ax; /* min(ax, ay) */
  481. r.real = m_log1p((am-1)*(am+1)+an*an)/2.;
  482. } else {
  483. r.real = log(h);
  484. }
  485. }
  486. r.imag = atan2(z.imag, z.real);
  487. errno = 0;
  488. return r;
  489. }
  490. static Py_complex
  491. c_log10(Py_complex z)
  492. {
  493. Py_complex r;
  494. int errno_save;
  495. r = c_log(z);
  496. errno_save = errno; /* just in case the divisions affect errno */
  497. r.real = r.real / M_LN10;
  498. r.imag = r.imag / M_LN10;
  499. errno = errno_save;
  500. return r;
  501. }
  502. PyDoc_STRVAR(c_log10_doc,
  503. "log10(x)\n"
  504. "\n"
  505. "Return the base-10 logarithm of x.");
  506. static Py_complex
  507. c_sin(Py_complex z)
  508. {
  509. /* sin(z) = -i sin(iz) */
  510. Py_complex s, r;
  511. s.real = -z.imag;
  512. s.imag = z.real;
  513. s = c_sinh(s);
  514. r.real = s.imag;
  515. r.imag = -s.real;
  516. return r;
  517. }
  518. PyDoc_STRVAR(c_sin_doc,
  519. "sin(x)\n"
  520. "\n"
  521. "Return the sine of x.");
  522. /* sinh(infinity + i*y) needs to be dealt with specially */
  523. static Py_complex sinh_special_values[7][7];
  524. static Py_complex
  525. c_sinh(Py_complex z)
  526. {
  527. Py_complex r;
  528. double x_minus_one;
  529. /* special treatment for sinh(+/-inf + iy) if y is finite and
  530. nonzero */
  531. if (!Py_IS_FINITE(z.real) || !Py_IS_FINITE(z.imag)) {
  532. if (Py_IS_INFINITY(z.real) && Py_IS_FINITE(z.imag)
  533. && (z.imag != 0.)) {
  534. if (z.real > 0) {
  535. r.real = copysign(INF, cos(z.imag));
  536. r.imag = copysign(INF, sin(z.imag));
  537. }
  538. else {
  539. r.real = -copysign(INF, cos(z.imag));
  540. r.imag = copysign(INF, sin(z.imag));
  541. }
  542. }
  543. else {
  544. r = sinh_special_values[special_type(z.real)]
  545. [special_type(z.imag)];
  546. }
  547. /* need to set errno = EDOM if y is +/- infinity and x is not
  548. a NaN */
  549. if (Py_IS_INFINITY(z.imag) && !Py_IS_NAN(z.real))
  550. errno = EDOM;
  551. else
  552. errno = 0;
  553. return r;
  554. }
  555. if (fabs(z.real) > CM_LOG_LARGE_DOUBLE) {
  556. x_minus_one = z.real - copysign(1., z.real);
  557. r.real = cos(z.imag) * sinh(x_minus_one) * Py_MATH_E;
  558. r.imag = sin(z.imag) * cosh(x_minus_one) * Py_MATH_E;
  559. } else {
  560. r.real = cos(z.imag) * sinh(z.real);
  561. r.imag = sin(z.imag) * cosh(z.real);
  562. }
  563. /* detect overflow, and set errno accordingly */
  564. if (Py_IS_INFINITY(r.real) || Py_IS_INFINITY(r.imag))
  565. errno = ERANGE;
  566. else
  567. errno = 0;
  568. return r;
  569. }
  570. PyDoc_STRVAR(c_sinh_doc,
  571. "sinh(x)\n"
  572. "\n"
  573. "Return the hyperbolic sine of x.");
  574. static Py_complex sqrt_special_values[7][7];
  575. static Py_complex
  576. c_sqrt(Py_complex z)
  577. {
  578. /*
  579. Method: use symmetries to reduce to the case when x = z.real and y
  580. = z.imag are nonnegative. Then the real part of the result is
  581. given by
  582. s = sqrt((x + hypot(x, y))/2)
  583. and the imaginary part is
  584. d = (y/2)/s
  585. If either x or y is very large then there's a risk of overflow in
  586. computation of the expression x + hypot(x, y). We can avoid this
  587. by rewriting the formula for s as:
  588. s = 2*sqrt(x/8 + hypot(x/8, y/8))
  589. This costs us two extra multiplications/divisions, but avoids the
  590. overhead of checking for x and y large.
  591. If both x and y are subnormal then hypot(x, y) may also be
  592. subnormal, so will lack full precision. We solve this by rescaling
  593. x and y by a sufficiently large power of 2 to ensure that x and y
  594. are normal.
  595. */
  596. Py_complex r;
  597. double s,d;
  598. double ax, ay;
  599. SPECIAL_VALUE(z, sqrt_special_values);
  600. if (z.real == 0. && z.imag == 0.) {
  601. r.real = 0.;
  602. r.imag = z.imag;
  603. return r;
  604. }
  605. ax = fabs(z.real);
  606. ay = fabs(z.imag);
  607. if (ax < DBL_MIN && ay < DBL_MIN && (ax > 0. || ay > 0.)) {
  608. /* here we catch cases where hypot(ax, ay) is subnormal */
  609. ax = ldexp(ax, CM_SCALE_UP);
  610. s = ldexp(sqrt(ax + hypot(ax, ldexp(ay, CM_SCALE_UP))),
  611. CM_SCALE_DOWN);
  612. } else {
  613. ax /= 8.;
  614. s = 2.*sqrt(ax + hypot(ax, ay/8.));
  615. }
  616. d = ay/(2.*s);
  617. if (z.real >= 0.) {
  618. r.real = s;
  619. r.imag = copysign(d, z.imag);
  620. } else {
  621. r.real = d;
  622. r.imag = copysign(s, z.imag);
  623. }
  624. errno = 0;
  625. return r;
  626. }
  627. PyDoc_STRVAR(c_sqrt_doc,
  628. "sqrt(x)\n"
  629. "\n"
  630. "Return the square root of x.");
  631. static Py_complex
  632. c_tan(Py_complex z)
  633. {
  634. /* tan(z) = -i tanh(iz) */
  635. Py_complex s, r;
  636. s.real = -z.imag;
  637. s.imag = z.real;
  638. s = c_tanh(s);
  639. r.real = s.imag;
  640. r.imag = -s.real;
  641. return r;
  642. }
  643. PyDoc_STRVAR(c_tan_doc,
  644. "tan(x)\n"
  645. "\n"
  646. "Return the tangent of x.");
  647. /* tanh(infinity + i*y) needs to be dealt with specially */
  648. static Py_complex tanh_special_values[7][7];
  649. static Py_complex
  650. c_tanh(Py_complex z)
  651. {
  652. /* Formula:
  653. tanh(x+iy) = (tanh(x)(1+tan(y)^2) + i tan(y)(1-tanh(x))^2) /
  654. (1+tan(y)^2 tanh(x)^2)
  655. To avoid excessive roundoff error, 1-tanh(x)^2 is better computed
  656. as 1/cosh(x)^2. When abs(x) is large, we approximate 1-tanh(x)^2
  657. by 4 exp(-2*x) instead, to avoid possible overflow in the
  658. computation of cosh(x).
  659. */
  660. Py_complex r;
  661. double tx, ty, cx, txty, denom;
  662. /* special treatment for tanh(+/-inf + iy) if y is finite and
  663. nonzero */
  664. if (!Py_IS_FINITE(z.real) || !Py_IS_FINITE(z.imag)) {
  665. if (Py_IS_INFINITY(z.real) && Py_IS_FINITE(z.imag)
  666. && (z.imag != 0.)) {
  667. if (z.real > 0) {
  668. r.real = 1.0;
  669. r.imag = copysign(0.,
  670. 2.*sin(z.imag)*cos(z.imag));
  671. }
  672. else {
  673. r.real = -1.0;
  674. r.imag = copysign(0.,
  675. 2.*sin(z.imag)*cos(z.imag));
  676. }
  677. }
  678. else {
  679. r = tanh_special_values[special_type(z.real)]
  680. [special_type(z.imag)];
  681. }
  682. /* need to set errno = EDOM if z.imag is +/-infinity and
  683. z.real is finite */
  684. if (Py_IS_INFINITY(z.imag) && Py_IS_FINITE(z.real))
  685. errno = EDOM;
  686. else
  687. errno = 0;
  688. return r;
  689. }
  690. /* danger of overflow in 2.*z.imag !*/
  691. if (fabs(z.real) > CM_LOG_LARGE_DOUBLE) {
  692. r.real = copysign(1., z.real);
  693. r.imag = 4.*sin(z.imag)*cos(z.imag)*exp(-2.*fabs(z.real));
  694. } else {
  695. tx = tanh(z.real);
  696. ty = tan(z.imag);
  697. cx = 1./cosh(z.real);
  698. txty = tx*ty;
  699. denom = 1. + txty*txty;
  700. r.real = tx*(1.+ty*ty)/denom;
  701. r.imag = ((ty/denom)*cx)*cx;
  702. }
  703. errno = 0;
  704. return r;
  705. }
  706. PyDoc_STRVAR(c_tanh_doc,
  707. "tanh(x)\n"
  708. "\n"
  709. "Return the hyperbolic tangent of x.");
  710. static PyObject *
  711. cmath_log(PyObject *self, PyObject *args)
  712. {
  713. Py_complex x;
  714. Py_complex y;
  715. if (!PyArg_ParseTuple(args, "D|D", &x, &y))
  716. return NULL;
  717. errno = 0;
  718. PyFPE_START_PROTECT("complex function", return 0)
  719. x = c_log(x);
  720. if (PyTuple_GET_SIZE(args) == 2) {
  721. y = c_log(y);
  722. x = c_quot(x, y);
  723. }
  724. PyFPE_END_PROTECT(x)
  725. if (errno != 0)
  726. return math_error();
  727. return PyComplex_FromCComplex(x);
  728. }
  729. PyDoc_STRVAR(cmath_log_doc,
  730. "log(x[, base]) -> the logarithm of x to the given base.\n\
  731. If the base not specified, returns the natural logarithm (base e) of x.");
  732. /* And now the glue to make them available from Python: */
  733. static PyObject *
  734. math_error(void)
  735. {
  736. if (errno == EDOM)
  737. PyErr_SetString(PyExc_ValueError, "math domain error");
  738. else if (errno == ERANGE)
  739. PyErr_SetString(PyExc_OverflowError, "math range error");
  740. else /* Unexpected math error */
  741. PyErr_SetFromErrno(PyExc_ValueError);
  742. return NULL;
  743. }
  744. static PyObject *
  745. math_1(PyObject *args, Py_complex (*func)(Py_complex))
  746. {
  747. Py_complex x,r ;
  748. if (!PyArg_ParseTuple(args, "D", &x))
  749. return NULL;
  750. errno = 0;
  751. PyFPE_START_PROTECT("complex function", return 0);
  752. r = (*func)(x);
  753. PyFPE_END_PROTECT(r);
  754. if (errno == EDOM) {
  755. PyErr_SetString(PyExc_ValueError, "math domain error");
  756. return NULL;
  757. }
  758. else if (errno == ERANGE) {
  759. PyErr_SetString(PyExc_OverflowError, "math range error");
  760. return NULL;
  761. }
  762. else {
  763. return PyComplex_FromCComplex(r);
  764. }
  765. }
  766. #define FUNC1(stubname, func) \
  767. static PyObject * stubname(PyObject *self, PyObject *args) { \
  768. return math_1(args, func); \
  769. }
  770. FUNC1(cmath_acos, c_acos)
  771. FUNC1(cmath_acosh, c_acosh)
  772. FUNC1(cmath_asin, c_asin)
  773. FUNC1(cmath_asinh, c_asinh)
  774. FUNC1(cmath_atan, c_atan)
  775. FUNC1(cmath_atanh, c_atanh)
  776. FUNC1(cmath_cos, c_cos)
  777. FUNC1(cmath_cosh, c_cosh)
  778. FUNC1(cmath_exp, c_exp)
  779. FUNC1(cmath_log10, c_log10)
  780. FUNC1(cmath_sin, c_sin)
  781. FUNC1(cmath_sinh, c_sinh)
  782. FUNC1(cmath_sqrt, c_sqrt)
  783. FUNC1(cmath_tan, c_tan)
  784. FUNC1(cmath_tanh, c_tanh)
  785. static PyObject *
  786. cmath_phase(PyObject *self, PyObject *args)
  787. {
  788. Py_complex z;
  789. double phi;
  790. if (!PyArg_ParseTuple(args, "D:phase", &z))
  791. return NULL;
  792. errno = 0;
  793. PyFPE_START_PROTECT("arg function", return 0)
  794. phi = c_atan2(z);
  795. PyFPE_END_PROTECT(phi)
  796. if (errno != 0)
  797. return math_error();
  798. else
  799. return PyFloat_FromDouble(phi);
  800. }
  801. PyDoc_STRVAR(cmath_phase_doc,
  802. "phase(z) -> float\n\n\
  803. Return argument, also known as the phase angle, of a complex.");
  804. static PyObject *
  805. cmath_polar(PyObject *self, PyObject *args)
  806. {
  807. Py_complex z;
  808. double r, phi;
  809. if (!PyArg_ParseTuple(args, "D:polar", &z))
  810. return NULL;
  811. errno = 0;
  812. PyFPE_START_PROTECT("polar function", return 0)
  813. phi = c_atan2(z); /* should not cause any exception */
  814. r = c_abs(z); /* sets errno to ERANGE on overflow */
  815. PyFPE_END_PROTECT(r)
  816. if (errno != 0)
  817. return math_error();
  818. else
  819. return Py_BuildValue("dd", r, phi);
  820. }
  821. PyDoc_STRVAR(cmath_polar_doc,
  822. "polar(z) -> r: float, phi: float\n\n\
  823. Convert a complex from rectangular coordinates to polar coordinates. r is\n\
  824. the distance from 0 and phi the phase angle.");
  825. /*
  826. rect() isn't covered by the C99 standard, but it's not too hard to
  827. figure out 'spirit of C99' rules for special value handing:
  828. rect(x, t) should behave like exp(log(x) + it) for positive-signed x
  829. rect(x, t) should behave like -exp(log(-x) + it) for negative-signed x
  830. rect(nan, t) should behave like exp(nan + it), except that rect(nan, 0)
  831. gives nan +- i0 with the sign of the imaginary part unspecified.
  832. */
  833. static Py_complex rect_special_values[7][7];
  834. static PyObject *
  835. cmath_rect(PyObject *self, PyObject *args)
  836. {
  837. Py_complex z;
  838. double r, phi;
  839. if (!PyArg_ParseTuple(args, "dd:rect", &r, &phi))
  840. return NULL;
  841. errno = 0;
  842. PyFPE_START_PROTECT("rect function", return 0)
  843. /* deal with special values */
  844. if (!Py_IS_FINITE(r) || !Py_IS_FINITE(phi)) {
  845. /* if r is +/-infinity and phi is finite but nonzero then
  846. result is (+-INF +-INF i), but we need to compute cos(phi)
  847. and sin(phi) to figure out the signs. */
  848. if (Py_IS_INFINITY(r) && (Py_IS_FINITE(phi)
  849. && (phi != 0.))) {
  850. if (r > 0) {
  851. z.real = copysign(INF, cos(phi));
  852. z.imag = copysign(INF, sin(phi));
  853. }
  854. else {
  855. z.real = -copysign(INF, cos(phi));
  856. z.imag = -copysign(INF, sin(phi));
  857. }
  858. }
  859. else {
  860. z = rect_special_values[special_type(r)]
  861. [special_type(phi)];
  862. }
  863. /* need to set errno = EDOM if r is a nonzero number and phi
  864. is infinite */
  865. if (r != 0. && !Py_IS_NAN(r) && Py_IS_INFINITY(phi))
  866. errno = EDOM;
  867. else
  868. errno = 0;
  869. }
  870. else if (phi == 0.0) {
  871. /* Workaround for buggy results with phi=-0.0 on OS X 10.8. See
  872. bugs.python.org/issue18513. */
  873. z.real = r;
  874. z.imag = r * phi;
  875. errno = 0;
  876. }
  877. else {
  878. z.real = r * cos(phi);
  879. z.imag = r * sin(phi);
  880. errno = 0;
  881. }
  882. PyFPE_END_PROTECT(z)
  883. if (errno != 0)
  884. return math_error();
  885. else
  886. return PyComplex_FromCComplex(z);
  887. }
  888. PyDoc_STRVAR(cmath_rect_doc,
  889. "rect(r, phi) -> z: complex\n\n\
  890. Convert from polar coordinates to rectangular coordinates.");
  891. static PyObject *
  892. cmath_isfinite(PyObject *self, PyObject *args)
  893. {
  894. Py_complex z;
  895. if (!PyArg_ParseTuple(args, "D:isfinite", &z))
  896. return NULL;
  897. return PyBool_FromLong(Py_IS_FINITE(z.real) && Py_IS_FINITE(z.imag));
  898. }
  899. PyDoc_STRVAR(cmath_isfinite_doc,
  900. "isfinite(z) -> bool\n\
  901. Return True if both the real and imaginary parts of z are finite, else False.");
  902. static PyObject *
  903. cmath_isnan(PyObject *self, PyObject *args)
  904. {
  905. Py_complex z;
  906. if (!PyArg_ParseTuple(args, "D:isnan", &z))
  907. return NULL;
  908. return PyBool_FromLong(Py_IS_NAN(z.real) || Py_IS_NAN(z.imag));
  909. }
  910. PyDoc_STRVAR(cmath_isnan_doc,
  911. "isnan(z) -> bool\n\
  912. Checks if the real or imaginary part of z not a number (NaN)");
  913. static PyObject *
  914. cmath_isinf(PyObject *self, PyObject *args)
  915. {
  916. Py_complex z;
  917. if (!PyArg_ParseTuple(args, "D:isinf", &z))
  918. return NULL;
  919. return PyBool_FromLong(Py_IS_INFINITY(z.real) ||
  920. Py_IS_INFINITY(z.imag));
  921. }
  922. PyDoc_STRVAR(cmath_isinf_doc,
  923. "isinf(z) -> bool\n\
  924. Checks if the real or imaginary part of z is infinite.");
  925. PyDoc_STRVAR(module_doc,
  926. "This module is always available. It provides access to mathematical\n"
  927. "functions for complex numbers.");
  928. static PyMethodDef cmath_methods[] = {
  929. {"acos", cmath_acos, METH_VARARGS, c_acos_doc},
  930. {"acosh", cmath_acosh, METH_VARARGS, c_acosh_doc},
  931. {"asin", cmath_asin, METH_VARARGS, c_asin_doc},
  932. {"asinh", cmath_asinh, METH_VARARGS, c_asinh_doc},
  933. {"atan", cmath_atan, METH_VARARGS, c_atan_doc},
  934. {"atanh", cmath_atanh, METH_VARARGS, c_atanh_doc},
  935. {"cos", cmath_cos, METH_VARARGS, c_cos_doc},
  936. {"cosh", cmath_cosh, METH_VARARGS, c_cosh_doc},
  937. {"exp", cmath_exp, METH_VARARGS, c_exp_doc},
  938. {"isfinite", cmath_isfinite, METH_VARARGS, cmath_isfinite_doc},
  939. {"isinf", cmath_isinf, METH_VARARGS, cmath_isinf_doc},
  940. {"isnan", cmath_isnan, METH_VARARGS, cmath_isnan_doc},
  941. {"log", cmath_log, METH_VARARGS, cmath_log_doc},
  942. {"log10", cmath_log10, METH_VARARGS, c_log10_doc},
  943. {"phase", cmath_phase, METH_VARARGS, cmath_phase_doc},
  944. {"polar", cmath_polar, METH_VARARGS, cmath_polar_doc},
  945. {"rect", cmath_rect, METH_VARARGS, cmath_rect_doc},
  946. {"sin", cmath_sin, METH_VARARGS, c_sin_doc},
  947. {"sinh", cmath_sinh, METH_VARARGS, c_sinh_doc},
  948. {"sqrt", cmath_sqrt, METH_VARARGS, c_sqrt_doc},
  949. {"tan", cmath_tan, METH_VARARGS, c_tan_doc},
  950. {"tanh", cmath_tanh, METH_VARARGS, c_tanh_doc},
  951. {NULL, NULL} /* sentinel */
  952. };
  953. static struct PyModuleDef cmathmodule = {
  954. PyModuleDef_HEAD_INIT,
  955. "cmath",
  956. module_doc,
  957. -1,
  958. cmath_methods,
  959. NULL,
  960. NULL,
  961. NULL,
  962. NULL
  963. };
  964. PyMODINIT_FUNC
  965. PyInit_cmath(void)
  966. {
  967. PyObject *m;
  968. m = PyModule_Create(&cmathmodule);
  969. if (m == NULL)
  970. return NULL;
  971. PyModule_AddObject(m, "pi",
  972. PyFloat_FromDouble(Py_MATH_PI));
  973. PyModule_AddObject(m, "e", PyFloat_FromDouble(Py_MATH_E));
  974. /* initialize special value tables */
  975. #define INIT_SPECIAL_VALUES(NAME, BODY) { Py_complex* p = (Py_complex*)NAME; BODY }
  976. #define C(REAL, IMAG) p->real = REAL; p->imag = IMAG; ++p;
  977. INIT_SPECIAL_VALUES(acos_special_values, {
  978. C(P34,INF) C(P,INF) C(P,INF) C(P,-INF) C(P,-INF) C(P34,-INF) C(N,INF)
  979. C(P12,INF) C(U,U) C(U,U) C(U,U) C(U,U) C(P12,-INF) C(N,N)
  980. C(P12,INF) C(U,U) C(P12,0.) C(P12,-0.) C(U,U) C(P12,-INF) C(P12,N)
  981. C(P12,INF) C(U,U) C(P12,0.) C(P12,-0.) C(U,U) C(P12,-INF) C(P12,N)
  982. C(P12,INF) C(U,U) C(U,U) C(U,U) C(U,U) C(P12,-INF) C(N,N)
  983. C(P14,INF) C(0.,INF) C(0.,INF) C(0.,-INF) C(0.,-INF) C(P14,-INF) C(N,INF)
  984. C(N,INF) C(N,N) C(N,N) C(N,N) C(N,N) C(N,-INF) C(N,N)
  985. })
  986. INIT_SPECIAL_VALUES(acosh_special_values, {
  987. C(INF,-P34) C(INF,-P) C(INF,-P) C(INF,P) C(INF,P) C(INF,P34) C(INF,N)
  988. C(INF,-P12) C(U,U) C(U,U) C(U,U) C(U,U) C(INF,P12) C(N,N)
  989. C(INF,-P12) C(U,U) C(0.,-P12) C(0.,P12) C(U,U) C(INF,P12) C(N,N)
  990. C(INF,-P12) C(U,U) C(0.,-P12) C(0.,P12) C(U,U) C(INF,P12) C(N,N)
  991. C(INF,-P12) C(U,U) C(U,U) C(U,U) C(U,U) C(INF,P12) C(N,N)
  992. C(INF,-P14) C(INF,-0.) C(INF,-0.) C(INF,0.) C(INF,0.) C(INF,P14) C(INF,N)
  993. C(INF,N) C(N,N) C(N,N) C(N,N) C(N,N) C(INF,N) C(N,N)
  994. })
  995. INIT_SPECIAL_VALUES(asinh_special_values, {
  996. C(-INF,-P14) C(-INF,-0.) C(-INF,-0.) C(-INF,0.) C(-INF,0.) C(-INF,P14) C(-INF,N)
  997. C(-INF,-P12) C(U,U) C(U,U) C(U,U) C(U,U) C(-INF,P12) C(N,N)
  998. C(-INF,-P12) C(U,U) C(-0.,-0.) C(-0.,0.) C(U,U) C(-INF,P12) C(N,N)
  999. C(INF,-P12) C(U,U) C(0.,-0.) C(0.,0.) C(U,U) C(INF,P12) C(N,N)
  1000. C(INF,-P12) C(U,U) C(U,U) C(U,U) C(U,U) C(INF,P12) C(N,N)
  1001. C(INF,-P14) C(INF,-0.) C(INF,-0.) C(INF,0.) C(INF,0.) C(INF,P14) C(INF,N)
  1002. C(INF,N) C(N,N) C(N,-0.) C(N,0.) C(N,N) C(INF,N) C(N,N)
  1003. })
  1004. INIT_SPECIAL_VALUES(atanh_special_values, {
  1005. C(-0.,-P12) C(-0.,-P12) C(-0.,-P12) C(-0.,P12) C(-0.,P12) C(-0.,P12) C(-0.,N)
  1006. C(-0.,-P12) C(U,U) C(U,U) C(U,U) C(U,U) C(-0.,P12) C(N,N)
  1007. C(-0.,-P12) C(U,U) C(-0.,-0.) C(-0.,0.) C(U,U) C(-0.,P12) C(-0.,N)
  1008. C(0.,-P12) C(U,U) C(0.,-0.) C(0.,0.) C(U,U) C(0.,P12) C(0.,N)
  1009. C(0.,-P12) C(U,U) C(U,U) C(U,U) C(U,U) C(0.,P12) C(N,N)
  1010. C(0.,-P12) C(0.,-P12) C(0.,-P12) C(0.,P12) C(0.,P12) C(0.,P12) C(0.,N)
  1011. C(0.,-P12) C(N,N) C(N,N) C(N,N) C(N,N) C(0.,P12) C(N,N)
  1012. })
  1013. INIT_SPECIAL_VALUES(cosh_special_values, {
  1014. C(INF,N) C(U,U) C(INF,0.) C(INF,-0.) C(U,U) C(INF,N) C(INF,N)
  1015. C(N,N) C(U,U) C(U,U) C(U,U) C(U,U) C(N,N) C(N,N)
  1016. C(N,0.) C(U,U) C(1.,0.) C(1.,-0.) C(U,U) C(N,0.) C(N,0.)
  1017. C(N,0.) C(U,U) C(1.,-0.) C(1.,0.) C(U,U) C(N,0.) C(N,0.)
  1018. C(N,N) C(U,U) C(U,U) C(U,U) C(U,U) C(N,N) C(N,N)
  1019. C(INF,N) C(U,U) C(INF,-0.) C(INF,0.) C(U,U) C(INF,N) C(INF,N)
  1020. C(N,N) C(N,N) C(N,0.) C(N,0.) C(N,N) C(N,N) C(N,N)
  1021. })
  1022. INIT_SPECIAL_VALUES(exp_special_values, {
  1023. C(0.,0.) C(U,U) C(0.,-0.) C(0.,0.) C(U,U) C(0.,0.) C(0.,0.)
  1024. C(N,N) C(U,U) C(U,U) C(U,U) C(U,U) C(N,N) C(N,N)
  1025. C(N,N) C(U,U) C(1.,-0.) C(1.,0.) C(U,U) C(N,N) C(N,N)
  1026. C(N,N) C(U,U) C(1.,-0.) C(1.,0.) C(U,U) C(N,N) C(N,N)
  1027. C(N,N) C(U,U) C(U,U) C(U,U) C(U,U) C(N,N) C(N,N)
  1028. C(INF,N) C(U,U) C(INF,-0.) C(INF,0.) C(U,U) C(INF,N) C(INF,N)
  1029. C(N,N) C(N,N) C(N,-0.) C(N,0.) C(N,N) C(N,N) C(N,N)
  1030. })
  1031. INIT_SPECIAL_VALUES(log_special_values, {
  1032. C(INF,-P34) C(INF,-P) C(INF,-P) C(INF,P) C(INF,P) C(INF,P34) C(INF,N)
  1033. C(INF,-P12) C(U,U) C(U,U) C(U,U) C(U,U) C(INF,P12) C(N,N)
  1034. C(INF,-P12) C(U,U) C(-INF,-P) C(-INF,P) C(U,U) C(INF,P12) C(N,N)
  1035. C(INF,-P12) C(U,U) C(-INF,-0.) C(-INF,0.) C(U,U) C(INF,P12) C(N,N)
  1036. C(INF,-P12) C(U,U) C(U,U) C(U,U) C(U,U) C(INF,P12) C(N,N)
  1037. C(INF,-P14) C(INF,-0.) C(INF,-0.) C(INF,0.) C(INF,0.) C(INF,P14) C(INF,N)
  1038. C(INF,N) C(N,N) C(N,N) C(N,N) C(N,N) C(INF,N) C(N,N)
  1039. })
  1040. INIT_SPECIAL_VALUES(sinh_special_values, {
  1041. C(INF,N) C(U,U) C(-INF,-0.) C(-INF,0.) C(U,U) C(INF,N) C(INF,N)
  1042. C(N,N) C(U,U) C(U,U) C(U,U) C(U,U) C(N,N) C(N,N)
  1043. C(0.,N) C(U,U) C(-0.,-0.) C(-0.,0.) C(U,U) C(0.,N) C(0.,N)
  1044. C(0.,N) C(U,U) C(0.,-0.) C(0.,0.) C(U,U) C(0.,N) C(0.,N)
  1045. C(N,N) C(U,U) C(U,U) C(U,U) C(U,U) C(N,N) C(N,N)
  1046. C(INF,N) C(U,U) C(INF,-0.) C(INF,0.) C(U,U) C(INF,N) C(INF,N)
  1047. C(N,N) C(N,N) C(N,-0.) C(N,0.) C(N,N) C(N,N) C(N,N)
  1048. })
  1049. INIT_SPECIAL_VALUES(sqrt_special_values, {
  1050. C(INF,-INF) C(0.,-INF) C(0.,-INF) C(0.,INF) C(0.,INF) C(INF,INF) C(N,INF)
  1051. C(INF,-INF) C(U,U) C(U,U) C(U,U) C(U,U) C(INF,INF) C(N,N)
  1052. C(INF,-INF) C(U,U) C(0.,-0.) C(0.,0.) C(U,U) C(INF,INF) C(N,N)
  1053. C(INF,-INF) C(U,U) C(0.,-0.) C(0.,0.) C(U,U) C(INF,INF) C(N,N)
  1054. C(INF,-INF) C(U,U) C(U,U) C(U,U) C(U,U) C(INF,INF) C(N,N)
  1055. C(INF,-INF) C(INF,-0.) C(INF,-0.) C(INF,0.) C(INF,0.) C(INF,INF) C(INF,N)
  1056. C(INF,-INF) C(N,N) C(N,N) C(N,N) C(N,N) C(INF,INF) C(N,N)
  1057. })
  1058. INIT_SPECIAL_VALUES(tanh_special_values, {
  1059. C(-1.,0.) C(U,U) C(-1.,-0.) C(-1.,0.) C(U,U) C(-1.,0.) C(-1.,0.)
  1060. C(N,N) C(U,U) C(U,U) C(U,U) C(U,U) C(N,N) C(N,N)
  1061. C(N,N) C(U,U) C(-0.,-0.) C(-0.,0.) C(U,U) C(N,N) C(N,N)
  1062. C(N,N) C(U,U) C(0.,-0.) C(0.,0.) C(U,U) C(N,N) C(N,N)
  1063. C(N,N) C(U,U) C(U,U) C(U,U) C(U,U) C(N,N) C(N,N)
  1064. C(1.,0.) C(U,U) C(1.,-0.) C(1.,0.) C(U,U) C(1.,0.) C(1.,0.)
  1065. C(N,N) C(N,N) C(N,-0.) C(N,0.) C(N,N) C(N,N) C(N,N)
  1066. })
  1067. INIT_SPECIAL_VALUES(rect_special_values, {
  1068. C(INF,N) C(U,U) C(-INF,0.) C(-INF,-0.) C(U,U) C(INF,N) C(INF,N)
  1069. C(N,N) C(U,U) C(U,U) C(U,U) C(U,U) C(N,N) C(N,N)
  1070. C(0.,0.) C(U,U) C(-0.,0.) C(-0.,-0.) C(U,U) C(0.,0.) C(0.,0.)
  1071. C(0.,0.) C(U,U) C(0.,-0.) C(0.,0.) C(U,U) C(0.,0.) C(0.,0.)
  1072. C(N,N) C(U,U) C(U,U) C(U,U) C(U,U) C(N,N) C(N,N)
  1073. C(INF,N) C(U,U) C(INF,-0.) C(INF,0.) C(U,U) C(INF,N) C(INF,N)
  1074. C(N,N) C(N,N) C(N,0.) C(N,0.) C(N,N) C(N,N) C(N,N)
  1075. })
  1076. return m;
  1077. }