npy_common.h 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069
  1. #ifndef _NPY_COMMON_H_
  2. #define _NPY_COMMON_H_
  3. /* numpconfig.h is auto-generated */
  4. #include "numpyconfig.h"
  5. #ifdef HAVE_NPY_CONFIG_H
  6. #include <npy_config.h>
  7. #endif
  8. /* need Python.h for npy_intp, npy_uintp */
  9. #include <Python.h>
  10. /*
  11. * gcc does not unroll even with -O3
  12. * use with care, unrolling on modern cpus rarely speeds things up
  13. */
  14. #ifdef HAVE_ATTRIBUTE_OPTIMIZE_UNROLL_LOOPS
  15. #define NPY_GCC_UNROLL_LOOPS \
  16. __attribute__((optimize("unroll-loops")))
  17. #else
  18. #define NPY_GCC_UNROLL_LOOPS
  19. #endif
  20. /* highest gcc optimization level, enabled autovectorizer */
  21. #ifdef HAVE_ATTRIBUTE_OPTIMIZE_OPT_3
  22. #define NPY_GCC_OPT_3 __attribute__((optimize("O3")))
  23. #else
  24. #define NPY_GCC_OPT_3
  25. #endif
  26. /*
  27. * mark an argument (starting from 1) that must not be NULL and is not checked
  28. * DO NOT USE IF FUNCTION CHECKS FOR NULL!! the compiler will remove the check
  29. */
  30. #ifdef HAVE_ATTRIBUTE_NONNULL
  31. #define NPY_GCC_NONNULL(n) __attribute__((nonnull(n)))
  32. #else
  33. #define NPY_GCC_NONNULL(n)
  34. #endif
  35. #if defined HAVE_XMMINTRIN_H && defined HAVE__MM_LOAD_PS
  36. #define NPY_HAVE_SSE_INTRINSICS
  37. #endif
  38. #if defined HAVE_EMMINTRIN_H && defined HAVE__MM_LOAD_PD
  39. #define NPY_HAVE_SSE2_INTRINSICS
  40. #endif
  41. /*
  42. * give a hint to the compiler which branch is more likely or unlikely
  43. * to occur, e.g. rare error cases:
  44. *
  45. * if (NPY_UNLIKELY(failure == 0))
  46. * return NULL;
  47. *
  48. * the double !! is to cast the expression (e.g. NULL) to a boolean required by
  49. * the intrinsic
  50. */
  51. #ifdef HAVE___BUILTIN_EXPECT
  52. #define NPY_LIKELY(x) __builtin_expect(!!(x), 1)
  53. #define NPY_UNLIKELY(x) __builtin_expect(!!(x), 0)
  54. #else
  55. #define NPY_LIKELY(x) (x)
  56. #define NPY_UNLIKELY(x) (x)
  57. #endif
  58. #ifdef HAVE___BUILTIN_PREFETCH
  59. /* unlike _mm_prefetch also works on non-x86 */
  60. #define NPY_PREFETCH(x, rw, loc) __builtin_prefetch((x), (rw), (loc))
  61. #else
  62. #ifdef HAVE__MM_PREFETCH
  63. /* _MM_HINT_ET[01] (rw = 1) unsupported, only available in gcc >= 4.9 */
  64. #define NPY_PREFETCH(x, rw, loc) _mm_prefetch((x), loc == 0 ? _MM_HINT_NTA : \
  65. (loc == 1 ? _MM_HINT_T2 : \
  66. (loc == 2 ? _MM_HINT_T1 : \
  67. (loc == 3 ? _MM_HINT_T0 : -1))))
  68. #else
  69. #define NPY_PREFETCH(x, rw,loc)
  70. #endif
  71. #endif
  72. #if defined(_MSC_VER)
  73. #define NPY_INLINE __inline
  74. #elif defined(__GNUC__)
  75. #if defined(__STRICT_ANSI__)
  76. #define NPY_INLINE __inline__
  77. #else
  78. #define NPY_INLINE inline
  79. #endif
  80. #else
  81. #define NPY_INLINE
  82. #endif
  83. #ifdef HAVE___THREAD
  84. #define NPY_TLS __thread
  85. #else
  86. #ifdef HAVE___DECLSPEC_THREAD_
  87. #define NPY_TLS __declspec(thread)
  88. #else
  89. #define NPY_TLS
  90. #endif
  91. #endif
  92. #ifdef WITH_CPYCHECKER_RETURNS_BORROWED_REF_ATTRIBUTE
  93. #define NPY_RETURNS_BORROWED_REF \
  94. __attribute__((cpychecker_returns_borrowed_ref))
  95. #else
  96. #define NPY_RETURNS_BORROWED_REF
  97. #endif
  98. #ifdef WITH_CPYCHECKER_STEALS_REFERENCE_TO_ARG_ATTRIBUTE
  99. #define NPY_STEALS_REF_TO_ARG(n) \
  100. __attribute__((cpychecker_steals_reference_to_arg(n)))
  101. #else
  102. #define NPY_STEALS_REF_TO_ARG(n)
  103. #endif
  104. /* 64 bit file position support, also on win-amd64. Ticket #1660 */
  105. #if defined(_MSC_VER) && defined(_WIN64) && (_MSC_VER > 1400) || \
  106. defined(__MINGW32__) || defined(__MINGW64__)
  107. #include <io.h>
  108. /* mingw based on 3.4.5 has lseek but not ftell/fseek */
  109. #if defined(__MINGW32__) || defined(__MINGW64__)
  110. extern int __cdecl _fseeki64(FILE *, long long, int);
  111. extern long long __cdecl _ftelli64(FILE *);
  112. #endif
  113. #define npy_fseek _fseeki64
  114. #define npy_ftell _ftelli64
  115. #define npy_lseek _lseeki64
  116. #define npy_off_t npy_int64
  117. #if NPY_SIZEOF_INT == 8
  118. #define NPY_OFF_T_PYFMT "i"
  119. #elif NPY_SIZEOF_LONG == 8
  120. #define NPY_OFF_T_PYFMT "l"
  121. #elif NPY_SIZEOF_LONGLONG == 8
  122. #define NPY_OFF_T_PYFMT "L"
  123. #else
  124. #error Unsupported size for type off_t
  125. #endif
  126. #else
  127. #ifdef HAVE_FSEEKO
  128. #define npy_fseek fseeko
  129. #else
  130. #define npy_fseek fseek
  131. #endif
  132. #ifdef HAVE_FTELLO
  133. #define npy_ftell ftello
  134. #else
  135. #define npy_ftell ftell
  136. #endif
  137. #include <sys/types.h>
  138. #define npy_lseek lseek
  139. #define npy_off_t off_t
  140. #if NPY_SIZEOF_OFF_T == NPY_SIZEOF_SHORT
  141. #define NPY_OFF_T_PYFMT "h"
  142. #elif NPY_SIZEOF_OFF_T == NPY_SIZEOF_INT
  143. #define NPY_OFF_T_PYFMT "i"
  144. #elif NPY_SIZEOF_OFF_T == NPY_SIZEOF_LONG
  145. #define NPY_OFF_T_PYFMT "l"
  146. #elif NPY_SIZEOF_OFF_T == NPY_SIZEOF_LONGLONG
  147. #define NPY_OFF_T_PYFMT "L"
  148. #else
  149. #error Unsupported size for type off_t
  150. #endif
  151. #endif
  152. /* enums for detected endianness */
  153. enum {
  154. NPY_CPU_UNKNOWN_ENDIAN,
  155. NPY_CPU_LITTLE,
  156. NPY_CPU_BIG
  157. };
  158. /*
  159. * This is to typedef npy_intp to the appropriate pointer size for this
  160. * platform. Py_intptr_t, Py_uintptr_t are defined in pyport.h.
  161. */
  162. typedef Py_intptr_t npy_intp;
  163. typedef Py_uintptr_t npy_uintp;
  164. /*
  165. * Define sizes that were not defined in numpyconfig.h.
  166. */
  167. #define NPY_SIZEOF_CHAR 1
  168. #define NPY_SIZEOF_BYTE 1
  169. #define NPY_SIZEOF_DATETIME 8
  170. #define NPY_SIZEOF_TIMEDELTA 8
  171. #define NPY_SIZEOF_INTP NPY_SIZEOF_PY_INTPTR_T
  172. #define NPY_SIZEOF_UINTP NPY_SIZEOF_PY_INTPTR_T
  173. #define NPY_SIZEOF_HALF 2
  174. #define NPY_SIZEOF_CFLOAT NPY_SIZEOF_COMPLEX_FLOAT
  175. #define NPY_SIZEOF_CDOUBLE NPY_SIZEOF_COMPLEX_DOUBLE
  176. #define NPY_SIZEOF_CLONGDOUBLE NPY_SIZEOF_COMPLEX_LONGDOUBLE
  177. #ifdef constchar
  178. #undef constchar
  179. #endif
  180. #define NPY_SSIZE_T_PYFMT "n"
  181. #define constchar char
  182. /* NPY_INTP_FMT Note:
  183. * Unlike the other NPY_*_FMT macros which are used with
  184. * PyOS_snprintf, NPY_INTP_FMT is used with PyErr_Format and
  185. * PyString_Format. These functions use different formatting
  186. * codes which are portably specified according to the Python
  187. * documentation. See ticket #1795.
  188. *
  189. * On Windows x64, the LONGLONG formatter should be used, but
  190. * in Python 2.6 the %lld formatter is not supported. In this
  191. * case we work around the problem by using the %zd formatter.
  192. */
  193. #if NPY_SIZEOF_PY_INTPTR_T == NPY_SIZEOF_INT
  194. #define NPY_INTP NPY_INT
  195. #define NPY_UINTP NPY_UINT
  196. #define PyIntpArrType_Type PyIntArrType_Type
  197. #define PyUIntpArrType_Type PyUIntArrType_Type
  198. #define NPY_MAX_INTP NPY_MAX_INT
  199. #define NPY_MIN_INTP NPY_MIN_INT
  200. #define NPY_MAX_UINTP NPY_MAX_UINT
  201. #define NPY_INTP_FMT "d"
  202. #elif NPY_SIZEOF_PY_INTPTR_T == NPY_SIZEOF_LONG
  203. #define NPY_INTP NPY_LONG
  204. #define NPY_UINTP NPY_ULONG
  205. #define PyIntpArrType_Type PyLongArrType_Type
  206. #define PyUIntpArrType_Type PyULongArrType_Type
  207. #define NPY_MAX_INTP NPY_MAX_LONG
  208. #define NPY_MIN_INTP NPY_MIN_LONG
  209. #define NPY_MAX_UINTP NPY_MAX_ULONG
  210. #define NPY_INTP_FMT "ld"
  211. #elif defined(PY_LONG_LONG) && (NPY_SIZEOF_PY_INTPTR_T == NPY_SIZEOF_LONGLONG)
  212. #define NPY_INTP NPY_LONGLONG
  213. #define NPY_UINTP NPY_ULONGLONG
  214. #define PyIntpArrType_Type PyLongLongArrType_Type
  215. #define PyUIntpArrType_Type PyULongLongArrType_Type
  216. #define NPY_MAX_INTP NPY_MAX_LONGLONG
  217. #define NPY_MIN_INTP NPY_MIN_LONGLONG
  218. #define NPY_MAX_UINTP NPY_MAX_ULONGLONG
  219. #if (PY_VERSION_HEX >= 0x02070000)
  220. #define NPY_INTP_FMT "lld"
  221. #else
  222. #define NPY_INTP_FMT "zd"
  223. #endif
  224. #endif
  225. /*
  226. * We can only use C99 formats for npy_int_p if it is the same as
  227. * intp_t, hence the condition on HAVE_UNITPTR_T
  228. */
  229. #if (NPY_USE_C99_FORMATS) == 1 \
  230. && (defined HAVE_UINTPTR_T) \
  231. && (defined HAVE_INTTYPES_H)
  232. #include <inttypes.h>
  233. #undef NPY_INTP_FMT
  234. #define NPY_INTP_FMT PRIdPTR
  235. #endif
  236. /*
  237. * Some platforms don't define bool, long long, or long double.
  238. * Handle that here.
  239. */
  240. #define NPY_BYTE_FMT "hhd"
  241. #define NPY_UBYTE_FMT "hhu"
  242. #define NPY_SHORT_FMT "hd"
  243. #define NPY_USHORT_FMT "hu"
  244. #define NPY_INT_FMT "d"
  245. #define NPY_UINT_FMT "u"
  246. #define NPY_LONG_FMT "ld"
  247. #define NPY_ULONG_FMT "lu"
  248. #define NPY_HALF_FMT "g"
  249. #define NPY_FLOAT_FMT "g"
  250. #define NPY_DOUBLE_FMT "g"
  251. #ifdef PY_LONG_LONG
  252. typedef PY_LONG_LONG npy_longlong;
  253. typedef unsigned PY_LONG_LONG npy_ulonglong;
  254. # ifdef _MSC_VER
  255. # define NPY_LONGLONG_FMT "I64d"
  256. # define NPY_ULONGLONG_FMT "I64u"
  257. # else
  258. # define NPY_LONGLONG_FMT "lld"
  259. # define NPY_ULONGLONG_FMT "llu"
  260. # endif
  261. # ifdef _MSC_VER
  262. # define NPY_LONGLONG_SUFFIX(x) (x##i64)
  263. # define NPY_ULONGLONG_SUFFIX(x) (x##Ui64)
  264. # else
  265. # define NPY_LONGLONG_SUFFIX(x) (x##LL)
  266. # define NPY_ULONGLONG_SUFFIX(x) (x##ULL)
  267. # endif
  268. #else
  269. typedef long npy_longlong;
  270. typedef unsigned long npy_ulonglong;
  271. # define NPY_LONGLONG_SUFFIX(x) (x##L)
  272. # define NPY_ULONGLONG_SUFFIX(x) (x##UL)
  273. #endif
  274. typedef unsigned char npy_bool;
  275. #define NPY_FALSE 0
  276. #define NPY_TRUE 1
  277. #if NPY_SIZEOF_LONGDOUBLE == NPY_SIZEOF_DOUBLE
  278. typedef double npy_longdouble;
  279. #define NPY_LONGDOUBLE_FMT "g"
  280. #else
  281. typedef long double npy_longdouble;
  282. #define NPY_LONGDOUBLE_FMT "Lg"
  283. #endif
  284. #ifndef Py_USING_UNICODE
  285. #error Must use Python with unicode enabled.
  286. #endif
  287. typedef signed char npy_byte;
  288. typedef unsigned char npy_ubyte;
  289. typedef unsigned short npy_ushort;
  290. typedef unsigned int npy_uint;
  291. typedef unsigned long npy_ulong;
  292. /* These are for completeness */
  293. typedef char npy_char;
  294. typedef short npy_short;
  295. typedef int npy_int;
  296. typedef long npy_long;
  297. typedef float npy_float;
  298. typedef double npy_double;
  299. /*
  300. * Hash value compatibility.
  301. * As of Python 3.2 hash values are of type Py_hash_t.
  302. * Previous versions use C long.
  303. */
  304. #if PY_VERSION_HEX < 0x03020000
  305. typedef long npy_hash_t;
  306. #define NPY_SIZEOF_HASH_T NPY_SIZEOF_LONG
  307. #else
  308. typedef Py_hash_t npy_hash_t;
  309. #define NPY_SIZEOF_HASH_T NPY_SIZEOF_INTP
  310. #endif
  311. /*
  312. * Disabling C99 complex usage: a lot of C code in numpy/scipy rely on being
  313. * able to do .real/.imag. Will have to convert code first.
  314. */
  315. #if 0
  316. #if defined(NPY_USE_C99_COMPLEX) && defined(NPY_HAVE_COMPLEX_DOUBLE)
  317. typedef complex npy_cdouble;
  318. #else
  319. typedef struct { double real, imag; } npy_cdouble;
  320. #endif
  321. #if defined(NPY_USE_C99_COMPLEX) && defined(NPY_HAVE_COMPLEX_FLOAT)
  322. typedef complex float npy_cfloat;
  323. #else
  324. typedef struct { float real, imag; } npy_cfloat;
  325. #endif
  326. #if defined(NPY_USE_C99_COMPLEX) && defined(NPY_HAVE_COMPLEX_LONG_DOUBLE)
  327. typedef complex long double npy_clongdouble;
  328. #else
  329. typedef struct {npy_longdouble real, imag;} npy_clongdouble;
  330. #endif
  331. #endif
  332. #if NPY_SIZEOF_COMPLEX_DOUBLE != 2 * NPY_SIZEOF_DOUBLE
  333. #error npy_cdouble definition is not compatible with C99 complex definition ! \
  334. Please contact Numpy maintainers and give detailed information about your \
  335. compiler and platform
  336. #endif
  337. typedef struct { double real, imag; } npy_cdouble;
  338. #if NPY_SIZEOF_COMPLEX_FLOAT != 2 * NPY_SIZEOF_FLOAT
  339. #error npy_cfloat definition is not compatible with C99 complex definition ! \
  340. Please contact Numpy maintainers and give detailed information about your \
  341. compiler and platform
  342. #endif
  343. typedef struct { float real, imag; } npy_cfloat;
  344. #if NPY_SIZEOF_COMPLEX_LONGDOUBLE != 2 * NPY_SIZEOF_LONGDOUBLE
  345. #error npy_clongdouble definition is not compatible with C99 complex definition ! \
  346. Please contact Numpy maintainers and give detailed information about your \
  347. compiler and platform
  348. #endif
  349. typedef struct { npy_longdouble real, imag; } npy_clongdouble;
  350. /*
  351. * numarray-style bit-width typedefs
  352. */
  353. #define NPY_MAX_INT8 127
  354. #define NPY_MIN_INT8 -128
  355. #define NPY_MAX_UINT8 255
  356. #define NPY_MAX_INT16 32767
  357. #define NPY_MIN_INT16 -32768
  358. #define NPY_MAX_UINT16 65535
  359. #define NPY_MAX_INT32 2147483647
  360. #define NPY_MIN_INT32 (-NPY_MAX_INT32 - 1)
  361. #define NPY_MAX_UINT32 4294967295U
  362. #define NPY_MAX_INT64 NPY_LONGLONG_SUFFIX(9223372036854775807)
  363. #define NPY_MIN_INT64 (-NPY_MAX_INT64 - NPY_LONGLONG_SUFFIX(1))
  364. #define NPY_MAX_UINT64 NPY_ULONGLONG_SUFFIX(18446744073709551615)
  365. #define NPY_MAX_INT128 NPY_LONGLONG_SUFFIX(85070591730234615865843651857942052864)
  366. #define NPY_MIN_INT128 (-NPY_MAX_INT128 - NPY_LONGLONG_SUFFIX(1))
  367. #define NPY_MAX_UINT128 NPY_ULONGLONG_SUFFIX(170141183460469231731687303715884105728)
  368. #define NPY_MAX_INT256 NPY_LONGLONG_SUFFIX(57896044618658097711785492504343953926634992332820282019728792003956564819967)
  369. #define NPY_MIN_INT256 (-NPY_MAX_INT256 - NPY_LONGLONG_SUFFIX(1))
  370. #define NPY_MAX_UINT256 NPY_ULONGLONG_SUFFIX(115792089237316195423570985008687907853269984665640564039457584007913129639935)
  371. #define NPY_MIN_DATETIME NPY_MIN_INT64
  372. #define NPY_MAX_DATETIME NPY_MAX_INT64
  373. #define NPY_MIN_TIMEDELTA NPY_MIN_INT64
  374. #define NPY_MAX_TIMEDELTA NPY_MAX_INT64
  375. /* Need to find the number of bits for each type and
  376. make definitions accordingly.
  377. C states that sizeof(char) == 1 by definition
  378. So, just using the sizeof keyword won't help.
  379. It also looks like Python itself uses sizeof(char) quite a
  380. bit, which by definition should be 1 all the time.
  381. Idea: Make Use of CHAR_BIT which should tell us how many
  382. BITS per CHARACTER
  383. */
  384. /* Include platform definitions -- These are in the C89/90 standard */
  385. #include <limits.h>
  386. #define NPY_MAX_BYTE SCHAR_MAX
  387. #define NPY_MIN_BYTE SCHAR_MIN
  388. #define NPY_MAX_UBYTE UCHAR_MAX
  389. #define NPY_MAX_SHORT SHRT_MAX
  390. #define NPY_MIN_SHORT SHRT_MIN
  391. #define NPY_MAX_USHORT USHRT_MAX
  392. #define NPY_MAX_INT INT_MAX
  393. #ifndef INT_MIN
  394. #define INT_MIN (-INT_MAX - 1)
  395. #endif
  396. #define NPY_MIN_INT INT_MIN
  397. #define NPY_MAX_UINT UINT_MAX
  398. #define NPY_MAX_LONG LONG_MAX
  399. #define NPY_MIN_LONG LONG_MIN
  400. #define NPY_MAX_ULONG ULONG_MAX
  401. #define NPY_BITSOF_BOOL (sizeof(npy_bool) * CHAR_BIT)
  402. #define NPY_BITSOF_CHAR CHAR_BIT
  403. #define NPY_BITSOF_BYTE (NPY_SIZEOF_BYTE * CHAR_BIT)
  404. #define NPY_BITSOF_SHORT (NPY_SIZEOF_SHORT * CHAR_BIT)
  405. #define NPY_BITSOF_INT (NPY_SIZEOF_INT * CHAR_BIT)
  406. #define NPY_BITSOF_LONG (NPY_SIZEOF_LONG * CHAR_BIT)
  407. #define NPY_BITSOF_LONGLONG (NPY_SIZEOF_LONGLONG * CHAR_BIT)
  408. #define NPY_BITSOF_INTP (NPY_SIZEOF_INTP * CHAR_BIT)
  409. #define NPY_BITSOF_HALF (NPY_SIZEOF_HALF * CHAR_BIT)
  410. #define NPY_BITSOF_FLOAT (NPY_SIZEOF_FLOAT * CHAR_BIT)
  411. #define NPY_BITSOF_DOUBLE (NPY_SIZEOF_DOUBLE * CHAR_BIT)
  412. #define NPY_BITSOF_LONGDOUBLE (NPY_SIZEOF_LONGDOUBLE * CHAR_BIT)
  413. #define NPY_BITSOF_CFLOAT (NPY_SIZEOF_CFLOAT * CHAR_BIT)
  414. #define NPY_BITSOF_CDOUBLE (NPY_SIZEOF_CDOUBLE * CHAR_BIT)
  415. #define NPY_BITSOF_CLONGDOUBLE (NPY_SIZEOF_CLONGDOUBLE * CHAR_BIT)
  416. #define NPY_BITSOF_DATETIME (NPY_SIZEOF_DATETIME * CHAR_BIT)
  417. #define NPY_BITSOF_TIMEDELTA (NPY_SIZEOF_TIMEDELTA * CHAR_BIT)
  418. #if NPY_BITSOF_LONG == 8
  419. #define NPY_INT8 NPY_LONG
  420. #define NPY_UINT8 NPY_ULONG
  421. typedef long npy_int8;
  422. typedef unsigned long npy_uint8;
  423. #define PyInt8ScalarObject PyLongScalarObject
  424. #define PyInt8ArrType_Type PyLongArrType_Type
  425. #define PyUInt8ScalarObject PyULongScalarObject
  426. #define PyUInt8ArrType_Type PyULongArrType_Type
  427. #define NPY_INT8_FMT NPY_LONG_FMT
  428. #define NPY_UINT8_FMT NPY_ULONG_FMT
  429. #elif NPY_BITSOF_LONG == 16
  430. #define NPY_INT16 NPY_LONG
  431. #define NPY_UINT16 NPY_ULONG
  432. typedef long npy_int16;
  433. typedef unsigned long npy_uint16;
  434. #define PyInt16ScalarObject PyLongScalarObject
  435. #define PyInt16ArrType_Type PyLongArrType_Type
  436. #define PyUInt16ScalarObject PyULongScalarObject
  437. #define PyUInt16ArrType_Type PyULongArrType_Type
  438. #define NPY_INT16_FMT NPY_LONG_FMT
  439. #define NPY_UINT16_FMT NPY_ULONG_FMT
  440. #elif NPY_BITSOF_LONG == 32
  441. #define NPY_INT32 NPY_LONG
  442. #define NPY_UINT32 NPY_ULONG
  443. typedef long npy_int32;
  444. typedef unsigned long npy_uint32;
  445. typedef unsigned long npy_ucs4;
  446. #define PyInt32ScalarObject PyLongScalarObject
  447. #define PyInt32ArrType_Type PyLongArrType_Type
  448. #define PyUInt32ScalarObject PyULongScalarObject
  449. #define PyUInt32ArrType_Type PyULongArrType_Type
  450. #define NPY_INT32_FMT NPY_LONG_FMT
  451. #define NPY_UINT32_FMT NPY_ULONG_FMT
  452. #elif NPY_BITSOF_LONG == 64
  453. #define NPY_INT64 NPY_LONG
  454. #define NPY_UINT64 NPY_ULONG
  455. typedef long npy_int64;
  456. typedef unsigned long npy_uint64;
  457. #define PyInt64ScalarObject PyLongScalarObject
  458. #define PyInt64ArrType_Type PyLongArrType_Type
  459. #define PyUInt64ScalarObject PyULongScalarObject
  460. #define PyUInt64ArrType_Type PyULongArrType_Type
  461. #define NPY_INT64_FMT NPY_LONG_FMT
  462. #define NPY_UINT64_FMT NPY_ULONG_FMT
  463. #define MyPyLong_FromInt64 PyLong_FromLong
  464. #define MyPyLong_AsInt64 PyLong_AsLong
  465. #elif NPY_BITSOF_LONG == 128
  466. #define NPY_INT128 NPY_LONG
  467. #define NPY_UINT128 NPY_ULONG
  468. typedef long npy_int128;
  469. typedef unsigned long npy_uint128;
  470. #define PyInt128ScalarObject PyLongScalarObject
  471. #define PyInt128ArrType_Type PyLongArrType_Type
  472. #define PyUInt128ScalarObject PyULongScalarObject
  473. #define PyUInt128ArrType_Type PyULongArrType_Type
  474. #define NPY_INT128_FMT NPY_LONG_FMT
  475. #define NPY_UINT128_FMT NPY_ULONG_FMT
  476. #endif
  477. #if NPY_BITSOF_LONGLONG == 8
  478. # ifndef NPY_INT8
  479. # define NPY_INT8 NPY_LONGLONG
  480. # define NPY_UINT8 NPY_ULONGLONG
  481. typedef npy_longlong npy_int8;
  482. typedef npy_ulonglong npy_uint8;
  483. # define PyInt8ScalarObject PyLongLongScalarObject
  484. # define PyInt8ArrType_Type PyLongLongArrType_Type
  485. # define PyUInt8ScalarObject PyULongLongScalarObject
  486. # define PyUInt8ArrType_Type PyULongLongArrType_Type
  487. #define NPY_INT8_FMT NPY_LONGLONG_FMT
  488. #define NPY_UINT8_FMT NPY_ULONGLONG_FMT
  489. # endif
  490. # define NPY_MAX_LONGLONG NPY_MAX_INT8
  491. # define NPY_MIN_LONGLONG NPY_MIN_INT8
  492. # define NPY_MAX_ULONGLONG NPY_MAX_UINT8
  493. #elif NPY_BITSOF_LONGLONG == 16
  494. # ifndef NPY_INT16
  495. # define NPY_INT16 NPY_LONGLONG
  496. # define NPY_UINT16 NPY_ULONGLONG
  497. typedef npy_longlong npy_int16;
  498. typedef npy_ulonglong npy_uint16;
  499. # define PyInt16ScalarObject PyLongLongScalarObject
  500. # define PyInt16ArrType_Type PyLongLongArrType_Type
  501. # define PyUInt16ScalarObject PyULongLongScalarObject
  502. # define PyUInt16ArrType_Type PyULongLongArrType_Type
  503. #define NPY_INT16_FMT NPY_LONGLONG_FMT
  504. #define NPY_UINT16_FMT NPY_ULONGLONG_FMT
  505. # endif
  506. # define NPY_MAX_LONGLONG NPY_MAX_INT16
  507. # define NPY_MIN_LONGLONG NPY_MIN_INT16
  508. # define NPY_MAX_ULONGLONG NPY_MAX_UINT16
  509. #elif NPY_BITSOF_LONGLONG == 32
  510. # ifndef NPY_INT32
  511. # define NPY_INT32 NPY_LONGLONG
  512. # define NPY_UINT32 NPY_ULONGLONG
  513. typedef npy_longlong npy_int32;
  514. typedef npy_ulonglong npy_uint32;
  515. typedef npy_ulonglong npy_ucs4;
  516. # define PyInt32ScalarObject PyLongLongScalarObject
  517. # define PyInt32ArrType_Type PyLongLongArrType_Type
  518. # define PyUInt32ScalarObject PyULongLongScalarObject
  519. # define PyUInt32ArrType_Type PyULongLongArrType_Type
  520. #define NPY_INT32_FMT NPY_LONGLONG_FMT
  521. #define NPY_UINT32_FMT NPY_ULONGLONG_FMT
  522. # endif
  523. # define NPY_MAX_LONGLONG NPY_MAX_INT32
  524. # define NPY_MIN_LONGLONG NPY_MIN_INT32
  525. # define NPY_MAX_ULONGLONG NPY_MAX_UINT32
  526. #elif NPY_BITSOF_LONGLONG == 64
  527. # ifndef NPY_INT64
  528. # define NPY_INT64 NPY_LONGLONG
  529. # define NPY_UINT64 NPY_ULONGLONG
  530. typedef npy_longlong npy_int64;
  531. typedef npy_ulonglong npy_uint64;
  532. # define PyInt64ScalarObject PyLongLongScalarObject
  533. # define PyInt64ArrType_Type PyLongLongArrType_Type
  534. # define PyUInt64ScalarObject PyULongLongScalarObject
  535. # define PyUInt64ArrType_Type PyULongLongArrType_Type
  536. #define NPY_INT64_FMT NPY_LONGLONG_FMT
  537. #define NPY_UINT64_FMT NPY_ULONGLONG_FMT
  538. # define MyPyLong_FromInt64 PyLong_FromLongLong
  539. # define MyPyLong_AsInt64 PyLong_AsLongLong
  540. # endif
  541. # define NPY_MAX_LONGLONG NPY_MAX_INT64
  542. # define NPY_MIN_LONGLONG NPY_MIN_INT64
  543. # define NPY_MAX_ULONGLONG NPY_MAX_UINT64
  544. #elif NPY_BITSOF_LONGLONG == 128
  545. # ifndef NPY_INT128
  546. # define NPY_INT128 NPY_LONGLONG
  547. # define NPY_UINT128 NPY_ULONGLONG
  548. typedef npy_longlong npy_int128;
  549. typedef npy_ulonglong npy_uint128;
  550. # define PyInt128ScalarObject PyLongLongScalarObject
  551. # define PyInt128ArrType_Type PyLongLongArrType_Type
  552. # define PyUInt128ScalarObject PyULongLongScalarObject
  553. # define PyUInt128ArrType_Type PyULongLongArrType_Type
  554. #define NPY_INT128_FMT NPY_LONGLONG_FMT
  555. #define NPY_UINT128_FMT NPY_ULONGLONG_FMT
  556. # endif
  557. # define NPY_MAX_LONGLONG NPY_MAX_INT128
  558. # define NPY_MIN_LONGLONG NPY_MIN_INT128
  559. # define NPY_MAX_ULONGLONG NPY_MAX_UINT128
  560. #elif NPY_BITSOF_LONGLONG == 256
  561. # define NPY_INT256 NPY_LONGLONG
  562. # define NPY_UINT256 NPY_ULONGLONG
  563. typedef npy_longlong npy_int256;
  564. typedef npy_ulonglong npy_uint256;
  565. # define PyInt256ScalarObject PyLongLongScalarObject
  566. # define PyInt256ArrType_Type PyLongLongArrType_Type
  567. # define PyUInt256ScalarObject PyULongLongScalarObject
  568. # define PyUInt256ArrType_Type PyULongLongArrType_Type
  569. #define NPY_INT256_FMT NPY_LONGLONG_FMT
  570. #define NPY_UINT256_FMT NPY_ULONGLONG_FMT
  571. # define NPY_MAX_LONGLONG NPY_MAX_INT256
  572. # define NPY_MIN_LONGLONG NPY_MIN_INT256
  573. # define NPY_MAX_ULONGLONG NPY_MAX_UINT256
  574. #endif
  575. #if NPY_BITSOF_INT == 8
  576. #ifndef NPY_INT8
  577. #define NPY_INT8 NPY_INT
  578. #define NPY_UINT8 NPY_UINT
  579. typedef int npy_int8;
  580. typedef unsigned int npy_uint8;
  581. # define PyInt8ScalarObject PyIntScalarObject
  582. # define PyInt8ArrType_Type PyIntArrType_Type
  583. # define PyUInt8ScalarObject PyUIntScalarObject
  584. # define PyUInt8ArrType_Type PyUIntArrType_Type
  585. #define NPY_INT8_FMT NPY_INT_FMT
  586. #define NPY_UINT8_FMT NPY_UINT_FMT
  587. #endif
  588. #elif NPY_BITSOF_INT == 16
  589. #ifndef NPY_INT16
  590. #define NPY_INT16 NPY_INT
  591. #define NPY_UINT16 NPY_UINT
  592. typedef int npy_int16;
  593. typedef unsigned int npy_uint16;
  594. # define PyInt16ScalarObject PyIntScalarObject
  595. # define PyInt16ArrType_Type PyIntArrType_Type
  596. # define PyUInt16ScalarObject PyIntUScalarObject
  597. # define PyUInt16ArrType_Type PyIntUArrType_Type
  598. #define NPY_INT16_FMT NPY_INT_FMT
  599. #define NPY_UINT16_FMT NPY_UINT_FMT
  600. #endif
  601. #elif NPY_BITSOF_INT == 32
  602. #ifndef NPY_INT32
  603. #define NPY_INT32 NPY_INT
  604. #define NPY_UINT32 NPY_UINT
  605. typedef int npy_int32;
  606. typedef unsigned int npy_uint32;
  607. typedef unsigned int npy_ucs4;
  608. # define PyInt32ScalarObject PyIntScalarObject
  609. # define PyInt32ArrType_Type PyIntArrType_Type
  610. # define PyUInt32ScalarObject PyUIntScalarObject
  611. # define PyUInt32ArrType_Type PyUIntArrType_Type
  612. #define NPY_INT32_FMT NPY_INT_FMT
  613. #define NPY_UINT32_FMT NPY_UINT_FMT
  614. #endif
  615. #elif NPY_BITSOF_INT == 64
  616. #ifndef NPY_INT64
  617. #define NPY_INT64 NPY_INT
  618. #define NPY_UINT64 NPY_UINT
  619. typedef int npy_int64;
  620. typedef unsigned int npy_uint64;
  621. # define PyInt64ScalarObject PyIntScalarObject
  622. # define PyInt64ArrType_Type PyIntArrType_Type
  623. # define PyUInt64ScalarObject PyUIntScalarObject
  624. # define PyUInt64ArrType_Type PyUIntArrType_Type
  625. #define NPY_INT64_FMT NPY_INT_FMT
  626. #define NPY_UINT64_FMT NPY_UINT_FMT
  627. # define MyPyLong_FromInt64 PyLong_FromLong
  628. # define MyPyLong_AsInt64 PyLong_AsLong
  629. #endif
  630. #elif NPY_BITSOF_INT == 128
  631. #ifndef NPY_INT128
  632. #define NPY_INT128 NPY_INT
  633. #define NPY_UINT128 NPY_UINT
  634. typedef int npy_int128;
  635. typedef unsigned int npy_uint128;
  636. # define PyInt128ScalarObject PyIntScalarObject
  637. # define PyInt128ArrType_Type PyIntArrType_Type
  638. # define PyUInt128ScalarObject PyUIntScalarObject
  639. # define PyUInt128ArrType_Type PyUIntArrType_Type
  640. #define NPY_INT128_FMT NPY_INT_FMT
  641. #define NPY_UINT128_FMT NPY_UINT_FMT
  642. #endif
  643. #endif
  644. #if NPY_BITSOF_SHORT == 8
  645. #ifndef NPY_INT8
  646. #define NPY_INT8 NPY_SHORT
  647. #define NPY_UINT8 NPY_USHORT
  648. typedef short npy_int8;
  649. typedef unsigned short npy_uint8;
  650. # define PyInt8ScalarObject PyShortScalarObject
  651. # define PyInt8ArrType_Type PyShortArrType_Type
  652. # define PyUInt8ScalarObject PyUShortScalarObject
  653. # define PyUInt8ArrType_Type PyUShortArrType_Type
  654. #define NPY_INT8_FMT NPY_SHORT_FMT
  655. #define NPY_UINT8_FMT NPY_USHORT_FMT
  656. #endif
  657. #elif NPY_BITSOF_SHORT == 16
  658. #ifndef NPY_INT16
  659. #define NPY_INT16 NPY_SHORT
  660. #define NPY_UINT16 NPY_USHORT
  661. typedef short npy_int16;
  662. typedef unsigned short npy_uint16;
  663. # define PyInt16ScalarObject PyShortScalarObject
  664. # define PyInt16ArrType_Type PyShortArrType_Type
  665. # define PyUInt16ScalarObject PyUShortScalarObject
  666. # define PyUInt16ArrType_Type PyUShortArrType_Type
  667. #define NPY_INT16_FMT NPY_SHORT_FMT
  668. #define NPY_UINT16_FMT NPY_USHORT_FMT
  669. #endif
  670. #elif NPY_BITSOF_SHORT == 32
  671. #ifndef NPY_INT32
  672. #define NPY_INT32 NPY_SHORT
  673. #define NPY_UINT32 NPY_USHORT
  674. typedef short npy_int32;
  675. typedef unsigned short npy_uint32;
  676. typedef unsigned short npy_ucs4;
  677. # define PyInt32ScalarObject PyShortScalarObject
  678. # define PyInt32ArrType_Type PyShortArrType_Type
  679. # define PyUInt32ScalarObject PyUShortScalarObject
  680. # define PyUInt32ArrType_Type PyUShortArrType_Type
  681. #define NPY_INT32_FMT NPY_SHORT_FMT
  682. #define NPY_UINT32_FMT NPY_USHORT_FMT
  683. #endif
  684. #elif NPY_BITSOF_SHORT == 64
  685. #ifndef NPY_INT64
  686. #define NPY_INT64 NPY_SHORT
  687. #define NPY_UINT64 NPY_USHORT
  688. typedef short npy_int64;
  689. typedef unsigned short npy_uint64;
  690. # define PyInt64ScalarObject PyShortScalarObject
  691. # define PyInt64ArrType_Type PyShortArrType_Type
  692. # define PyUInt64ScalarObject PyUShortScalarObject
  693. # define PyUInt64ArrType_Type PyUShortArrType_Type
  694. #define NPY_INT64_FMT NPY_SHORT_FMT
  695. #define NPY_UINT64_FMT NPY_USHORT_FMT
  696. # define MyPyLong_FromInt64 PyLong_FromLong
  697. # define MyPyLong_AsInt64 PyLong_AsLong
  698. #endif
  699. #elif NPY_BITSOF_SHORT == 128
  700. #ifndef NPY_INT128
  701. #define NPY_INT128 NPY_SHORT
  702. #define NPY_UINT128 NPY_USHORT
  703. typedef short npy_int128;
  704. typedef unsigned short npy_uint128;
  705. # define PyInt128ScalarObject PyShortScalarObject
  706. # define PyInt128ArrType_Type PyShortArrType_Type
  707. # define PyUInt128ScalarObject PyUShortScalarObject
  708. # define PyUInt128ArrType_Type PyUShortArrType_Type
  709. #define NPY_INT128_FMT NPY_SHORT_FMT
  710. #define NPY_UINT128_FMT NPY_USHORT_FMT
  711. #endif
  712. #endif
  713. #if NPY_BITSOF_CHAR == 8
  714. #ifndef NPY_INT8
  715. #define NPY_INT8 NPY_BYTE
  716. #define NPY_UINT8 NPY_UBYTE
  717. typedef signed char npy_int8;
  718. typedef unsigned char npy_uint8;
  719. # define PyInt8ScalarObject PyByteScalarObject
  720. # define PyInt8ArrType_Type PyByteArrType_Type
  721. # define PyUInt8ScalarObject PyUByteScalarObject
  722. # define PyUInt8ArrType_Type PyUByteArrType_Type
  723. #define NPY_INT8_FMT NPY_BYTE_FMT
  724. #define NPY_UINT8_FMT NPY_UBYTE_FMT
  725. #endif
  726. #elif NPY_BITSOF_CHAR == 16
  727. #ifndef NPY_INT16
  728. #define NPY_INT16 NPY_BYTE
  729. #define NPY_UINT16 NPY_UBYTE
  730. typedef signed char npy_int16;
  731. typedef unsigned char npy_uint16;
  732. # define PyInt16ScalarObject PyByteScalarObject
  733. # define PyInt16ArrType_Type PyByteArrType_Type
  734. # define PyUInt16ScalarObject PyUByteScalarObject
  735. # define PyUInt16ArrType_Type PyUByteArrType_Type
  736. #define NPY_INT16_FMT NPY_BYTE_FMT
  737. #define NPY_UINT16_FMT NPY_UBYTE_FMT
  738. #endif
  739. #elif NPY_BITSOF_CHAR == 32
  740. #ifndef NPY_INT32
  741. #define NPY_INT32 NPY_BYTE
  742. #define NPY_UINT32 NPY_UBYTE
  743. typedef signed char npy_int32;
  744. typedef unsigned char npy_uint32;
  745. typedef unsigned char npy_ucs4;
  746. # define PyInt32ScalarObject PyByteScalarObject
  747. # define PyInt32ArrType_Type PyByteArrType_Type
  748. # define PyUInt32ScalarObject PyUByteScalarObject
  749. # define PyUInt32ArrType_Type PyUByteArrType_Type
  750. #define NPY_INT32_FMT NPY_BYTE_FMT
  751. #define NPY_UINT32_FMT NPY_UBYTE_FMT
  752. #endif
  753. #elif NPY_BITSOF_CHAR == 64
  754. #ifndef NPY_INT64
  755. #define NPY_INT64 NPY_BYTE
  756. #define NPY_UINT64 NPY_UBYTE
  757. typedef signed char npy_int64;
  758. typedef unsigned char npy_uint64;
  759. # define PyInt64ScalarObject PyByteScalarObject
  760. # define PyInt64ArrType_Type PyByteArrType_Type
  761. # define PyUInt64ScalarObject PyUByteScalarObject
  762. # define PyUInt64ArrType_Type PyUByteArrType_Type
  763. #define NPY_INT64_FMT NPY_BYTE_FMT
  764. #define NPY_UINT64_FMT NPY_UBYTE_FMT
  765. # define MyPyLong_FromInt64 PyLong_FromLong
  766. # define MyPyLong_AsInt64 PyLong_AsLong
  767. #endif
  768. #elif NPY_BITSOF_CHAR == 128
  769. #ifndef NPY_INT128
  770. #define NPY_INT128 NPY_BYTE
  771. #define NPY_UINT128 NPY_UBYTE
  772. typedef signed char npy_int128;
  773. typedef unsigned char npy_uint128;
  774. # define PyInt128ScalarObject PyByteScalarObject
  775. # define PyInt128ArrType_Type PyByteArrType_Type
  776. # define PyUInt128ScalarObject PyUByteScalarObject
  777. # define PyUInt128ArrType_Type PyUByteArrType_Type
  778. #define NPY_INT128_FMT NPY_BYTE_FMT
  779. #define NPY_UINT128_FMT NPY_UBYTE_FMT
  780. #endif
  781. #endif
  782. #if NPY_BITSOF_DOUBLE == 32
  783. #ifndef NPY_FLOAT32
  784. #define NPY_FLOAT32 NPY_DOUBLE
  785. #define NPY_COMPLEX64 NPY_CDOUBLE
  786. typedef double npy_float32;
  787. typedef npy_cdouble npy_complex64;
  788. # define PyFloat32ScalarObject PyDoubleScalarObject
  789. # define PyComplex64ScalarObject PyCDoubleScalarObject
  790. # define PyFloat32ArrType_Type PyDoubleArrType_Type
  791. # define PyComplex64ArrType_Type PyCDoubleArrType_Type
  792. #define NPY_FLOAT32_FMT NPY_DOUBLE_FMT
  793. #define NPY_COMPLEX64_FMT NPY_CDOUBLE_FMT
  794. #endif
  795. #elif NPY_BITSOF_DOUBLE == 64
  796. #ifndef NPY_FLOAT64
  797. #define NPY_FLOAT64 NPY_DOUBLE
  798. #define NPY_COMPLEX128 NPY_CDOUBLE
  799. typedef double npy_float64;
  800. typedef npy_cdouble npy_complex128;
  801. # define PyFloat64ScalarObject PyDoubleScalarObject
  802. # define PyComplex128ScalarObject PyCDoubleScalarObject
  803. # define PyFloat64ArrType_Type PyDoubleArrType_Type
  804. # define PyComplex128ArrType_Type PyCDoubleArrType_Type
  805. #define NPY_FLOAT64_FMT NPY_DOUBLE_FMT
  806. #define NPY_COMPLEX128_FMT NPY_CDOUBLE_FMT
  807. #endif
  808. #elif NPY_BITSOF_DOUBLE == 80
  809. #ifndef NPY_FLOAT80
  810. #define NPY_FLOAT80 NPY_DOUBLE
  811. #define NPY_COMPLEX160 NPY_CDOUBLE
  812. typedef double npy_float80;
  813. typedef npy_cdouble npy_complex160;
  814. # define PyFloat80ScalarObject PyDoubleScalarObject
  815. # define PyComplex160ScalarObject PyCDoubleScalarObject
  816. # define PyFloat80ArrType_Type PyDoubleArrType_Type
  817. # define PyComplex160ArrType_Type PyCDoubleArrType_Type
  818. #define NPY_FLOAT80_FMT NPY_DOUBLE_FMT
  819. #define NPY_COMPLEX160_FMT NPY_CDOUBLE_FMT
  820. #endif
  821. #elif NPY_BITSOF_DOUBLE == 96
  822. #ifndef NPY_FLOAT96
  823. #define NPY_FLOAT96 NPY_DOUBLE
  824. #define NPY_COMPLEX192 NPY_CDOUBLE
  825. typedef double npy_float96;
  826. typedef npy_cdouble npy_complex192;
  827. # define PyFloat96ScalarObject PyDoubleScalarObject
  828. # define PyComplex192ScalarObject PyCDoubleScalarObject
  829. # define PyFloat96ArrType_Type PyDoubleArrType_Type
  830. # define PyComplex192ArrType_Type PyCDoubleArrType_Type
  831. #define NPY_FLOAT96_FMT NPY_DOUBLE_FMT
  832. #define NPY_COMPLEX192_FMT NPY_CDOUBLE_FMT
  833. #endif
  834. #elif NPY_BITSOF_DOUBLE == 128
  835. #ifndef NPY_FLOAT128
  836. #define NPY_FLOAT128 NPY_DOUBLE
  837. #define NPY_COMPLEX256 NPY_CDOUBLE
  838. typedef double npy_float128;
  839. typedef npy_cdouble npy_complex256;
  840. # define PyFloat128ScalarObject PyDoubleScalarObject
  841. # define PyComplex256ScalarObject PyCDoubleScalarObject
  842. # define PyFloat128ArrType_Type PyDoubleArrType_Type
  843. # define PyComplex256ArrType_Type PyCDoubleArrType_Type
  844. #define NPY_FLOAT128_FMT NPY_DOUBLE_FMT
  845. #define NPY_COMPLEX256_FMT NPY_CDOUBLE_FMT
  846. #endif
  847. #endif
  848. #if NPY_BITSOF_FLOAT == 32
  849. #ifndef NPY_FLOAT32
  850. #define NPY_FLOAT32 NPY_FLOAT
  851. #define NPY_COMPLEX64 NPY_CFLOAT
  852. typedef float npy_float32;
  853. typedef npy_cfloat npy_complex64;
  854. # define PyFloat32ScalarObject PyFloatScalarObject
  855. # define PyComplex64ScalarObject PyCFloatScalarObject
  856. # define PyFloat32ArrType_Type PyFloatArrType_Type
  857. # define PyComplex64ArrType_Type PyCFloatArrType_Type
  858. #define NPY_FLOAT32_FMT NPY_FLOAT_FMT
  859. #define NPY_COMPLEX64_FMT NPY_CFLOAT_FMT
  860. #endif
  861. #elif NPY_BITSOF_FLOAT == 64
  862. #ifndef NPY_FLOAT64
  863. #define NPY_FLOAT64 NPY_FLOAT
  864. #define NPY_COMPLEX128 NPY_CFLOAT
  865. typedef float npy_float64;
  866. typedef npy_cfloat npy_complex128;
  867. # define PyFloat64ScalarObject PyFloatScalarObject
  868. # define PyComplex128ScalarObject PyCFloatScalarObject
  869. # define PyFloat64ArrType_Type PyFloatArrType_Type
  870. # define PyComplex128ArrType_Type PyCFloatArrType_Type
  871. #define NPY_FLOAT64_FMT NPY_FLOAT_FMT
  872. #define NPY_COMPLEX128_FMT NPY_CFLOAT_FMT
  873. #endif
  874. #elif NPY_BITSOF_FLOAT == 80
  875. #ifndef NPY_FLOAT80
  876. #define NPY_FLOAT80 NPY_FLOAT
  877. #define NPY_COMPLEX160 NPY_CFLOAT
  878. typedef float npy_float80;
  879. typedef npy_cfloat npy_complex160;
  880. # define PyFloat80ScalarObject PyFloatScalarObject
  881. # define PyComplex160ScalarObject PyCFloatScalarObject
  882. # define PyFloat80ArrType_Type PyFloatArrType_Type
  883. # define PyComplex160ArrType_Type PyCFloatArrType_Type
  884. #define NPY_FLOAT80_FMT NPY_FLOAT_FMT
  885. #define NPY_COMPLEX160_FMT NPY_CFLOAT_FMT
  886. #endif
  887. #elif NPY_BITSOF_FLOAT == 96
  888. #ifndef NPY_FLOAT96
  889. #define NPY_FLOAT96 NPY_FLOAT
  890. #define NPY_COMPLEX192 NPY_CFLOAT
  891. typedef float npy_float96;
  892. typedef npy_cfloat npy_complex192;
  893. # define PyFloat96ScalarObject PyFloatScalarObject
  894. # define PyComplex192ScalarObject PyCFloatScalarObject
  895. # define PyFloat96ArrType_Type PyFloatArrType_Type
  896. # define PyComplex192ArrType_Type PyCFloatArrType_Type
  897. #define NPY_FLOAT96_FMT NPY_FLOAT_FMT
  898. #define NPY_COMPLEX192_FMT NPY_CFLOAT_FMT
  899. #endif
  900. #elif NPY_BITSOF_FLOAT == 128
  901. #ifndef NPY_FLOAT128
  902. #define NPY_FLOAT128 NPY_FLOAT
  903. #define NPY_COMPLEX256 NPY_CFLOAT
  904. typedef float npy_float128;
  905. typedef npy_cfloat npy_complex256;
  906. # define PyFloat128ScalarObject PyFloatScalarObject
  907. # define PyComplex256ScalarObject PyCFloatScalarObject
  908. # define PyFloat128ArrType_Type PyFloatArrType_Type
  909. # define PyComplex256ArrType_Type PyCFloatArrType_Type
  910. #define NPY_FLOAT128_FMT NPY_FLOAT_FMT
  911. #define NPY_COMPLEX256_FMT NPY_CFLOAT_FMT
  912. #endif
  913. #endif
  914. /* half/float16 isn't a floating-point type in C */
  915. #define NPY_FLOAT16 NPY_HALF
  916. typedef npy_uint16 npy_half;
  917. typedef npy_half npy_float16;
  918. #if NPY_BITSOF_LONGDOUBLE == 32
  919. #ifndef NPY_FLOAT32
  920. #define NPY_FLOAT32 NPY_LONGDOUBLE
  921. #define NPY_COMPLEX64 NPY_CLONGDOUBLE
  922. typedef npy_longdouble npy_float32;
  923. typedef npy_clongdouble npy_complex64;
  924. # define PyFloat32ScalarObject PyLongDoubleScalarObject
  925. # define PyComplex64ScalarObject PyCLongDoubleScalarObject
  926. # define PyFloat32ArrType_Type PyLongDoubleArrType_Type
  927. # define PyComplex64ArrType_Type PyCLongDoubleArrType_Type
  928. #define NPY_FLOAT32_FMT NPY_LONGDOUBLE_FMT
  929. #define NPY_COMPLEX64_FMT NPY_CLONGDOUBLE_FMT
  930. #endif
  931. #elif NPY_BITSOF_LONGDOUBLE == 64
  932. #ifndef NPY_FLOAT64
  933. #define NPY_FLOAT64 NPY_LONGDOUBLE
  934. #define NPY_COMPLEX128 NPY_CLONGDOUBLE
  935. typedef npy_longdouble npy_float64;
  936. typedef npy_clongdouble npy_complex128;
  937. # define PyFloat64ScalarObject PyLongDoubleScalarObject
  938. # define PyComplex128ScalarObject PyCLongDoubleScalarObject
  939. # define PyFloat64ArrType_Type PyLongDoubleArrType_Type
  940. # define PyComplex128ArrType_Type PyCLongDoubleArrType_Type
  941. #define NPY_FLOAT64_FMT NPY_LONGDOUBLE_FMT
  942. #define NPY_COMPLEX128_FMT NPY_CLONGDOUBLE_FMT
  943. #endif
  944. #elif NPY_BITSOF_LONGDOUBLE == 80
  945. #ifndef NPY_FLOAT80
  946. #define NPY_FLOAT80 NPY_LONGDOUBLE
  947. #define NPY_COMPLEX160 NPY_CLONGDOUBLE
  948. typedef npy_longdouble npy_float80;
  949. typedef npy_clongdouble npy_complex160;
  950. # define PyFloat80ScalarObject PyLongDoubleScalarObject
  951. # define PyComplex160ScalarObject PyCLongDoubleScalarObject
  952. # define PyFloat80ArrType_Type PyLongDoubleArrType_Type
  953. # define PyComplex160ArrType_Type PyCLongDoubleArrType_Type
  954. #define NPY_FLOAT80_FMT NPY_LONGDOUBLE_FMT
  955. #define NPY_COMPLEX160_FMT NPY_CLONGDOUBLE_FMT
  956. #endif
  957. #elif NPY_BITSOF_LONGDOUBLE == 96
  958. #ifndef NPY_FLOAT96
  959. #define NPY_FLOAT96 NPY_LONGDOUBLE
  960. #define NPY_COMPLEX192 NPY_CLONGDOUBLE
  961. typedef npy_longdouble npy_float96;
  962. typedef npy_clongdouble npy_complex192;
  963. # define PyFloat96ScalarObject PyLongDoubleScalarObject
  964. # define PyComplex192ScalarObject PyCLongDoubleScalarObject
  965. # define PyFloat96ArrType_Type PyLongDoubleArrType_Type
  966. # define PyComplex192ArrType_Type PyCLongDoubleArrType_Type
  967. #define NPY_FLOAT96_FMT NPY_LONGDOUBLE_FMT
  968. #define NPY_COMPLEX192_FMT NPY_CLONGDOUBLE_FMT
  969. #endif
  970. #elif NPY_BITSOF_LONGDOUBLE == 128
  971. #ifndef NPY_FLOAT128
  972. #define NPY_FLOAT128 NPY_LONGDOUBLE
  973. #define NPY_COMPLEX256 NPY_CLONGDOUBLE
  974. typedef npy_longdouble npy_float128;
  975. typedef npy_clongdouble npy_complex256;
  976. # define PyFloat128ScalarObject PyLongDoubleScalarObject
  977. # define PyComplex256ScalarObject PyCLongDoubleScalarObject
  978. # define PyFloat128ArrType_Type PyLongDoubleArrType_Type
  979. # define PyComplex256ArrType_Type PyCLongDoubleArrType_Type
  980. #define NPY_FLOAT128_FMT NPY_LONGDOUBLE_FMT
  981. #define NPY_COMPLEX256_FMT NPY_CLONGDOUBLE_FMT
  982. #endif
  983. #elif NPY_BITSOF_LONGDOUBLE == 256
  984. #define NPY_FLOAT256 NPY_LONGDOUBLE
  985. #define NPY_COMPLEX512 NPY_CLONGDOUBLE
  986. typedef npy_longdouble npy_float256;
  987. typedef npy_clongdouble npy_complex512;
  988. # define PyFloat256ScalarObject PyLongDoubleScalarObject
  989. # define PyComplex512ScalarObject PyCLongDoubleScalarObject
  990. # define PyFloat256ArrType_Type PyLongDoubleArrType_Type
  991. # define PyComplex512ArrType_Type PyCLongDoubleArrType_Type
  992. #define NPY_FLOAT256_FMT NPY_LONGDOUBLE_FMT
  993. #define NPY_COMPLEX512_FMT NPY_CLONGDOUBLE_FMT
  994. #endif
  995. /* datetime typedefs */
  996. typedef npy_int64 npy_timedelta;
  997. typedef npy_int64 npy_datetime;
  998. #define NPY_DATETIME_FMT NPY_INT64_FMT
  999. #define NPY_TIMEDELTA_FMT NPY_INT64_FMT
  1000. /* End of typedefs for numarray style bit-width names */
  1001. #endif