@@ -365,7 +365,7 @@ quad_to_string_adaptive_cstr(Sleef_quad *sleef_val, npy_intp unicode_size_chars)
365365
366366}
367367
368- /* *
368+ /*
369369 * Same-value check for quad to string conversions.
370370 * Works for bytes (S), unicode (U), and StringDType.
371371 *
@@ -1136,216 +1136,219 @@ numpy_to_quad_strided_loop(PyArrayMethod_Context *context, char *const data[],
11361136
11371137template <typename T>
11381138static inline typename NpyType<T>::TYPE
1139- from_quad (quad_value x, QuadBackendType backend);
1139+ from_quad (const quad_value * x, QuadBackendType backend);
11401140
11411141template <>
11421142inline npy_bool
1143- from_quad<spec_npy_bool>(quad_value x, QuadBackendType backend)
1143+ from_quad<spec_npy_bool>(const quad_value * x, QuadBackendType backend)
11441144{
11451145 if (backend == BACKEND_SLEEF ) {
1146- return Sleef_cast_to_int64q1 (x. sleef_value ) != 0 ;
1146+ return Sleef_cast_to_int64q1 (x-> sleef_value ) != 0 ;
11471147 }
11481148 else {
1149- return x. longdouble_value != 0 ;
1149+ return x-> longdouble_value != 0 ;
11501150 }
11511151}
11521152
11531153template <>
11541154inline npy_byte
1155- from_quad<npy_byte>(quad_value x, QuadBackendType backend)
1155+ from_quad<npy_byte>(const quad_value * x, QuadBackendType backend)
11561156{
11571157 // runtime warnings often comes from/to casting of NaN, inf
11581158 // casting is used by ops at several positions leading to warnings
11591159 // fix can be catching the cases and returning corresponding type value without casting
11601160 if (backend == BACKEND_SLEEF ) {
1161- return (npy_byte)Sleef_cast_to_int64q1 (x. sleef_value );
1161+ return (npy_byte)Sleef_cast_to_int64q1 (x-> sleef_value );
11621162 }
11631163 else {
1164- return (npy_byte)x. longdouble_value ;
1164+ return (npy_byte)x-> longdouble_value ;
11651165 }
11661166}
11671167
11681168template <>
11691169inline npy_ubyte
1170- from_quad<npy_ubyte>(quad_value x, QuadBackendType backend)
1170+ from_quad<npy_ubyte>(const quad_value * x, QuadBackendType backend)
11711171{
11721172 if (backend == BACKEND_SLEEF ) {
1173- return (npy_ubyte)Sleef_cast_to_uint64q1 (x. sleef_value );
1173+ return (npy_ubyte)Sleef_cast_to_uint64q1 (x-> sleef_value );
11741174 }
11751175 else {
1176- return (npy_ubyte)x. longdouble_value ;
1176+ return (npy_ubyte)x-> longdouble_value ;
11771177 }
11781178}
11791179
11801180template <>
11811181inline npy_short
1182- from_quad<npy_short>(quad_value x, QuadBackendType backend)
1182+ from_quad<npy_short>(const quad_value * x, QuadBackendType backend)
11831183{
11841184 if (backend == BACKEND_SLEEF ) {
1185- return (npy_short)Sleef_cast_to_int64q1 (x. sleef_value );
1185+ return (npy_short)Sleef_cast_to_int64q1 (x-> sleef_value );
11861186 }
11871187 else {
1188- return (npy_short)x. longdouble_value ;
1188+ return (npy_short)x-> longdouble_value ;
11891189 }
11901190}
11911191
11921192template <>
11931193inline npy_ushort
1194- from_quad<npy_ushort>(quad_value x, QuadBackendType backend)
1194+ from_quad<npy_ushort>(const quad_value * x, QuadBackendType backend)
11951195{
11961196 if (backend == BACKEND_SLEEF ) {
1197- return (npy_ushort)Sleef_cast_to_uint64q1 (x. sleef_value );
1197+ return (npy_ushort)Sleef_cast_to_uint64q1 (x-> sleef_value );
11981198 }
11991199 else {
1200- return (npy_ushort)x. longdouble_value ;
1200+ return (npy_ushort)x-> longdouble_value ;
12011201 }
12021202}
12031203
12041204template <>
12051205inline npy_int
1206- from_quad<npy_int>(quad_value x, QuadBackendType backend)
1206+ from_quad<npy_int>(const quad_value * x, QuadBackendType backend)
12071207{
12081208 if (backend == BACKEND_SLEEF ) {
1209- return (npy_int)Sleef_cast_to_int64q1 (x. sleef_value );
1209+ return (npy_int)Sleef_cast_to_int64q1 (x-> sleef_value );
12101210 }
12111211 else {
1212- return (npy_int)x. longdouble_value ;
1212+ return (npy_int)x-> longdouble_value ;
12131213 }
12141214}
12151215
12161216template <>
12171217inline npy_uint
1218- from_quad<npy_uint>(quad_value x, QuadBackendType backend)
1218+ from_quad<npy_uint>(const quad_value * x, QuadBackendType backend)
12191219{
12201220 if (backend == BACKEND_SLEEF ) {
1221- return (npy_uint)Sleef_cast_to_uint64q1 (x. sleef_value );
1221+ return (npy_uint)Sleef_cast_to_uint64q1 (x-> sleef_value );
12221222 }
12231223 else {
1224- return (npy_uint)x. longdouble_value ;
1224+ return (npy_uint)x-> longdouble_value ;
12251225 }
12261226}
12271227
12281228template <>
12291229inline npy_long
1230- from_quad<npy_long>(quad_value x, QuadBackendType backend)
1230+ from_quad<npy_long>(const quad_value * x, QuadBackendType backend)
12311231{
12321232 if (backend == BACKEND_SLEEF ) {
1233- return (npy_long)Sleef_cast_to_int64q1 (x. sleef_value );
1233+ return (npy_long)Sleef_cast_to_int64q1 (x-> sleef_value );
12341234 }
12351235 else {
1236- return (npy_long)x. longdouble_value ;
1236+ return (npy_long)x-> longdouble_value ;
12371237 }
12381238}
12391239
12401240template <>
12411241inline npy_ulong
1242- from_quad<npy_ulong>(quad_value x, QuadBackendType backend)
1242+ from_quad<npy_ulong>(const quad_value * x, QuadBackendType backend)
12431243{
12441244 if (backend == BACKEND_SLEEF ) {
1245- return (npy_ulong)Sleef_cast_to_uint64q1 (x. sleef_value );
1245+ return (npy_ulong)Sleef_cast_to_uint64q1 (x-> sleef_value );
12461246 }
12471247 else {
1248- return (npy_ulong)x. longdouble_value ;
1248+ return (npy_ulong)x-> longdouble_value ;
12491249 }
12501250}
12511251
12521252template <>
12531253inline npy_longlong
1254- from_quad<npy_longlong>(quad_value x, QuadBackendType backend)
1254+ from_quad<npy_longlong>(const quad_value * x, QuadBackendType backend)
12551255{
12561256 if (backend == BACKEND_SLEEF ) {
1257- return Sleef_cast_to_int64q1 (x. sleef_value );
1257+ return Sleef_cast_to_int64q1 (x-> sleef_value );
12581258 }
12591259 else {
1260- return (npy_longlong)x. longdouble_value ;
1260+ return (npy_longlong)x-> longdouble_value ;
12611261 }
12621262}
12631263
12641264template <>
12651265inline npy_ulonglong
1266- from_quad<npy_ulonglong>(quad_value x, QuadBackendType backend)
1266+ from_quad<npy_ulonglong>(const quad_value * x, QuadBackendType backend)
12671267{
12681268 if (backend == BACKEND_SLEEF ) {
1269- return Sleef_cast_to_uint64q1 (x. sleef_value );
1269+ return Sleef_cast_to_uint64q1 (x-> sleef_value );
12701270 }
12711271 else {
1272- return (npy_ulonglong)x. longdouble_value ;
1272+ return (npy_ulonglong)x-> longdouble_value ;
12731273 }
12741274}
12751275
12761276template <>
12771277inline npy_half
1278- from_quad<spec_npy_half>(quad_value x, QuadBackendType backend)
1278+ from_quad<spec_npy_half>(const quad_value * x, QuadBackendType backend)
12791279{
12801280 if (backend == BACKEND_SLEEF ) {
1281- return npy_double_to_half (Sleef_cast_to_doubleq1 (x.sleef_value ));
1281+ double d = Sleef_cast_to_doubleq1 (x->sleef_value );
1282+ return npy_double_to_half (d);
12821283 }
12831284 else {
1284- return npy_double_to_half ((double )x. longdouble_value );
1285+ return npy_double_to_half ((double )x-> longdouble_value );
12851286 }
12861287}
12871288
12881289template <>
12891290inline float
1290- from_quad<float >(quad_value x, QuadBackendType backend)
1291+ from_quad<float >(const quad_value * x, QuadBackendType backend)
12911292{
12921293 if (backend == BACKEND_SLEEF ) {
1293- return (float )Sleef_cast_to_doubleq1 (x. sleef_value );
1294+ return (float )Sleef_cast_to_doubleq1 (x-> sleef_value );
12941295 }
12951296 else {
1296- return (float )x. longdouble_value ;
1297+ return (float )x-> longdouble_value ;
12971298 }
12981299}
12991300
13001301template <>
13011302inline double
1302- from_quad<double >(quad_value x, QuadBackendType backend)
1303+ from_quad<double >(const quad_value * x, QuadBackendType backend)
13031304{
13041305 if (backend == BACKEND_SLEEF ) {
1305- return Sleef_cast_to_doubleq1 (x. sleef_value );
1306+ return Sleef_cast_to_doubleq1 (x-> sleef_value );
13061307 }
13071308 else {
1308- return (double )x. longdouble_value ;
1309+ return (double )x-> longdouble_value ;
13091310 }
13101311}
13111312
13121313template <>
13131314inline long double
1314- from_quad<long double >(quad_value x, QuadBackendType backend)
1315+ from_quad<long double >(const quad_value * x, QuadBackendType backend)
13151316{
13161317 if (backend == BACKEND_SLEEF ) {
1317- return (long double )Sleef_cast_to_doubleq1 (x. sleef_value );
1318+ return (long double )Sleef_cast_to_doubleq1 (x-> sleef_value );
13181319 }
13191320 else {
1320- return x. longdouble_value ;
1321+ return x-> longdouble_value ;
13211322 }
13221323}
13231324
13241325template <typename T>
1325- static inline int quad_to_numpy_same_value_check (quad_value x, QuadBackendType backend, typename NpyType<T>::TYPE *y)
1326+ static inline int quad_to_numpy_same_value_check (const quad_value * x, QuadBackendType backend, typename NpyType<T>::TYPE *y)
13261327{
13271328 *y = from_quad<T>(x, backend);
13281329 quad_value roundtrip = to_quad<T>(*y, backend);
1329- if (backend == BACKEND_SLEEF ) {
1330- if (Sleef_iunordq1 (x.sleef_value , roundtrip.sleef_value ))
1330+ if (backend == BACKEND_SLEEF )
1331+ {
1332+ if (Sleef_iunordq1 (x->sleef_value , roundtrip.sleef_value ))
13311333 return 1 ;
1332- if (Sleef_icmpeqq1 (x. sleef_value , roundtrip.sleef_value ))
1334+ if (Sleef_icmpeqq1 (x-> sleef_value , roundtrip.sleef_value ))
13331335 return 1 ;
13341336 // Handle -0.0 == +0.0 case: both zeros are considered equal for same_value casting
1335- if (Sleef_icmpeqq1 (x. sleef_value , QUAD_ZERO ) && Sleef_icmpeqq1 (roundtrip.sleef_value , QUAD_ZERO ))
1337+ if (Sleef_icmpeqq1 (x-> sleef_value , QUAD_ZERO ) && Sleef_icmpeqq1 (roundtrip.sleef_value , QUAD_ZERO ))
13361338 return 1 ;
13371339 }
1338- else {
1339- if (std::isnan (x.longdouble_value ) && std::isnan (roundtrip.longdouble_value ))
1340+ else
1341+ {
1342+ if (std::isnan (x->longdouble_value ) && std::isnan (roundtrip.longdouble_value ))
13401343 return 1 ;
1341- if (x. longdouble_value == roundtrip.longdouble_value )
1344+ if (x-> longdouble_value == roundtrip.longdouble_value )
13421345 return 1 ;
13431346 // Handle -0.0 == +0.0 case for longdouble backend
1344- if (x. longdouble_value == 0 .0L && roundtrip.longdouble_value == 0 .0L )
1347+ if (x-> longdouble_value == 0 .0L && roundtrip.longdouble_value == 0 .0L )
13451348 return 1 ;
13461349 }
13471350 // Sleef_quad sleef_val = quad_to_sleef_quad(&x, backend);
1348- Sleef_quad sleef_val = x. sleef_value ;
1351+ Sleef_quad sleef_val = x-> sleef_value ;
13491352 const char *val_str = quad_to_string_adaptive_cstr (&sleef_val, QUAD_STR_WIDTH );
13501353 if (val_str != NULL ) {
13511354 PyErr_Format (PyExc_ValueError,
@@ -1409,7 +1412,7 @@ quad_to_numpy_strided_loop(PyArrayMethod_Context *context, char *const data[],
14091412 while (N--) {
14101413 quad_value in_val = load_quad<Aligned>(in_ptr, backend);
14111414 typename NpyType<T>::TYPE out_val;
1412- int ret = quad_to_numpy_same_value_check<T>(in_val, backend, &out_val);
1415+ int ret = quad_to_numpy_same_value_check<T>(& in_val, backend, &out_val);
14131416 if (ret < 0 )
14141417 return -1 ;
14151418 store<Aligned, typename NpyType<T>::TYPE >(out_ptr, out_val);
@@ -1421,7 +1424,7 @@ quad_to_numpy_strided_loop(PyArrayMethod_Context *context, char *const data[],
14211424 }
14221425 while (N--) {
14231426 quad_value in_val = load_quad<Aligned>(in_ptr, backend);
1424- typename NpyType<T>::TYPE out_val = from_quad<T>(in_val, backend);
1427+ typename NpyType<T>::TYPE out_val = from_quad<T>(& in_val, backend);
14251428 store<Aligned, typename NpyType<T>::TYPE >(out_ptr, out_val);
14261429
14271430 in_ptr += strides[0 ];
0 commit comments