Michele De Stefano's C++ Utilities
mds_utils::python::numpy::NDArrayIterator< T, Storage, rw_flag > Class Template Reference

Iterator on a NumPy ndarray. More...

#include <mds_utils/python/numpy/array_iterator.hpp>

Inheritance diagram for mds_utils::python::numpy::NDArrayIterator< T, Storage, rw_flag >:

Public Types

typedef detail::ArrayElementProxy< T, Storage, rw_flag > reference
 The type of a reference to an element.
 
typedef ptrdiff_t difference_type
 The type of the difference between two memory locations.
 

Public Member Functions

 NDArrayIterator ()
 Default constructor.
 
 NDArrayIterator (PyArrayObject *parray)
 Builds the start iterator for a particular ndarray object. More...
 
 ~NDArrayIterator ()
 Destructor.
 
 NDArrayIterator (const NDArrayIterator &rhs, bool end=false)
 Copy-constructor or constructor for the Past-the-End iterator. More...
 
NDArrayIteratoroperator= (const NDArrayIterator &rhs)
 Assignment. More...
 

Friends

class boost::iterator_core_access
 
class detail::ArrayElementProxy< T, Storage, rw_flag >
 

Detailed Description

template<class T, class Storage, npy_uint32 rw_flag = NPY_ITER_READWRITE>
class mds_utils::python::numpy::NDArrayIterator< T, Storage, rw_flag >

Iterator on a NumPy ndarray.

It is a Random Access Iterator. It wraps (i.e. adapts) the NumPy C-API implementation of the iterator for ndarray objects. When a cast is needed, it operates on a casted copy of the original array.

Template Parameters
TThe output type in C++ code. It may be obtained by cast, if the data type in Python is not the same.
StorageOrdering used for accessing the array. It can be different from the actual ordering of the ndarray object. It can be either c_storage or fortran_storage.
rw_flagRead-write flag. It can assume one of three values:
  • NPY_ITER_READWRITE: (default) the iterator will be used for reading and writing from/into the array.
  • NPY_ITER_READONLY: the iterator will only read from the array.
  • NPY_ITER_WRITEONLY: the iterator will only write into the array.
Author
Michele De Stefano
Date
21/11/2014

Definition at line 116 of file array_iterator.hpp.

Constructor & Destructor Documentation

template<class T, class Storage, npy_uint32 rw_flag = NPY_ITER_READWRITE>
mds_utils::python::numpy::NDArrayIterator< T, Storage, rw_flag >::NDArrayIterator ( PyArrayObject *  parray)
inline

Builds the start iterator for a particular ndarray object.

Warning
For a limitation in the underlying C API, this constructor can be called only once for each ndarray object. A new call can be done only if the first NDArrayIterator object has already been destroyed. Other start iterators can be built through the copy-constructor or by assignment.
Parameters
parrayPointer to the ndarray object.
Author
Michele De Stefano
Date
17/07/2014

Definition at line 209 of file array_iterator.hpp.

template<class T, class Storage, npy_uint32 rw_flag = NPY_ITER_READWRITE>
mds_utils::python::numpy::NDArrayIterator< T, Storage, rw_flag >::NDArrayIterator ( const NDArrayIterator< T, Storage, rw_flag > &  rhs,
bool  end = false 
)
inline

Copy-constructor or constructor for the Past-the-End iterator.

Parameters
rhsThe iterator to be copied.
endIf true, then constructs the Past-the-End iterator.
Author
Michele De Stefano
Date
12/06/2014

Definition at line 264 of file array_iterator.hpp.

Member Function Documentation

template<class T, class Storage, npy_uint32 rw_flag = NPY_ITER_READWRITE>
NDArrayIterator& mds_utils::python::numpy::NDArrayIterator< T, Storage, rw_flag >::operator= ( const NDArrayIterator< T, Storage, rw_flag > &  rhs)
inline

Assignment.

Parameters
rhsThe iterator to be copied.
Author
Michele De Stefano
Date
12/06/2014

Definition at line 303 of file array_iterator.hpp.


The documentation for this class was generated from the following file: