Strange results with CUFFT 3D

Hi, I seem to get some strange result with CUFFT 3D. If I run it on a 128 x 128 x 128 volume and compare with fftn in Matlab it gives the same result, also for 128 x 256 x 128, but not for 256 x 128 x 128 or 128 x 128 x 256.

I guess it can have something to do with that Matlab saves data column by column instead of row by row, but I try to compensate for this when I read the data from Matlab

I read a real-valued volume from Matlab like this

void pack_r2c(Complex  *output_float, 

			  double *input_re, int DATA_W, int DATA_H, int DATA_D)


	int i = 0;

	for (int z = 0; z < DATA_D; z++)


		for (int x = 0; x < DATA_W; x++)


			for (int y = 0; y < DATA_H; y++)


								output_float[x + y * DATA_W + z * DATA_W * DATA_H].x = (float)input_re[i];

			   					output_float[x + y * DATA_W + z * DATA_W * DATA_H].y = 0.0f;






Is there any difference between using



typedef float2 Complex ?

Seems like I’ve managed to switch x and z, but I don’t understand how. If I switch them in the plan creation it seems to work…

cufftSafeCall( cufftPlan3d(&FFTplan, DATA_D, DATA_H, DATA_W, CUFFT_C2C) );