Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
9e720e39
Commit
9e720e39
authored
Jul 21, 1996
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
complex -> Py_complex
parent
f5030abc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
96 additions
and
96 deletions
+96
-96
Modules/cmathmodule.c
Modules/cmathmodule.c
+56
-56
Objects/complexobject.c
Objects/complexobject.c
+40
-40
No files found.
Modules/cmathmodule.c
View file @
9e720e39
...
...
@@ -29,137 +29,137 @@
/* First, the C functions that do the real work */
/* constants */
static
complex
c_1
=
{
1
.,
0
.};
static
complex
c_half
=
{
0
.
5
,
0
.};
static
complex
c_i
=
{
0
.,
1
.};
static
complex
c_i2
=
{
0
.,
0
.
5
};
static
complex
c_mi
=
{
0
.,
-
1
.};
static
complex
c_pi2
=
{
M_PI
/
2
.,
0
.};
static
Py_
complex
c_1
=
{
1
.,
0
.};
static
Py_
complex
c_half
=
{
0
.
5
,
0
.};
static
Py_
complex
c_i
=
{
0
.,
1
.};
static
Py_
complex
c_i2
=
{
0
.,
0
.
5
};
static
Py_
complex
c_mi
=
{
0
.,
-
1
.};
static
Py_
complex
c_pi2
=
{
M_PI
/
2
.,
0
.};
/* forward declarations */
staticforward
complex
c_log
();
staticforward
complex
c_prodi
();
staticforward
complex
c_sqrt
();
staticforward
Py_
complex
c_log
();
staticforward
Py_
complex
c_prodi
();
staticforward
Py_
complex
c_sqrt
();
static
complex
c_acos
(
x
)
complex
x
;
static
Py_
complex
c_acos
(
x
)
Py_
complex
x
;
{
return
c_neg
(
c_prodi
(
c_log
(
c_sum
(
x
,
c_prod
(
c_i
,
c_sqrt
(
c_diff
(
c_1
,
c_prod
(
x
,
x
))))))));
}
static
complex
c_acosh
(
x
)
complex
x
;
static
Py_
complex
c_acosh
(
x
)
Py_
complex
x
;
{
return
c_log
(
c_sum
(
x
,
c_prod
(
c_i
,
c_sqrt
(
c_diff
(
c_1
,
c_prod
(
x
,
x
))))));
}
static
complex
c_asin
(
x
)
complex
x
;
static
Py_
complex
c_asin
(
x
)
Py_
complex
x
;
{
return
c_neg
(
c_prodi
(
c_log
(
c_sum
(
c_prod
(
c_i
,
x
),
c_sqrt
(
c_diff
(
c_1
,
c_prod
(
x
,
x
)))))));
}
static
complex
c_asinh
(
x
)
complex
x
;
static
Py_
complex
c_asinh
(
x
)
Py_
complex
x
;
{
return
c_neg
(
c_log
(
c_diff
(
c_sqrt
(
c_sum
(
c_1
,
c_prod
(
x
,
x
))),
x
)));
}
static
complex
c_atan
(
x
)
complex
x
;
static
Py_
complex
c_atan
(
x
)
Py_
complex
x
;
{
return
c_prod
(
c_i2
,
c_log
(
c_quot
(
c_sum
(
c_i
,
x
),
c_diff
(
c_i
,
x
))));
}
static
complex
c_atanh
(
x
)
complex
x
;
static
Py_
complex
c_atanh
(
x
)
Py_
complex
x
;
{
return
c_prod
(
c_half
,
c_log
(
c_quot
(
c_sum
(
c_1
,
x
),
c_diff
(
c_1
,
x
))));
}
static
complex
c_cos
(
x
)
complex
x
;
static
Py_
complex
c_cos
(
x
)
Py_
complex
x
;
{
complex
r
;
Py_
complex
r
;
r
.
real
=
cos
(
x
.
real
)
*
cosh
(
x
.
imag
);
r
.
imag
=
-
sin
(
x
.
real
)
*
sinh
(
x
.
imag
);
return
r
;
}
static
complex
c_cosh
(
x
)
complex
x
;
static
Py_
complex
c_cosh
(
x
)
Py_
complex
x
;
{
complex
r
;
Py_
complex
r
;
r
.
real
=
cos
(
x
.
imag
)
*
cosh
(
x
.
real
);
r
.
imag
=
sin
(
x
.
imag
)
*
sinh
(
x
.
real
);
return
r
;
}
static
complex
c_exp
(
x
)
complex
x
;
static
Py_
complex
c_exp
(
x
)
Py_
complex
x
;
{
complex
r
;
Py_
complex
r
;
double
l
=
exp
(
x
.
real
);
r
.
real
=
l
*
cos
(
x
.
imag
);
r
.
imag
=
l
*
sin
(
x
.
imag
);
return
r
;
}
static
complex
c_log
(
x
)
complex
x
;
static
Py_
complex
c_log
(
x
)
Py_
complex
x
;
{
complex
r
;
Py_
complex
r
;
double
l
=
hypot
(
x
.
real
,
x
.
imag
);
r
.
imag
=
atan2
(
x
.
imag
,
x
.
real
);
r
.
real
=
log
(
l
);
return
r
;
}
static
complex
c_log10
(
x
)
complex
x
;
static
Py_
complex
c_log10
(
x
)
Py_
complex
x
;
{
complex
r
;
Py_
complex
r
;
double
l
=
hypot
(
x
.
real
,
x
.
imag
);
r
.
imag
=
atan2
(
x
.
imag
,
x
.
real
)
/
log
(
10
.);
r
.
real
=
log10
(
l
);
return
r
;
}
static
complex
c_prodi
(
x
)
complex
x
;
static
Py_
complex
c_prodi
(
x
)
Py_
complex
x
;
{
complex
r
;
Py_
complex
r
;
r
.
real
=
-
x
.
imag
;
r
.
imag
=
x
.
real
;
return
r
;
}
static
complex
c_sin
(
x
)
complex
x
;
static
Py_
complex
c_sin
(
x
)
Py_
complex
x
;
{
complex
r
;
Py_
complex
r
;
r
.
real
=
sin
(
x
.
real
)
*
cosh
(
x
.
imag
);
r
.
imag
=
cos
(
x
.
real
)
*
sinh
(
x
.
imag
);
return
r
;
}
static
complex
c_sinh
(
x
)
complex
x
;
static
Py_
complex
c_sinh
(
x
)
Py_
complex
x
;
{
complex
r
;
Py_
complex
r
;
r
.
real
=
cos
(
x
.
imag
)
*
sinh
(
x
.
real
);
r
.
imag
=
sin
(
x
.
imag
)
*
cosh
(
x
.
real
);
return
r
;
}
static
complex
c_sqrt
(
x
)
complex
x
;
static
Py_
complex
c_sqrt
(
x
)
Py_
complex
x
;
{
complex
r
;
Py_
complex
r
;
double
s
,
d
;
if
(
x
.
real
==
0
.
&&
x
.
imag
==
0
.)
r
=
x
;
...
...
@@ -182,10 +182,10 @@ static complex c_sqrt(x)
return
r
;
}
static
complex
c_tan
(
x
)
complex
x
;
static
Py_
complex
c_tan
(
x
)
Py_
complex
x
;
{
complex
r
;
Py_
complex
r
;
double
sr
,
cr
,
shi
,
chi
;
double
rs
,
is
,
rc
,
ic
;
double
d
;
...
...
@@ -203,10 +203,10 @@ static complex c_tan(x)
return
r
;
}
static
complex
c_tanh
(
x
)
complex
x
;
static
Py_
complex
c_tanh
(
x
)
Py_
complex
x
;
{
complex
r
;
Py_
complex
r
;
double
si
,
ci
,
shr
,
chr
;
double
rs
,
is
,
rc
,
ic
;
double
d
;
...
...
@@ -242,9 +242,9 @@ math_error()
static
object
*
math_1
(
args
,
func
)
object
*
args
;
complex
(
*
func
)
FPROTO
((
complex
));
Py_complex
(
*
func
)
FPROTO
((
Py_
complex
));
{
complex
x
;
Py_
complex
x
;
if
(
!
PyArg_ParseTuple
(
args
,
"D"
,
&
x
))
return
NULL
;
errno
=
0
;
...
...
Objects/complexobject.c
View file @
9e720e39
...
...
@@ -56,48 +56,48 @@ extern double pow PROTO((double, double));
/* elementary operations on complex numbers */
static
int
c_error
;
static
complex
c_1
=
{
1
.,
0
.};
static
Py_
complex
c_1
=
{
1
.,
0
.};
complex
c_sum
(
a
,
b
)
complex
a
,
b
;
Py_
complex
c_sum
(
a
,
b
)
Py_
complex
a
,
b
;
{
complex
r
;
Py_
complex
r
;
r
.
real
=
a
.
real
+
b
.
real
;
r
.
imag
=
a
.
imag
+
b
.
imag
;
return
r
;
}
complex
c_diff
(
a
,
b
)
complex
a
,
b
;
Py_
complex
c_diff
(
a
,
b
)
Py_
complex
a
,
b
;
{
complex
r
;
Py_
complex
r
;
r
.
real
=
a
.
real
-
b
.
real
;
r
.
imag
=
a
.
imag
-
b
.
imag
;
return
r
;
}
complex
c_neg
(
a
)
complex
a
;
Py_
complex
c_neg
(
a
)
Py_
complex
a
;
{
complex
r
;
Py_
complex
r
;
r
.
real
=
-
a
.
real
;
r
.
imag
=
-
a
.
imag
;
return
r
;
}
complex
c_prod
(
a
,
b
)
complex
a
,
b
;
Py_
complex
c_prod
(
a
,
b
)
Py_
complex
a
,
b
;
{
complex
r
;
Py_
complex
r
;
r
.
real
=
a
.
real
*
b
.
real
-
a
.
imag
*
b
.
imag
;
r
.
imag
=
a
.
real
*
b
.
imag
+
a
.
imag
*
b
.
real
;
return
r
;
}
complex
c_quot
(
a
,
b
)
complex
a
,
b
;
Py_
complex
c_quot
(
a
,
b
)
Py_
complex
a
,
b
;
{
complex
r
;
Py_
complex
r
;
double
d
=
b
.
real
*
b
.
real
+
b
.
imag
*
b
.
imag
;
if
(
d
==
0
.)
c_error
=
1
;
...
...
@@ -106,10 +106,10 @@ complex c_quot(a,b)
return
r
;
}
complex
c_pow
(
a
,
b
)
complex
a
,
b
;
Py_
complex
c_pow
(
a
,
b
)
Py_
complex
a
,
b
;
{
complex
r
;
Py_
complex
r
;
double
vabs
,
len
,
at
,
phase
;
if
(
b
.
real
==
0
.
&&
b
.
imag
==
0
.)
{
r
.
real
=
1
.;
...
...
@@ -136,12 +136,12 @@ complex c_pow(a,b)
return
r
;
}
static
complex
c_powu
(
x
,
n
)
complex
x
;
static
Py_
complex
c_powu
(
x
,
n
)
Py_
complex
x
;
long
n
;
{
complex
r
=
c_1
;
complex
p
=
x
;
Py_
complex
r
=
c_1
;
Py_
complex
p
=
x
;
long
mask
=
1
;
while
(
mask
>
0
&&
n
>=
mask
)
{
if
(
n
&
mask
)
...
...
@@ -152,11 +152,11 @@ static complex c_powu(x, n)
return
r
;
}
static
complex
c_powi
(
x
,
n
)
complex
x
;
static
Py_
complex
c_powi
(
x
,
n
)
Py_
complex
x
;
long
n
;
{
complex
cn
;
Py_
complex
cn
;
if
(
n
>
100
||
n
<
-
100
)
{
cn
.
real
=
(
double
)
n
;
...
...
@@ -171,7 +171,7 @@ static complex c_powi(x, n)
}
PyObject
*
PyComplex_FromCComplex
(
complex
cval
)
PyComplex_FromCComplex
(
Py_
complex
cval
)
{
register
complexobject
*
op
=
(
complexobject
*
)
malloc
(
sizeof
(
complexobject
));
if
(
op
==
NULL
)
...
...
@@ -184,7 +184,7 @@ PyComplex_FromCComplex(complex cval)
PyObject
*
PyComplex_FromDoubles
(
double
real
,
double
imag
)
{
complex
c
;
Py_
complex
c
;
c
.
real
=
real
;
c
.
imag
=
imag
;
return
PyComplex_FromCComplex
(
c
);
...
...
@@ -208,9 +208,9 @@ PyComplex_ImagAsDouble(PyObject *op) {
}
}
complex
Py_
complex
PyComplex_AsCComplex
(
PyObject
*
op
)
{
complex
cv
;
Py_
complex
cv
;
if
(
PyComplex_Check
(
op
))
{
return
((
PyComplexObject
*
)
op
)
->
cval
;
}
else
{
...
...
@@ -266,8 +266,8 @@ complex_compare(v, w)
{
/* Note: "greater" and "smaller" have no meaning for complex numbers,
but Python requires that they be defined nevertheless. */
complex
i
=
v
->
cval
;
complex
j
=
w
->
cval
;
Py_
complex
i
=
v
->
cval
;
Py_
complex
j
=
w
->
cval
;
if
(
i
.
real
==
j
.
real
&&
i
.
imag
==
j
.
imag
)
return
0
;
else
if
(
i
.
real
!=
j
.
real
)
...
...
@@ -348,7 +348,7 @@ complex_div(v, w)
complexobject
*
v
;
complexobject
*
w
;
{
complex
quot
;
Py_
complex
quot
;
c_error
=
0
;
quot
=
c_quot
(
v
->
cval
,
w
->
cval
);
if
(
c_error
==
1
)
{
...
...
@@ -365,8 +365,8 @@ complex_pow(v, w, z)
object
*
w
;
complexobject
*
z
;
{
complex
p
;
complex
exponent
;
Py_
complex
p
;
Py_
complex
exponent
;
long
int_exponent
;
if
((
object
*
)
z
!=
None
)
{
...
...
@@ -394,7 +394,7 @@ static object *
complex_neg
(
v
)
complexobject
*
v
;
{
complex
neg
;
Py_
complex
neg
;
neg
.
real
=
-
v
->
cval
.
real
;
neg
.
imag
=
-
v
->
cval
.
imag
;
return
newcomplexobject
(
neg
);
...
...
@@ -427,7 +427,7 @@ complex_coerce(pv, pw)
object
**
pv
;
object
**
pw
;
{
complex
cval
;
Py_
complex
cval
;
cval
.
imag
=
0
.;
if
(
is_intobject
(
*
pw
))
{
cval
.
real
=
(
double
)
getintvalue
(
*
pw
);
...
...
@@ -485,7 +485,7 @@ complex_new(self, args)
object
*
self
;
object
*
args
;
{
complex
cval
;
Py_
complex
cval
;
cval
.
imag
=
0
.;
if
(
!
PyArg_ParseTuple
(
args
,
"d|d"
,
&
cval
.
real
,
&
cval
.
imag
))
...
...
@@ -497,7 +497,7 @@ static object *
complex_conjugate
(
self
)
object
*
self
;
{
complex
c
=
((
complexobject
*
)
self
)
->
cval
;
Py_
complex
c
=
((
complexobject
*
)
self
)
->
cval
;
c
.
imag
=
-
c
.
imag
;
return
newcomplexobject
(
c
);
}
...
...
@@ -513,7 +513,7 @@ complex_getattr(self, name)
complexobject
*
self
;
char
*
name
;
{
complex
cval
;
Py_
complex
cval
;
if
(
strcmp
(
name
,
"real"
)
==
0
)
return
(
object
*
)
newfloatobject
(
self
->
cval
.
real
);
else
if
(
strcmp
(
name
,
"imag"
)
==
0
)
...
...
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