35 int main(
int argc,
char** argv) {
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;
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) {
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;
BEGIN_PROLOG could also be cerr
TensorIndices class to flatten multi-dimension indices into linear.
unsigned int Index_t
Type to denote the index of the flag.
then echo ***************************************echo array
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 makeTensorIndices(DIMS...dims)
Instantiates a TensorIndices class with the specified dimensions.
std::size_t count(Cont const &cont)
int main(int argc, char **argv)
BEGIN_PROLOG could also be cout