我在CUDA是356x896x60一个矩阵中。
I have one matrix in CUDA which is 356x896x60.
在我的节目我编码的三个空间坐标是这样的:
In my program I am coding the three spatial coordinates like this:
voxel[threadIdx.x]= indexx+indexy*(DETECTOR_X_DIM)+indexz*DETECTOR_X_DIM*DETECTOR_Y_DIM;
这是正确的?我看到的是使用了此事的一些话题 X * dimx * dimy + Y * dimx + Z
所以,我真的不知道什么是正确的方法
Is this right? I have seen some topics on the matter that use x*dimx*dimy + y*dimx + z
So I am not really sure what is the right method
取决于你的矩阵元素是如何在内存布局。您正在使用 X + Y * dimx + Z * dimx * dimy
这是有效的,如果你的价值观被映射到内存中的东西,如:
Depends how your matrix elements are laid out in memory. You are using x + y*dimx +z*dimx*dimy
which is valid if your values were mapped to memory with something like:
index = 0;
for (z = 0; z<dimz; ++z)
for(y = 0; y<dimy; ++y)
for(x = 0; x<dimx; ++x) {
matrix[index] = value;
index++;
}
如果你想像许多小立方体立方体您可以通过改变x走沿立方体的每一行,然后切换为Y线和层立方体以Z。
If you imagine a cube made of many small cubes you walk along each line of cubes by changing x, then you switch lines with y and the layers of cubes with z.
你是在哪里看到 X * dimx * dimy + Y * dimx + Z
?我想不出一个3D矩阵,你可以正确地使用它,除非dimx = dimz的。我不认为这是正确的。
Where did you see x*dimx*dimy + y*dimx + z
? I can't think of a 3D matrix where you can use it correctly unless dimx=dimz. I don't think it is correct.