Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
ba006541
Commit
ba006541
authored
8 years ago
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pure real results for pure real complex powers.
parent
d20dd69d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
0 deletions
+6
-0
Cython/Utility/Complex.c
Cython/Utility/Complex.c
+4
-0
tests/run/complex_numbers_T305.pyx
tests/run/complex_numbers_T305.pyx
+2
-0
No files found.
Cython/Utility/Complex.c
View file @
ba006541
...
...
@@ -264,6 +264,10 @@ static {{type}} __Pyx_PyComplex_As_{{type_name}}(PyObject* o) {
if
(
a
.
imag
==
0
)
{
if
(
a
.
real
==
0
)
{
return
a
;
}
else
if
(
b
.
imag
==
0
)
{
z
.
real
=
pow
{{
m
}}(
a
.
real
,
b
.
real
);
z
.
imag
=
0
;
return
z
;
}
else
if
(
a
.
real
>
0
)
{
r
=
a
.
real
;
theta
=
0
;
...
...
This diff is collapsed.
Click to expand it.
tests/run/complex_numbers_T305.pyx
View file @
ba006541
...
...
@@ -64,6 +64,8 @@ def test_int_pow(double complex z, int n, tol=None):
[True, True, True, True, True, True, True, True, True]
>>> [test_int_pow(complex(2, 0.5), k, 1e-14) for k in range(0, 10)]
[True, True, True, True, True, True, True, True, True, True]
>>> test_int_pow(-0.5, 5, tol=1e-15)
True
"""
if
tol
is
None
:
return
z
**
n
+
<
object
>
0
# add zero to normalize zero sign
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment