Everything of this library can be found in this namespace. More...
Namespaces | |
mw_py_impl | |
Some implementation details are in here. | |
Classes | |
class | arraytbase |
This is the base class from which type specific variants are derived. More... | |
class | arrayt |
This class defines operators () and [] to allow for direct memory access to array elements of type T. More... | |
Typedefs | |
typedef Py_ssize_t | ssize_t |
Synonymous for Py_ssize_t. | |
Enumerations | |
enum | { MAX_DIM = 32 } |
Equal to NPY_MAX_DIMS. Provided so that the numpy headers don't have to be included. | |
Functions | |
void | importNumpyAndRegisterTypes () |
Initializes things. More... | |
object | zeros (int rank, const Py_ssize_t *dims, int type) |
Creates a new ndarray filled with zeros. More... | |
object | empty (int rank, const Py_ssize_t *dims, int type) |
Create a new ndarray with uninitialized memory. More... | |
int | getItemtype (const object &arr) |
Obtain numpy's data type number from an boost-python object which should hold a ndarray. More... | |
template<class T > | |
bool | isCompatibleType (int id) |
Determines if a numpy data type identified by the type number id is binary compatible with the c-type given by T. More... | |
template<class T > | |
int | getItemtype () |
Obtain numpy's data type number from template parameter T. More... | |
template<class T , int rank> | |
static object | copy (const int *dims, const T *src, const int *strides) |
Copy contents of n-dimensional non-contiguous arrays. More... | |
template<class T , int rank> | |
static void | copy (T *dst, const int *dims, const int *strides, const object &pyarr) |
Copy contents of n-dimensional non-contiguous arrays. Inverse variant. More... | |
Everything of this library can be found in this namespace.
Hint: you can use something like
namespace py = boost::python;
namespace np = boost::python::numpy;
for convenience.
|
static |
Copy contents of n-dimensional non-contiguous arrays.
[in] | dims | - Number of items to copy along each dimension |
[in] | src | - Pointer to the source memory |
[in] | strides | - How far to move in (source) memory if the corresponding index is increased by one. Strides are given in number of items, not in bytes. |
|
static |
Copy contents of n-dimensional non-contiguous arrays. Inverse variant.
[out] | dst | - Pointer to destination memory. |
[in] | dims | - Number of items to copy along each dimension |
[in] | strides | - How far to move in (destination) memory if the corresponding index is increased by one. Strides are given in number of items, not in bytes. |
[in] | pyarr | - Must contain an instance of ndarray. |
object boost::python::numpy::empty | ( | int | rank, |
const Py_ssize_t * | dims, | ||
int | type | ||
) |
Create a new ndarray with uninitialized memory.
The type parameter specifies the numpy data type number. You can use getItemtype<T>() to obtain one.
int boost::python::numpy::getItemtype | ( | ) |
Obtain numpy's data type number from template parameter T.
By default, basic types are mapped to NPY_FLOAT32, NPY_FLOAT64, NPY_INT, NPY_LONG, NPY_LONGLONG, NPY_SHORT, NPY_BYTE, NPY_BOOL, NPY_UINT, NPY_ULONG, NPY_USHORT, NPY_UBYTE, NPY_ULONGLONG. PyObject* is mapped to NPY_OBJECT.
int boost::python::numpy::getItemtype | ( | const object & | arr | ) |
Obtain numpy's data type number from an boost-python object which should hold a ndarray.
Returns the result of PyArray_TYPE() if arr is derived from ndarray, and -1 otherwise.
void boost::python::numpy::importNumpyAndRegisterTypes | ( | ) |
bool boost::python::numpy::isCompatibleType | ( | int | id | ) |
Determines if a numpy data type identified by the type number id is binary compatible with the c-type given by T.
This function is specialized for basic number types: various sizes of integers, and float and double. This is a many to one correspondence. For instance depending on the platform, numpy types 'int' and 'long' which have different type numbers are both 8 bytes in length and therefore both correspond to the long type in c++!
object boost::python::numpy::zeros | ( | int | rank, |
const Py_ssize_t * | dims, | ||
int | type | ||
) |
Creates a new ndarray filled with zeros.
The type parameter specifies the numpy data type number. You can use getItemtype<T>() to obtain one.