// ------------------------------------------------------------------------ // File: osd_order5.c // // Simulation of ordered statistics decoding, reprocessing order = 5 // ------------------------------------------------------------------------ // 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 #include #include "def.h" #define MAXRAND LONG_MAX char name1[40], name2[40]; int G[K][N]; int info[N], code[N], deco[N]; double R[N], D[N]; int ord; double INIT, FINAL, INC; double RATE; double snr; double sigma; long seed; long num_sim, error, sim; void channel(); void encoder(); void order5(); main(int argc, char *argv[]) { register int i,j; FILE *fp; // Command line processing if (argc != 8) { printf("Usage: %s file_matrix file_ber init_snr final_snr snr_inc num_sim seed\n", argv[0]); } sscanf(argv[1],"%s", name1); sscanf(argv[2],"%s", name2); sscanf(argv[3],"%lf", &INIT); sscanf(argv[4],"%lf", &FINAL); sscanf(argv[5],"%lf", &INC); sscanf(argv[6],"%ld",&num_sim); sscanf(argv[7],"%ld",&seed); RATE = (double)K/(double)N; printf("\nSimulation of soft-decision decoding with ordered statistics\n"); printf("This is a (%d,%d,%d) linear code with generator matrix:\n", N, K, D_H); printf("(IMPORTANT NOTE: The matrix MUST be in systematic form)\n\n"); fp = fopen(name1,"r"); for (i=0; i>10)&01; encoder(); channel(); order5(G,R,D); for (i=0; i= 1 ); noise = u1 * sqrt( (-2.0*log(s))/s ); if (code[i]) R[i] = -1.0 + noise*sigma; else R[i] = +1.0 + noise*sigma; } }