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

3G开发

开发平台:

Visual C++

  1. //
  2. //  File = rect_pulse_theory.cpp
  3. //
  4. #include <stdlib.h>
  5. #include <math.h>
  6. #include "rect_pulse_theory.h"
  7. #include "sinc.h"
  8. #include <fstream>
  9. #ifndef PI
  10.   #define PI 3.1415926535897932
  11. #endif
  12. using namespace std;
  13. void RectPulseAliasPower( double fold_freq_hz,
  14.                           int samps_per_hz,
  15.                           char* out_filename)
  16. {
  17.    double freq, val;
  18.    ofstream *out_file;
  19.    out_file = new ofstream(out_filename, ios::out);
  20.    int num_pts = int(1 + fold_freq_hz * samps_per_hz);
  21.    double cumul_val = 0.0;
  22.    double denom = double(samps_per_hz)/2.0;
  23.    for(int n=0; n<num_pts; n++)
  24.    {
  25.       freq = n / double(samps_per_hz);
  26.       val = sinc_sqrd(freq);
  27.       cumul_val += val;
  28.       (*out_file) << freq << ", " << val << ", " << cumul_val/denom << endl;
  29.    }
  30.    out_file->close();
  31.    delete out_file;
  32. }
  33. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++