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