// ------------------------------------------------------------------------ // File: primint.c // Date: April 5, 2002 // Description: Generate a PRIMITIVE interleaver. Output is the interleaver // array in a files with name specified at command line // // The permuted position is computed as a recursion: // // position[i] = ( position[i-1] + root ) modulo N // // Care must be taken in selecting N and root to obtain a valid interlaver // ------------------------------------------------------------------------ // 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 #define NMAX 16384 main(int argc, char *argv[]) { int interleaver[NMAX]; int deinterleaver[NMAX]; int check[NMAX]; int i, j, position; int N; // Interleaver length int root; // Primitive root modulo N char name1[40]; FILE *fp1; // Command line processing if (argc != 4) { printf("Usage %s N primitive_root INT_file\n", argv[0]); exit(0); } sscanf(argv[1],"%d", &N); sscanf(argv[2],"%d", &root); sscanf(argv[3],"%s", name1); fp1 = fopen(name1,"w"); interleaver[0] = 0; deinterleaver[0] = 0; position = 0; for (i=1; i %5d\n",i,interleaver[i]); } fclose(fp1); }