AFF --- A container for numbers (array) by Friederich and Forbriger.
stridedstepper.cc
Go to the documentation of this file.
1 
42 #define AFF_STRIDEDSTEPPER_CC_VERSION \
43  "AFF_STRIDEDSTEPPER_DEF_H V1.2"
44 
46 
47 namespace aff {
48 
49 namespace util {
50 
53  Mshape(strided), Mcurrent(strided.first_offset()),
54  Mindex(strided.first()), Mcarry(0), Mvalid(true),
55  Mfirst_offset(strided.first_offset()),
56  Mlast_offset(strided.last_offset())
57  {
58  // calculate Mcarry
59  for (Tsubscript i=0; i<(Tshape::Mmax_dimen); i++)
60  { Mcarry[i]=strided.size(i)*strided.stride(i); }
61  }
62 
63  /*----------------------------------------------------------------------*/
64 
67  {
68  if (!this->more()) Mvalid=false;
69  Tsubscript i=0;
70  while (i<Tshape::Mmax_dimen)
71  {
72  ++Mindex[i];
74  if (Mindex[i]>Mshape.last(i))
75  {
76  Mindex[i]=Mshape.first(i);
77  Mcurrent-=Mcarry[i];
78  ++i;
79  }
80  else
81  {
83  }
84  }
85  return(*this);
86  }
87 
88  /*----------------------------------------------------------------------*/
89 
92  {
93  if (!this->less()) Mvalid=false;
94  Tsubscript i=0;
95  while (i<Tshape::Mmax_dimen)
96  {
97  --Mindex[i];
99  if (Mindex[i]<Mshape.first(i))
100  {
101  Mindex[i]=Mshape.last(i);
102  Mcurrent+=Mcarry[i];
103  ++i;
104  }
105  else
106  {
108  }
109  }
110  return(*this);
111  }
112 
113 } // namespace util
114 
115 } // namespace aff
116 
117 /* ----- END OF stridedstepper.cc ----- */
StridedStepper & decr()
decrement offset - return reference to itself
Root namespace of library.
Definition: array.h:148
Shape for a rectangular array layout.
Definition: strided.h:117
StridedStepper(const Strided &strided)
only non-copy constructor
Tsubscript Mcurrent
hold current position offset to memory
bool more() const
returns true if there are more elements in incr-direction
StridedStepper & incr()
increment offset - return reference to itself
Stepper class for strided shapes (prototypes)
const Tsubscript & first(const Tsubscript &i) const
first index of dimension
Definition: strided.h:194
const Tsize & stride(const Tsubscript &i) const
stride of dimension
Definition: strided.h:203
static const Tdim Mmax_dimen
instantiate static member (otherwise the linker won&#39;t find it)
Definition: strided.h:123
TIndexVec Mindex
hold current index vector
TSizeVec Mcarry
hold carry values
Tsize size() const
total number of mapped elements
Definition: strided.cc:140
A stepper for all strided shapes.
ptrdiff_t Tsubscript
Type to hold an array&#39;s subscript value.
Definition: types.h:53
bool less() const
returns true if there are more elements in decr-direction
const Tshape & Mshape
hold reference to shape
const Tsubscript & last(const Tsubscript &i) const
last index of dimension
Definition: strided.h:197