c++n-dimensionalhypercube

C++ Generate and store the co-ordinates of an n-cube


I want to write a function to generate and store the co-ordinates of an n-cube and I have no idea how to start. Specifically, I wish to generate the co-ordinates for an evenly or randomly distributed cloud of points for this n-cube and store them. What would be a good way to start with this or if possible, a quick solution?


Solution

  • I don't want to give C++ source code for this problem, however, here's the thought how you could generate it.

    A hypercube contains all bit-strings of length n. Thus there are 2^n possibilities for coordinates in total.

    Now how you can do it recursively: