# Seeking two dimensional forward and inverse FFT working example

Dear ROOT Users,

I am seeking the working example for the forward and inverse FFT in two dimension. At the present moment I am trying to understand the thread : Inverse FFT for 2D histogram question

and running the 2DFFTCut.c example code given in thread : 2D FFT Frequency Cut

but receiving the following error :
/media/dsiwal/DSIWAL/RadonTransform_Imaging/./2DFFTCut.c:49:46: error: only the first dimension of an allocated array may have dynamic size
Double_t *re_full = new Double_t[nBins[0]][nBins[1]];

/media/dsiwal/DSIWAL/RadonTransform_Imaging/./2DFFTCut.c:50:46: error: only the first dimension of an allocated array may have dynamic size
Double_t *im_full = new Double_t[nBins[0]][nBins[1]];

I request for help from the experts…

Thank you Wile

I now have constructed the two dimensional array correctly as and try to implement it. The code snippet is as follow…

const Int_t nDims = 2;
Int_t nBins[nDims] = {100,100};

TH1 *hm =0;
TVirtualFFT::SetTransform(0);
hm = hist->FFT(hm, “MAG”);
double **re_full=NULL;
double **im_full=NULL;

re_full = new double*[nBins[0]];
im_full = new double*[nBins[0]];

for(int i=0; i<nBins[0]; i++)
{
re_full[i] = new double[nBins[1]];
im_full[i] = new double[nBins[1]];
}

TVirtualFFT *fft = TVirtualFFT::GetCurrentTransform();
fft->GetPointsComplex(re_full, im_full);

TVirtualFFT *fft_back = TVirtualFFT::FFT(nDims, nBins, “C2R M K”);
fft_back->SetPointsComplex(re_full,im_full);
fft_back->Transform();

But getting following error, seeing help…

././FFT2D.C:153:8: error: no matching member function for call to ‘GetPointsComplex’
fft->GetPointsComplex(re_full, im_full);

``````/home/dsiwal/softwares/root_build/include/TVirtualFFT.h:115:23: note: candidate function not viable: no known conversion from 'double **' to
'Double_t *' (aka 'double *') for 1st argument; dereference the argument
with *
virtual void       GetPointsComplex(Double_t *data, Bool_t fromInput ...
^
/home/dsiwal/softwares/root_build/include/TVirtualFFT.h:114:23: note: candidate function not viable: no known conversion from 'double **' to
'Double_t *' (aka 'double *') for 1st argument; dereference the argument
with *
virtual void       GetPointsComplex(Double_t *re, Double_t *im, Bool_...
^
In file included from input_line_12:6:
././FFT2D.C:156:30: error: cannot initialize a parameter of type 'const Double_t *' (aka 'const double *')
with an lvalue of type 'double **'
fft_back->SetPointsComplex(re_full,im_full);
^~~~~~~
/home/dsiwal/softwares/root_build/include/TVirtualFFT.h:121:56: note: passing argument to parameter 're' here
virtual void       SetPointsComplex(const Double_t *re, const Double_...``````

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