// ------------------------------------------------------------------------ // File: bound_rate12_bsc.c // // Union bound on the probability of a bit error of a memory-2 // rate-1/2 convolutional code over a binary symmetric channel // ------------------------------------------------------------------------ // 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 #include #include #include 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) { x = 2.0*sqrt(p*(1.0-p)); ber = pow(x,5.0) / pow((1.0-2.0*x),2.0); printf("%lf\t%e\n",p,ber); fprintf(fp,"%lf\t%e\n",p,ber); } }