Data Types
Fixed-sized allases
| Nnumpy types | C type | Description |
|---|
| np.int8 | int8_t | Byte(-128 to 127) |
| np.int16 | int16_t | integer(-32768 to 32767) |
| np.int32 | int32_t | integer |
| np.int64 | int64_t | None |
| np.uint8 | uint8_t | Unsigned integer |
| np.uint16 | uint16_t | Unsigned integer |
| np.uint32 | uint32_t | Unsigned integer |
| np.uint64 | uint64_t | Unsigned integer |
| np.intp | intptr_t | integer used for indexing |
| np.float32 | float | |
| np.float64/np.float_ | double | the precision of the builtin python float |
| np.complex64 | float complex | complex number |
| np.complex128 | double complex | the precision of the builtin python complex |
Primitive types
| Numpy type | C type |
|---|
| np.bool_ | bool |
| np.byte | signed char |
| np.ubyte | unsigned char |
| np.short | short |
| np.ushort | unsigned short |
| np.intc | int |
| np.uint | long |
| np.longlong | long long |
| np.single | float |
| np.double | double |
| np.longdouble | long double |
| np.csingle | float complex |
| np.cdouble | double complex |
| np.clongdouble | long double complex |
Examples
import numpy as np
x = np.float32(1.0)
y = np.int_([1,2,3])
z = np.arange(3, dtype=np.uint8)