Skip to content

Commit 704ca94

Browse files
committed
nextafter is mandatory
1 parent 2c4cc10 commit 704ca94

File tree

2 files changed

+0
-412
lines changed

2 files changed

+0
-412
lines changed

numpy/core/src/npymath/ieee754.c.src

Lines changed: 0 additions & 201 deletions
Original file line numberDiff line numberDiff line change
@@ -310,201 +310,6 @@ static npy_longdouble _nextl(npy_longdouble x, int p)
310310
}
311311
#endif
312312

313-
/*
314-
* nextafter code taken from BSD math lib, the code contains the following
315-
* notice:
316-
*
317-
* ====================================================
318-
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
319-
*
320-
* Developed at SunPro, a Sun Microsystems, Inc. business.
321-
* Permission to use, copy, modify, and distribute this
322-
* software is freely granted, provided that this notice
323-
* is preserved.
324-
* ====================================================
325-
*/
326-
327-
#ifndef HAVE_NEXTAFTER
328-
double npy_nextafter(double x, double y)
329-
{
330-
volatile double t;
331-
npy_int32 hx, hy, ix, iy;
332-
npy_uint32 lx, ly;
333-
334-
EXTRACT_WORDS(hx, lx, x);
335-
EXTRACT_WORDS(hy, ly, y);
336-
ix = hx & 0x7fffffff; /* |x| */
337-
iy = hy & 0x7fffffff; /* |y| */
338-
339-
if (((ix >= 0x7ff00000) && ((ix - 0x7ff00000) | lx) != 0) || /* x is nan */
340-
((iy >= 0x7ff00000) && ((iy - 0x7ff00000) | ly) != 0)) /* y is nan */
341-
return x + y;
342-
if (x == y)
343-
return y; /* x=y, return y */
344-
if ((ix | lx) == 0) { /* x == 0 */
345-
INSERT_WORDS(x, hy & 0x80000000, 1); /* return +-minsubnormal */
346-
t = x * x;
347-
if (t == x)
348-
return t;
349-
else
350-
return x; /* raise underflow flag */
351-
}
352-
if (hx >= 0) { /* x > 0 */
353-
if (hx > hy || ((hx == hy) && (lx > ly))) { /* x > y, x -= ulp */
354-
if (lx == 0)
355-
hx -= 1;
356-
lx -= 1;
357-
} else { /* x < y, x += ulp */
358-
lx += 1;
359-
if (lx == 0)
360-
hx += 1;
361-
}
362-
} else { /* x < 0 */
363-
if (hy >= 0 || hx > hy || ((hx == hy) && (lx > ly))) { /* x < y, x -= ulp */
364-
if (lx == 0)
365-
hx -= 1;
366-
lx -= 1;
367-
} else { /* x > y, x += ulp */
368-
lx += 1;
369-
if (lx == 0)
370-
hx += 1;
371-
}
372-
}
373-
hy = hx & 0x7ff00000;
374-
if (hy >= 0x7ff00000)
375-
return x + x; /* overflow */
376-
if (hy < 0x00100000) { /* underflow */
377-
t = x * x;
378-
if (t != x) { /* raise underflow flag */
379-
INSERT_WORDS(y, hx, lx);
380-
return y;
381-
}
382-
}
383-
INSERT_WORDS(x, hx, lx);
384-
return x;
385-
}
386-
#endif
387-
388-
#ifndef HAVE_NEXTAFTERF
389-
float npy_nextafterf(float x, float y)
390-
{
391-
volatile float t;
392-
npy_int32 hx, hy, ix, iy;
393-
394-
GET_FLOAT_WORD(hx, x);
395-
GET_FLOAT_WORD(hy, y);
396-
ix = hx & 0x7fffffff; /* |x| */
397-
iy = hy & 0x7fffffff; /* |y| */
398-
399-
if ((ix > 0x7f800000) || /* x is nan */
400-
(iy > 0x7f800000)) /* y is nan */
401-
return x + y;
402-
if (x == y)
403-
return y; /* x=y, return y */
404-
if (ix == 0) { /* x == 0 */
405-
SET_FLOAT_WORD(x, (hy & 0x80000000) | 1); /* return +-minsubnormal */
406-
t = x * x;
407-
if (t == x)
408-
return t;
409-
else
410-
return x; /* raise underflow flag */
411-
}
412-
if (hx >= 0) { /* x > 0 */
413-
if (hx > hy) { /* x > y, x -= ulp */
414-
hx -= 1;
415-
} else { /* x < y, x += ulp */
416-
hx += 1;
417-
}
418-
} else { /* x < 0 */
419-
if (hy >= 0 || hx > hy) { /* x < y, x -= ulp */
420-
hx -= 1;
421-
} else { /* x > y, x += ulp */
422-
hx += 1;
423-
}
424-
}
425-
hy = hx & 0x7f800000;
426-
if (hy >= 0x7f800000)
427-
return x + x; /* overflow */
428-
if (hy < 0x00800000) { /* underflow */
429-
t = x * x;
430-
if (t != x) { /* raise underflow flag */
431-
SET_FLOAT_WORD(y, hx);
432-
return y;
433-
}
434-
}
435-
SET_FLOAT_WORD(x, hx);
436-
return x;
437-
}
438-
#endif
439-
440-
#ifndef HAVE_NEXTAFTERL
441-
npy_longdouble npy_nextafterl(npy_longdouble x, npy_longdouble y)
442-
{
443-
volatile npy_longdouble t;
444-
union IEEEl2bitsrep ux;
445-
union IEEEl2bitsrep uy;
446-
447-
ux.e = x;
448-
uy.e = y;
449-
450-
if ((GET_LDOUBLE_EXP(ux) == 0x7fff &&
451-
((GET_LDOUBLE_MANH(ux) & ~LDBL_NBIT) | GET_LDOUBLE_MANL(ux)) != 0) ||
452-
(GET_LDOUBLE_EXP(uy) == 0x7fff &&
453-
((GET_LDOUBLE_MANH(uy) & ~LDBL_NBIT) | GET_LDOUBLE_MANL(uy)) != 0)) {
454-
return ux.e + uy.e; /* x or y is nan */
455-
}
456-
if (ux.e == uy.e) {
457-
return uy.e; /* x=y, return y */
458-
}
459-
if (ux.e == 0.0) {
460-
SET_LDOUBLE_MANH(ux, 0); /* return +-minsubnormal */
461-
SET_LDOUBLE_MANL(ux, 1);
462-
SET_LDOUBLE_SIGN(ux, GET_LDOUBLE_SIGN(uy));
463-
t = ux.e * ux.e;
464-
if (t == ux.e) {
465-
return t;
466-
} else {
467-
return ux.e; /* raise underflow flag */
468-
}
469-
}
470-
if ((ux.e > 0.0) ^ (ux.e < uy.e)) { /* x -= ulp */
471-
if (GET_LDOUBLE_MANL(ux) == 0) {
472-
if ((GET_LDOUBLE_MANH(ux) & ~LDBL_NBIT) == 0) {
473-
SET_LDOUBLE_EXP(ux, GET_LDOUBLE_EXP(ux) - 1);
474-
}
475-
SET_LDOUBLE_MANH(ux,
476-
(GET_LDOUBLE_MANH(ux) - 1) |
477-
(GET_LDOUBLE_MANH(ux) & LDBL_NBIT));
478-
}
479-
SET_LDOUBLE_MANL(ux, GET_LDOUBLE_MANL(ux) - 1);
480-
} else { /* x += ulp */
481-
SET_LDOUBLE_MANL(ux, GET_LDOUBLE_MANL(ux) + 1);
482-
if (GET_LDOUBLE_MANL(ux) == 0) {
483-
SET_LDOUBLE_MANH(ux,
484-
(GET_LDOUBLE_MANH(ux) + 1) |
485-
(GET_LDOUBLE_MANH(ux) & LDBL_NBIT));
486-
if ((GET_LDOUBLE_MANH(ux) & ~LDBL_NBIT) == 0) {
487-
SET_LDOUBLE_EXP(ux, GET_LDOUBLE_EXP(ux) + 1);
488-
}
489-
}
490-
}
491-
if (GET_LDOUBLE_EXP(ux) == 0x7fff) {
492-
return ux.e + ux.e; /* overflow */
493-
}
494-
if (GET_LDOUBLE_EXP(ux) == 0) { /* underflow */
495-
if (LDBL_NBIT) {
496-
SET_LDOUBLE_MANH(ux, GET_LDOUBLE_MANH(ux) & ~LDBL_NBIT);
497-
}
498-
t = ux.e * ux.e;
499-
if (t != ux.e) { /* raise underflow flag */
500-
return ux.e;
501-
}
502-
}
503-
504-
return ux.e;
505-
}
506-
#endif
507-
508313
/**begin repeat
509314
* #suff = f,,l#
510315
* #SUFF = F,,L#
@@ -525,26 +330,20 @@ npy_longdouble npy_nextafterl(npy_longdouble x, npy_longdouble y)
525330
* Decorate all the math functions which are available on the current platform
526331
*/
527332

528-
#ifdef HAVE_NEXTAFTERF
529333
float npy_nextafterf(float x, float y)
530334
{
531335
return nextafterf(x, y);
532336
}
533-
#endif
534337

535-
#ifdef HAVE_NEXTAFTER
536338
double npy_nextafter(double x, double y)
537339
{
538340
return nextafter(x, y);
539341
}
540-
#endif
541342

542-
#ifdef HAVE_NEXTAFTERL
543343
npy_longdouble npy_nextafterl(npy_longdouble x, npy_longdouble y)
544344
{
545345
return nextafterl(x, y);
546346
}
547-
#endif
548347

549348
int npy_clear_floatstatus() {
550349
char x=0;

0 commit comments

Comments
 (0)