39 unsigned int dimSize = 80;
41 unsigned int dimSize = 32;
48 std::istringstream sstr(argv[1]);
50 if (!sstr || (dimSize <= 0)) {
51 std::cerr <<
"Invalid dimension size: '" << argv[1] <<
"'." <<
std::endl;
63 std::cout <<
"Running through " <<
indices.dim<0>()
68 <<
" = " <<
indices.size() <<
" tensor elements" 78 for (i[0] = 0; i[0] < (index_t)
indices.dim<0>(); ++(i[0])) {
79 for (i[1] = 0; i[1] < (index_t)
indices.dim<1>(); ++(i[1])) {
80 for (i[2] = 0; i[2] < (index_t)
indices.dim<2>(); ++(i[2])) {
81 for (i[3] = 0; i[3] < (index_t)
indices.dim<3>(); ++(i[3])) {
82 for (i[4] = 0; i[4] < (index_t)
indices.dim<4>(); ++(i[4])) {
84 auto linIndex =
indices(i[0], i[1], i[2], i[3], i[4]);
85 if (count != linIndex) {
86 std::cerr <<
"Error: [" 87 << i[0] <<
"][" << i[1] <<
"][" << i[2] <<
"][" 88 << i[3] <<
"][" << i[4]
89 <<
"] => " << linIndex <<
" (expected: " << count <<
")" 101 std::chrono::duration<double> elapsed = stopTime - startTime;
102 std::cout <<
"Iterating through all " << count <<
" indices took " 103 << (elapsed.count() * 1000.) <<
" milliseconds." <<
std::endl;
TensorIndices class to flatten multi-dimension indices into linear.
int main(int argc, char **argv)
unsigned int Index_t
Type to denote the index of the flag.
constexpr std::array< std::size_t, geo::vect::dimension< Vector >)> indices()
Returns a sequence of indices valid for a vector of the specified type.
auto array(Array const &a)
Returns a manipulator which will print the specified array.
auto makeTensorIndices(DIMS...dims)
Instantiates a TensorIndices class with the specified dimensions.
QTextStream & endl(QTextStream &s)