#include <boost/python.hpp>
#include <numarray/arrayobject.h>
#include <iostream>
#include <sstream>
#include <vector>
#include <numeric>
#include <map>
#include <complex>
Include dependency graph for num_util.h:
This graph shows which files directly or indirectly include this file:
Go to the source code of this file.
Namespaces | |
namespace | num_util |
Defines | |
#define | NO_IMPORT_ARRAY |
#define | NO_IMPORT_ARRAY |
#define | PY_ARRAY_UNIQUE_SYMBOL HippoPyArrayHandle |
Typedefs | |
typedef int | intp |
typedef std::map< PyArray_TYPES, char > | KindCharMap |
Mapping from a PyArray_TYPE to its corresponding typeID in char. | |
typedef std::map< PyArray_TYPES, std::string > | KindStringMap |
Mapping from a PyArray_TYPE to its corresponding name in string. | |
typedef std::map< char, PyArray_TYPES > | KindTypeMap |
Mapping from a typeID to its corresponding PyArray_TYPE. | |
Functions | |
numeric::array | astype (boost::python::numeric::array arr, PyArray_TYPES t) |
Returns a clone of this array with a new type. | |
PyArray_TYPES | char2type (char e_type) |
Coverts a single character typecode to its PyArray_TYPES. | |
void | check_contiguous (boost::python::numeric::array arr) |
Throws an exception if the array is not contiguous. | |
void | check_dim (boost::python::numeric::array arr, int dimnum, intp dimsize) |
Throws an exception if a specific dimension from a numpy array does not match the expected size. | |
void | check_PyArrayElementType (boost::python::object newo) |
Throws an exception if the element of a numpy array is type cast to PyArray_OBJECT. | |
void | check_rank (boost::python::numeric::array arr, int expected_rank) |
Throws an exception if the actual rank is not equal to the expected rank. | |
void | check_shape (boost::python::numeric::array arr, std::vector< intp > expected_dims) |
Throws an exception if the actual dimensions of the array are not equal to the expected dimensions. | |
void | check_size (boost::python::numeric::array arr, intp expected_size) |
Throw an exception if the actual total size of the array is not equal to the expected size. | |
void | check_size_match (std::vector< intp > dims, intp n) |
Throws an exception if the total size computed from a vector of integer does not match with the expected size. | |
void | check_type (boost::python::numeric::array arr, PyArray_TYPES expected_type) |
Throws an exception if the actual array type is not equal to the expected type. | |
boost::python::numeric::array | clone (boost::python::numeric::array arr) |
Returns a clone of this array. | |
void | copy_data (boost::python::numeric::array arr, char *new_data) |
Copies data into the array. | |
void * | data (boost::python::numeric::array arr) |
Returns a pointer to the data in the array. | |
intp | get_dim (boost::python::numeric::array arr, int dimnum) |
Returns the size of a specific dimension. | |
template<typename T> | |
PyArray_TYPES | getEnum () |
Function template returns PyArray_Type for C++ type See num_util.cpp for specializations. | |
bool | iscontiguous (boost::python::numeric::array arr) |
Returns true if the array is contiguous. | |
boost::python::numeric::array | makeNum (const boost::python::numeric::array &arr) |
Creates a numpy array from a numpy array, referencing the data. | |
template<typename T> | |
boost::python::numeric::array | makeNum (T *data, std::vector< int > dims) |
Function template creates an n-dimensional numpy array with dimensions dimens containing a copy of values starting at data. | |
template<typename T> | |
boost::python::numeric::array | makeNum (T *data, int n=0) |
Function template creates a one-dimensional numpy array of length n containing a copy of data at data*. | |
numeric::array | makeNum (std::vector< int > dimens, PyArray_TYPES t) |
Creates a n-dimensional numpy array with dimensions dimens and numpy type t. | |
numeric::array | makeNum (intp n, PyArray_TYPES t) |
Creates an one-dimensional numpy array of length n and numpy type t. | |
boost::python::numeric::array | makeNum (boost::python::object x) |
A free function that extracts a PyArrayObject from any sequential PyObject. | |
template<> | |
boost::python::numeric::array | makeNum< double > (double *data, std::vector< int > dims) |
int | rank (boost::python::numeric::array arr) |
A free function that retrieves the number of dimensions of a numpy array. | |
int | refcount (boost::python::numeric::array arr) |
std::vector< intptr_t > | shape (boost::python::numeric::array arr) |
Returns the dimensions in a vector. | |
intp | size (boost::python::numeric::array arr) |
A free function that returns the total size of the array. | |
std::vector< intp > | strides (boost::python::numeric::array arr) |
Returns the strides array in a vector of integer. | |
PyArray_TYPES | type (boost::python::numeric::array arr) |
A free function that retrieves the numpy type of a numpy array. | |
char | type2char (PyArray_TYPES t_type) |
Converts a PyArray_TYPE to its single character typecode. | |
std::string | type2string (PyArray_TYPES t_type) |
Converts a PyArray_TYPE to its name in string. | |
template<class T> | |
std::string | vector_str (const std::vector< T > &vec) |
Constructs a string which contains a list of elements extracted from the input vector. |
#define NO_IMPORT_ARRAY |
Definition at line 22 of file num_util.h.
#define NO_IMPORT_ARRAY |
Definition at line 22 of file num_util.h.
#define PY_ARRAY_UNIQUE_SYMBOL HippoPyArrayHandle |
Definition at line 13 of file num_util.h.
typedef int intp |
Definition at line 32 of file num_util.h.