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
cfd735ea
Unverified
Kaydet (Commit)
cfd735ea
authored
Ock 30, 2019
tarafından
Raymond Hettinger
Kaydeden (comit)
GitHub
Ock 30, 2019
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Move float conversion into a macro. Apply to fsum (GH-11698)
üst
bafa8487
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
49 deletions
+32
-49
mathmodule.c
Modules/mathmodule.c
+32
-49
No files found.
Modules/mathmodule.c
Dosyayı görüntüle @
cfd735ea
...
@@ -76,6 +76,29 @@ static const double logpi = 1.144729885849400174143427351353058711647;
...
@@ -76,6 +76,29 @@ static const double logpi = 1.144729885849400174143427351353058711647;
static
const
double
sqrtpi
=
1
.
772453850905516027298167483341145182798
;
static
const
double
sqrtpi
=
1
.
772453850905516027298167483341145182798
;
#endif
/* !defined(HAVE_ERF) || !defined(HAVE_ERFC) */
#endif
/* !defined(HAVE_ERF) || !defined(HAVE_ERFC) */
/* Version of PyFloat_AsDouble() with in-line fast paths
for exact floats and integers. Gives a substantial
speed improvement for extracting float arguments.
*/
#define ASSIGN_DOUBLE(target_var, obj, error_label) \
if (PyFloat_CheckExact(obj)) { \
target_var = PyFloat_AS_DOUBLE(obj); \
} \
else if (PyLong_CheckExact(obj)) { \
target_var = PyLong_AsDouble(obj); \
if (target_var == -1.0 && PyErr_Occurred()) { \
goto error_label; \
} \
} \
else { \
target_var = PyFloat_AsDouble(obj); \
if (target_var == -1.0 && PyErr_Occurred()) { \
goto error_label; \
} \
}
static
double
static
double
sinpi
(
double
x
)
sinpi
(
double
x
)
{
{
...
@@ -1323,10 +1346,8 @@ math_fsum(PyObject *module, PyObject *seq)
...
@@ -1323,10 +1346,8 @@ math_fsum(PyObject *module, PyObject *seq)
goto
_fsum_error
;
goto
_fsum_error
;
break
;
break
;
}
}
x
=
PyFloat_AsDouble
(
item
);
ASSIGN_DOUBLE
(
x
,
item
,
error_with_
item
);
Py_DECREF
(
item
);
Py_DECREF
(
item
);
if
(
PyErr_Occurred
())
goto
_fsum_error
;
xsave
=
x
;
xsave
=
x
;
for
(
i
=
j
=
0
;
j
<
n
;
j
++
)
{
/* for y in partials */
for
(
i
=
j
=
0
;
j
<
n
;
j
++
)
{
/* for y in partials */
...
@@ -1407,12 +1428,16 @@ math_fsum(PyObject *module, PyObject *seq)
...
@@ -1407,12 +1428,16 @@ math_fsum(PyObject *module, PyObject *seq)
}
}
sum
=
PyFloat_FromDouble
(
hi
);
sum
=
PyFloat_FromDouble
(
hi
);
_fsum_error
:
_fsum_error
:
PyFPE_END_PROTECT
(
hi
)
PyFPE_END_PROTECT
(
hi
)
Py_DECREF
(
iter
);
Py_DECREF
(
iter
);
if
(
p
!=
ps
)
if
(
p
!=
ps
)
PyMem_Free
(
p
);
PyMem_Free
(
p
);
return
sum
;
return
sum
;
error_with_item
:
Py_DECREF
(
item
);
goto
_fsum_error
;
}
}
#undef NUM_PARTIALS
#undef NUM_PARTIALS
...
@@ -2142,37 +2167,9 @@ math_dist_impl(PyObject *module, PyObject *p, PyObject *q)
...
@@ -2142,37 +2167,9 @@ math_dist_impl(PyObject *module, PyObject *p, PyObject *q)
}
}
for
(
i
=
0
;
i
<
n
;
i
++
)
{
for
(
i
=
0
;
i
<
n
;
i
++
)
{
item
=
PyTuple_GET_ITEM
(
p
,
i
);
item
=
PyTuple_GET_ITEM
(
p
,
i
);
if
(
PyFloat_CheckExact
(
item
))
{
ASSIGN_DOUBLE
(
px
,
item
,
error_exit
);
px
=
PyFloat_AS_DOUBLE
(
item
);
}
else
if
(
PyLong_CheckExact
(
item
))
{
px
=
PyLong_AsDouble
(
item
);
if
(
px
==
-
1
.
0
&&
PyErr_Occurred
())
{
goto
error_exit
;
}
}
else
{
px
=
PyFloat_AsDouble
(
item
);
if
(
px
==
-
1
.
0
&&
PyErr_Occurred
())
{
goto
error_exit
;
}
}
item
=
PyTuple_GET_ITEM
(
q
,
i
);
item
=
PyTuple_GET_ITEM
(
q
,
i
);
if
(
PyFloat_CheckExact
(
item
))
{
ASSIGN_DOUBLE
(
qx
,
item
,
error_exit
);
qx
=
PyFloat_AS_DOUBLE
(
item
);
}
else
if
(
PyLong_CheckExact
(
item
))
{
qx
=
PyLong_AsDouble
(
item
);
if
(
qx
==
-
1
.
0
&&
PyErr_Occurred
())
{
goto
error_exit
;
}
}
else
{
qx
=
PyFloat_AsDouble
(
item
);
if
(
qx
==
-
1
.
0
&&
PyErr_Occurred
())
{
goto
error_exit
;
}
}
x
=
fabs
(
px
-
qx
);
x
=
fabs
(
px
-
qx
);
diffs
[
i
]
=
x
;
diffs
[
i
]
=
x
;
found_nan
|=
Py_IS_NAN
(
x
);
found_nan
|=
Py_IS_NAN
(
x
);
...
@@ -2213,21 +2210,7 @@ math_hypot(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
...
@@ -2213,21 +2210,7 @@ math_hypot(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
}
}
for
(
i
=
0
;
i
<
nargs
;
i
++
)
{
for
(
i
=
0
;
i
<
nargs
;
i
++
)
{
item
=
args
[
i
];
item
=
args
[
i
];
if
(
PyFloat_CheckExact
(
item
))
{
ASSIGN_DOUBLE
(
x
,
item
,
error_exit
);
x
=
PyFloat_AS_DOUBLE
(
item
);
}
else
if
(
PyLong_CheckExact
(
item
))
{
x
=
PyLong_AsDouble
(
item
);
if
(
x
==
-
1
.
0
&&
PyErr_Occurred
())
{
goto
error_exit
;
}
}
else
{
x
=
PyFloat_AsDouble
(
item
);
if
(
x
==
-
1
.
0
&&
PyErr_Occurred
())
{
goto
error_exit
;
}
}
x
=
fabs
(
x
);
x
=
fabs
(
x
);
coordinates
[
i
]
=
x
;
coordinates
[
i
]
=
x
;
found_nan
|=
Py_IS_NAN
(
x
);
found_nan
|=
Py_IS_NAN
(
x
);
...
...
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