AFF --- A container for numbers (array) by Friederich and Forbriger.

◆ collapse()

Strided & aff::Strided::collapse ( const Tdim i,
const Tsubscript index 
)

slice

Todo:
This is implementation of slicing is straightforward but rather inefficient. If you do a lot of slicing it might be worth to review and rework the code.

Definition at line 224 of file strided.cc.

References AFF_assert, calculate_base(), first_offset(), Mfirst, Mlast, Mmax_dimen, Mstride, offset(), shrink(), and size().

225  {
227  "ERROR (Strided::collapse): illegal dimension");
228  AFF_assert(((Mfirst[i]<=index)&&(index<=Mlast[i])),
229  "ERROR (Strided::collapse): index range error");
230  this->shrink(i,index,index);
232  Tdim j=i+1;
233  while (j<Mmax_dimen)
234  {
235  Mfirst[j-1]=Mfirst[j];
236  Mlast[j-1]=Mlast[j];
237  Mstride[j-1]=Mstride[j];
238  j++;
239  }
240  Mfirst[Mmax_dimen-1]=1;
241  Mlast[Mmax_dimen-1]=1;
243  this->calculate_base(offset);
244  return(*this);
245  }
TIndexVec Mlast
Definition: strided.h:288
static const Tdim Mmax_dimen
instantiate static member (otherwise the linker won&#39;t find it)
Definition: strided.h:123
#define AFF_assert(C, M)
Check an assertion and report by throwing an exception.
Definition: error.h:162
void calculate_base(const Tsubscript &offset)
construct do given first and last index
Definition: strided.cc:128
Tsize size() const
total number of mapped elements
Definition: strided.cc:140
TSizeVec Mstride
Definition: strided.h:286
Tsubscript first_offset() const
first mapped position
Definition: strided.h:188
unsigned short int Tdim
Type to hold an array dimensionality.
Definition: types.h:49
ptrdiff_t Tsubscript
Type to hold an array&#39;s subscript value.
Definition: types.h:53
TIndexVec Mfirst
Definition: strided.h:287
Tsubscript offset(const TIndexVec &index) const
full dimensionality access
Definition: strided.h:220
Strided & shrink(const TIndexVec &last)
subarray
Definition: strided.cc:151
Here is the call graph for this function: