diff options
Diffstat (limited to 'numpy/core/src')
-rw-r--r-- | numpy/core/src/umathmodule.c.src | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/numpy/core/src/umathmodule.c.src b/numpy/core/src/umathmodule.c.src index 9096cdbf1..760d6d57e 100644 --- a/numpy/core/src/umathmodule.c.src +++ b/numpy/core/src/umathmodule.c.src @@ -1683,9 +1683,15 @@ static void #define BOOL_negative BOOL_logical_not -#define _SIGN1(x) ((x) > 0 ? 1 : ((x) < 0 ? -1 : 0)) +#define _SIGN1(x) (isnan((x)) ? NAN : ((x) > 0 ? 1 : ((x) < 0 ? -1 : 0)) ) #define _SIGN2(x) ((x) == 0 ? 0 : 1) -#define _SIGNC(x) (((x).real > 0) ? 1 : ((x).real < 0 ? -1 : ((x).imag > 0 ? 1 : ((x).imag < 0) ? -1 : 0))) +#define _SIGNC(x) (isnan((x.real)) ? NAN : \ + isnan((x.imag)) ? NAN : \ + ((x).real > 0) ? 1 : \ + ((x).real < 0 ? -1 : \ + ((x).imag > 0 ? 1 : \ + ((x).imag < 0) ? -1 : 0))) + /**begin repeat #TYPE=BYTE,SHORT,INT,LONG,LONGLONG,FLOAT,DOUBLE,LONGDOUBLE,UBYTE,USHORT,UINT,ULONG,ULONGLONG# #typ=byte,short,int,long,longlong,float,double,longdouble,ubyte,ushort,uint,ulong,ulonglong# |