Skip to content

Instantly share code, notes, and snippets.

@shelling
Created December 5, 2011 07:27
Show Gist options
  • Select an option

  • Save shelling/1432704 to your computer and use it in GitHub Desktop.

Select an option

Save shelling/1432704 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <boost/multi_array.hpp>
using namespace std;
typedef boost::multi_array<double, 2> array2d;
typedef array2d::index index2d;
int main(int argc, char **argv) {
array2d hello(boost::extents[20][25]);
for (index2d i = 0; i < hello.shape()[0]; i++) {
for (index2d j = 0; j < hello.shape()[1]; j++) {
cout << hello[i][j] << " ";
}
cout << endl;
}
for (int i = 0; i < hello.num_dimensions(); i++) {
cout << "shape-" << i << " " << hello.shape()[i] << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment