How can I generate a set of n-dimensional vectors that contains all integer points in an n-dimensional rectangular prism

Ok, so I'm working on a quantum chaos problem, and one of the things I need to do is map a unit cube in n-dimensions to a box in n-dimensions, and find all the integer points in inside that box. I tried to do it using the following scheme:

  • Given the linear mapping B and the dimension of the cube n, we find the coordinates of the corners of the unit hypercube by converting the numbers j from 0 to (2 ^ n -1) into their binary representation and converting them into vectors that describe the vertices of the cube.
  • The next step was to apply map B to each of these vectors, which gives me a set of 2 ^ n vectors describing the coordinates of the vertices of the parallelepiped in n dimensions
  • Now we take the maximum and minimum value reached by any of these vertices in each direction of coordinates, i.e. the first element of my vectors can have a maximum value of 4 at all vertices and a minimum value of -3, etc. This gives me an n-dimensional rectangular prism that contains my box and some extra unwanted space.
  • Now I find all points with integer coordinates in this bounded rectangular prism, described as vectors in n dimensions
  • Finally, I apply an inverse to map B to each of the points and discard any points with any coefficients greater than 1, since they must initially be located outside my hypercube of one.

My problem occurs in step 4, I am struggling to create a way to create all vectors with integer coordinates in my rectangular hyperprism so that I can change the number of dimensions n on the fly. Ideally I would like to increase n as I see fit until it becomes too hard to calculate, but every method I have tried to find all integer points in a prism so far has relied on n for

permute each element, and so I you need to rewrite the code every time.

So I guess my question is, is there a way to code this so that I can change n on the fly? Also, any thoughts on the idea of ​​the algorithm itself would be appreciated :) It wouldn't surprise me if I complicated things a lot ...

EDIT: Of course, as soon as I post the question, I see a lovely little link in the sidebar where a clever way has already been given: Create a matrix containing all combinations of elements taken from n vectors

I'll leave that for now just in case anyone has any comments on the method in general, but otherwise (since I can't push yet, I'll just say it here) Luis Mendo, you are a hero

+3


source to share


1 answer


Of course, as soon as I post the question, I see a lovely little link in the sidebar where a clever way has already been given: Generate a matrix containing all combinations of elements taken from n vectors



I'll leave that for now just in case anyone has any comments on the method in general, but otherwise (since I can't push yet, I'll just say it here) Luis Mendo, you are a hero

0


source







All Articles