Skip to content

Commit

Permalink
MultiArray3d.cpp (+3) [29+/24-] - fix
Browse files Browse the repository at this point in the history
  • Loading branch information
skynowa committed Jan 2, 2025
1 parent 6a777a6 commit 8a17bee
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 24 deletions.
21 changes: 12 additions & 9 deletions Libs/Boost/MultiArray2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// safety: array dimensions and data tied into one, can't mix them up!
// also: type safety.
void
print(const boost::multi_array<double, 2>& array)
print(const boost::multi_array<double, 2> &array)
{
for (std::size_t i=0; i<array.shape()[0]; i++) {
for (std::size_t j=0; j<array.shape()[1]; j++) {
Expand All @@ -27,18 +27,21 @@ print(const boost::multi_array<double, 2>& array)
//--------------------------------------------------------------------------------------------------
int main(int argc, char **argv)
{
int m = (argc>1) ? atoi(argv[1]) : 4;
int n = (argc>2) ? atoi(argv[2]) : 5;
const std::size_t m = (argc>1) ? atoi(argv[1]) : 4;
const std::size_t n = (argc>2) ? atoi(argv[2]) : 5;

boost::multi_array<double, 2> A(boost::extents[n][m]);
for(int i=0; i<n; i++)
for(int j=0; j<m; j++)
A[i][j] = i * m + j;

for(std::size_t i=0; i<n; i++)
for(std::size_t j=0; j<m; j++)
A[i][j] = i * m + j;

boost::multi_array<double, 2> B(boost::extents[n][m]);
for(int i=0; i<n; i++)
for(int j=0; j<m; j++)
B[i][j] = i * m + j + 0.5;

for(std::size_t i=0; i<n; i++)
for(std::size_t j=0; j<m; j++)
B[i][j] = i * m + j + 0.5;

print(A);
print(B);

Expand Down
29 changes: 16 additions & 13 deletions Libs/Boost/MultiArray3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
// safety: array dimensions and data tied into one, can't mix them up!
// also: type safety.
void
print(const boost::multi_array<double, 3>& array)
print(const boost::multi_array<double, 3> &array)
{
for(int i=0; i<array.shape()[0]; i++) {
for(int j=0; j<array.shape()[1]; j++) {
for(int k=0; k<array.shape()[2]; k++) {
for (std::size_t i=0; i<array.shape()[0]; i++) {
for (std::size_t j=0; j<array.shape()[1]; j++) {
for (std::size_t k=0; k<array.shape()[2]; k++) {
std::cout << array[i][j][k] << " ";
}
std::cout << "\n";
Expand All @@ -28,21 +28,24 @@ print(const boost::multi_array<double, 3>& array)
//--------------------------------------------------------------------------------------------------
int main(int argc, char **argv)
{
int m = (argc>1) ? atoi(argv[1]) : 4;
int n = (argc>2) ? atoi(argv[2]) : 5;
int o = (argc>3) ? atoi(argv[3]) : 2;
const std::size_t m = (argc>1) ? atoi(argv[1]) : 4;
const std::size_t n = (argc>2) ? atoi(argv[2]) : 5;
const std::size_t o = (argc>3) ? atoi(argv[3]) : 2;

boost::multi_array<double, 3> A(boost::extents[o][n][m]);
for(int i=0; i<o; i++)
for(int j=0; j<n; j++)
for(int k=0; k<m; k++)

for (std::size_t i=0; i<o; i++)
for (std::size_t j=0; j<n; j++)
for (std::size_t k=0; k<m; k++)
A[i][j][k] = i * m * n + j * m + k;

boost::multi_array<double, 3> B(boost::extents[o][n][m]);
for(int i=0; i<o; i++)
for(int j=0; j<n; j++)
for(int k=0; k<m; k++)

for (std::size_t i=0; i<o; i++)
for (std::size_t j=0; j<n; j++)
for (std::size_t k=0; k<m; k++)
B[i][j][k] = i * m * n + j * m + k + 0.5;

print(A);
print(B);

Expand Down
3 changes: 1 addition & 2 deletions OS/Unix/Backtrace_libunwind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ void funcA()
funcB();
}
//--------------------------------------------------------------------------------------------------
int
main(int, char** argv)
int main(int, char **)
{
funcA();

Expand Down

0 comments on commit 8a17bee

Please sign in to comment.