开发者

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开发者_如何学Go 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?


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:

  • if you want to generate coordinates for n=1, just return 0 and 1

  • if you want to generate coordinates for n>1, take 0 and concatenate it to all possible coordinates for n'=n-1, then take 1 and concatenate it to all possible coordinates for n'=n-1

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