RMOL Logo Get Revenue Management Optimisation Library at SourceForge.net. Fast, secure and Free Open Source software downloads

ldpc_gen_codes.cpp

Go to the documentation of this file.
00001 // Generate some example LDPC codes
00002 
00003 #include <itpp/itcomm.h>
00004 
00005 using namespace itpp;
00006 using namespace std;
00007 
00008 extern int main(int argc, char **argv)
00009 { 
00010   { // This generates a random regular (3,6) code with 500 bits
00011     cout << "========= RANDOM (3,6) CODE ==========" << endl;
00012     LDPC_Parity_Matrix H;
00013     H.generate_regular_ldpc(500,3,6,
00014                             "rand",  // random unstructured matrix
00015                             "500 10");   // optimize girth
00016     H.display_stats();
00017     LDPC_Code C1(H);
00018     C1.save_to_file("random_3_6_code.it"); 
00019   }
00020 
00021   { // This is the code "204.33.484 (N=204,K=102,M=102,R=0.5)" from
00022     // David MacKay's database over sparse-graph code.  It can be
00023     // obtained with "wget
00024     // http://www.inference.phy.cam.ac.uk/mackay/codes/EN/C/204.33.484"
00025     cout << "========= MACKAY CODE ==========" << endl;
00026     LDPC_Parity_Matrix H("204.33.484","alist");
00027     H.display_stats();
00028     LDPC_Generator_Matrix G(H);
00029     LDPC_Code C(H,G);
00030     C.save_to_file("mackay_204.33.484.it"); 
00031 
00032     // Now produce a girth-optimized version of this code by removing
00033     // cycles. This slightly improves the performance at high SNR.
00034     H.cycle_removal_MGW(12);
00035     LDPC_Generator_Matrix G1(H);
00036     LDPC_Code C1(H,G1);
00037     C1.save_to_file("mackay_204.33.484_opt.it"); 
00038   }
00039     
00040   // Irregular 1/2-rate codes optimized for the AWGN channel. The
00041   // degree distributions are taken from Richardson & Urbanke,
00042   // Trans. IT 2001.  
00043 
00044   { // 1000 bits
00045     cout << "========= IRREGULAR CODE 1000 BITS ==========" << endl;
00046     LDPC_Parity_Matrix H;
00047     H.generate_irregular_ldpc(1000,
00048                               "0 0.27684 0.28342 0 0 0 0 0 0.43974",
00049                               "0 0 0 0 0 0.01568 0.85244 0.13188",
00050                               "rand",   // random unstructured matrix
00051                               "500 8"); // optimize girth
00052     LDPC_Code C(H);
00053     C.save_to_file("RU_1000.it"); 
00054   }
00055 
00056   {  // 10000 bits (takes a few minutes to run)
00057     cout << "========= IRREGULAR CODE 10000 BITS ==========" << endl;
00058     LDPC_Parity_Matrix H;
00059     H.generate_irregular_ldpc(10000,"0 0.21991 0.23328 0.02058 0 0.08543 0.06540 0.04767 \
00060                               0.01912 0 0 0 0 0 0 0 0 0 0.08064 0.22798", 
00061                               "0 0 0 0 0 0 0 0.64854 0.34747 0.00399",
00062                               "rand",  // random unstructured matrix
00063                               "150 8"); // optimize
00064     LDPC_Code C(H);
00065     C.save_to_file("RU_10000.it"); 
00066   }
00067 
00068   { // 100000 bits (takes a while to run)
00069     cout << "========= IRREGULAR CODE 100000 BITS ==========" << endl;
00070     LDPC_Parity_Matrix H;
00071     H.generate_irregular_ldpc(100000,"0 0.1712 0.21053 0.00273 0 0 0.00009 0.15269 0.09227 \
00072                               0.02802 0 0 0 0 0.01206 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.07212 0 0 0 0 \
00073                               0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25830",
00074                               "0 0 0 0 0 0 0 0 0.33620 0.08883 0.57497",
00075                               "rand",  
00076                               "40 4");  // less aggressive optimization
00077     LDPC_Code C(H);
00078     C.save_to_file("RU_100000.it"); 
00079   }
00080     
00081   exit(0);
00082   
00083   { // 1000000 bits (THIS CODE REQUIRES ABOUT 450 MB TO STORE AND 2GB
00084     // INTERNAL MEMORY TO GENERATE)
00085     cout << "========= IRREGULAR CODE 1000000 BITS ==========" << endl;
00086     LDPC_Parity_Matrix H;
00087     H.generate_irregular_ldpc(1000000,"0 0.1712 0.21053 0.00273 0 0 0.00009 0.15269 0.09227 \
00088                               0.02802 0 0 0 0 0.01206 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.07212 0 0 0 0 \
00089                               0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25830",
00090                               "0 0 0 0 0 0 0 0 0.33620 0.08883 0.57497",
00091                               "rand",
00092                               "0 0");  // no optimization here
00093     LDPC_Code C(H);
00094     C.save_to_file("RU_1000000.it"); 
00095   }
00096     
00097 }
SourceForge Logo

Generated on Fri Jul 30 21:53:39 2010 for RMOL by Doxygen 1.6.1