Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7e0adbe

Browse files
committed
Add MPL_isfinite64() and MPL_isinf64() for testing doubles in (the now misnamed) MPL_isnan.h.
svn path=/trunk/matplotlib/; revision=3523
1 parent 742305d commit 7e0adbe

2 files changed

Lines changed: 32 additions & 7 deletions

File tree

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2007-07-13 Add MPL_isfinite64() and MPL_isinf64() for testing
2+
doubles in (the now misnamed) MPL_isnan.h. - ADS
3+
14
2007-07-13 The matplotlib._isnan module removed (use numpy.isnan) - ADS
25

36
2007-07-13 Some minor cleanups in _transforms.cpp - ADS

src/MPL_isnan.h

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1-
// These definitions modified from numarray's Include/numarray/nummacro.h
1+
/*
22
3-
// The "64" in this code refers to double precision floating point numbers.
3+
These definitions were inspired by and originally modified from
4+
numarray's Include/numarray/nummacro.h
5+
6+
The "64" below refers to double precision floating point numbers. This
7+
code only works on doubles.
8+
9+
*/
410

511
#if defined(SIZEOF_VOID_P)
612
#if SIZEOF_VOID_P == 8
@@ -22,20 +28,36 @@ typedef long long MPL_Int64;
2228
#endif
2329
#endif
2430

25-
#if !defined(MPL_isnan64)
31+
#if !defined(MPL_U64)
2632
#define MPL_U64(u) (* (MPL_Int64 *) &(u) )
33+
#endif /* MPL_U64 */
2734

35+
#if !defined(MPL_isnan64)
2836
#if !defined(_MSC_VER)
2937
#define MPL_isnan64(u) \
30-
( (( MPL_U64(u) & 0x7ff0000000000000LL) == 0x7ff0000000000000LL) && ((MPL_U64(u) & 0x000fffffffffffffLL) != 0)) ? 1:0
38+
( (( MPL_U64(u) & 0x7ff0000000000000LL) == 0x7ff0000000000000LL) && ((MPL_U64(u) & 0x000fffffffffffffLL) != 0)) ? 1:0
3139
#else
3240
#define MPL_isnan64(u) \
3341
( (( MPL_U64(u) & 0x7ff0000000000000i64) == 0x7ff0000000000000i64) && ((MPL_U64(u) & 0x000fffffffffffffi64) != 0)) ? 1:0
3442
#endif
35-
3643
#endif /* MPL_isnan64 */
3744

3845
#if !defined(MPL_isinf64)
39-
// This beauty from translated from numpy.
40-
#define MPL_isinf64(x) (!MPL_isnan64((x)) && MPL_isnan64((x)-(x)))
46+
#if !defined(_MSC_VER)
47+
#define MPL_isinf64(u) \
48+
( (( MPL_U64(u) & 0x7ff0000000000000LL) == 0x7ff0000000000000LL) && ((MPL_U64(u) & 0x000fffffffffffffLL) == 0)) ? 1:0
49+
#else
50+
#define MPL_isinf64(u) \
51+
( (( MPL_U64(u) & 0x7ff0000000000000i64) == 0x7ff0000000000000i64) && ((MPL_U64(u) & 0x000fffffffffffffi64) == 0)) ? 1:0
52+
#endif
53+
#endif /* MPL_isinf64 */
54+
55+
#if !defined(MPL_isfinite64)
56+
#if !defined(_MSC_VER)
57+
#define MPL_isfinite64(u) \
58+
( (( MPL_U64(u) & 0x7ff0000000000000LL) != 0x7ff0000000000000LL)) ? 1:0
59+
#else
60+
#define MPL_isfinite64(u) \
61+
( (( MPL_U64(u) & 0x7ff0000000000000i64) != 0x7ff0000000000000i64)) ? 1:0
4162
#endif
63+
#endif /* MPL_isfinite64 */

0 commit comments

Comments
 (0)