// ------------------------------------------------------------------------ // File: ber_ray_ebno2.c // // Union bound on the error performance of a linear code with // BPSK modulation over a flat Rayleigh fading channel. NO CSI. // // The expected value of the bit error probability is computed by // Monte Carlo simulation. // ------------------------------------------------------------------------ // 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(int argc, char *argv[]) { int iter,i,i1,j,n,k,dimension,n_max,level; double ii1,init_snr,final_snr,inc_snr,eb_no_db,es_no,P1,P2; double sum,sum1,sum2,sumj,aux,beta,rate,c1,jaux,d12; int d_hi[128]; double d_h[128],n_d[128],fade[128]; char name1[40],name2[40]; double delta1,delta2,average,sed,prod; FILE *fp,*fp1; // Command line processing if (argc != 8) { printf("Usage: %s length(n) dimension(k) file_weight_dist bound_file init_snr final_snr inc_snr\n",argv[0]); exit(0); } sscanf(argv[1],"%d", &n); sscanf(argv[2],"%d", &k); sscanf(argv[3],"%s", name1); sscanf(argv[4],"%s", name2); sscanf(argv[5],"%lf", &init_snr); sscanf(argv[6],"%lf", &final_snr); sscanf(argv[7],"%lf", &inc_snr); rate = (float) k / (float) n; fp1 = fopen(name1,"r"); n_max = 0; while(fscanf(fp1,"%d %lf\n",&d_hi[n_max],&n_d[n_max])!=EOF) n_max++; fclose(fp1); printf("Weight distribution:\n"); for (i=0; i