samp_spect_util.cpp
上传用户:jtjnyq9001
上传日期:2014-11-21
资源大小:3974k
文件大小:1k
源码类别:

3G开发

开发平台:

Visual C++

  1. //
  2. //  File = samp.cpp
  3. //
  4. #include <iostream> 
  5. #include <fstream>
  6. #include <complex>
  7. #include "fft_T.h"
  8. #include "samp_spect_util.h"
  9. using std::complex;
  10. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
  11. template <class T>
  12. SampleSpectrum<T>::SampleSpectrum(  int num_samps,
  13.                                     int fft_len,
  14.                                     double samp_intvl )
  15.                   :SpectrumEstimator<T>(  num_samps,
  16.                                        fft_len,
  17.                                        samp_intvl)
  18. {
  19. }
  20. //=================================================================
  21. template <class T>
  22. void SampleSpectrum<T>::Calculate(  T* time_signal )
  23. {
  24.    int i;
  25.    complex<double>* freq_signal;
  26.    freq_signal = new complex<double>[Fft_Len];
  27.    FFT<double>( time_signal,
  28.                  freq_signal,
  29.                  Num_Samps,
  30.                  Fft_Len );
  31.    for(i=0; i<Num_Samps; i++)
  32.    {
  33.       Psd_Estimate[i] = Samp_Intvl * std::norm(freq_signal[i])/Num_Samps;
  34.    }
  35.    return;
  36. }
  37. template SampleSpectrum<float>;
  38. template SampleSpectrum< std::complex<float> >;