Skip to content

Instantly share code, notes, and snippets.

@usagi
Created December 15, 2012 03:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save usagi/4291249 to your computer and use it in GitHub Desktop.
Save usagi/4291249 to your computer and use it in GitHub Desktop.
#include <boost/multi_array.hpp>
#include <algorithm>
#include <random>
#include <iostream>
int main(){
using value_type = size_t;
const size_t dimension = 3;
using c = boost::multi_array<value_type, dimension>;
const size_t scaling = 2;
auto a = c(boost::extents[scaling][scaling][scaling]);
auto origin_begin = a.origin();
auto origin_end = origin_begin + a.num_elements();
const value_type index_initial = 0;
std::iota(origin_begin, origin_end, index_initial);
std::random_device rd;
std::mt19937_64 rng(rd());
std::shuffle(origin_begin, origin_end, rng);
for(const auto& a0: a)
for(const auto& a1: a0)
for(const auto& v: a1)
std::cout << v << " ";
std::cout << std::endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment