Main Page | Namespace List | File List | Namespace Members | File Members

num_util Namespace Reference


Typedefs

typedef KindStringMap::value_type KindStringMapEntry
typedef KindCharMap::value_type KindCharMapEntry
typedef KindTypeMap::value_type KindTypeMapEntry
typedef std::map< PyArray_TYPES,
std::string > 
KindStringMap
typedef std::map< PyArray_TYPES,
char > 
KindCharMap
typedef std::map< char, PyArray_TYPES > KindTypeMap

Functions

template<>
PyArray_TYPES getEnum< char > (void)
template<>
PyArray_TYPES getEnum< unsigned char > (void)
template<>
PyArray_TYPES getEnum< signed char > (void)
template<>
PyArray_TYPES getEnum< short > (void)
template<>
PyArray_TYPES getEnum< unsigned short > (void)
template<>
PyArray_TYPES getEnum< unsigned int > (void)
template<>
PyArray_TYPES getEnum< int > (void)
template<>
PyArray_TYPES getEnum< long > (void)
template<>
PyArray_TYPES getEnum< unsigned long > (void)
template<>
PyArray_TYPES getEnum< long long > (void)
template<>
PyArray_TYPES getEnum< unsigned long long > (void)
template<>
PyArray_TYPES getEnum< float > (void)
template<>
PyArray_TYPES getEnum< double > (void)
template<>
PyArray_TYPES getEnum< long double > (void)
template<>
PyArray_TYPES getEnum< std::complex< float > > (void)
template<>
PyArray_TYPES getEnum< std::complex< double > > (void)
template<>
PyArray_TYPES getEnum< std::complex< long double > > (void)
numeric::array makeNum (object x)
numeric::array makeNum (intp n, PyArray_TYPES t=PyArray_DOUBLE)
numeric::array makeNum (std::vector< intp > dimens, PyArray_TYPES t=PyArray_DOUBLE)
numeric::array makeNum (const numeric::array &arr)
PyArray_TYPES type (numeric::array arr)
void check_type (boost::python::numeric::array arr, PyArray_TYPES expected_type)
int rank (numeric::array arr)
void check_rank (boost::python::numeric::array arr, int expected_rank)
intp size (numeric::array arr)
void check_size (boost::python::numeric::array arr, intp expected_size)
std::vector< intp > shape (numeric::array arr)
intp get_dim (boost::python::numeric::array arr, int dimnum)
void check_shape (boost::python::numeric::array arr, std::vector< intp > expected_dims)
void check_dim (boost::python::numeric::array arr, int dimnum, intp dimsize)
bool iscontiguous (numeric::array arr)
void check_contiguous (numeric::array arr)
void * data (numeric::array arr)
void copy_data (boost::python::numeric::array arr, char *new_data)
numeric::array clone (numeric::array arr)
numeric::array astype (boost::python::numeric::array arr, PyArray_TYPES t)
std::vector< intp > strides (numeric::array arr)
int refcount (numeric::array arr)
void check_PyArrayElementType (object newo)
std::string type2string (PyArray_TYPES t_type)
char type2char (PyArray_TYPES t_type)
PyArray_TYPES char2type (char e_type)
template<class T>
std::string vector_str (const std::vector< T > &vec)
void check_size_match (std::vector< intp > dims, intp n)
boost::python::numeric::array makeNum (boost::python::object x)
template<typename T>
PyArray_TYPES getEnum (void)
template<typename T>
boost::python::numeric::array makeNum (T *data, intp n=0)
template<typename T>
boost::python::numeric::array makeNum (T *data, std::vector< intp > dims)
boost::python::numeric::array makeNum (const boost::python::numeric::array &arr)
PyArray_TYPES type (boost::python::numeric::array arr)
int rank (boost::python::numeric::array arr)
intp size (boost::python::numeric::array arr)
std::vector< intp > shape (boost::python::numeric::array arr)
bool iscontiguous (boost::python::numeric::array arr)
void check_contiguous (boost::python::numeric::array arr)
void * data (boost::python::numeric::array arr)
boost::python::numeric::array clone (boost::python::numeric::array arr)
int refcount (boost::python::numeric::array arr)
std::vector< intp > strides (boost::python::numeric::array arr)
void check_PyArrayElementType (boost::python::object newo)

Variables

KindStringMapEntry kindStringMapEntries []
KindCharMapEntry kindCharMapEntries []
KindTypeMapEntry kindTypeMapEntries []
int numStringEntries = sizeof(kindStringMapEntries)/sizeof(KindStringMapEntry)
int numCharEntries = sizeof(kindCharMapEntries)/sizeof(KindCharMapEntry)
int numTypeEntries = sizeof(kindTypeMapEntries)/sizeof(KindTypeMapEntry)


Typedef Documentation

typedef std::map<PyArray_TYPES, char> num_util::KindCharMap
 

Mapping from a PyArray_TYPE to its corresponding typeID in char.

Definition at line 267 of file num_util.h.

typedef KindCharMap::value_type num_util::KindCharMapEntry
 

Definition at line 144 of file num_util.cpp.

typedef std::map<PyArray_TYPES, std::string> num_util::KindStringMap
 

Mapping from a PyArray_TYPE to its corresponding name in string.

Definition at line 262 of file num_util.h.

typedef KindStringMap::value_type num_util::KindStringMapEntry
 

Definition at line 126 of file num_util.cpp.

typedef std::map<char, PyArray_TYPES> num_util::KindTypeMap
 

Mapping from a typeID to its corresponding PyArray_TYPE.

Definition at line 272 of file num_util.h.

typedef KindTypeMap::value_type num_util::KindTypeMapEntry
 

Definition at line 160 of file num_util.cpp.


Function Documentation

boost::python::numeric::array num_util::astype boost::python::numeric::array  arr,
PyArray_TYPES  t
 

Returns a clone of this array with a new type.

Parameters:
arr a Boost/Python numeric array.
t PyArray_TYPES of the output array.
Returns:
a replicate of 'arr' with type set to 't'.

Definition at line 378 of file num_util.cpp.

PyArray_TYPES num_util::char2type char  e_type  ) 
 

Coverts a single character typecode to its PyArray_TYPES.

Parameters:
e_type a PyArray_TYPES typecode in char.
Returns:
its corresponding PyArray_TYPES.

Definition at line 421 of file num_util.cpp.

void num_util::check_contiguous boost::python::numeric::array  arr  ) 
 

Throws an exception if the array is not contiguous.

Parameters:
arr a Boost/Python numeric array.
Returns:
-----

void num_util::check_contiguous numeric::array  arr  ) 
 

Definition at line 343 of file num_util.cpp.

void num_util::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.

Parameters:
arr a Boost/Python numeric array.
dimnum an integer that specifies which dimension of 'arr' to check.
dimsize an expected size of the specified dimension.
Returns:
-----

Definition at line 324 of file num_util.cpp.

void num_util::check_PyArrayElementType boost::python::object  newo  ) 
 

Throws an exception if the element of a numpy array is type cast to PyArray_OBJECT.

Parameters:
newo a Boost/Python object.
Returns:
-----

void num_util::check_PyArrayElementType object  newo  ) 
 

Definition at line 400 of file num_util.cpp.

void num_util::check_rank boost::python::numeric::array  arr,
int  expected_rank
 

Throws an exception if the actual rank is not equal to the expected rank.

Parameters:
arr a Boost/Python numeric array.
expected_rank an expected rank of the numeric array.
Returns:
-----

Definition at line 251 of file num_util.cpp.

void num_util::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.

Parameters:
arr a Boost/Python numeric array.
expected_dims an integer vector of expected dimension.
Returns:
-----

Definition at line 312 of file num_util.cpp.

void num_util::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.

Parameters:
arr a Boost/Python numeric array.
expected_size the expected size of an array.
Returns:
-----

Definition at line 272 of file num_util.cpp.

void num_util::check_size_match std::vector< intp >  dims,
intp  n
[inline]
 

Throws an exception if the total size computed from a vector of integer does not match with the expected size.

Parameters:
dims an integer vector of dimensions.
n an expected size.
Returns:
-----

Definition at line 438 of file num_util.cpp.

void num_util::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.

Parameters:
arr a Boost/Python numeric array.
expected_type an expected numpy type.
Returns:
-----

Definition at line 228 of file num_util.cpp.

boost::python::numeric::array num_util::clone boost::python::numeric::array  arr  ) 
 

Returns a clone of this array.

Parameters:
arr a Boost/Python numeric array.
Returns:
a replicate of the Boost/Python numeric array.

numeric::array num_util::clone numeric::array  arr  ) 
 

Definition at line 371 of file num_util.cpp.

void num_util::copy_data boost::python::numeric::array  arr,
char *  new_data
 

Copies data into the array.

Parameters:
arr a Boost/Python numeric array.
new_data a char pointer referencing the new data.
Returns:
-----

Definition at line 361 of file num_util.cpp.

void* num_util::data boost::python::numeric::array  arr  ) 
 

Returns a pointer to the data in the array.

Parameters:
arr a Boost/Python numeric array.
Returns:
a char pointer pointing at the first element of the array.

void* num_util::data numeric::array  arr  ) 
 

Definition at line 352 of file num_util.cpp.

intp num_util::get_dim boost::python::numeric::array  arr,
int  dimnum
 

Returns the size of a specific dimension.

Parameters:
arr a Boost/Python numeric array.
dimnum an integer that identifies the dimension to retrieve.
Returns:
the size of the requested dimension.

Definition at line 298 of file num_util.cpp.

template<typename T>
PyArray_TYPES num_util::getEnum void   ) 
 

Function template returns PyArray_Type for C++ type See num_util.cpp for specializations

Parameters:
T C++ type
Returns:
numpy type enum

Definition at line 59 of file num_util.h.

template<>
PyArray_TYPES num_util::getEnum< char > void   ) 
 

template<>
PyArray_TYPES num_util::getEnum< double > void   ) 
 

template<>
PyArray_TYPES num_util::getEnum< float > void   ) 
 

template<>
PyArray_TYPES num_util::getEnum< int > void   ) 
 

template<>
PyArray_TYPES num_util::getEnum< long > void   ) 
 

template<>
PyArray_TYPES num_util::getEnum< long double > void   ) 
 

template<>
PyArray_TYPES num_util::getEnum< long long > void   ) 
 

template<>
PyArray_TYPES num_util::getEnum< short > void   ) 
 

template<>
PyArray_TYPES num_util::getEnum< signed char > void   ) 
 

template<>
PyArray_TYPES num_util::getEnum< std::complex< double > > void   ) 
 

template<>
PyArray_TYPES num_util::getEnum< std::complex< float > > void   ) 
 

template<>
PyArray_TYPES num_util::getEnum< std::complex< long double > > void   ) 
 

template<>
PyArray_TYPES num_util::getEnum< unsigned char > void   ) 
 

template<>
PyArray_TYPES num_util::getEnum< unsigned int > void   ) 
 

template<>
PyArray_TYPES num_util::getEnum< unsigned long > void   ) 
 

template<>
PyArray_TYPES num_util::getEnum< unsigned long long > void   ) 
 

template<>
PyArray_TYPES num_util::getEnum< unsigned short > void   ) 
 

bool num_util::iscontiguous boost::python::numeric::array  arr  ) 
 

Returns true if the array is contiguous.

Parameters:
arr a Boost/Python numeric array.
Returns:
true if the array is contiguous, false otherwise.

bool num_util::iscontiguous numeric::array  arr  ) 
 

Definition at line 337 of file num_util.cpp.

boost::python::numeric::array num_util::makeNum const boost::python::numeric::array &  arr  ) 
 

Creates a numpy array from a numpy array, referencing the data.

Parameters:
arr a Boost/Python numeric array.
Returns:
a numeric array referencing the input array.

template<typename T>
boost::python::numeric::array num_util::makeNum T *  data,
std::vector< intp >  dims
 

Function template creates an n-dimensional numpy array with dimensions dimens containing a copy of values starting at data. See num_util.cpp::getEnum<T>() for list of specializations

Parameters:
T C type of data
T* data pointer to start of data
n an integer indicates the size of the array.
Returns:
a numpy array of size n with elements initialized to data.

