runrayleigh.cpp

来自「Rayleigh channel model」· C++ 代码 · 共 53 行

CPP
53
字号
#include <iostream.h>
#include <stdio.h>
#include <math.h>
#include <fstream.h>
#include <string.h>
#include "Complex.h"
#include "Random.h"
#include "flat_rayleigh.h"

main(int argc, char *argv[])
{
  const int blocklength = 4000;
  const int maxblocks = 100;
  const double fD = 0.01;

  char logfile[35];

  if (argc == 3)
    sprintf(logfile, argv[2]);
  else {
    sprintf(logfile, "logR%.3f.txt", fD);
  }
  
  // construct it: seed, discrete Doppler fD, pwr=1.0, and continuous
  long seed = -115;
  flat_rayleigh mychan(seed, fD, 1.0, false);

  int i, blocknum;

  Complex inp[blocklength], outp[blocklength];  

  for (i=0; i<blocklength; i++)
	  inp[i] = Complex(1.0, 0.0);
  // If you want to run it on the background,
  // just comment out the following three lines.
  cout << "***********************************\n";
  cout << "************   BEGIN   ************\n";
  cout << "***********************************\n";
  for (blocknum = 1; blocknum<=maxblocks; blocknum++) {
	mychan.pass_through(blocklength, inp, outp);
    ofstream out(logfile, ios::app);
    if (!out)
		cout << "Sorry, I cannot write on the output file\n";
	else {
		for (i=0; i<blocklength; i++)
			out << i << "\t" << outp[i] << endl;
    }
	out.close();
  }
  return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?