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.

1358 lines
41 KiB

30 years ago
29 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
29 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
29 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. #include "clinic/cmathmodule.c.h"
  9. /*[clinic input]
  10. module cmath
  11. [clinic start generated code]*/
  12. /*[clinic end generated code: output=da39a3ee5e6b4b0d input=308d6839f4a46333]*/
  13. /*[python input]
  14. class Py_complex_protected_converter(Py_complex_converter):
  15. def modify(self):
  16. return 'errno = 0; PyFPE_START_PROTECT("complex function", goto exit);'
  17. class Py_complex_protected_return_converter(CReturnConverter):
  18. type = "Py_complex"
  19. def render(self, function, data):
  20. self.declare(data)
  21. data.return_conversion.append("""
  22. PyFPE_END_PROTECT(_return_value);
  23. if (errno == EDOM) {
  24. PyErr_SetString(PyExc_ValueError, "math domain error");
  25. goto exit;
  26. }
  27. else if (errno == ERANGE) {
  28. PyErr_SetString(PyExc_OverflowError, "math range error");
  29. goto exit;
  30. }
  31. else {
  32. return_value = PyComplex_FromCComplex(_return_value);
  33. }
  34. """.strip())
  35. [python start generated code]*/
  36. /*[python end generated code: output=da39a3ee5e6b4b0d input=345daa075b1028e7]*/
  37. #if (FLT_RADIX != 2 && FLT_RADIX != 16)
  38. #error "Modules/cmathmodule.c expects FLT_RADIX to be 2 or 16"
  39. #endif
  40. #ifndef M_LN2
  41. #define M_LN2 (0.6931471805599453094) /* natural log of 2 */
  42. #endif
  43. #ifndef M_LN10
  44. #define M_LN10 (2.302585092994045684) /* natural log of 10 */
  45. #endif
  46. /*
  47. CM_LARGE_DOUBLE is used to avoid spurious overflow in the sqrt, log,
  48. inverse trig and inverse hyperbolic trig functions. Its log is used in the
  49. evaluation of exp, cos, cosh, sin, sinh, tan, and tanh to avoid unnecessary
  50. overflow.
  51. */
  52. #define CM_LARGE_DOUBLE (DBL_MAX/4.)
  53. #define CM_SQRT_LARGE_DOUBLE (sqrt(CM_LARGE_DOUBLE))
  54. #define CM_LOG_LARGE_DOUBLE (log(CM_LARGE_DOUBLE))
  55. #define CM_SQRT_DBL_MIN (sqrt(DBL_MIN))
  56. /*
  57. CM_SCALE_UP is an odd integer chosen such that multiplication by
  58. 2**CM_SCALE_UP is sufficient to turn a subnormal into a normal.
  59. CM_SCALE_DOWN is (-(CM_SCALE_UP+1)/2). These scalings are used to compute
  60. square roots accurately when the real and imaginary parts of the argument
  61. are subnormal.
  62. */
  63. #if FLT_RADIX==2
  64. #define CM_SCALE_UP (2*(DBL_MANT_DIG/2) + 1)
  65. #elif FLT_RADIX==16
  66. #define CM_SCALE_UP (4*DBL_MANT_DIG+1)
  67. #endif
  68. #define CM_SCALE_DOWN (-(CM_SCALE_UP+1)/2)
  69. /* forward declarations */
  70. static Py_complex cmath_asinh_impl(PyModuleDef *, Py_complex);
  71. static Py_complex cmath_atanh_impl(PyModuleDef *, Py_complex);
  72. static Py_complex cmath_cosh_impl(PyModuleDef *, Py_complex);
  73. static Py_complex cmath_sinh_impl(PyModuleDef *, Py_complex);
  74. static Py_complex cmath_sqrt_impl(PyModuleDef *, Py_complex);
  75. static Py_complex cmath_tanh_impl(PyModuleDef *, Py_complex);
  76. static PyObject * math_error(void);
  77. /* Code to deal with special values (infinities, NaNs, etc.). */
  78. /* special_type takes a double and returns an integer code indicating
  79. the type of the double as follows:
  80. */
  81. enum special_types {
  82. ST_NINF, /* 0, negative infinity */
  83. ST_NEG, /* 1, negative finite number (nonzero) */
  84. ST_NZERO, /* 2, -0. */
  85. ST_PZERO, /* 3, +0. */
  86. ST_POS, /* 4, positive finite number (nonzero) */
  87. ST_PINF, /* 5, positive infinity */
  88. ST_NAN /* 6, Not a Number */
  89. };
  90. static enum special_types
  91. special_type(double d)
  92. {
  93. if (Py_IS_FINITE(d)) {
  94. if (d != 0) {
  95. if (copysign(1., d) == 1.)
  96. return ST_POS;
  97. else
  98. return ST_NEG;
  99. }
  100. else {
  101. if (copysign(1., d) == 1.)
  102. return ST_PZERO;
  103. else
  104. return ST_NZERO;
  105. }
  106. }
  107. if (Py_IS_NAN(d))
  108. return ST_NAN;
  109. if (copysign(1., d) == 1.)
  110. return ST_PINF;
  111. else
  112. return ST_NINF;
  113. }
  114. #define SPECIAL_VALUE(z, table) \
  115. if (!Py_IS_FINITE((z).real) || !Py_IS_FINITE((z).imag)) { \
  116. errno = 0; \
  117. return table[special_type((z).real)] \
  118. [special_type((z).imag)]; \
  119. }
  120. #define P Py_MATH_PI
  121. #define P14 0.25*Py_MATH_PI
  122. #define P12 0.5*Py_MATH_PI
  123. #define P34 0.75*Py_MATH_PI
  124. #define INF Py_HUGE_VAL
  125. #define N Py_NAN
  126. #define U -9.5426319407711027e33 /* unlikely value, used as placeholder */
  127. /* First, the C functions that do the real work. Each of the c_*
  128. functions computes and returns the C99 Annex G recommended result
  129. and also sets errno as follows: errno = 0 if no floating-point
  130. exception is associated with the result; errno = EDOM if C99 Annex
  131. G recommends raising divide-by-zero or invalid for this result; and
  132. errno = ERANGE where the overflow floating-point signal should be
  133. raised.
  134. */
  135. static Py_complex acos_special_values[7][7];
  136. /*[clinic input]
  137. cmath.acos -> Py_complex_protected
  138. z: Py_complex_protected
  139. /
  140. Return the arc cosine of z.
  141. [clinic start generated code]*/
  142. static Py_complex
  143. cmath_acos_impl(PyModuleDef *module, Py_complex z)
  144. /*[clinic end generated code: output=7c1dd21ff818db6b input=bd6cbd78ae851927]*/
  145. {
  146. Py_complex s1, s2, r;
  147. SPECIAL_VALUE(z, acos_special_values);
  148. if (fabs(z.real) > CM_LARGE_DOUBLE || fabs(z.imag) > CM_LARGE_DOUBLE) {
  149. /* avoid unnecessary overflow for large arguments */
  150. r.real = atan2(fabs(z.imag), z.real);
  151. /* split into cases to make sure that the branch cut has the
  152. correct continuity on systems with unsigned zeros */
  153. if (z.real < 0.) {
  154. r.imag = -copysign(log(hypot(z.real/2., z.imag/2.)) +
  155. M_LN2*2., z.imag);
  156. } else {
  157. r.imag = copysign(log(hypot(z.real/2., z.imag/2.)) +
  158. M_LN2*2., -z.imag);
  159. }
  160. } else {
  161. s1.real = 1.-z.real;
  162. s1.imag = -z.imag;
  163. s1 = cmath_sqrt_impl(module, s1);
  164. s2.real = 1.+z.real;
  165. s2.imag = z.imag;
  166. s2 = cmath_sqrt_impl(module, s2);
  167. r.real = 2.*atan2(s1.real, s2.real);
  168. r.imag = m_asinh(s2.real*s1.imag - s2.imag*s1.real);
  169. }
  170. errno = 0;
  171. return r;
  172. }
  173. static Py_complex acosh_special_values[7][7];
  174. /*[clinic input]
  175. cmath.acosh = cmath.acos
  176. Return the inverse hyperbolic cosine of z.
  177. [clinic start generated code]*/
  178. static Py_complex
  179. cmath_acosh_impl(PyModuleDef *module, Py_complex z)
  180. /*[clinic end generated code: output=c23c776429def981 input=3f61bee7d703e53c]*/
  181. {
  182. Py_complex s1, s2, r;
  183. SPECIAL_VALUE(z, acosh_special_values);
  184. if (fabs(z.real) > CM_LARGE_DOUBLE || fabs(z.imag) > CM_LARGE_DOUBLE) {
  185. /* avoid unnecessary overflow for large arguments */
  186. r.real = log(hypot(z.real/2., z.imag/2.)) + M_LN2*2.;
  187. r.imag = atan2(z.imag, z.real);
  188. } else {
  189. s1.real = z.real - 1.;
  190. s1.imag = z.imag;
  191. s1 = cmath_sqrt_impl(module, s1);
  192. s2.real = z.real + 1.;
  193. s2.imag = z.imag;
  194. s2 = cmath_sqrt_impl(module, s2);
  195. r.real = m_asinh(s1.real*s2.real + s1.imag*s2.imag);
  196. r.imag = 2.*atan2(s1.imag, s2.real);
  197. }
  198. errno = 0;
  199. return r;
  200. }
  201. /*[clinic input]
  202. cmath.asin = cmath.acos
  203. Return the arc sine of z.
  204. [clinic start generated code]*/
  205. static Py_complex
  206. cmath_asin_impl(PyModuleDef *module, Py_complex z)
  207. /*[clinic end generated code: output=42d2346d46690826 input=be0bf0cfdd5239c5]*/
  208. {
  209. /* asin(z) = -i asinh(iz) */
  210. Py_complex s, r;
  211. s.real = -z.imag;
  212. s.imag = z.real;
  213. s = cmath_asinh_impl(module, s);
  214. r.real = s.imag;
  215. r.imag = -s.real;
  216. return r;
  217. }
  218. static Py_complex asinh_special_values[7][7];
  219. /*[clinic input]
  220. cmath.asinh = cmath.acos
  221. Return the inverse hyperbolic sine of z.
  222. [clinic start generated code]*/
  223. static Py_complex
  224. cmath_asinh_impl(PyModuleDef *module, Py_complex z)
  225. /*[clinic end generated code: output=0c6664823c7b1b35 input=5c09448fcfc89a79]*/
  226. {
  227. Py_complex s1, s2, r;
  228. SPECIAL_VALUE(z, asinh_special_values);
  229. if (fabs(z.real) > CM_LARGE_DOUBLE || fabs(z.imag) > CM_LARGE_DOUBLE) {
  230. if (z.imag >= 0.) {
  231. r.real = copysign(log(hypot(z.real/2., z.imag/2.)) +
  232. M_LN2*2., z.real);
  233. } else {
  234. r.real = -copysign(log(hypot(z.real/2., z.imag/2.)) +
  235. M_LN2*2., -z.real);
  236. }
  237. r.imag = atan2(z.imag, fabs(z.real));
  238. } else {
  239. s1.real = 1.+z.imag;
  240. s1.imag = -z.real;
  241. s1 = cmath_sqrt_impl(module, s1);
  242. s2.real = 1.-z.imag;
  243. s2.imag = z.real;
  244. s2 = cmath_sqrt_impl(module, s2);
  245. r.real = m_asinh(s1.real*s2.imag-s2.real*s1.imag);
  246. r.imag = atan2(z.imag, s1.real*s2.real-s1.imag*s2.imag);
  247. }
  248. errno = 0;
  249. return r;
  250. }
  251. /*[clinic input]
  252. cmath.atan = cmath.acos
  253. Return the arc tangent of z.
  254. [clinic start generated code]*/
  255. static Py_complex
  256. cmath_atan_impl(PyModuleDef *module, Py_complex z)
  257. /*[clinic end generated code: output=b7d44f02c6a5c3b5 input=3b21ff7d5eac632a]*/
  258. {
  259. /* atan(z) = -i atanh(iz) */
  260. Py_complex s, r;
  261. s.real = -z.imag;
  262. s.imag = z.real;
  263. s = cmath_atanh_impl(module, s);
  264. r.real = s.imag;
  265. r.imag = -s.real;
  266. return r;
  267. }
  268. /* Windows screws up atan2 for inf and nan, and alpha Tru64 5.1 doesn't follow
  269. C99 for atan2(0., 0.). */
  270. static double
  271. c_atan2(Py_complex z)
  272. {
  273. if (Py_IS_NAN(z.real) || Py_IS_NAN(z.imag))
  274. return Py_NAN;
  275. if (Py_IS_INFINITY(z.imag)) {
  276. if (Py_IS_INFINITY(z.real)) {
  277. if (copysign(1., z.real) == 1.)
  278. /* atan2(+-inf, +inf) == +-pi/4 */
  279. return copysign(0.25*Py_MATH_PI, z.imag);
  280. else
  281. /* atan2(+-inf, -inf) == +-pi*3/4 */
  282. return copysign(0.75*Py_MATH_PI, z.imag);
  283. }
  284. /* atan2(+-inf, x) == +-pi/2 for finite x */
  285. return copysign(0.5*Py_MATH_PI, z.imag);
  286. }
  287. if (Py_IS_INFINITY(z.real) || z.imag == 0.) {
  288. if (copysign(1., z.real) == 1.)
  289. /* atan2(+-y, +inf) = atan2(+-0, +x) = +-0. */
  290. return copysign(0., z.imag);
  291. else
  292. /* atan2(+-y, -inf) = atan2(+-0., -x) = +-pi. */
  293. return copysign(Py_MATH_PI, z.imag);
  294. }
  295. return atan2(z.imag, z.real);
  296. }
  297. static Py_complex atanh_special_values[7][7];
  298. /*[clinic input]
  299. cmath.atanh = cmath.acos
  300. Return the inverse hyperbolic tangent of z.
  301. [clinic start generated code]*/
  302. static Py_complex
  303. cmath_atanh_impl(PyModuleDef *module, Py_complex z)
  304. /*[clinic end generated code: output=279e0b9fefc8da7c input=2b3fdb82fb34487b]*/
  305. {
  306. Py_complex r;
  307. double ay, h;
  308. SPECIAL_VALUE(z, atanh_special_values);
  309. /* Reduce to case where z.real >= 0., using atanh(z) = -atanh(-z). */
  310. if (z.real < 0.) {
  311. return _Py_c_neg(cmath_atanh_impl(module, _Py_c_neg(z)));
  312. }
  313. ay = fabs(z.imag);
  314. if (z.real > CM_SQRT_LARGE_DOUBLE || ay > CM_SQRT_LARGE_DOUBLE) {
  315. /*
  316. if abs(z) is large then we use the approximation
  317. atanh(z) ~ 1/z +/- i*pi/2 (+/- depending on the sign
  318. of z.imag)
  319. */
  320. h = hypot(z.real/2., z.imag/2.); /* safe from overflow */
  321. r.real = z.real/4./h/h;
  322. /* the two negations in the next line cancel each other out
  323. except when working with unsigned zeros: they're there to
  324. ensure that the branch cut has the correct continuity on
  325. systems that don't support signed zeros */
  326. r.imag = -copysign(Py_MATH_PI/2., -z.imag);
  327. errno = 0;
  328. } else if (z.real == 1. && ay < CM_SQRT_DBL_MIN) {
  329. /* C99 standard says: atanh(1+/-0.) should be inf +/- 0i */
  330. if (ay == 0.) {
  331. r.real = INF;
  332. r.imag = z.imag;
  333. errno = EDOM;
  334. } else {
  335. r.real = -log(sqrt(ay)/sqrt(hypot(ay, 2.)));
  336. r.imag = copysign(atan2(2., -ay)/2, z.imag);
  337. errno = 0;
  338. }
  339. } else {
  340. r.real = m_log1p(4.*z.real/((1-z.real)*(1-z.real) + ay*ay))/4.;
  341. r.imag = -atan2(-2.*z.imag, (1-z.real)*(1+z.real) - ay*ay)/2.;
  342. errno = 0;
  343. }
  344. return r;
  345. }
  346. /*[clinic input]
  347. cmath.cos = cmath.acos
  348. Return the cosine of z.
  349. [clinic start generated code]*/
  350. static Py_complex
  351. cmath_cos_impl(PyModuleDef *module, Py_complex z)
  352. /*[clinic end generated code: output=9d1cdc1b5e761667 input=6022e39b77127ac7]*/
  353. {
  354. /* cos(z) = cosh(iz) */
  355. Py_complex r;
  356. r.real = -z.imag;
  357. r.imag = z.real;
  358. r = cmath_cosh_impl(module, r);
  359. return r;
  360. }
  361. /* cosh(infinity + i*y) needs to be dealt with specially */
  362. static Py_complex cosh_special_values[7][7];
  363. /*[clinic input]
  364. cmath.cosh = cmath.acos
  365. Return the hyperbolic cosine of z.
  366. [clinic start generated code]*/
  367. static Py_complex
  368. cmath_cosh_impl(PyModuleDef *module, Py_complex z)
  369. /*[clinic end generated code: output=f3b5d3282b3024d3 input=d6b66339e9cc332b]*/
  370. {
  371. Py_complex r;
  372. double x_minus_one;
  373. /* special treatment for cosh(+/-inf + iy) if y is not a NaN */
  374. if (!Py_IS_FINITE(z.real) || !Py_IS_FINITE(z.imag)) {
  375. if (Py_IS_INFINITY(z.real) && Py_IS_FINITE(z.imag) &&
  376. (z.imag != 0.)) {
  377. if (z.real > 0) {
  378. r.real = copysign(INF, cos(z.imag));
  379. r.imag = copysign(INF, sin(z.imag));
  380. }
  381. else {
  382. r.real = copysign(INF, cos(z.imag));
  383. r.imag = -copysign(INF, sin(z.imag));
  384. }
  385. }
  386. else {
  387. r = cosh_special_values[special_type(z.real)]
  388. [special_type(z.imag)];
  389. }
  390. /* need to set errno = EDOM if y is +/- infinity and x is not
  391. a NaN */
  392. if (Py_IS_INFINITY(z.imag) && !Py_IS_NAN(z.real))
  393. errno = EDOM;
  394. else
  395. errno = 0;
  396. return r;
  397. }
  398. if (fabs(z.real) > CM_LOG_LARGE_DOUBLE) {
  399. /* deal correctly with cases where cosh(z.real) overflows but
  400. cosh(z) does not. */
  401. x_minus_one = z.real - copysign(1., z.real);
  402. r.real = cos(z.imag) * cosh(x_minus_one) * Py_MATH_E;
  403. r.imag = sin(z.imag) * sinh(x_minus_one) * Py_MATH_E;
  404. } else {
  405. r.real = cos(z.imag) * cosh(z.real);
  406. r.imag = sin(z.imag) * sinh(z.real);
  407. }
  408. /* detect overflow, and set errno accordingly */
  409. if (Py_IS_INFINITY(r.real) || Py_IS_INFINITY(r.imag))
  410. errno = ERANGE;
  411. else
  412. errno = 0;
  413. return r;
  414. }
  415. /* exp(infinity + i*y) and exp(-infinity + i*y) need special treatment for
  416. finite y */
  417. static Py_complex exp_special_values[7][7];
  418. /*[clinic input]
  419. cmath.exp = cmath.acos
  420. Return the exponential value e**z.
  421. [clinic start generated code]*/
  422. static Py_complex
  423. cmath_exp_impl(PyModuleDef *module, Py_complex z)
  424. /*[clinic end generated code: output=6f8825eb2bcad9ba input=8b9e6cf8a92174c3]*/
  425. {
  426. Py_complex r;
  427. double l;
  428. if (!Py_IS_FINITE(z.real) || !Py_IS_FINITE(z.imag)) {
  429. if (Py_IS_INFINITY(z.real) && Py_IS_FINITE(z.imag)
  430. && (z.imag != 0.)) {
  431. if (z.real > 0) {
  432. r.real = copysign(INF, cos(z.imag));
  433. r.imag = copysign(INF, sin(z.imag));
  434. }
  435. else {
  436. r.real = copysign(0., cos(z.imag));
  437. r.imag = copysign(0., sin(z.imag));
  438. }
  439. }
  440. else {
  441. r = exp_special_values[special_type(z.real)]
  442. [special_type(z.imag)];
  443. }
  444. /* need to set errno = EDOM if y is +/- infinity and x is not
  445. a NaN and not -infinity */
  446. if (Py_IS_INFINITY(z.imag) &&
  447. (Py_IS_FINITE(z.real) ||
  448. (Py_IS_INFINITY(z.real) && z.real > 0)))
  449. errno = EDOM;
  450. else
  451. errno = 0;
  452. return r;
  453. }
  454. if (z.real > CM_LOG_LARGE_DOUBLE) {
  455. l = exp(z.real-1.);
  456. r.real = l*cos(z.imag)*Py_MATH_E;
  457. r.imag = l*sin(z.imag)*Py_MATH_E;
  458. } else {
  459. l = exp(z.real);
  460. r.real = l*cos(z.imag);
  461. r.imag = l*sin(z.imag);
  462. }
  463. /* detect overflow, and set errno accordingly */
  464. if (Py_IS_INFINITY(r.real) || Py_IS_INFINITY(r.imag))
  465. errno = ERANGE;
  466. else
  467. errno = 0;
  468. return r;
  469. }
  470. static Py_complex log_special_values[7][7];
  471. static Py_complex
  472. c_log(Py_complex z)
  473. {
  474. /*
  475. The usual formula for the real part is log(hypot(z.real, z.imag)).
  476. There are four situations where this formula is potentially
  477. problematic:
  478. (1) the absolute value of z is subnormal. Then hypot is subnormal,
  479. so has fewer than the usual number of bits of accuracy, hence may
  480. have large relative error. This then gives a large absolute error
  481. in the log. This can be solved by rescaling z by a suitable power
  482. of 2.
  483. (2) the absolute value of z is greater than DBL_MAX (e.g. when both
  484. z.real and z.imag are within a factor of 1/sqrt(2) of DBL_MAX)
  485. Again, rescaling solves this.
  486. (3) the absolute value of z is close to 1. In this case it's
  487. difficult to achieve good accuracy, at least in part because a
  488. change of 1ulp in the real or imaginary part of z can result in a
  489. change of billions of ulps in the correctly rounded answer.
  490. (4) z = 0. The simplest thing to do here is to call the
  491. floating-point log with an argument of 0, and let its behaviour
  492. (returning -infinity, signaling a floating-point exception, setting
  493. errno, or whatever) determine that of c_log. So the usual formula
  494. is fine here.
  495. */
  496. Py_complex r;
  497. double ax, ay, am, an, h;
  498. SPECIAL_VALUE(z, log_special_values);
  499. ax = fabs(z.real);
  500. ay = fabs(z.imag);
  501. if (ax > CM_LARGE_DOUBLE || ay > CM_LARGE_DOUBLE) {
  502. r.real = log(hypot(ax/2., ay/2.)) + M_LN2;
  503. } else if (ax < DBL_MIN && ay < DBL_MIN) {
  504. if (ax > 0. || ay > 0.) {
  505. /* catch cases where hypot(ax, ay) is subnormal */
  506. r.real = log(hypot(ldexp(ax, DBL_MANT_DIG),
  507. ldexp(ay, DBL_MANT_DIG))) - DBL_MANT_DIG*M_LN2;
  508. }
  509. else {
  510. /* log(+/-0. +/- 0i) */
  511. r.real = -INF;
  512. r.imag = atan2(z.imag, z.real);
  513. errno = EDOM;
  514. return r;
  515. }
  516. } else {
  517. h = hypot(ax, ay);
  518. if (0.71 <= h && h <= 1.73) {
  519. am = ax > ay ? ax : ay; /* max(ax, ay) */
  520. an = ax > ay ? ay : ax; /* min(ax, ay) */
  521. r.real = m_log1p((am-1)*(am+1)+an*an)/2.;
  522. } else {
  523. r.real = log(h);
  524. }
  525. }
  526. r.imag = atan2(z.imag, z.real);
  527. errno = 0;
  528. return r;
  529. }
  530. /*[clinic input]
  531. cmath.log10 = cmath.acos
  532. Return the base-10 logarithm of z.
  533. [clinic start generated code]*/
  534. static Py_complex
  535. cmath_log10_impl(PyModuleDef *module, Py_complex z)
  536. /*[clinic end generated code: output=c7c426ca0e782341 input=cff5644f73c1519c]*/
  537. {
  538. Py_complex r;
  539. int errno_save;
  540. r = c_log(z);
  541. errno_save = errno; /* just in case the divisions affect errno */
  542. r.real = r.real / M_LN10;
  543. r.imag = r.imag / M_LN10;
  544. errno = errno_save;
  545. return r;
  546. }
  547. /*[clinic input]
  548. cmath.sin = cmath.acos
  549. Return the sine of z.
  550. [clinic start generated code]*/
  551. static Py_complex
  552. cmath_sin_impl(PyModuleDef *module, Py_complex z)
  553. /*[clinic end generated code: output=e7f5e2b253825ac7 input=2d3519842a8b4b85]*/
  554. {
  555. /* sin(z) = -i sin(iz) */
  556. Py_complex s, r;
  557. s.real = -z.imag;
  558. s.imag = z.real;
  559. s = cmath_sinh_impl(module, s);
  560. r.real = s.imag;
  561. r.imag = -s.real;
  562. return r;
  563. }
  564. /* sinh(infinity + i*y) needs to be dealt with specially */
  565. static Py_complex sinh_special_values[7][7];
  566. /*[clinic input]
  567. cmath.sinh = cmath.acos
  568. Return the hyperbolic sine of z.
  569. [clinic start generated code]*/
  570. static Py_complex
  571. cmath_sinh_impl(PyModuleDef *module, Py_complex z)
  572. /*[clinic end generated code: output=d71fff8298043a95 input=d2d3fc8c1ddfd2dd]*/
  573. {
  574. Py_complex r;
  575. double x_minus_one;
  576. /* special treatment for sinh(+/-inf + iy) if y is finite and
  577. nonzero */
  578. if (!Py_IS_FINITE(z.real) || !Py_IS_FINITE(z.imag)) {
  579. if (Py_IS_INFINITY(z.real) && Py_IS_FINITE(z.imag)
  580. && (z.imag != 0.)) {
  581. if (z.real > 0) {
  582. r.real = copysign(INF, cos(z.imag));
  583. r.imag = copysign(INF, sin(z.imag));
  584. }
  585. else {
  586. r.real = -copysign(INF, cos(z.imag));
  587. r.imag = copysign(INF, sin(z.imag));
  588. }
  589. }
  590. else {
  591. r = sinh_special_values[special_type(z.real)]
  592. [special_type(z.imag)];
  593. }
  594. /* need to set errno = EDOM if y is +/- infinity and x is not
  595. a NaN */
  596. if (Py_IS_INFINITY(z.imag) && !Py_IS_NAN(z.real))
  597. errno = EDOM;
  598. else
  599. errno = 0;
  600. return r;
  601. }
  602. if (fabs(z.real) > CM_LOG_LARGE_DOUBLE) {
  603. x_minus_one = z.real - copysign(1., z.real);
  604. r.real = cos(z.imag) * sinh(x_minus_one) * Py_MATH_E;
  605. r.imag = sin(z.imag) * cosh(x_minus_one) * Py_MATH_E;
  606. } else {
  607. r.real = cos(z.imag) * sinh(z.real);
  608. r.imag = sin(z.imag) * cosh(z.real);
  609. }
  610. /* detect overflow, and set errno accordingly */
  611. if (Py_IS_INFINITY(r.real) || Py_IS_INFINITY(r.imag))
  612. errno = ERANGE;
  613. else
  614. errno = 0;
  615. return r;
  616. }
  617. static Py_complex sqrt_special_values[7][7];
  618. /*[clinic input]
  619. cmath.sqrt = cmath.acos
  620. Return the square root of z.
  621. [clinic start generated code]*/
  622. static Py_complex
  623. cmath_sqrt_impl(PyModuleDef *module, Py_complex z)
  624. /*[clinic end generated code: output=b6bda283d0c5a7b4 input=7088b166fc9a58c7]*/
  625. {
  626. /*
  627. Method: use symmetries to reduce to the case when x = z.real and y
  628. = z.imag are nonnegative. Then the real part of the result is
  629. given by
  630. s = sqrt((x + hypot(x, y))/2)
  631. and the imaginary part is
  632. d = (y/2)/s
  633. If either x or y is very large then there's a risk of overflow in
  634. computation of the expression x + hypot(x, y). We can avoid this
  635. by rewriting the formula for s as:
  636. s = 2*sqrt(x/8 + hypot(x/8, y/8))
  637. This costs us two extra multiplications/divisions, but avoids the
  638. overhead of checking for x and y large.
  639. If both x and y are subnormal then hypot(x, y) may also be
  640. subnormal, so will lack full precision. We solve this by rescaling
  641. x and y by a sufficiently large power of 2 to ensure that x and y
  642. are normal.
  643. */
  644. Py_complex r;
  645. double s,d;
  646. double ax, ay;
  647. SPECIAL_VALUE(z, sqrt_special_values);
  648. if (z.real == 0. && z.imag == 0.) {
  649. r.real = 0.;
  650. r.imag = z.imag;
  651. return r;
  652. }
  653. ax = fabs(z.real);
  654. ay = fabs(z.imag);
  655. if (ax < DBL_MIN && ay < DBL_MIN && (ax > 0. || ay > 0.)) {
  656. /* here we catch cases where hypot(ax, ay) is subnormal */
  657. ax = ldexp(ax, CM_SCALE_UP);
  658. s = ldexp(sqrt(ax + hypot(ax, ldexp(ay, CM_SCALE_UP))),
  659. CM_SCALE_DOWN);
  660. } else {
  661. ax /= 8.;
  662. s = 2.*sqrt(ax + hypot(ax, ay/8.));
  663. }
  664. d = ay/(2.*s);
  665. if (z.real >= 0.) {
  666. r.real = s;
  667. r.imag = copysign(d, z.imag);
  668. } else {
  669. r.real = d;
  670. r.imag = copysign(s, z.imag);
  671. }
  672. errno = 0;
  673. return r;
  674. }
  675. /*[clinic input]
  676. cmath.tan = cmath.acos
  677. Return the tangent of z.
  678. [clinic start generated code]*/
  679. static Py_complex
  680. cmath_tan_impl(PyModuleDef *module, Py_complex z)
  681. /*[clinic end generated code: output=df374bacf36d99b4 input=fc167e528767888e]*/
  682. {
  683. /* tan(z) = -i tanh(iz) */
  684. Py_complex s, r;
  685. s.real = -z.imag;
  686. s.imag = z.real;
  687. s = cmath_tanh_impl(module, s);
  688. r.real = s.imag;
  689. r.imag = -s.real;
  690. return r;
  691. }
  692. /* tanh(infinity + i*y) needs to be dealt with specially */
  693. static Py_complex tanh_special_values[7][7];
  694. /*[clinic input]
  695. cmath.tanh = cmath.acos
  696. Return the hyperbolic tangent of z.
  697. [clinic start generated code]*/
  698. static Py_complex
  699. cmath_tanh_impl(PyModuleDef *module, Py_complex z)
  700. /*[clinic end generated code: output=f578773d27a18e96 input=22f67f9dc6d29685]*/
  701. {
  702. /* Formula:
  703. tanh(x+iy) = (tanh(x)(1+tan(y)^2) + i tan(y)(1-tanh(x))^2) /
  704. (1+tan(y)^2 tanh(x)^2)
  705. To avoid excessive roundoff error, 1-tanh(x)^2 is better computed
  706. as 1/cosh(x)^2. When abs(x) is large, we approximate 1-tanh(x)^2
  707. by 4 exp(-2*x) instead, to avoid possible overflow in the
  708. computation of cosh(x).
  709. */
  710. Py_complex r;
  711. double tx, ty, cx, txty, denom;
  712. /* special treatment for tanh(+/-inf + iy) if y is finite and
  713. nonzero */
  714. if (!Py_IS_FINITE(z.real) || !Py_IS_FINITE(z.imag)) {
  715. if (Py_IS_INFINITY(z.real) && Py_IS_FINITE(z.imag)
  716. && (z.imag != 0.)) {
  717. if (z.real > 0) {
  718. r.real = 1.0;
  719. r.imag = copysign(0.,
  720. 2.*sin(z.imag)*cos(z.imag));
  721. }
  722. else {
  723. r.real = -1.0;
  724. r.imag = copysign(0.,
  725. 2.*sin(z.imag)*cos(z.imag));
  726. }
  727. }
  728. else {
  729. r = tanh_special_values[special_type(z.real)]
  730. [special_type(z.imag)];
  731. }
  732. /* need to set errno = EDOM if z.imag is +/-infinity and
  733. z.real is finite */
  734. if (Py_IS_INFINITY(z.imag) && Py_IS_FINITE(z.real))
  735. errno = EDOM;
  736. else
  737. errno = 0;
  738. return r;
  739. }
  740. /* danger of overflow in 2.*z.imag !*/
  741. if (fabs(z.real) > CM_LOG_LARGE_DOUBLE) {
  742. r.real = copysign(1., z.real);
  743. r.imag = 4.*sin(z.imag)*cos(z.imag)*exp(-2.*fabs(z.real));
  744. } else {
  745. tx = tanh(z.real);
  746. ty = tan(z.imag);
  747. cx = 1./cosh(z.real);
  748. txty = tx*ty;
  749. denom = 1. + txty*txty;
  750. r.real = tx*(1.+ty*ty)/denom;
  751. r.imag = ((ty/denom)*cx)*cx;
  752. }
  753. errno = 0;
  754. return r;
  755. }
  756. /*[clinic input]
  757. cmath.log
  758. x: Py_complex
  759. y_obj: object = NULL
  760. /
  761. The logarithm of z to the given base.
  762. If the base not specified, returns the natural logarithm (base e) of z.
  763. [clinic start generated code]*/
  764. static PyObject *
  765. cmath_log_impl(PyModuleDef *module, Py_complex x, PyObject *y_obj)
  766. /*[clinic end generated code: output=35e2a1e5229b5a46 input=ee0e823a7c6e68ea]*/
  767. {
  768. Py_complex y;
  769. errno = 0;
  770. PyFPE_START_PROTECT("complex function", return 0)
  771. x = c_log(x);
  772. if (y_obj != NULL) {
  773. y = PyComplex_AsCComplex(y_obj);
  774. if (PyErr_Occurred()) {
  775. return NULL;
  776. }
  777. y = c_log(y);
  778. x = _Py_c_quot(x, y);
  779. }
  780. PyFPE_END_PROTECT(x)
  781. if (errno != 0)
  782. return math_error();
  783. return PyComplex_FromCComplex(x);
  784. }
  785. /* And now the glue to make them available from Python: */
  786. static PyObject *
  787. math_error(void)
  788. {
  789. if (errno == EDOM)
  790. PyErr_SetString(PyExc_ValueError, "math domain error");
  791. else if (errno == ERANGE)
  792. PyErr_SetString(PyExc_OverflowError, "math range error");
  793. else /* Unexpected math error */
  794. PyErr_SetFromErrno(PyExc_ValueError);
  795. return NULL;
  796. }
  797. /*[clinic input]
  798. cmath.phase
  799. z: Py_complex
  800. /
  801. Return argument, also known as the phase angle, of a complex.
  802. [clinic start generated code]*/
  803. static PyObject *
  804. cmath_phase_impl(PyModuleDef *module, Py_complex z)
  805. /*[clinic end generated code: output=e09eaf373cb624c3 input=5cf75228ba94b69d]*/
  806. {
  807. double phi;
  808. errno = 0;
  809. PyFPE_START_PROTECT("arg function", return 0)
  810. phi = c_atan2(z);
  811. PyFPE_END_PROTECT(phi)
  812. if (errno != 0)
  813. return math_error();
  814. else
  815. return PyFloat_FromDouble(phi);
  816. }
  817. /*[clinic input]
  818. cmath.polar
  819. z: Py_complex
  820. /
  821. Convert a complex from rectangular coordinates to polar coordinates.
  822. r is the distance from 0 and phi the phase angle.
  823. [clinic start generated code]*/
  824. static PyObject *
  825. cmath_polar_impl(PyModuleDef *module, Py_complex z)
  826. /*[clinic end generated code: output=07d41b16c877875a input=26c353574fd1a861]*/
  827. {
  828. double r, phi;
  829. errno = 0;
  830. PyFPE_START_PROTECT("polar function", return 0)
  831. phi = c_atan2(z); /* should not cause any exception */
  832. r = _Py_c_abs(z); /* sets errno to ERANGE on overflow */
  833. PyFPE_END_PROTECT(r)
  834. if (errno != 0)
  835. return math_error();
  836. else
  837. return Py_BuildValue("dd", r, phi);
  838. }
  839. /*
  840. rect() isn't covered by the C99 standard, but it's not too hard to
  841. figure out 'spirit of C99' rules for special value handing:
  842. rect(x, t) should behave like exp(log(x) + it) for positive-signed x
  843. rect(x, t) should behave like -exp(log(-x) + it) for negative-signed x
  844. rect(nan, t) should behave like exp(nan + it), except that rect(nan, 0)
  845. gives nan +- i0 with the sign of the imaginary part unspecified.
  846. */
  847. static Py_complex rect_special_values[7][7];
  848. /*[clinic input]
  849. cmath.rect
  850. r: double
  851. phi: double
  852. /
  853. Convert from polar coordinates to rectangular coordinates.
  854. [clinic start generated code]*/
  855. static PyObject *
  856. cmath_rect_impl(PyModuleDef *module, double r, double phi)
  857. /*[clinic end generated code: output=d97a8749bd63e9d5 input=24c5646d147efd69]*/
  858. {
  859. Py_complex z;
  860. errno = 0;
  861. PyFPE_START_PROTECT("rect function", return 0)
  862. /* deal with special values */
  863. if (!Py_IS_FINITE(r) || !Py_IS_FINITE(phi)) {
  864. /* if r is +/-infinity and phi is finite but nonzero then
  865. result is (+-INF +-INF i), but we need to compute cos(phi)
  866. and sin(phi) to figure out the signs. */
  867. if (Py_IS_INFINITY(r) && (Py_IS_FINITE(phi)
  868. && (phi != 0.))) {
  869. if (r > 0) {
  870. z.real = copysign(INF, cos(phi));
  871. z.imag = copysign(INF, sin(phi));
  872. }
  873. else {
  874. z.real = -copysign(INF, cos(phi));
  875. z.imag = -copysign(INF, sin(phi));
  876. }
  877. }
  878. else {
  879. z = rect_special_values[special_type(r)]
  880. [special_type(phi)];
  881. }
  882. /* need to set errno = EDOM if r is a nonzero number and phi
  883. is infinite */
  884. if (r != 0. && !Py_IS_NAN(r) && Py_IS_INFINITY(phi))
  885. errno = EDOM;
  886. else
  887. errno = 0;
  888. }
  889. else if (phi == 0.0) {
  890. /* Workaround for buggy results with phi=-0.0 on OS X 10.8. See
  891. bugs.python.org/issue18513. */
  892. z.real = r;
  893. z.imag = r * phi;
  894. errno = 0;
  895. }
  896. else {
  897. z.real = r * cos(phi);
  898. z.imag = r * sin(phi);
  899. errno = 0;
  900. }
  901. PyFPE_END_PROTECT(z)
  902. if (errno != 0)
  903. return math_error();
  904. else
  905. return PyComplex_FromCComplex(z);
  906. }
  907. /*[clinic input]
  908. cmath.isfinite = cmath.polar
  909. Return True if both the real and imaginary parts of z are finite, else False.
  910. [clinic start generated code]*/
  911. static PyObject *
  912. cmath_isfinite_impl(PyModuleDef *module, Py_complex z)
  913. /*[clinic end generated code: output=8f6682fa93de45d6 input=848e7ee701895815]*/
  914. {
  915. return PyBool_FromLong(Py_IS_FINITE(z.real) && Py_IS_FINITE(z.imag));
  916. }
  917. /*[clinic input]
  918. cmath.isnan = cmath.polar
  919. Checks if the real or imaginary part of z not a number (NaN).
  920. [clinic start generated code]*/
  921. static PyObject *
  922. cmath_isnan_impl(PyModuleDef *module, Py_complex z)
  923. /*[clinic end generated code: output=b85fe8c2047718ee input=71799f5d284c9baf]*/
  924. {
  925. return PyBool_FromLong(Py_IS_NAN(z.real) || Py_IS_NAN(z.imag));
  926. }
  927. /*[clinic input]
  928. cmath.isinf = cmath.polar
  929. Checks if the real or imaginary part of z is infinite.
  930. [clinic start generated code]*/
  931. static PyObject *
  932. cmath_isinf_impl(PyModuleDef *module, Py_complex z)
  933. /*[clinic end generated code: output=8ca9c6109e468bf4 input=363df155c7181329]*/
  934. {
  935. return PyBool_FromLong(Py_IS_INFINITY(z.real) ||
  936. Py_IS_INFINITY(z.imag));
  937. }
  938. /*[clinic input]
  939. cmath.isclose -> bool
  940. a: Py_complex
  941. b: Py_complex
  942. *
  943. rel_tol: double = 1e-09
  944. maximum difference for being considered "close", relative to the
  945. magnitude of the input values
  946. abs_tol: double = 0.0
  947. maximum difference for being considered "close", regardless of the
  948. magnitude of the input values
  949. Determine whether two complex numbers are close in value.
  950. Return True if a is close in value to b, and False otherwise.
  951. For the values to be considered close, the difference between them must be
  952. smaller than at least one of the tolerances.
  953. -inf, inf and NaN behave similarly to the IEEE 754 Standard. That is, NaN is
  954. not close to anything, even itself. inf and -inf are only close to themselves.
  955. [clinic start generated code]*/
  956. static int
  957. cmath_isclose_impl(PyModuleDef *module, Py_complex a, Py_complex b,
  958. double rel_tol, double abs_tol)
  959. /*[clinic end generated code: output=da0c535fb54e2310 input=df9636d7de1d4ac3]*/
  960. {
  961. double diff;
  962. /* sanity check on the inputs */
  963. if (rel_tol < 0.0 || abs_tol < 0.0 ) {
  964. PyErr_SetString(PyExc_ValueError,
  965. "tolerances must be non-negative");
  966. return -1;
  967. }
  968. if ( (a.real == b.real) && (a.imag == b.imag) ) {
  969. /* short circuit exact equality -- needed to catch two infinities of
  970. the same sign. And perhaps speeds things up a bit sometimes.
  971. */
  972. return 1;
  973. }
  974. /* This catches the case of two infinities of opposite sign, or
  975. one infinity and one finite number. Two infinities of opposite
  976. sign would otherwise have an infinite relative tolerance.
  977. Two infinities of the same sign are caught by the equality check
  978. above.
  979. */
  980. if (Py_IS_INFINITY(a.real) || Py_IS_INFINITY(a.imag) ||
  981. Py_IS_INFINITY(b.real) || Py_IS_INFINITY(b.imag)) {
  982. return 0;
  983. }
  984. /* now do the regular computation
  985. this is essentially the "weak" test from the Boost library
  986. */
  987. diff = _Py_c_abs(_Py_c_diff(a, b));
  988. return (((diff <= rel_tol * _Py_c_abs(b)) ||
  989. (diff <= rel_tol * _Py_c_abs(a))) ||
  990. (diff <= abs_tol));
  991. }
  992. PyDoc_STRVAR(module_doc,
  993. "This module is always available. It provides access to mathematical\n"
  994. "functions for complex numbers.");
  995. static PyMethodDef cmath_methods[] = {
  996. CMATH_ACOS_METHODDEF
  997. CMATH_ACOSH_METHODDEF
  998. CMATH_ASIN_METHODDEF
  999. CMATH_ASINH_METHODDEF
  1000. CMATH_ATAN_METHODDEF
  1001. CMATH_ATANH_METHODDEF
  1002. CMATH_COS_METHODDEF
  1003. CMATH_COSH_METHODDEF
  1004. CMATH_EXP_METHODDEF
  1005. CMATH_ISCLOSE_METHODDEF
  1006. CMATH_ISFINITE_METHODDEF
  1007. CMATH_ISINF_METHODDEF
  1008. CMATH_ISNAN_METHODDEF
  1009. CMATH_LOG_METHODDEF
  1010. CMATH_LOG10_METHODDEF
  1011. CMATH_PHASE_METHODDEF
  1012. CMATH_POLAR_METHODDEF
  1013. CMATH_RECT_METHODDEF
  1014. CMATH_SIN_METHODDEF
  1015. CMATH_SINH_METHODDEF
  1016. CMATH_SQRT_METHODDEF
  1017. CMATH_TAN_METHODDEF
  1018. CMATH_TANH_METHODDEF
  1019. {NULL, NULL} /* sentinel */
  1020. };
  1021. static struct PyModuleDef cmathmodule = {
  1022. PyModuleDef_HEAD_INIT,
  1023. "cmath",
  1024. module_doc,
  1025. -1,
  1026. cmath_methods,
  1027. NULL,
  1028. NULL,
  1029. NULL,
  1030. NULL
  1031. };
  1032. PyMODINIT_FUNC
  1033. PyInit_cmath(void)
  1034. {
  1035. PyObject *m;
  1036. m = PyModule_Create(&cmathmodule);
  1037. if (m == NULL)
  1038. return NULL;
  1039. PyModule_AddObject(m, "pi",
  1040. PyFloat_FromDouble(Py_MATH_PI));
  1041. PyModule_AddObject(m, "e", PyFloat_FromDouble(Py_MATH_E));
  1042. /* initialize special value tables */
  1043. #define INIT_SPECIAL_VALUES(NAME, BODY) { Py_complex* p = (Py_complex*)NAME; BODY }
  1044. #define C(REAL, IMAG) p->real = REAL; p->imag = IMAG; ++p;
  1045. INIT_SPECIAL_VALUES(acos_special_values, {
  1046. C(P34,INF) C(P,INF) C(P,INF) C(P,-INF) C(P,-INF) C(P34,-INF) C(N,INF)
  1047. C(P12,INF) C(U,U) C(U,U) C(U,U) C(U,U) C(P12,-INF) C(N,N)
  1048. C(P12,INF) C(U,U) C(P12,0.) C(P12,-0.) C(U,U) C(P12,-INF) C(P12,N)
  1049. C(P12,INF) C(U,U) C(P12,0.) C(P12,-0.) C(U,U) C(P12,-INF) C(P12,N)
  1050. C(P12,INF) C(U,U) C(U,U) C(U,U) C(U,U) C(P12,-INF) C(N,N)
  1051. C(P14,INF) C(0.,INF) C(0.,INF) C(0.,-INF) C(0.,-INF) C(P14,-INF) C(N,INF)
  1052. C(N,INF) C(N,N) C(N,N) C(N,N) C(N,N) C(N,-INF) C(N,N)
  1053. })
  1054. INIT_SPECIAL_VALUES(acosh_special_values, {
  1055. C(INF,-P34) C(INF,-P) C(INF,-P) C(INF,P) C(INF,P) C(INF,P34) C(INF,N)
  1056. C(INF,-P12) C(U,U) C(U,U) C(U,U) C(U,U) C(INF,P12) C(N,N)
  1057. C(INF,-P12) C(U,U) C(0.,-P12) C(0.,P12) C(U,U) C(INF,P12) C(N,N)
  1058. C(INF,-P12) C(U,U) C(0.,-P12) C(0.,P12) C(U,U) C(INF,P12) C(N,N)
  1059. C(INF,-P12) C(U,U) C(U,U) C(U,U) C(U,U) C(INF,P12) C(N,N)
  1060. C(INF,-P14) C(INF,-0.) C(INF,-0.) C(INF,0.) C(INF,0.) C(INF,P14) C(INF,N)
  1061. C(INF,N) C(N,N) C(N,N) C(N,N) C(N,N) C(INF,N) C(N,N)
  1062. })
  1063. INIT_SPECIAL_VALUES(asinh_special_values, {
  1064. C(-INF,-P14) C(-INF,-0.) C(-INF,-0.) C(-INF,0.) C(-INF,0.) C(-INF,P14) C(-INF,N)
  1065. C(-INF,-P12) C(U,U) C(U,U) C(U,U) C(U,U) C(-INF,P12) C(N,N)
  1066. C(-INF,-P12) C(U,U) C(-0.,-0.) C(-0.,0.) C(U,U) C(-INF,P12) C(N,N)
  1067. C(INF,-P12) C(U,U) C(0.,-0.) C(0.,0.) C(U,U) C(INF,P12) C(N,N)
  1068. C(INF,-P12) C(U,U) C(U,U) C(U,U) C(U,U) C(INF,P12) C(N,N)
  1069. C(INF,-P14) C(INF,-0.) C(INF,-0.) C(INF,0.) C(INF,0.) C(INF,P14) C(INF,N)
  1070. C(INF,N) C(N,N) C(N,-0.) C(N,0.) C(N,N) C(INF,N) C(N,N)
  1071. })
  1072. INIT_SPECIAL_VALUES(atanh_special_values, {
  1073. C(-0.,-P12) C(-0.,-P12) C(-0.,-P12) C(-0.,P12) C(-0.,P12) C(-0.,P12) C(-0.,N)
  1074. C(-0.,-P12) C(U,U) C(U,U) C(U,U) C(U,U) C(-0.,P12) C(N,N)
  1075. C(-0.,-P12) C(U,U) C(-0.,-0.) C(-0.,0.) C(U,U) C(-0.,P12) C(-0.,N)
  1076. C(0.,-P12) C(U,U) C(0.,-0.) C(0.,0.) C(U,U) C(0.,P12) C(0.,N)
  1077. C(0.,-P12) C(U,U) C(U,U) C(U,U) C(U,U) C(0.,P12) C(N,N)
  1078. C(0.,-P12) C(0.,-P12) C(0.,-P12) C(0.,P12) C(0.,P12) C(0.,P12) C(0.,N)
  1079. C(0.,-P12) C(N,N) C(N,N) C(N,N) C(N,N) C(0.,P12) C(N,N)
  1080. })
  1081. INIT_SPECIAL_VALUES(cosh_special_values, {
  1082. C(INF,N) C(U,U) C(INF,0.) C(INF,-0.) C(U,U) C(INF,N) C(INF,N)
  1083. C(N,N) C(U,U) C(U,U) C(U,U) C(U,U) C(N,N) C(N,N)
  1084. C(N,0.) C(U,U) C(1.,0.) C(1.,-0.) C(U,U) C(N,0.) C(N,0.)
  1085. C(N,0.) C(U,U) C(1.,-0.) C(1.,0.) C(U,U) C(N,0.) C(N,0.)
  1086. C(N,N) C(U,U) C(U,U) C(U,U) C(U,U) C(N,N) C(N,N)
  1087. C(INF,N) C(U,U) C(INF,-0.) C(INF,0.) C(U,U) C(INF,N) C(INF,N)
  1088. C(N,N) C(N,N) C(N,0.) C(N,0.) C(N,N) C(N,N) C(N,N)
  1089. })
  1090. INIT_SPECIAL_VALUES(exp_special_values, {
  1091. C(0.,0.) C(U,U) C(0.,-0.) C(0.,0.) C(U,U) C(0.,0.) C(0.,0.)
  1092. C(N,N) C(U,U) C(U,U) C(U,U) C(U,U) C(N,N) C(N,N)
  1093. C(N,N) C(U,U) C(1.,-0.) C(1.,0.) C(U,U) C(N,N) C(N,N)
  1094. C(N,N) C(U,U) C(1.,-0.) C(1.,0.) C(U,U) C(N,N) C(N,N)
  1095. C(N,N) C(U,U) C(U,U) C(U,U) C(U,U) C(N,N) C(N,N)
  1096. C(INF,N) C(U,U) C(INF,-0.) C(INF,0.) C(U,U) C(INF,N) C(INF,N)
  1097. C(N,N) C(N,N) C(N,-0.) C(N,0.) C(N,N) C(N,N) C(N,N)
  1098. })
  1099. INIT_SPECIAL_VALUES(log_special_values, {
  1100. C(INF,-P34) C(INF,-P) C(INF,-P) C(INF,P) C(INF,P) C(INF,P34) C(INF,N)
  1101. C(INF,-P12) C(U,U) C(U,U) C(U,U) C(U,U) C(INF,P12) C(N,N)
  1102. C(INF,-P12) C(U,U) C(-INF,-P) C(-INF,P) C(U,U) C(INF,P12) C(N,N)
  1103. C(INF,-P12) C(U,U) C(-INF,-0.) C(-INF,0.) C(U,U) C(INF,P12) C(N,N)
  1104. C(INF,-P12) C(U,U) C(U,U) C(U,U) C(U,U) C(INF,P12) C(N,N)
  1105. C(INF,-P14) C(INF,-0.) C(INF,-0.) C(INF,0.) C(INF,0.) C(INF,P14) C(INF,N)
  1106. C(INF,N) C(N,N) C(N,N) C(N,N) C(N,N) C(INF,N) C(N,N)
  1107. })
  1108. INIT_SPECIAL_VALUES(sinh_special_values, {
  1109. C(INF,N) C(U,U) C(-INF,-0.) C(-INF,0.) C(U,U) C(INF,N) C(INF,N)
  1110. C(N,N) C(U,U) C(U,U) C(U,U) C(U,U) C(N,N) C(N,N)
  1111. C(0.,N) C(U,U) C(-0.,-0.) C(-0.,0.) C(U,U) C(0.,N) C(0.,N)
  1112. C(0.,N) C(U,U) C(0.,-0.) C(0.,0.) C(U,U) C(0.,N) C(0.,N)
  1113. C(N,N) C(U,U) C(U,U) C(U,U) C(U,U) C(N,N) C(N,N)
  1114. C(INF,N) C(U,U) C(INF,-0.) C(INF,0.) C(U,U) C(INF,N) C(INF,N)
  1115. C(N,N) C(N,N) C(N,-0.) C(N,0.) C(N,N) C(N,N) C(N,N)
  1116. })
  1117. INIT_SPECIAL_VALUES(sqrt_special_values, {
  1118. C(INF,-INF) C(0.,-INF) C(0.,-INF) C(0.,INF) C(0.,INF) C(INF,INF) C(N,INF)
  1119. C(INF,-INF) C(U,U) C(U,U) C(U,U) C(U,U) C(INF,INF) C(N,N)
  1120. C(INF,-INF) C(U,U) C(0.,-0.) C(0.,0.) C(U,U) C(INF,INF) C(N,N)
  1121. C(INF,-INF) C(U,U) C(0.,-0.) C(0.,0.) C(U,U) C(INF,INF) C(N,N)
  1122. C(INF,-INF) C(U,U) C(U,U) C(U,U) C(U,U) C(INF,INF) C(N,N)
  1123. C(INF,-INF) C(INF,-0.) C(INF,-0.) C(INF,0.) C(INF,0.) C(INF,INF) C(INF,N)
  1124. C(INF,-INF) C(N,N) C(N,N) C(N,N) C(N,N) C(INF,INF) C(N,N)
  1125. })
  1126. INIT_SPECIAL_VALUES(tanh_special_values, {
  1127. C(-1.,0.) C(U,U) C(-1.,-0.) C(-1.,0.) C(U,U) C(-1.,0.) C(-1.,0.)
  1128. C(N,N) C(U,U) C(U,U) C(U,U) C(U,U) C(N,N) C(N,N)
  1129. C(N,N) C(U,U) C(-0.,-0.) C(-0.,0.) C(U,U) C(N,N) C(N,N)
  1130. C(N,N) C(U,U) C(0.,-0.) C(0.,0.) C(U,U) C(N,N) C(N,N)
  1131. C(N,N) C(U,U) C(U,U) C(U,U) C(U,U) C(N,N) C(N,N)
  1132. C(1.,0.) C(U,U) C(1.,-0.) C(1.,0.) C(U,U) C(1.,0.) C(1.,0.)
  1133. C(N,N) C(N,N) C(N,-0.) C(N,0.) C(N,N) C(N,N) C(N,N)
  1134. })
  1135. INIT_SPECIAL_VALUES(rect_special_values, {
  1136. C(INF,N) C(U,U) C(-INF,0.) C(-INF,-0.) C(U,U) C(INF,N) C(INF,N)
  1137. C(N,N) C(U,U) C(U,U) C(U,U) C(U,U) C(N,N) C(N,N)
  1138. C(0.,0.) C(U,U) C(-0.,0.) C(-0.,-0.) C(U,U) C(0.,0.) C(0.,0.)
  1139. C(0.,0.) C(U,U) C(0.,-0.) C(0.,0.) C(U,U) C(0.,0.) C(0.,0.)
  1140. C(N,N) C(U,U) C(U,U) C(U,U) C(U,U) C(N,N) C(N,N)
  1141. C(INF,N) C(U,U) C(INF,-0.) C(INF,0.) C(U,U) C(INF,N) C(INF,N)
  1142. C(N,N) C(N,N) C(N,0.) C(N,0.) C(N,N) C(N,N) C(N,N)
  1143. })
  1144. return m;
  1145. }