4D ARRAYS for dihedral angles

hi,

i’m yet in the learning stages of cuda.
now i’m working on a program where 4D arrays are needed.
i.e. all the possible dihedral angles are calculated from a distribution of points in the space.

the way i do it is by calculating the angle between two planes.
i.e. consider 4 points. the first three points and the last three points form a plane each. and then the angle between the planes is calculated.

i’ve found two ways to do it so far.
1. using a 4D array where all the possible combinations of points are considered.
2. as soon as the results are obtained they are copied back to host and then outputted to a file or the screen.

the problem is i don’t know how to work it out in both ways. can someone give me a hand?