Skip to content

Commit 83167d4

Browse files
barracuda156steppi
authored andcommitted
MAINT: special: Use consistent std::isnan and std::isinf in a few C++ headers (#21861)
* bessel.h: use std::isnan consistently * sph_bessel.h: use std:: with isinf/isnan consistently * boost_special_functions.h: use std::isnan consistently
1 parent 432d1ff commit 83167d4

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

scipy/special/xsf/bessel.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ inline std::complex<double> cyl_bessel_je(double v, std::complex<double> z) {
605605
cy_y.real(NAN);
606606
cy_y.imag(NAN);
607607

608-
if (isnan(v) || isnan(z.real()) || isnan(z.imag())) {
608+
if (std::isnan(v) || std::isnan(z.real()) || std::isnan(z.imag())) {
609609
return cy_j;
610610
}
611611
if (v < 0) {
@@ -658,7 +658,7 @@ inline std::complex<double> cyl_bessel_ye(double v, std::complex<double> z) {
658658
cy_y.real(NAN);
659659
cy_y.imag(NAN);
660660

661-
if (isnan(v) || isnan(z.real()) || isnan(z.imag())) {
661+
if (std::isnan(v) || std::isnan(z.real()) || std::isnan(z.imag())) {
662662
return cy_y;
663663
}
664664
if (v < 0) {
@@ -711,7 +711,7 @@ inline std::complex<double> cyl_bessel_ie(double v, std::complex<double> z) {
711711
cy_k.real(NAN);
712712
cy_k.imag(NAN);
713713

714-
if (isnan(v) || isnan(z.real()) || isnan(z.imag())) {
714+
if (std::isnan(v) || std::isnan(z.real()) || std::isnan(z.imag())) {
715715
return cy;
716716
}
717717
if (v < 0) {
@@ -755,7 +755,7 @@ T cyl_bessel_ie(T v, T x) {
755755

756756
inline std::complex<double> cyl_bessel_ke(double v, std::complex<double> z) {
757757
std::complex<double> cy{NAN, NAN};
758-
if (isnan(v) || isnan(std::real(z)) || isnan(std::imag(z))) {
758+
if (std::isnan(v) || std::isnan(std::real(z)) || std::isnan(std::imag(z))) {
759759
return cy;
760760
}
761761

@@ -808,7 +808,7 @@ inline std::complex<double> cyl_hankel_1e(double v, std::complex<double> z) {
808808
cy.real(NAN);
809809
cy.imag(NAN);
810810

811-
if (isnan(v) || isnan(z.real()) || isnan(z.imag())) {
811+
if (std::isnan(v) || std::isnan(z.real()) || std::isnan(z.imag())) {
812812
return cy;
813813
}
814814
if (v < 0) {
@@ -836,7 +836,7 @@ inline std::complex<double> cyl_hankel_2e(double v, std::complex<double> z) {
836836
int sign = 1;
837837

838838
std::complex<double> cy{NAN, NAN};
839-
if (isnan(v) || isnan(z.real()) || isnan(z.imag())) {
839+
if (std::isnan(v) || std::isnan(z.real()) || std::isnan(z.imag())) {
840840
return cy;
841841
}
842842

@@ -877,7 +877,7 @@ inline std::complex<double> cyl_bessel_j(double v, std::complex<double> z) {
877877
cy_y.real(NAN);
878878
cy_y.imag(NAN);
879879

880-
if (isnan(v) || isnan(z.real()) || isnan(z.imag())) {
880+
if (std::isnan(v) || std::isnan(z.real()) || std::isnan(z.imag())) {
881881
return cy_j;
882882
}
883883
if (v < 0) {
@@ -935,7 +935,7 @@ inline std::complex<double> cyl_bessel_y(double v, std::complex<double> z) {
935935
cy_y.real(NAN);
936936
cy_y.imag(NAN);
937937

938-
if (isnan(v) || isnan(z.real()) || isnan(z.imag())) {
938+
if (std::isnan(v) || std::isnan(z.real()) || std::isnan(z.imag())) {
939939
return cy_y;
940940
}
941941
if (v < 0) {
@@ -1022,7 +1022,7 @@ inline std::complex<double> cyl_bessel_i(double v, std::complex<double> z) {
10221022
cy_k.real(NAN);
10231023
cy_k.imag(NAN);
10241024

1025-
if (isnan(v) || isnan(z.real()) || isnan(z.imag())) {
1025+
if (std::isnan(v) || std::isnan(z.real()) || std::isnan(z.imag())) {
10261026
return cy;
10271027
}
10281028
if (v < 0) {
@@ -1139,7 +1139,7 @@ inline std::complex<double> cyl_hankel_1(double v, std::complex<double> z) {
11391139
cy.real(NAN);
11401140
cy.imag(NAN);
11411141

1142-
if (isnan(v) || isnan(z.real()) || isnan(z.imag())) {
1142+
if (std::isnan(v) || std::isnan(z.real()) || std::isnan(z.imag())) {
11431143
return cy;
11441144
}
11451145
if (v < 0) {
@@ -1169,7 +1169,7 @@ inline std::complex<double> cyl_hankel_2(double v, std::complex<double> z) {
11691169
cy.real(NAN);
11701170
cy.imag(NAN);
11711171

1172-
if (isnan(v) || isnan(z.real()) || isnan(z.imag())) {
1172+
if (std::isnan(v) || std::isnan(z.real()) || std::isnan(z.imag())) {
11731173
return cy;
11741174
}
11751175
if (v == 0 && z == 0.0) {

scipy/special/xsf/sph_bessel.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ T sph_bessel_y(long n, T x) {
144144
T s0, s1, sn;
145145
int idx;
146146

147-
if (isnan(x)) {
147+
if (std::isnan(x)) {
148148
return x;
149149
}
150150

@@ -179,7 +179,7 @@ T sph_bessel_y(long n, T x) {
179179
sn = (2 * idx + 3) * s1 / x - s0;
180180
s0 = s1;
181181
s1 = sn;
182-
if (isinf(sn)) {
182+
if (std::isinf(sn)) {
183183
// Overflow occurred already: terminate recurrence.
184184
return sn;
185185
}
@@ -229,7 +229,7 @@ T sph_bessel_y_jac(long n, T x) {
229229

230230
template <typename T>
231231
T sph_bessel_i(long n, T x) {
232-
if (isnan(x)) {
232+
if (std::isnan(x)) {
233233
return x;
234234
}
235235

@@ -246,7 +246,7 @@ T sph_bessel_i(long n, T x) {
246246
return 0;
247247
}
248248

249-
if (isinf(x)) {
249+
if (std::isinf(x)) {
250250
// https://dlmf.nist.gov/10.49.E8
251251
if (x == -std::numeric_limits<T>::infinity()) {
252252
return std::pow(-1, n) * std::numeric_limits<T>::infinity();
@@ -314,7 +314,7 @@ T sph_bessel_i_jac(long n, T z) {
314314

315315
template <typename T>
316316
T sph_bessel_k(long n, T z) {
317-
if (isnan(z)) {
317+
if (std::isnan(z)) {
318318
return z;
319319
}
320320

@@ -327,7 +327,7 @@ T sph_bessel_k(long n, T z) {
327327
return std::numeric_limits<T>::infinity();
328328
}
329329

330-
if (isinf(z)) {
330+
if (std::isinf(z)) {
331331
// https://dlmf.nist.gov/10.52.E6
332332
if (z == std::numeric_limits<T>::infinity()) {
333333
return 0;

0 commit comments

Comments
 (0)