Definition at line 92 of file num_util.h.

template<typename T>
boost::python::numeric::array num_util::makeNum T *  data,
intp  n = 0
 

Function template creates a one-dimensional numpy array of length n containing a copy of data at data*. See num_util.cpp::getEnum<T>() for list of specializations

Parameters:
T C type of data
T* data pointer to start of data
n an integer indicates the size of the array.
Returns:
a numpy array of size n with elements initialized to data.

Definition at line 75 of file num_util.h.

boost::python::numeric::array num_util::makeNum boost::python::object  x  ) 
 

A free function that extracts a PyArrayObject from any sequential PyObject.

Parameters:
x a sequential PyObject wrapped in a Boost/Python 'object'.
Returns:
a PyArrayObject wrapped in Boost/Python numeric array.

numeric::array num_util::makeNum const numeric::array &  arr  ) 
 

Definition at line 218 of file num_util.cpp.

boost::python::numeric::array num_util::makeNum std::vector< intp >  dimens,
PyArray_TYPES  t
 

Creates a n-dimensional numpy array with dimensions dimens and numpy type t. The elements of the array are initialized to zero.

Parameters:
dimens a vector of interger specifies the dimensions of the array.
t elements' numpy type. Default is double.
Returns:
a numeric array of shape dimens with elements initialized to zero.

Definition at line 212 of file num_util.cpp.

boost::python::numeric::array num_util::makeNum intp  n,
PyArray_TYPES  t
 

Creates an one-dimensional numpy array of length n and numpy type t. The elements of the array are initialized to zero.

Parameters:
n an integer representing the length of the array.
t elements' numpy type. Default is double.
Returns:
a numeric array of size n with elements initialized to zero.

Definition at line 206 of file num_util.cpp.

numeric::array num_util::makeNum object  x  ) 
 

Definition at line 194 of file num_util.cpp.

int num_util::rank boost::python::numeric::array  arr  ) 
 

A free function that retrieves the number of dimensions of a numpy array.

Parameters:
arr a Boost/Python numeric array.
Returns:
an integer that indicates the rank of an array.

int num_util::rank numeric::array  arr  ) 
 

Definition at line 242 of file num_util.cpp.

int num_util::refcount boost::python::numeric::array  arr  ) 
 

int num_util::refcount numeric::array  arr  ) 
 

Definition at line 396 of file num_util.cpp.

std::vector<intp> num_util::shape boost::python::numeric::array  arr  ) 
 

Returns the dimensions in a vector.

Parameters:
arr a Boost/Python numeric array.
Returns:
a vector with integer values that indicates the shape of the array.

std::vector<intp> num_util::shape numeric::array  arr  ) 
 

Definition at line 284 of file num_util.cpp.

intp num_util::size boost::python::numeric::array  arr  ) 
 

A free function that returns the total size of the array.

Parameters:
arr a Boost/Python numeric array.
Returns:
an integer that indicates the total size of the array.

intp num_util::size numeric::array  arr  ) 
 

Definition at line 263 of file num_util.cpp.

std::vector<intp> num_util::strides boost::python::numeric::array  arr  ) 
 

Returns the strides array in a vector of integer.

Parameters:
arr a Boost/Python numeric array.
Returns:
the strides of an array.

std::vector<intp> num_util::strides numeric::array  arr  ) 
 

Definition at line 382 of file num_util.cpp.

PyArray_TYPES num_util::type boost::python::numeric::array  arr  ) 
 

A free function that retrieves the numpy type of a numpy array.

Parameters:
arr a Boost/Python numeric array.
Returns:
the numpy type of the array's elements

PyArray_TYPES num_util::type numeric::array  arr  ) 
 

Definition at line 224 of file num_util.cpp.

char num_util::type2char PyArray_TYPES  t_type  ) 
 

Converts a PyArray_TYPE to its single character typecode.

Parameters:
t_type a PyArray_TYPES.
Returns:
the corresponding typecode in char.

Definition at line 417 of file num_util.cpp.

std::string num_util::type2string PyArray_TYPES  t_type  ) 
 

Converts a PyArray_TYPE to its name in string.

