1 #ifndef NPSTAT_BOXNDSCANNER_HH_ 2 #define NPSTAT_BOXNDSCANNER_HH_ 37 template <
typename Numeric>
47 const std::vector<unsigned>& shape)
49 {
initialize(shape.empty() ?
static_cast<unsigned*
>(0) :
50 &shape[0], shape.size());}
53 const unsigned* shape,
const unsigned lenShape)
58 inline unsigned dim()
const {
return box_.dim();}
73 void getIndex(
unsigned*
index,
unsigned indexBufferLen)
const;
92 void initialize(
const unsigned* shape,
unsigned lenShape);
96 std::vector<double>
bw_;
106 template <
typename Numeric>
111 "In npstat::BoxNDScanner::initialize: incompatible scan shape");
113 for (
unsigned j=0; j<
dim; ++j)
115 "In npstat::BoxNDScanner::initialize: " 116 "number of scans must be positive in each dimension");
120 for (
unsigned j=dim - 1; j>0; --j)
125 for (
unsigned j=0; j<
dim; ++j)
126 bw_.push_back(
box_[j].length()*1.0/shape[j]);
129 template <
typename Numeric>
134 "In npstat::BoxNDScanner::getCoords: " 135 "insufficient length of the output buffer");
137 "In npstat::BoxNDScanner::getCoords: invalid scanner state");
141 for (
unsigned i=0;
i<
dim; ++
i)
149 template <
typename Numeric>
154 "In npstat::BoxNDScanner::getIndex: " 155 "insufficient length of the output buffer");
157 "In npstat::BoxNDScanner::getIndex: invalid scanner state");
161 for (
unsigned i=0;
i<
dim; ++
i)
164 ix[
i] =
static_cast<unsigned>(
idx);
171 #endif // NPSTAT_BOXNDSCANNER_HH_ void setState(const unsigned long state)
void getCoords(Numeric *x, unsigned nx) const
BoxNDScanner(const BoxND< Numeric > &box, const std::vector< unsigned > &shape)
BoxNDScanner(const BoxND< Numeric > &box, const unsigned *shape, const unsigned lenShape)
T x() const
Cartesian x coordinate.
Exceptions for the npstat namespace.
void getIndex(unsigned *index, unsigned indexBufferLen) const
void initialize(const unsigned *shape, unsigned lenShape)
BoxNDScanner & operator++()
std::vector< unsigned long > strides_
std::vector< double > bw_
unsigned long state() const
unsigned long maxState() const
Template to represent rectangles, boxes, and hyperboxes.