72 fIn = fftw_malloc(
sizeof(Double_t)*n);
73 fOut = fftw_malloc(
sizeof(fftw_complex)*(n/2+1));
75 fIn = fftw_malloc(
sizeof(Double_t)*(2*(n/2+1)));
91 if (ndim>1 && inPlace==kTRUE){
92 Error(
"TFFTRealComplex",
"multidimensional in-place r2c transforms are not implemented yet");
98 for (Int_t i=0; i<
fNdim; i++){
102 Int_t sizeout = Int_t(Double_t(
fTotalSize)*(n[ndim-1]/2+1)/n[ndim-1]);
105 fOut = fftw_malloc(
sizeof(fftw_complex)*sizeout);
107 fIn = fftw_malloc(
sizeof(Double_t)*(2*sizeout));
120 fftw_destroy_plan((fftw_plan)
fPlan);
125 fftw_free((fftw_complex*)
fOut);
154 fftw_destroy_plan((fftw_plan)
fPlan);
160 fPlan = (
void*)fftw_plan_dft_r2c(
fNdim,
fN, (Double_t*)
fIn, (fftw_complex*)
fIn,
MapFlag(flags));
170 fftw_execute((fftw_plan)
fPlan);
173 Error(
"Transform",
"transform hasn't been initialised");
187 data[i] = ((Double_t*)
fIn)[i];
191 for (Int_t i=0; i<realN; i+=2){
192 data[i] = ((fftw_complex*)
fOut)[i/2][0];
193 data[i+1] = ((fftw_complex*)
fOut)[i/2][1];
197 for (Int_t i=0; i<realN; i++)
198 data[i] = ((Double_t*)
fIn)[i];
209 if (
fOut && !fromInput){
210 Warning(
"GetPointReal",
"Output is complex. Only real part returned");
211 return ((fftw_complex*)
fOut)[ipoint][0];
214 return ((Double_t*)
fIn)[ipoint];
223 Int_t ireal = ipoint[0];
224 for (Int_t i=0; i<
fNdim-1; i++)
225 ireal=
fN[i+1]*ireal + ipoint[i+1];
227 if (
fOut && !fromInput){
228 Warning(
"GetPointReal",
"Output is complex. Only real part returned");
229 return ((fftw_complex*)
fOut)[ireal][0];
232 return ((Double_t*)
fIn)[ireal];
245 re = ((Double_t*)
fIn)[ipoint];
249 if (ipoint<
fN[0]/2+1){
250 re = ((fftw_complex*)
fOut)[ipoint][0];
251 im = ((fftw_complex*)
fOut)[ipoint][1];
253 re = ((fftw_complex*)
fOut)[
fN[0]-ipoint][0];
254 im = -((fftw_complex*)
fOut)[
fN[0]-ipoint][1];
257 if (ipoint<
fN[0]/2+1){
258 re = ((Double_t*)
fIn)[2*ipoint];
259 im = ((Double_t*)
fIn)[2*ipoint+1];
261 re = ((Double_t*)
fIn)[2*(
fN[0]-ipoint)];
262 im = ((Double_t*)
fIn)[2*(
fN[0]-ipoint)+1];
269 Error(
"GetPointComplex",
"Illegal index value");
273 re = ((fftw_complex*)
fOut)[ipoint][0];
274 im = ((fftw_complex*)
fOut)[ipoint][1];
276 re = ((Double_t*)
fIn)[2*ipoint];
277 im = ((Double_t*)
fIn)[2*ipoint+1];
290 Int_t ireal = ipoint[0];
291 for (Int_t i=0; i<
fNdim-2; i++)
292 ireal=
fN[i+1]*ireal + ipoint[i+1];
294 ireal = (
fN[fNdim-1]/2+1)*ireal + ipoint[fNdim-1];
297 re = ((Double_t*)
fIn)[ireal];
302 if (ipoint[0] <
fN[0]/2+1){
303 re = ((fftw_complex*)
fOut)[ipoint[0]][0];
304 im = ((fftw_complex*)
fOut)[ipoint[0]][1];
306 re = ((fftw_complex*)
fOut)[
fN[0]-ipoint[0]][0];
307 im = -((fftw_complex*)
fOut)[
fN[0]-ipoint[0]][1];
310 if (ireal <
fN[0]/2+1){
311 re = ((Double_t*)
fIn)[2*ipoint[0]];
312 im = ((Double_t*)
fIn)[2*ipoint[0]+1];
314 re = ((Double_t*)
fIn)[2*(
fN[0]-ipoint[0])];
315 im = ((Double_t*)
fIn)[2*(
fN[0]-ipoint[0])+1];
321 if (ipoint[1]<
fN[1]/2+1){
322 re = ((fftw_complex*)
fOut)[ipoint[1]+(
fN[1]/2+1)*ipoint[0]][0];
323 im = ((fftw_complex*)
fOut)[ipoint[1]+(
fN[1]/2+1)*ipoint[0]][1];
326 re = ((fftw_complex*)
fOut)[
fN[1]-ipoint[1]][0];
327 im = -((fftw_complex*)
fOut)[
fN[1]-ipoint[1]][1];
329 re = ((fftw_complex*)
fOut)[(
fN[1]-ipoint[1])+(
fN[1]/2+1)*(
fN[0]-ipoint[0])][0];
330 im = -((fftw_complex*)
fOut)[(
fN[1]-ipoint[1])+(
fN[1]/2+1)*(
fN[0]-ipoint[0])][1];
334 if (ipoint[1]<
fN[1]/2+1){
335 re = ((Double_t*)
fIn)[2*(ipoint[1]+(
fN[1]/2+1)*ipoint[0])];
336 im = ((Double_t*)
fIn)[2*(ipoint[1]+(fN[1]/2+1)*ipoint[0])+1];
339 re = ((Double_t*)
fIn)[2*(
fN[1]-ipoint[1])];
340 im = -((Double_t*)
fIn)[2*(
fN[1]-ipoint[1])+1];
342 re = ((Double_t*)
fIn)[2*((
fN[1]-ipoint[1])+(
fN[1]/2+1)*(
fN[0]-ipoint[0]))];
343 im = -((Double_t*)
fIn)[2*((
fN[1]-ipoint[1])+(
fN[1]/2+1)*(
fN[0]-ipoint[0]))+1];
351 re = ((fftw_complex*)
fOut)[ireal][0];
352 im = ((fftw_complex*)
fOut)[ireal][1];
354 re = ((Double_t*)
fIn)[2*ireal];
355 im = ((Double_t*)
fIn)[2*ireal+1];
368 Error(
"GetPointsReal",
"Output array is complex");
371 return (Double_t*)
fIn;
382 if (
fOut && !fromInput){
384 for (Int_t i=0; i<nreal; i++){
385 re[i] = ((fftw_complex*)
fOut)[i][0];
386 im[i] = ((fftw_complex*)
fOut)[i][1];
388 }
else if (fromInput) {
390 re[i] = ((Double_t *)
fIn)[i];
396 for (Int_t i=0; i<nreal; i+=2){
397 re[i/2] = ((Double_t*)
fIn)[i];
398 im[i/2] = ((Double_t*)
fIn)[i+1];
412 if (
fOut && !fromInput){
415 for (Int_t i=0; i<nreal; i+=2){
416 data[i] = ((fftw_complex*)
fOut)[i/2][0];
417 data[i+1] = ((fftw_complex*)
fOut)[i/2][1];
419 }
else if (fromInput){
421 data[i] = ((Double_t*)
fIn)[i/2];
428 for (Int_t i=0; i<nreal; i++)
429 data[i] = ((Double_t*)
fIn)[i];
438 ((Double_t *)
fIn)[ipoint] = re;
446 Int_t ireal = ipoint[0];
447 for (Int_t i=0; i<
fNdim-1; i++)
448 ireal=
fN[i+1]*ireal + ipoint[i+1];
449 ((Double_t*)
fIn)[ireal]=re;
458 ((Double_t*)
fIn)[i]=data[i];
467 ((Double_t *)
fIn)[ipoint]=c.
Re();
476 ((Double_t *)
fIn)[i] = re[i];
491 if (opt.Contains(
"ES"))
492 return FFTW_ESTIMATE;
493 if (opt.Contains(
"M"))
495 if (opt.Contains(
"P"))
497 if (opt.Contains(
"EX"))
498 return FFTW_EXHAUSTIVE;
499 return FFTW_ESTIMATE;
virtual Double_t * GetPointsReal(Bool_t fromInput=kFALSE) const
Returns the input array// One of the interface classes to the FFTW package, can be used directly or v...
virtual void GetPoints(Double_t *data, Bool_t fromInput=kFALSE) const
Fills the array data with the computed transform.
virtual ~TFFTRealComplex()
Destroys the data arrays and the plan.
virtual Double_t GetPointReal(Int_t ipoint, Bool_t fromInput=kFALSE) const
Returns the real part of the point #ipoint from the output or the point #ipoint from the input...
virtual void Transform()
Computes the transform, specified in Init() function.
virtual void GetPointsComplex(Double_t *re, Double_t *im, Bool_t fromInput=kFALSE) const
Fills the argument arrays with the real and imaginary parts of the computed transform.
virtual void SetPoint(Int_t ipoint, Double_t re, Double_t im=0)
Set the point #ipoint.
virtual void Init(Option_t *flags, Int_t, const Int_t *)
Creates the fftw-plan.
virtual void SetPoints(const Double_t *data)
Set all input points.
virtual void GetPointComplex(Int_t ipoint, Double_t &re, Double_t &im, Bool_t fromInput=kFALSE) const
Returns the point #ipoint.
UInt_t MapFlag(Option_t *flag)
allowed options: "ES" "M" "P" "EX"
virtual void SetPointsComplex(const Double_t *re, const Double_t *im)
Set all points. Only the real array is used.
virtual void SetPointComplex(Int_t ipoint, TComplex &c)
Sets the point #ipoint (only the real part of the argument is taken)