NPL
Neurological Programs and Libraries
npl::Counter< T, MAXDIM > Struct Template Reference

Very basic counter that iterates over an ND region. More...

#include <basic_functions.h>

Public Member Functions

 Counter (size_t dim)
 Default constructor. Just sizes pos to 0. dim is the number of dimensions to use/iterate over. More...
 
 Counter (size_t dim, const T *stop)
 Initialize counter with the specified dimension and stop point. More...
 
bool advance (bool rorder=false)
 Advance through ND-counter. 0,0,0 to 0,0,1 and so on. If roder is true then this will start at 0,0,0 and then go to 1,0,0 then 2,0,0, etc. More...
 

Public Attributes

sz [MAXDIM]
 
pos [MAXDIM]
 
size_t ndim
 

Detailed Description

template<typename T = int, int MAXDIM = 10>
struct npl::Counter< T, MAXDIM >

Very basic counter that iterates over an ND region.

Example usage:

size_t ret = 0; size_t width = 5; Counter c; c.ndim = ndim; for(size_t ii=0; ii<ndim; ii++) c.sz[ii] = width;

do { double weight = 1; for(int dd = 0; dd < ndim; dd++) weight *= c.pos[dd]; } while(c.advance());

Template Parameters
TType of size/position
MAXDIMMaximum supported dimension, static array will be this size

Definition at line 532 of file basic_functions.h.

Constructor & Destructor Documentation

template<typename T = int, int MAXDIM = 10>
npl::Counter< T, MAXDIM >::Counter ( size_t  dim)
inline

Default constructor. Just sizes pos to 0. dim is the number of dimensions to use/iterate over.

Parameters
dim

Definition at line 544 of file basic_functions.h.

template<typename T = int, int MAXDIM = 10>
npl::Counter< T, MAXDIM >::Counter ( size_t  dim,
const T *  stop 
)
inline

Initialize counter with the specified dimension and stop point.

Parameters
dimNumber of dimensions
stop

Definition at line 560 of file basic_functions.h.

Member Function Documentation

template<typename T = int, int MAXDIM = 10>
bool npl::Counter< T, MAXDIM >::advance ( bool  rorder = false)
inline

Advance through ND-counter. 0,0,0 to 0,0,1 and so on. If roder is true then this will start at 0,0,0 and then go to 1,0,0 then 2,0,0, etc.

Parameters
rorderWhether to reverse the order and do low dimension fastest
Returns

Definition at line 581 of file basic_functions.h.

Member Data Documentation

template<typename T = int, int MAXDIM = 10>
size_t npl::Counter< T, MAXDIM >::ndim

Definition at line 536 of file basic_functions.h.

template<typename T = int, int MAXDIM = 10>
T npl::Counter< T, MAXDIM >::pos[MAXDIM]

Definition at line 535 of file basic_functions.h.

template<typename T = int, int MAXDIM = 10>
T npl::Counter< T, MAXDIM >::sz[MAXDIM]

Definition at line 534 of file basic_functions.h.


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