⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bound_rate12_bsc_best.c

📁 error correction code
💻 C
字号:
// ------------------------------------------------------------------------
// File: bound_rate12_bsc_best.c
//
// Improved union bound on the probability of a bit error of a memory-2
// rate-1/2 convolutional code over a binary symmetric channel.
//
// Example 61 in the book.
// ------------------------------------------------------------------------
// This program is complementary material for the book:
//
// R.H. Morelos-Zaragoza, The Art of Error Correcting Coding, Wiley, 2002.
//
// ISBN 0471 49581 6
//
// This and other programs are available at http://the-art-of-ecc.com
//
// You may use this program for academic and personal purposes only.
// If this program is used to perform simulations whose results are
// published in a journal or book, please refer to the book above.
//
// The use of this program in a commercial product requires explicit
// written permission from the author. The author is not responsible or
// liable for damage or loss that may be caused by the use of this program.
//
// Copyright (c) 2002. Robert H. Morelos-Zaragoza. All rights reserved.
// ------------------------------------------------------------------------
#include <stdio.h>
#include <math.h>
#include <float.h>
#include <limits.h>

main(argc,argv)
int argc;
char **argv;
{
  double p, init, final, inc, x, ber;
  char name[40];

  FILE *fp;

  if (argc != 5)
  {
    printf("Usage: %s output_file init_p final_p inc_p\n",
    argv[0]);
    exit(1);
  }
  sscanf(argv[1], "%s", name);
  sscanf(argv[2], "%lf", &init);
  sscanf(argv[3], "%lf", &final);
  sscanf(argv[4], "%lf", &inc);

  fp = fopen(name,"w");
  printf("\np       \t   BER\n");

  for (p = init; p <= final; p += inc)
    {
#include <stdio.h>
#include <math.h>
#include <float.h>
#include <limits.h>

main(argc,argv)
int argc;
char **argv;
{
  double p, init, final, inc, x, ber, ber1, ber2;
  char name[40];

  FILE *fp;

  if (argc != 5)
  {
    printf("Usage: %s output_file init_p final_p inc_p\n",
    argv[0]);
    exit(1);
  }
  sscanf(argv[1], "%s", name);
  sscanf(argv[2], "%lf", &init);
  sscanf(argv[3], "%lf", &final);
  sscanf(argv[4], "%lf", &inc);

  fp = fopen(name,"w");
  printf("\np       \t   BER\n");

  for (p = init; p <= final; p += inc)
    {
      x = 2.0*sqrt(p*(1.0-p));
      ber1 = pow(x,5.0) / pow((1.0-2.0*x),2.0);
      ber2 = pow(-x,5.0) / pow((1.0+2.0*x),2.0);

      ber = ((1.0+x)/2.0) * ber1 + ((1.0-x)/2.0) * ber2 ;


      printf("%lf\t%e\n",p,ber);
      fprintf(fp,"%lf\t%e\n",p,ber);
    }
}

⌨️ 快捷键说明

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