npstat is hosted by Hepforge, IPPP Durham
NPStat  5.10.0
npstat::BoxNDScanner< Numeric > Class Template Reference

#include <BoxNDScanner.hh>

Public Member Functions

 BoxNDScanner (const BoxND< Numeric > &box, const std::vector< unsigned > &shape)
 
 BoxNDScanner (const BoxND< Numeric > &box, const unsigned *shape, const unsigned lenShape)
 
unsigned dim () const
 
unsigned long state () const
 
unsigned long maxState () const
 
bool isValid () const
 
void getCoords (Numeric *x, unsigned nx) const
 
void getIndex (unsigned *index, unsigned indexBufferLen) const
 
void reset ()
 
BoxNDScanneroperator++ ()
 
void operator++ (int)
 
void setState (const unsigned long state)
 

Detailed Description

template<typename Numeric>
class npstat::BoxNDScanner< Numeric >

A class for iterating over all coordinates in a multidimensional box (but not a full-fledeged iterator). The expected usage pattern is as follows:

double* coords = ... (the buffer size should be at least box.dim())
for (BoxNDScanner<double> scan(box,shape); scan.isValid(); ++scan)
{
scan.getCoords(coords, coordsBufferSize);
.... Do what is necessary with coordinates ....
.... Extract linear bin number: ..............
scan.state();
}

The coordinates will be in the middle of the bins (imagine a multivariate histogram with boundaries defined by the given box).

Constructor & Destructor Documentation

◆ BoxNDScanner()

template<typename Numeric >
npstat::BoxNDScanner< Numeric >::BoxNDScanner ( const BoxND< Numeric > &  box,
const std::vector< unsigned > &  shape 
)
inline

Constructor from a bounding box and a multidimensional array shape

Member Function Documentation

◆ dim()

template<typename Numeric >
unsigned npstat::BoxNDScanner< Numeric >::dim ( ) const
inline

Dimensionality of the scan

◆ getCoords()

template<typename Numeric >
void npstat::BoxNDScanner< Numeric >::getCoords ( Numeric *  x,
unsigned  nx 
) const

Retrieve current coordinates inside the box

◆ getIndex()

template<typename Numeric >
void npstat::BoxNDScanner< Numeric >::getIndex ( unsigned *  index,
unsigned  indexBufferLen 
) const

Retrieve current multidimensional index

◆ isValid()

template<typename Numeric >
bool npstat::BoxNDScanner< Numeric >::isValid ( ) const
inline

Returns false when iteration is complete

◆ maxState()

template<typename Numeric >
unsigned long npstat::BoxNDScanner< Numeric >::maxState ( ) const
inline

Maximum possible state (i.e., linear index of the scan) plus one

◆ operator++() [1/2]

template<typename Numeric >
BoxNDScanner& npstat::BoxNDScanner< Numeric >::operator++ ( )
inline

Prefix increment

◆ operator++() [2/2]

template<typename Numeric >
void npstat::BoxNDScanner< Numeric >::operator++ ( int  )
inline

Postfix increment (distinguished by the dummy "int" parameter)

◆ reset()

template<typename Numeric >
void npstat::BoxNDScanner< Numeric >::reset ( )
inline

Reset the state (as if the object has just been constructed)

◆ setState()

template<typename Numeric >
void npstat::BoxNDScanner< Numeric >::setState ( const unsigned long  state)
inline

Set the state directly

◆ state()

template<typename Numeric >
unsigned long npstat::BoxNDScanner< Numeric >::state ( ) const
inline

Retrieve current state (i.e., linear index of the scan)


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