Skip to content

Commit 41cc67a

Browse files
authored
Merge pull request numpy#27096 from SlobodanMiletic/fix_complex_imag_zero
BUG: Complex printing tests fail on Windows ARM64
2 parents e151e44 + c56a453 commit 41cc67a

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

numpy/_core/include/numpy/npy_math.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,11 @@ NPY_INPLACE npy_longdouble npy_heavisidel(npy_longdouble x, npy_longdouble h0);
362362

363363
static inline double npy_creal(const npy_cdouble z)
364364
{
365+
#if defined(__cplusplus)
365366
return ((double *) &z)[0];
367+
#else
368+
return creal(z);
369+
#endif
366370
}
367371

368372
static inline void npy_csetreal(npy_cdouble *z, const double r)
@@ -372,7 +376,11 @@ static inline void npy_csetreal(npy_cdouble *z, const double r)
372376

373377
static inline double npy_cimag(const npy_cdouble z)
374378
{
379+
#if defined(__cplusplus)
375380
return ((double *) &z)[1];
381+
#else
382+
return cimag(z);
383+
#endif
376384
}
377385

378386
static inline void npy_csetimag(npy_cdouble *z, const double i)
@@ -382,7 +390,11 @@ static inline void npy_csetimag(npy_cdouble *z, const double i)
382390

383391
static inline float npy_crealf(const npy_cfloat z)
384392
{
393+
#if defined(__cplusplus)
385394
return ((float *) &z)[0];
395+
#else
396+
return crealf(z);
397+
#endif
386398
}
387399

388400
static inline void npy_csetrealf(npy_cfloat *z, const float r)
@@ -392,7 +404,11 @@ static inline void npy_csetrealf(npy_cfloat *z, const float r)
392404

393405
static inline float npy_cimagf(const npy_cfloat z)
394406
{
407+
#if defined(__cplusplus)
395408
return ((float *) &z)[1];
409+
#else
410+
return cimagf(z);
411+
#endif
396412
}
397413

398414
static inline void npy_csetimagf(npy_cfloat *z, const float i)
@@ -402,7 +418,11 @@ static inline void npy_csetimagf(npy_cfloat *z, const float i)
402418

403419
static inline npy_longdouble npy_creall(const npy_clongdouble z)
404420
{
421+
#if defined(__cplusplus)
405422
return ((longdouble_t *) &z)[0];
423+
#else
424+
return creall(z);
425+
#endif
406426
}
407427

408428
static inline void npy_csetreall(npy_clongdouble *z, const longdouble_t r)
@@ -412,7 +432,11 @@ static inline void npy_csetreall(npy_clongdouble *z, const longdouble_t r)
412432

413433
static inline npy_longdouble npy_cimagl(const npy_clongdouble z)
414434
{
435+
#if defined(__cplusplus)
415436
return ((longdouble_t *) &z)[1];
437+
#else
438+
return cimagl(z);
439+
#endif
416440
}
417441

418442
static inline void npy_csetimagl(npy_clongdouble *z, const longdouble_t i)

0 commit comments

Comments
 (0)