@@ -175,7 +175,7 @@ static @ctype@ _npy_scaled_cexp@c@(@type@ x, @type@ y, npy_int expt)
175175#if @precision @ == 3
176176 const npy_int k = 19547 ;
177177#endif
178- const @type @ kln2 = k * NPY_LOGE2 ;
178+ const @type @ kln2 = k * NPY_LOGE2 @ c @ ;
179179 @type @ mant , mantcos , mantsin ;
180180 npy_int ex , excos , exsin ;
181181
@@ -211,7 +211,7 @@ static @ctype@ _npy_scaled_cexp@c@(@type@ x, @type@ y, npy_int expt)
211211 if (npy_isfinite (i )) {
212212 ret = npy_cpack @c @(x * c , x * s );
213213 } else {
214- ret = npy_cpack @c @(NPY_NAN , npy_copysign @c @(NPY_NAN , i ));
214+ ret = npy_cpack @c @(NPY_NAN @ C @ , npy_copysign @c @(NPY_NAN @ C @ , i ));
215215 }
216216 }
217217
@@ -220,7 +220,7 @@ static @ctype@ _npy_scaled_cexp@c@(@type@ x, @type@ y, npy_int expt)
220220 if (i == 0 ) {
221221 ret = z ;
222222 } else {
223- ret = npy_cpack @c @(r , npy_copysign @c @(NPY_NAN , i ));
223+ ret = npy_cpack @c @(r , npy_copysign @c @(NPY_NAN @ C @ , i ));
224224 }
225225 } else {
226226 /* r is +- inf */
@@ -235,7 +235,7 @@ static @ctype@ _npy_scaled_cexp@c@(@type@ x, @type@ y, npy_int expt)
235235 } else {
236236 /* x = +inf, y = +-inf | nan */
237237 npy_set_floatstatus_invalid ();
238- ret = npy_cpack @c @(r , NPY_NAN );
238+ ret = npy_cpack @c @(r , NPY_NAN @ C @ );
239239 }
240240 } else {
241241 if (npy_isfinite (i )) {
@@ -342,7 +342,7 @@ static @ctype@ _npy_scaled_cexp@c@(@type@ x, @type@ y, npy_int expt)
342342 if (a == 0 && b == 0 )
343343 return (npy_cpack @c @(0 , b ));
344344 if (npy_isinf (b ))
345- return (npy_cpack @c @(NPY_INFINITY , b ));
345+ return (npy_cpack @c @(NPY_INFINITY @ C @ , b ));
346346 if (npy_isnan (a )) {
347347 t = (b - b ) / (b - b ); /* raise invalid if b is not a NaN */
348348 return (npy_cpack @c @(a , t )); /* return NaN + NaN i */
@@ -375,10 +375,10 @@ static @ctype@ _npy_scaled_cexp@c@(@type@ x, @type@ y, npy_int expt)
375375
376376 /* Algorithm 312, CACM vol 10, Oct 1967. */
377377 if (a >= 0 ) {
378- t = npy_sqrt @c @((a + npy_hypot @c @(a , b )) * 0.5 );
378+ t = npy_sqrt @c @((a + npy_hypot @c @(a , b )) * 0.5 @ c @ );
379379 result = npy_cpack @c @(t , b / (2 * t ));
380380 } else {
381- t = npy_sqrt @c @((- a + npy_hypot @c @(a , b )) * 0.5 );
381+ t = npy_sqrt @c @((- a + npy_hypot @c @(a , b )) * 0.5 @ c @ );
382382 result = npy_cpack @c @(npy_fabs @c @(b ) / (2 * t ), npy_copysign @c @(t , b ));
383383 }
384384
@@ -409,17 +409,17 @@ static @ctype@ _npy_scaled_cexp@c@(@type@ x, @type@ y, npy_int expt)
409409 return npy_cpack @c @(0. , 0. );
410410 }
411411 else {
412- volatile @type @ tmp = NPY_INFINITY ;
412+ volatile @type @ tmp = NPY_INFINITY @ C @ ;
413413 /* NB: there are four complex zeros; c0 = (+-0, +-0), so that unlike
414414 * for reals, c0**p, with `p` negative is in general
415415 * ill-defined.
416416 *
417417 * c0**z with z complex is also ill-defined.
418418 */
419- r = npy_cpack @c @(NPY_NAN , NPY_NAN );
419+ r = npy_cpack @c @(NPY_NAN @ C @ , NPY_NAN @ C @ );
420420
421421 /* Raise invalid */
422- tmp -= NPY_INFINITY ;
422+ tmp -= NPY_INFINITY @ C @ ;
423423 ar = tmp ;
424424 return r ;
425425 }
@@ -506,21 +506,26 @@ static @ctype@ _npy_scaled_cexp@c@(@type@ x, @type@ y, npy_int expt)
506506 * spacing(0.5 * exp(CCOSH_BIG)) > 0.5*exp(-CCOSH_BIG)
507507 * although the exact value assigned to CCOSH_BIG is not so important
508508 */
509+ @ctype @ npy_ccosh @c @(@ctype @ z )
510+ {
509511#if @precision @ == 1
510- #define CCOSH_BIG 9.0f
511- #define CCOSH_HUGE 1.70141183e+38f
512+ const npy_float CCOSH_BIG = 9.0f ;
513+ const npy_float CCOSH_HUGE = 1.70141183e+38f ;
512514#endif
513515#if @precision @ == 2
514- #define CCOSH_BIG 22.0
515- #define CCOSH_HUGE 8.9884656743115795e+307
516+ const npy_double CCOSH_BIG = 22.0 ;
517+ const npy_double CCOSH_HUGE = 8.9884656743115795e+307 ;
516518#endif
517519#if @precision @ >= 3
518- #define CCOSH_BIG 24.0L
519- #define CCOSH_HUGE 5.94865747678615882543e+4931L
520+ #if NPY_SIZEOF_LONGDOUBLE == NPY_SIZEOF_DOUBLE
521+ const npy_longdouble CCOSH_BIG = 22.0L ;
522+ const npy_longdouble CCOSH_HUGE = 8.9884656743115795e+307L ;
523+ #else
524+ const npy_longdouble CCOSH_BIG = 24.0L ;
525+ const npy_longdouble CCOSH_HUGE = 5.94865747678615882543e+4931L ;
526+ #endif
520527#endif
521528
522- @ctype @ npy_ccosh @c @(@ctype @ z )
523- {
524529 @type @ x , y , h , absx ;
525530 npy_int xfinite , yfinite ;
526531
@@ -542,7 +547,7 @@ static @ctype@ _npy_scaled_cexp@c@(@type@ x, @type@ y, npy_int expt)
542547 /* |x| >= 22, so cosh(x) ~= exp(|x|) */
543548 if (absx < SCALED_CEXP_LOWER @C @) {
544549 /* x < 710: exp(|x|) won't overflow */
545- h = npy_exp @c @(absx ) * 0.5 ;
550+ h = npy_exp @c @(absx ) * 0.5 @ c @ ;
546551 return npy_cpack @c @(h * npy_cos @c @(y ),
547552 npy_copysign @c @(h , x ) * npy_sin @c @(y ));
548553 } else if (absx < SCALED_CEXP_UPPER @C @) {
@@ -633,22 +638,26 @@ static @ctype@ _npy_scaled_cexp@c@(@type@ x, @type@ y, npy_int expt)
633638 * Exceptional values are noted in the comments within the source code.
634639 * These values and the return value were taken from n1124.pdf.
635640 */
636-
641+ @ctype @ npy_csinh @c @(@ctype @ z )
642+ {
637643#if @precision @ == 1
638- #define CSINH_BIG 9.0f
639- #define CSINH_HUGE 1.70141183e+38f
644+ const npy_float CSINH_BIG = 9.0f ;
645+ const npy_float CSINH_HUGE = 1.70141183e+38f ;
640646#endif
641647#if @precision @ == 2
642- #define CSINH_BIG 22.0
643- #define CSINH_HUGE 8.9884656743115795e+307
648+ const npy_double CSINH_BIG = 22.0 ;
649+ const npy_double CSINH_HUGE = 8.9884656743115795e+307 ;
644650#endif
645651#if @precision @ >= 3
646- #define CSINH_BIG 24.0L
647- #define CSINH_HUGE 5.94865747678615882543e+4931L
652+ #if NPY_SIZEOF_LONGDOUBLE == NPY_SIZEOF_DOUBLE
653+ const npy_longdouble CSINH_BIG = 22.0L ;
654+ const npy_longdouble CSINH_HUGE = 8.9884656743115795e+307L ;
655+ #else
656+ const npy_longdouble CSINH_BIG = 24.0L ;
657+ const npy_longdouble CSINH_HUGE = 5.94865747678615882543e+4931L ;
658+ #endif
648659#endif
649660
650- @ctype @ npy_csinh @c @(@ctype @ z )
651- {
652661 @type @ x , y , h , absx ;
653662 npy_int xfinite , yfinite ;
654663
@@ -670,7 +679,7 @@ static @ctype@ _npy_scaled_cexp@c@(@type@ x, @type@ y, npy_int expt)
670679 /* |x| >= 22, so cosh(x) ~= exp(|x|) */
671680 if (absx < SCALED_CEXP_LOWER @C @) {
672681 /* x < 710: exp(|x|) won't overflow */
673- h = npy_exp @c @(npy_fabs @c @(x )) * 0.5 ;
682+ h = npy_exp @c @(npy_fabs @c @(x )) * 0.5 @ c @ ;
674683 return npy_cpack @c @(npy_copysign @c @(h , x ) * npy_cos @c @(y ),
675684 h * npy_sin @c @(y ));
676685 } else if (x < SCALED_CEXP_UPPER @C @) {
@@ -851,7 +860,7 @@ static @ctype@ _npy_scaled_cexp@c@(@type@ x, @type@ y, npy_int expt)
851860
852861 /* Kahan's algorithm */
853862 t = npy_tan @c @(y );
854- beta = 1.0 + t * t ; /* = 1 / cos^2(y) */
863+ beta = 1 + t * t ; /* = 1 / cos^2(y) */
855864 s = npy_sinh @c @(x );
856865 rho = npy_sqrt @c @(1 + s * s ); /* = cosh(x) */
857866 denom = 1 + beta * s * s ;
@@ -939,17 +948,21 @@ static inline void _do_hard_work@c@(@type@ x, @type@ y, @type@ *rx,
939948#if @precision @ == 1
940949 const npy_float A_crossover = 10.0f ;
941950 const npy_float B_crossover = 0.6417f ;
942- const npy_float FOUR_SQRT_MIN = 0x1p-61f ;
951+ const npy_float FOUR_SQRT_MIN = 4.3368086899420177e-19f ;
943952#endif
944953#if @precision @ == 2
945954 const npy_double A_crossover = 10.0 ;
946955 const npy_double B_crossover = 0.6417 ;
947- const npy_double FOUR_SQRT_MIN = 0x1p-509 ;
956+ const npy_double FOUR_SQRT_MIN = 5.9666725849601654e-154 ;
948957#endif
949958#if @precision @ == 3
950959 const npy_longdouble A_crossover = 10.0l ;
951960 const npy_longdouble B_crossover = 0.6417l ;
952- const npy_longdouble FOUR_SQRT_MIN = 0x1p-8189l ;
961+ #if NPy_SIZEOF_LONGDOUBLE == NPY_SIZEOF_DOUBLE
962+ const npy_longdouble FOUR_SQRT_MIN = 5.9666725849601654e-154 ;
963+ #else
964+ const npy_longdouble FOUR_SQRT_MIN = 7.3344154702193886625e-2466l ;
965+ #endif
953966#endif
954967 @type @ R , S , A ; /* A, B, R, and S are as in Hull et al. */
955968 @type @ Am1 , Amy ; /* A-1, A-y. */
@@ -1068,16 +1081,21 @@ static inline void _clog_for_large_values@c@(@type@ x, @type@ y,
10681081 @type @ * rr , @type @ * ri )
10691082{
10701083#if @precision @ == 1
1071- const npy_float QUARTER_SQRT_MAX = 0x1p61f ;
1072- const npy_float SQRT_MIN = 0x1p-63f ;
1073- #endif
1084+ const npy_float QUARTER_SQRT_MAX = 4.611685743549481e+18f ;
1085+ const npy_float SQRT_MIN = 1.0842021724855044e-19f ;
1086+ #endif
10741087#if @precision @ == 2
1075- const npy_double QUARTER_SQRT_MAX = 0x1p509 ;
1076- const npy_double SQRT_MIN = 0x1p-511 ;
1077- #endif
1088+ const npy_double QUARTER_SQRT_MAX = 3.3519519824856489e+153 ;
1089+ const npy_double SQRT_MIN = 1.4916681462400413e-154 ;
1090+ #endif
10781091#if @precision @ == 3
1079- const npy_longdouble QUARTER_SQRT_MAX = 0x1p8189l ;
1080- const npy_longdouble SQRT_MIN = 0x1p-8191l ;
1092+ #if NPY_SIZEOF_LONGDOUBLE == NPY_SIZEOF_DOUBLE
1093+ const npy_longdouble QUARTER_SQRT_MAX = 3.3519519824856489e+153 ;
1094+ const npy_longdouble SQRT_MIN = 1.4916681462400413e-154 ;
1095+ #else
1096+ const npy_longdouble QUARTER_SQRT_MAX = 2.7268703390485398235e+2465l ;
1097+ const npy_longdouble SQRT_MIN = 1.8336038675548471656e-2466l ;
1098+ #endif
10811099#endif
10821100 @type @ ax , ay , t ;
10831101
@@ -1146,7 +1164,7 @@ static inline void _clog_for_large_values@c@(@type@ x, @type@ y,
11461164 if (npy_isnan (x ) || npy_isnan (y )) {
11471165 /* cacos(+-Inf + I*NaN) = NaN + I*opt(-)Inf */
11481166 if (npy_isinf (x ))
1149- return npy_cpack @c @(y + y , - INFINITY );
1167+ return npy_cpack @c @(y + y , - NPY_INFINITY @ C @ );
11501168 /* cacos(NaN + I*+-Inf) = NaN + I*-+Inf */
11511169 if (npy_isinf (y ))
11521170 return npy_cpack @c @(x + x , - y );
@@ -1158,7 +1176,7 @@ static inline void _clog_for_large_values@c@(@type@ x, @type@ y,
11581176 * C99 leaves it optional whether to raise invalid if one of
11591177 * the arguments is not NaN, so we opt not to raise it.
11601178 */
1161- return npy_cpack @c @(x + 0.0L + ( y + 0 ), x + 0.0L + ( y + 0 ) );
1179+ return npy_cpack @c @(NPY_NAN @ C @, NPY_NAN @ C @ );
11621180 }
11631181
11641182 if (ax > RECIP_EPSILON || ay > RECIP_EPSILON ) {
@@ -1294,7 +1312,7 @@ static inline void _clog_for_large_values@c@(@type@ x, @type@ y,
12941312 * C99 leaves it optional whether to raise invalid if one of
12951313 * the arguments is not NaN, so we opt not to raise it.
12961314 */
1297- return npy_cpack @c @(x + 0.0L + ( y + 0 ), x + 0.0L + ( y + 0 ) );
1315+ return npy_cpack @c @(NPY_NAN @ C @, NPY_NAN @ C @ );
12981316 }
12991317
13001318 if (ax > RECIP_EPSILON || ay > RECIP_EPSILON ) {
@@ -1502,7 +1520,7 @@ static inline npy_longdouble _real_part_reciprocall(npy_longdouble x,
15021520 * C99 leaves it optional whether to raise invalid if one of
15031521 * the arguments is not NaN, so we opt not to raise it.
15041522 */
1505- return npy_cpack @c @(x + 0.0L + ( y + 0 ), x + 0.0L + ( y + 0 ) );
1523+ return npy_cpack @c @(NPY_NAN @ C @, NPY_NAN @ C @ );
15061524 }
15071525
15081526 if (ax > RECIP_EPSILON || ay > RECIP_EPSILON )
0 commit comments