NPL
Neurological Programs and Libraries
|
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 | |
T | sz [MAXDIM] |
T | pos [MAXDIM] |
size_t | ndim |
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());
T | Type of size/position |
MAXDIM | Maximum supported dimension, static array will be this size |
Definition at line 532 of file basic_functions.h.
|
inline |
Default constructor. Just sizes pos to 0. dim is the number of dimensions to use/iterate over.
dim |
Definition at line 544 of file basic_functions.h.
|
inline |
Initialize counter with the specified dimension and stop point.
dim | Number of dimensions |
stop |
Definition at line 560 of file basic_functions.h.
|
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.
rorder | Whether to reverse the order and do low dimension fastest |
Definition at line 581 of file basic_functions.h.
size_t npl::Counter< T, MAXDIM >::ndim |
Definition at line 536 of file basic_functions.h.
T npl::Counter< T, MAXDIM >::pos[MAXDIM] |
Definition at line 535 of file basic_functions.h.
T npl::Counter< T, MAXDIM >::sz[MAXDIM] |
Definition at line 534 of file basic_functions.h.