3-dimension Fourier transform by TVirtualFFT

Hello,I want to do Fourier transform on 3 dimension(128128128) data. And I try the class “TVirtualFFT”,this is my code to do so.

I know the first parameter of “FFT” is the dimensions, and the second one is the length for every dimension. But I do not know how to upload the data, so I use a one dimensional array to save the input data, and use “SavePoints” to upload it. However, the result is wrong, the following picture shows the real part of the FFT result projection.

Resulti3_2_XY_FFT_Re

So I think there is something wrong about the input data uploading, could anybody helps me?

@couet Could you please help me?

Hi, @eguiraud , could you please help me solve this problem?

Can you post an example reproducing your problem? (not a screen dump please)

Hi, thank for your reply, this is my code, from 1 to 66 lines, I’m generating the data, and then I used the Fourier transform。
FFT3.C (2.8 KB)

I get this:

$ root FFT3.C 
   ------------------------------------------------------------------
  | Welcome to ROOT 6.27/01                        https://root.cern |
  | (c) 1995-2022, The ROOT Team; conception: R. Brun, F. Rademakers |
  | Built for macosx64 on Dec 20 2022, 09:26:19                      |
  | From heads/master@v6-25-02-3381-geecfc4aff9                      |
  | With Apple clang version 14.0.0 (clang-1400.0.29.202)            |
  | Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q'  |
   ------------------------------------------------------------------

root [0] 
Processing FFT3.C...
Error in <TVirtualFFT::FFT>: handler not found
Error in <HandleInterpreterException>: Trying to dereference null pointer or trying to call routine taking non-null arguments
Execution of your code was aborted.
In file included from input_line_9:1:
/Users/couet/Downloads/FFT3.C:82:4: warning: null passed to a callee that requires a non-null argument [-Wnonnull]
   fft->SetPoints(A);
   ^~~
root [1] 

does it work for you ?

yes, it work for me, and this is my result.

Mabey, you don’t install the FFTW3 library as following shows

I guess @moneta can help.

1 Like

Hi,

The functions TVirtualFFT::SetPoints and TVirtualFFT::GetPoints are for 1d data. For multi-dimensional data you should use the SetPoint and GetPointComplex or GetPointReal functions where you pass an int * for the point coordinates.

Here is your modified example

Cheers

Lorenzo
FFT3.C (3.4 KB)

Thank you very much, it works. I want to make Inverse Fourier transform with the real part and imaginary part which I got before to check the result. So I use “SetPoint” to upload the data like this:

But I get some errors as followings:
微信截图_20230110101551

However, I get the correct result which is the same as the primary data. I don’t know the reason, can you help me please?
XY_FFT_Re
This is my new code, Thank you a lot.
FFT3.C (4.4 KB)

Hi,

Thank you for posting your problem. First of all if you are doing a complex to real transform the input data should have the size n1n2(n3/2+1), so in your loop on k you should go not until 128, but only until 65.

This is the reason of getting this error. I attached here the update script.
FFT3.C (4.4 KB)

The code should work after the changes. I have verified the code for the implementation and seems to be correct. If you have further issues, please let me know

Cheers

Lorenzo

1 Like

Thank you very much. I can run this code now :grinning:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.