Iterator over a dense tensor-like object with a secondary index running. More...
#include <dense_iter.h>
Public Member Functions | |
template<typename OrdType > | |
DenseIterDual (std::array< Index, rank > const &dim_, std::array< OrdType, rank > const &ord_) | |
Ctor for nontrivial ordering. More... | |
Size | dual_offset () const |
Returns the dual offset, i.e. More... | |
Size | offset () const |
Returns the offset from the start, mostly only valid if the ordering is trivial (but there are cases where it makes sense for non-trivial orderings as well) More... | |
operator bool () const | |
False if we reached the last element. More... | |
void | operator++ () |
Increase the indices in the order specified by ord. More... | |
DenseIterDual | operator= (DenseIterDual &&)=delete |
Move assignment op deleted, would require pointer fiddling. More... | |
DenseIterDual | operator= (DenseIterDual const &)=delete |
Copy assignment op deleted, would require pointer fiddling. More... | |
Protected Attributes | |
bool | alive |
True unless we have reached the last element. More... | |
std::array< Index, rank > | cur |
Current value of the array, cur[i] is the value of the i-th increased index. More... | |
std::array< Index, rank > | dim |
Dimensions of individual indices, dim[i] is the dimension of the i-th increased index. More... | |
Size | dual_running |
Dual running index. More... | |
std::array< Index, rank > | factors |
Array of factors. More... | |
Size | running |
Current primary offset. More... | |
Iterator over a dense tensor-like object with a secondary index running.
Given a set of dimensions \( D = \left(d_1, d_2, \ldots, d_n
\right) \) and a set of orderings \( O = \left(o_1, o_2,
\ldots, o_n \right) \) on each call to operator++
, the \(
o_n \)-th element of \( r \) is increased, or, if this results in \( d_{o_n} \), set to zero and the \( o_{n-1} \) element is increases instead (and similarly if that is then equal to \( d_{o_{n-1}} \)).
One running index, obtainable via offset()
, can be used to simply count the number of steps taken. The secondary index obtainable via dual_offset()
will be incremented to be the index into a well-ordered dimensions array, which is useful for tensor permutations.
This iterator does not provide a properly-ordered coordinate array.