Skip to content

Commit

Permalink
Fix build of examples with bracket operator
Browse files Browse the repository at this point in the history
  • Loading branch information
crtrott committed Apr 4, 2023
1 parent e78a29c commit 9396793
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions examples/dot_product/dot_product.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ T dot_product(
T result = 0;
for(int i = 0; i < a.extent(0); ++i) {
for(int j = 0; j < a.extent(1); ++j) {
#ifdef MDSPAN_USE_BRACKET_OPERATOR
result += a[i, j] * b[i, j];
#else
result += a(i, j) * b(i, j);
#endif
}
}
return result;
Expand All @@ -78,7 +82,11 @@ void fill_in_order(
T count = 0;
for(int i = 0; i < a.extent(0); ++i) {
for(int j = 0; j < a.extent(1); ++j) {
#ifdef MDSPAN_USE_BRACKET_OPERATOR
a[i, j] = count++;
#else
a(i, j) = count++;
#endif
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions examples/tiled_layout/simple_tiled_layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,23 @@ int main() {
int failures = 0;
for (int irow = 0; irow < n_rows; ++irow) {
for (int icol = 0; icol < n_cols; ++icol) {
#ifdef MDSPAN_USE_BRACKET_OPERATOR
if(tiled[irow, icol] != row_major[irow, icol]) {
std::cout << "Mismatch for entry " << irow << ", " << icol << ":" << std::endl;
std::cout << " tiled(" << irow << ", " << icol << ") = "
<< tiled[irow, icol] << std::endl;
std::cout << " row_major(" << irow << ", " << icol << ") = "
<< row_major[irow, icol] << std::endl;
#else
if(tiled(irow, icol) != row_major(irow, icol)) {
std::cout << "Mismatch for entry " << irow << ", " << icol << ":" << std::endl;
std::cout << " tiled(" << irow << ", " << icol << ") = "
<< tiled(irow, icol) << std::endl;
std::cout << " row_major(" << irow << ", " << icol << ") = "
<< row_major(irow, icol) << std::endl;
#endif
++failures;

}

}
Expand Down

0 comments on commit 9396793

Please sign in to comment.