00001 //# FFT2D.h 00002 //# Copyright (C) 2016 00003 //# Associated Universities, Inc. Washington DC, USA. 00004 //# 00005 //# This library is free software; you can redistribute it and/or modify it 00006 //# under the terms of the GNU General Public License as published by 00007 //# the Free Software Foundation; either version 2 of the License, or (at your 00008 //# option) any later version. 00009 //# 00010 //# This library is distributed in the hope that it will be useful, but WITHOUT 00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00012 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 00013 //# License for more details. 00014 //# 00015 //# You should have received a copy of the GNU General Public License 00016 //# along with this library; if not, write to the Free Software Foundation, 00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. 00018 //# 00019 //# Correspondence concerning AIPS++ should be adressed as follows: 00020 //# Internet email: aips2-request@nrao.edu. 00021 //# Postal address: AIPS++ Project Office 00022 //# National Radio Astronomy Observatory 00023 //# 520 Edgemont Road 00024 //# Charlottesville, VA 22903-2475 USA 00025 //# 00026 //# 00027 //# $kgolap$ 00028 #ifndef SYNTHESIS_FFT2D_H 00029 #define SYNTHESIS_FFT2D_H 00030 #include <scimath/Mathematics/FFTW.h> 00031 #include <scimath/Mathematics/FFTPack.h> 00032 #include <fftw3.h> 00033 namespace casa{ 00034 class FFT2D 00035 { 00037 //This is optimized with minimal memcopies for 2D FFTs 00038 //Assumes 2D x, y array to be even numbers (e.g (100, 200)...will not work for (101, 200)) 00039 public: 00040 FFT2D(Bool useFFTW=True); 00041 ~FFT2D(); 00042 FFT2D& operator=(const FFT2D& other); 00043 //out has to be a pointer to an array [(x/2+1), y] shape 00044 void r2cFFT(Complex*& out, Float*& in, Long x, Long y); 00046 //the remainder of of the X part is untouched of out lattice is larger than 00047 //X/2+1 on the x-axis 00048 void r2cFFT(Lattice<Complex>& out, Lattice<Float>& in); 00050 void c2cFFT(Complex*& out, Long x, Long y, Bool toFreq=True); 00051 void c2cFFT(DComplex*& out, Long x, Long y, Bool toFreq=True); 00052 //This will return the 2D FFT of each x-y planes back into the lattice. 00053 void c2cFFT(Lattice<Complex>& inout, Bool toFreq=True); 00054 void c2cFFT(Lattice<DComplex>& inout, Bool toFreq=True); 00055 //The toFreq=False in FFTShift does the normalization of 1/N_sample expected of ifft 00056 void fftShift(Complex*& scr, Long x, Long y, Bool toFreq=False); 00057 void fftShift(DComplex*& scr, Long x, Long y, Bool toFreq=False); 00058 void fftShift(Float*& scr, Long x, Long y); 00059 void doFFT(Complex*& out, Long x, Long y, Bool toFreq); 00060 void doFFT(DComplex*& out, Long x, Long y, Bool toFreq); 00061 void doFFT(Complex*& out, Float *& in, Long x, Long y); 00062 private: 00063 //FFTW stuff 00064 fftwf_plan planC2C_p; 00065 fftwf_plan planR2C_p; 00066 fftw_plan planC2CD_p; 00067 Bool useFFTW_p; 00068 //FFTPack stuff 00069 std::vector<Float> wsave_p; 00070 Int lsav_p; 00071 //FFTW fft1_p; 00072 }; 00073 };// end of namespace casa 00074 #endif