core/vnl/algo/vnl_fft_prime_factors.h
Go to the documentation of this file.
00001 // This is core/vnl/algo/vnl_fft_prime_factors.h
00002 #ifndef vnl_fft_prime_factors_h_
00003 #define vnl_fft_prime_factors_h_
00004 //:
00005 // \file
00006 // \brief Holds prime factor information
00007 // \author Veit U.B. Schenk, Oxford RRG
00008 // \date   19 Mar 98
00009 //
00010 // \verbatim
00011 //  Modifications
00012 //   10/4/2001 Ian Scott (Manchester) Converted perceps header to doxygen
00013 // \endverbatim
00014 
00015 #include <vcl_compiler.h> // for "export" keyword
00016 
00017 //: Holds prime factor information
00018 // Helper class used by the vnl_fft_xd<> FFT routines
00019 //
00020 // Given an integer N of the form
00021 //   $N = 2^P 3^Q 5^R$
00022 // split N into its primefactors (2, 3, 5)
00023 
00024 export template <class T>
00025 struct vnl_fft_prime_factors
00026 {
00027 private:
00028   VCL_SAFE_BOOL_DEFINE;
00029 public:
00030   vnl_fft_prime_factors();
00031 
00032   //: constructor takes the size of the signal.
00033   vnl_fft_prime_factors(int N) { construct(N); }
00034 
00035   ~vnl_fft_prime_factors () { destruct(); }
00036 
00037   //: array of twiddle factors.
00038   T const *trigs () const { return trigs_; }
00039 
00040   //: number which was factorized
00041   int number () const { return number_; }
00042 
00043   //: exponents P, Q, R.
00044   long const *pqr () const { return pqr_; }
00045 
00046   operator safe_bool () const
00047     { return (trigs_ && info_ >= 0)? VCL_SAFE_BOOL_TRUE : 0; }
00048   bool operator!() const
00049     { return (trigs_ && info_ >= 0)? false : true; }
00050 
00051   void resize(int N) {
00052     destruct();
00053     construct(N);
00054   }
00055 
00056  private:
00057   T *trigs_;
00058   long number_;   // the number that is being split into prime-facs
00059   long pqr_[3];   // store P, Q and R
00060   long info_;
00061 
00062   void construct(int N);
00063   void destruct();
00064 
00065   // disallow copying
00066   vnl_fft_prime_factors (vnl_fft_prime_factors<T> const &) { }
00067   vnl_fft_prime_factors<T>& operator= (vnl_fft_prime_factors<T> const &) { return *this; }
00068 };
00069 
00070 #endif // vnl_fft_prime_factors_h_