Parameters:
t_type a PyArray_TYPES.
Returns:
the corresponding name in string.

Definition at line 413 of file num_util.cpp.

template<class T>
std::string num_util::vector_str const std::vector< T > &  vec  )  [inline]
 

Constructs a string which contains a list of elements extracted from the input vector.

Parameters:
vec a vector of any type.
Returns:
a string that lists the elements from the input vector.

Definition at line 426 of file num_util.cpp.


Variable Documentation

KindCharMapEntry num_util::kindCharMapEntries[]
 

Initial value:

  {
    KindCharMapEntry(PyArray_CHAR,   'c'),
    KindCharMapEntry(PyArray_UBYTE,  'b'),
    KindCharMapEntry(PyArray_SBYTE,  '1'),
    KindCharMapEntry(PyArray_SHORT,  's'),
    KindCharMapEntry(PyArray_INT,    'i'),
    KindCharMapEntry(PyArray_LONG,   'l'),
    KindCharMapEntry(PyArray_FLOAT,  'f'),
    KindCharMapEntry(PyArray_DOUBLE, 'd'),
    KindCharMapEntry(PyArray_CFLOAT, 'F'),
    KindCharMapEntry(PyArray_CDOUBLE,'D'),
    KindCharMapEntry(PyArray_OBJECT, 'O')
  }

Definition at line 145 of file num_util.cpp.

KindStringMapEntry num_util::kindStringMapEntries[]
 

Initial value:

  {
    KindStringMapEntry(PyArray_CHAR,   "PyArray_CHAR"),
    KindStringMapEntry(PyArray_UBYTE,  "PyArray_UBYTE"),
    KindStringMapEntry(PyArray_SBYTE,  "PyArray_SBYTE"),
    KindStringMapEntry(PyArray_SHORT,  "PyArray_SHORT"),
    KindStringMapEntry(PyArray_INT,    "PyArray_INT"),
    KindStringMapEntry(PyArray_LONG,   "PyArray_LONG"),
    KindStringMapEntry(PyArray_FLOAT,  "PyArray_FLOAT"),
    KindStringMapEntry(PyArray_DOUBLE, "PyArray_DOUBLE"),
    KindStringMapEntry(PyArray_CFLOAT, "PyArray_CFLOAT"),
    KindStringMapEntry(PyArray_CDOUBLE,"PyArray_CDOUBLE"),
    KindStringMapEntry(PyArray_OBJECT, "PyArray_OBJECT"),
    KindStringMapEntry(PyArray_NTYPES, "PyArray_NTYPES"),
    KindStringMapEntry(PyArray_NOTYPE ,"PyArray_NOTYPE")
  }

Definition at line 127 of file num_util.cpp.

KindTypeMapEntry num_util::kindTypeMapEntries[]
 

Initial value:

  {
    KindTypeMapEntry('c',PyArray_CHAR),
    KindTypeMapEntry('b',PyArray_UBYTE),
    KindTypeMapEntry('1',PyArray_SBYTE),
    KindTypeMapEntry('s',PyArray_SHORT),
    KindTypeMapEntry('i',PyArray_INT),
    KindTypeMapEntry('l',PyArray_LONG),
    KindTypeMapEntry('f',PyArray_FLOAT),
    KindTypeMapEntry('d',PyArray_DOUBLE),
    KindTypeMapEntry('F',PyArray_CFLOAT),
    KindTypeMapEntry('D',PyArray_CDOUBLE),
    KindTypeMapEntry('O',PyArray_OBJECT)
  }

Definition at line 161 of file num_util.cpp.

int num_util::numCharEntries = sizeof(kindCharMapEntries)/sizeof(KindCharMapEntry)
 

Definition at line 178 of file num_util.cpp.

int num_util::numStringEntries = sizeof(kindStringMapEntries)/sizeof(KindStringMapEntry)
 

Definition at line 177 of file num_util.cpp.

int num_util::numTypeEntries = sizeof(kindTypeMapEntries)/sizeof(KindTypeMapEntry)
 

Definition at line 179 of file num_util.cpp.


Generated on Wed Jul 5 15:26:11 2006 for num_util by  doxygen 1.4.4