core/vnl/algo/vnl_fft_1d.h
Go to the documentation of this file.
00001 // This is core/vnl/algo/vnl_fft_1d.h
00002 #ifndef vnl_fft_1d_h_
00003 #define vnl_fft_1d_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007 //:
00008 // \file
00009 // \brief In-place 1D fast Fourier transform
00010 // \author fsm
00011 //
00012 // \verbatim
00013 //  Modifications
00014 //   19 June 2003 - Peter Vanroose - added cmplx* and vector<cmplx> interfaces
00015 // \endverbatim
00016 
00017 
00018 #if (defined _MSC_VER) && _MSC_VER == 1200
00019 // disable warning buried deep in the standard library
00020 // warning C4018: '<' : signed/unsigned mismatch: vector(159)
00021 # pragma warning(disable: 4018)
00022 #endif
00023 
00024 
00025 #include <vcl_vector.h>
00026 #include <vnl/vnl_vector.h>
00027 #include <vnl/algo/vnl_fft_base.h>
00028 
00029 //: In-place 1D fast Fourier transform
00030 
00031 template <class T>
00032 struct vnl_fft_1d : public vnl_fft_base<1, T>
00033 {
00034   typedef vnl_fft_base<1, T> base;
00035 
00036   //: constructor takes length of signal.
00037   vnl_fft_1d(int N) {
00038     base::factors_[0].resize(N);
00039   }
00040 
00041   //: return length of signal.
00042   unsigned int size() const { return base::factors_[0].number(); }
00043 
00044   //: dir = +1/-1 according to direction of transform.
00045   void transform(vcl_vector<vcl_complex<T> > &signal, int dir)
00046   { base::transform(&signal[0], dir); }
00047 
00048   //: dir = +1/-1 according to direction of transform.
00049   void transform(vcl_complex<T> *signal, int dir)
00050   { base::transform(signal, dir); }
00051 
00052   //: dir = +1/-1 according to direction of transform.
00053   void transform(vnl_vector<vcl_complex<T> > &signal, int dir)
00054   { base::transform(signal.data_block(), dir); }
00055 
00056   //: forward FFT
00057   void fwd_transform(vcl_vector<vcl_complex<T> > &signal)
00058   { transform(signal, +1); }
00059 
00060   //: forward FFT
00061   void fwd_transform(vcl_complex<T> *signal)
00062   { transform(signal, +1); }
00063 
00064   //: forward FFT
00065   void fwd_transform(vnl_vector<vcl_complex<T> > &signal)
00066   { transform(signal, +1); }
00067 
00068   //: backward (inverse) FFT
00069   void bwd_transform(vcl_vector<vcl_complex<T> > &signal)
00070   { transform(signal, -1); }
00071 
00072   //: backward (inverse) FFT
00073   void bwd_transform(vcl_complex<T> *signal)
00074   { transform(signal, -1); }
00075 
00076   //: backward (inverse) FFT
00077   void bwd_transform(vnl_vector<vcl_complex<T> > &signal)
00078   { transform(signal, -1); }
00079 };
00080 
00081 #endif // vnl_fft_1d_h_