Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
1eee8e52
Kaydet (Commit)
1eee8e52
authored
Tem 07, 2014
tarafından
Antoine Pitrou
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #21803: remove macro indirections in complexobject.h
üst
db5f8fcd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
32 deletions
+24
-32
complexobject.h
Include/complexobject.h
+7
-15
complexobject.c
Objects/complexobject.c
+17
-17
No files found.
Include/complexobject.h
Dosyayı görüntüle @
1eee8e52
...
...
@@ -14,21 +14,13 @@ typedef struct {
/* Operations on complex numbers from complexmodule.c */
#define c_sum _Py_c_sum
#define c_diff _Py_c_diff
#define c_neg _Py_c_neg
#define c_prod _Py_c_prod
#define c_quot _Py_c_quot
#define c_pow _Py_c_pow
#define c_abs _Py_c_abs
PyAPI_FUNC
(
Py_complex
)
c_sum
(
Py_complex
,
Py_complex
);
PyAPI_FUNC
(
Py_complex
)
c_diff
(
Py_complex
,
Py_complex
);
PyAPI_FUNC
(
Py_complex
)
c_neg
(
Py_complex
);
PyAPI_FUNC
(
Py_complex
)
c_prod
(
Py_complex
,
Py_complex
);
PyAPI_FUNC
(
Py_complex
)
c_quot
(
Py_complex
,
Py_complex
);
PyAPI_FUNC
(
Py_complex
)
c_pow
(
Py_complex
,
Py_complex
);
PyAPI_FUNC
(
double
)
c_abs
(
Py_complex
);
PyAPI_FUNC
(
Py_complex
)
_Py_c_sum
(
Py_complex
,
Py_complex
);
PyAPI_FUNC
(
Py_complex
)
_Py_c_diff
(
Py_complex
,
Py_complex
);
PyAPI_FUNC
(
Py_complex
)
_Py_c_neg
(
Py_complex
);
PyAPI_FUNC
(
Py_complex
)
_Py_c_prod
(
Py_complex
,
Py_complex
);
PyAPI_FUNC
(
Py_complex
)
_Py_c_quot
(
Py_complex
,
Py_complex
);
PyAPI_FUNC
(
Py_complex
)
_Py_c_pow
(
Py_complex
,
Py_complex
);
PyAPI_FUNC
(
double
)
_Py_c_abs
(
Py_complex
);
#endif
/* Complex object interface */
...
...
Objects/complexobject.c
Dosyayı görüntüle @
1eee8e52
...
...
@@ -13,7 +13,7 @@
static
Py_complex
c_1
=
{
1
.,
0
.};
Py_complex
c_sum
(
Py_complex
a
,
Py_complex
b
)
_Py_
c_sum
(
Py_complex
a
,
Py_complex
b
)
{
Py_complex
r
;
r
.
real
=
a
.
real
+
b
.
real
;
...
...
@@ -22,7 +22,7 @@ c_sum(Py_complex a, Py_complex b)
}
Py_complex
c_diff
(
Py_complex
a
,
Py_complex
b
)
_Py_
c_diff
(
Py_complex
a
,
Py_complex
b
)
{
Py_complex
r
;
r
.
real
=
a
.
real
-
b
.
real
;
...
...
@@ -31,7 +31,7 @@ c_diff(Py_complex a, Py_complex b)
}
Py_complex
c_neg
(
Py_complex
a
)
_Py_
c_neg
(
Py_complex
a
)
{
Py_complex
r
;
r
.
real
=
-
a
.
real
;
...
...
@@ -40,7 +40,7 @@ c_neg(Py_complex a)
}
Py_complex
c_prod
(
Py_complex
a
,
Py_complex
b
)
_Py_
c_prod
(
Py_complex
a
,
Py_complex
b
)
{
Py_complex
r
;
r
.
real
=
a
.
real
*
b
.
real
-
a
.
imag
*
b
.
imag
;
...
...
@@ -49,7 +49,7 @@ c_prod(Py_complex a, Py_complex b)
}
Py_complex
c_quot
(
Py_complex
a
,
Py_complex
b
)
_Py_
c_quot
(
Py_complex
a
,
Py_complex
b
)
{
/******************************************************************
This was the original algorithm. It's grossly prone to spurious
...
...
@@ -103,7 +103,7 @@ c_quot(Py_complex a, Py_complex b)
}
Py_complex
c_pow
(
Py_complex
a
,
Py_complex
b
)
_Py_
c_pow
(
Py_complex
a
,
Py_complex
b
)
{
Py_complex
r
;
double
vabs
,
len
,
at
,
phase
;
...
...
@@ -141,9 +141,9 @@ c_powu(Py_complex x, long n)
p
=
x
;
while
(
mask
>
0
&&
n
>=
mask
)
{
if
(
n
&
mask
)
r
=
c_prod
(
r
,
p
);
r
=
_Py_
c_prod
(
r
,
p
);
mask
<<=
1
;
p
=
c_prod
(
p
,
p
);
p
=
_Py_
c_prod
(
p
,
p
);
}
return
r
;
}
...
...
@@ -156,17 +156,17 @@ c_powi(Py_complex x, long n)
if
(
n
>
100
||
n
<
-
100
)
{
cn
.
real
=
(
double
)
n
;
cn
.
imag
=
0
.;
return
c_pow
(
x
,
cn
);
return
_Py_
c_pow
(
x
,
cn
);
}
else
if
(
n
>
0
)
return
c_powu
(
x
,
n
);
else
return
c_quot
(
c_1
,
c_powu
(
x
,
-
n
));
return
_Py_c_quot
(
c_1
,
c_powu
(
x
,
-
n
));
}
double
c_abs
(
Py_complex
z
)
_Py_
c_abs
(
Py_complex
z
)
{
/* sets errno = ERANGE on overflow; otherwise errno = 0 */
double
result
;
...
...
@@ -441,7 +441,7 @@ complex_add(PyObject *v, PyObject *w)
TO_COMPLEX
(
v
,
a
);
TO_COMPLEX
(
w
,
b
);
PyFPE_START_PROTECT
(
"complex_add"
,
return
0
)
result
=
c_sum
(
a
,
b
);
result
=
_Py_
c_sum
(
a
,
b
);
PyFPE_END_PROTECT
(
result
)
return
PyComplex_FromCComplex
(
result
);
}
...
...
@@ -454,7 +454,7 @@ complex_sub(PyObject *v, PyObject *w)
TO_COMPLEX
(
v
,
a
);
TO_COMPLEX
(
w
,
b
);
PyFPE_START_PROTECT
(
"complex_sub"
,
return
0
)
result
=
c_diff
(
a
,
b
);
result
=
_Py_
c_diff
(
a
,
b
);
PyFPE_END_PROTECT
(
result
)
return
PyComplex_FromCComplex
(
result
);
}
...
...
@@ -467,7 +467,7 @@ complex_mul(PyObject *v, PyObject *w)
TO_COMPLEX
(
v
,
a
);
TO_COMPLEX
(
w
,
b
);
PyFPE_START_PROTECT
(
"complex_mul"
,
return
0
)
result
=
c_prod
(
a
,
b
);
result
=
_Py_
c_prod
(
a
,
b
);
PyFPE_END_PROTECT
(
result
)
return
PyComplex_FromCComplex
(
result
);
}
...
...
@@ -481,7 +481,7 @@ complex_div(PyObject *v, PyObject *w)
TO_COMPLEX
(
w
,
b
);
PyFPE_START_PROTECT
(
"complex_div"
,
return
0
)
errno
=
0
;
quot
=
c_quot
(
a
,
b
);
quot
=
_Py_
c_quot
(
a
,
b
);
PyFPE_END_PROTECT
(
quot
)
if
(
errno
==
EDOM
)
{
PyErr_SetString
(
PyExc_ZeroDivisionError
,
"complex division by zero"
);
...
...
@@ -528,7 +528,7 @@ complex_pow(PyObject *v, PyObject *w, PyObject *z)
if
(
exponent
.
imag
==
0
.
&&
exponent
.
real
==
int_exponent
)
p
=
c_powi
(
a
,
int_exponent
);
else
p
=
c_pow
(
a
,
exponent
);
p
=
_Py_
c_pow
(
a
,
exponent
);
PyFPE_END_PROTECT
(
p
)
Py_ADJUST_ERANGE2
(
p
.
real
,
p
.
imag
);
...
...
@@ -579,7 +579,7 @@ complex_abs(PyComplexObject *v)
double
result
;
PyFPE_START_PROTECT
(
"complex_abs"
,
return
0
)
result
=
c_abs
(
v
->
cval
);
result
=
_Py_
c_abs
(
v
->
cval
);
PyFPE_END_PROTECT
(
result
)
if
(
errno
==
ERANGE
)
{
...
...
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