i need some help with a liitle problem here. i want to multiply a fourier transformed volume with a volume of the same size. the second volume is a real volume. how could i do this. because if i do the elementwise multiplication i get something strange output and this is not corresponding to the result in matlab. matlab: x = fftn(v1) .* v2; is there some memory rearrangement during the fft and where could i find how it is done. or in other words how to convert a volium to intereaved volum"?
This is explained in the CUFFT documentation. Complex to real (and R2C) transforms in CUFFT have a special memory layout - only the non-redundant N/2+1 complex coefficients are stored.
For higher dimensional transforms of the form N0×N1×…×Nn, the last dimension is cut in half such that the data is N0×N1×…×(Nn/2+1) complex elements.
This the same arrangement used by the FFTW library, their documentation has more details:
ok that is also what i found but i don’t get thru. any examples? any code available?
I have similar question sometime ago. And i find the answer myself, that is you should only perform elements wise multiplication within the limits size that is N0×N1×…×(Nn/2+1).
and if you use R2C to perform spatial - Fourier transformation you MUST use C2R to perform the inverse transformation to get the correct result, remember scale the value after performing R2C (i think it is informed in CUDA FFT spec, but i don’t think it is well documented ). Make some easy example with small size matrix you will find how it work
Hope this help
ok u mean that it should work to multiply n1 * n2 * (n3/2 +1) part of each volume?
what i want to do is this:
s = sphere(3,64);
pic = ones(64,64,64);
r = ifourier(fourier(pic) .* fftshift(s));
should this work with n1 * n2 * (n3/2 +1) ?
Yes. It is what i did. But remember it is true with real input only.
The easier way to do this is to make complex input from the real input and perform full component-wise matrix multiplication and working on Complex domain only. Output result should be complex too, but will have the imagine part equal to zero.
ok i am now able to do the whole stuff and i have checked that i have before the ifft. i have the correct values in memory but then something happens and the output of the ifft is not correct. so my question is can i multiply all of the n+1 parts or must the +1 value be unchanged?
i need a for this stupid thing a second time some help.
i have now made the fftshift and use the fft and ifft of cufft.
what i am doing is
pic1 = load picture1;
pic2 = load picture2;
pic2 = fftshift(pic2);
pic3 = fft(pic1);
/now the interessting part/
pic4 = multiply(pic3, pic2); //is a elementwise mulitplication from 0,0,0 to length_z, length_y, length_x/2+1
pic5 = ifft(pic4);
my problem is now this stupid multiplication. something went wrong. i have tried to figure out but i don’t get it.
if have tested the fft, ifft, fftshift and this functions are working. (compared with matlab results)
but i don’t get this multiplication running. is there any value in that should not be changed? any special trick? my results looks like there is something going on in the multiplicatio but…