I'm looking to obtain the coordinates of all the 4D-hypercubes generated by using meshgrid in 4D.
The thing is that I have irregular divisions of the axes.
For example:
x = [0,1,2,3,5]
y = [0,1,2,3]
z = [0,1,2,3,4]
w = [0,1,2,3,5,6]
My idea is to
I've tried to find a solution without success.
Could anyone give me a python solution.
I found a solution myself even without using Meshgrid:
import itertools
import numpy as np
x = [0,1,2,3,5]
y = [0,1,2,3]
z = [0,1,2,3,4]
w = [0,1,2,3,5,6]
pairs_x = list(zip(x[:-1],x[1:]))
pairs_y = list(zip(y[:-1],y[1:]))
pairs_z = list(zip(z[:-1],z[1:]))
pairs_w = list(zip(w[:-1],w[1:]))
count=0
for p1 in itertools.product( *([pairs_x]+[pairs_y]+[pairs_z]+[pairs_w]) ):
print("Hyper-cube: ",count+1)
count+=1
for p2 in itertools.product(*p1):
print(p2)
print('Total number of hypercubes: ',count)