1 #ifndef NPSTAT_BOXNDSCANNER_HH_
2 #define NPSTAT_BOXNDSCANNER_HH_
37 template <
typename Numeric>
47 const std::vector<unsigned>& shape)
48 : box_(box), state_(0UL)
49 {initialize(shape.empty() ?
static_cast<unsigned*
>(0) :
50 &shape[0], shape.size());}
53 const unsigned* shape,
const unsigned lenShape)
54 : box_(box), state_(0UL) {initialize(shape, lenShape);}
58 inline unsigned dim()
const {
return box_.dim();}
61 inline unsigned long state()
const {
return state_;}
64 inline unsigned long maxState()
const {
return maxState_;}
67 inline bool isValid()
const {
return state_ < maxState_;}
73 void getIndex(
unsigned* index,
unsigned indexBufferLen)
const;
76 inline void reset() {state_ = 0UL;}
80 {
if (state_ < maxState_) ++state_;
return *
this;}
83 inline void operator++(
int) {
if (state_ < maxState_) ++state_;}
87 {state_ =
state <= maxState_ ?
state : maxState_;}
92 void initialize(
const unsigned* shape,
unsigned lenShape);
95 std::vector<unsigned long> strides_;
96 std::vector<double> bw_;
98 unsigned long maxState_;
102 inline std::vector<Numeric> getCoords_2()
const
104 const unsigned ndim = strides_.size();
105 std::vector<Numeric> out(ndim);
110 inline std::vector<unsigned> getIndex_2()
const
112 const unsigned ndim = strides_.size();
113 std::vector<unsigned> out(ndim);
118 inline void next() {
if (state_ < maxState_) ++state_;}
123 #include "npstat/nm/BoxNDScanner.icc"
Template to represent rectangles, boxes, and hyperboxes.
Definition: BoxNDScanner.hh:39
void setState(const unsigned long state)
Definition: BoxNDScanner.hh:86
bool isValid() const
Definition: BoxNDScanner.hh:67
void getCoords(Numeric *x, unsigned nx) const
unsigned long maxState() const
Definition: BoxNDScanner.hh:64
void operator++(int)
Definition: BoxNDScanner.hh:83
void getIndex(unsigned *index, unsigned indexBufferLen) const
unsigned dim() const
Definition: BoxNDScanner.hh:58
unsigned long state() const
Definition: BoxNDScanner.hh:61
void reset()
Definition: BoxNDScanner.hh:76
BoxNDScanner(const BoxND< Numeric > &box, const std::vector< unsigned > &shape)
Definition: BoxNDScanner.hh:46
BoxNDScanner & operator++()
Definition: BoxNDScanner.hh:79
Definition: AbsArrayProjector.hh:14