summaryrefslogtreecommitdiff
path: root/lib/ldpc/peg
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ldpc/peg')
-rw-r--r--lib/ldpc/peg/128-64-reg4.deg4
-rw-r--r--lib/ldpc/peg/BigGirth.C573
-rw-r--r--lib/ldpc/peg/BigGirth.h54
-rw-r--r--lib/ldpc/peg/CodeName68
-rw-r--r--lib/ldpc/peg/CyclesOfGraph.C237
-rw-r--r--lib/ldpc/peg/CyclesOfGraph.h40
-rw-r--r--lib/ldpc/peg/DenEvl_11.deg3
-rw-r--r--lib/ldpc/peg/DenEvl_15.deg3
-rw-r--r--lib/ldpc/peg/DenEvl_20.deg4
-rw-r--r--lib/ldpc/peg/DenEvl_7.deg3
-rw-r--r--lib/ldpc/peg/DenEvl_9.deg3
-rw-r--r--lib/ldpc/peg/MainPEG.C200
-rw-r--r--lib/ldpc/peg/Makefile29
-rw-r--r--lib/ldpc/peg/Random.C101
-rw-r--r--lib/ldpc/peg/Random.h29
-rw-r--r--lib/ldpc/peg/Reg_2.deg3
-rw-r--r--lib/ldpc/peg/Reg_3.deg3
-rw-r--r--lib/ldpc/peg/Reg_4.deg3
-rw-r--r--lib/ldpc/peg/ldpc-peg-128-80.alist180
-rw-r--r--lib/ldpc/peg/peg-128-64-reg4.alist196
-rw-r--r--lib/ldpc/peg/peg-128-64-reg4.code67
-rw-r--r--lib/ldpc/peg/peg-128-72-reg4.alist188
-rw-r--r--lib/ldpc/peg/peg-128-72-reg4.code59
-rw-r--r--lib/ldpc/peg/peg-128-80-reg3.alist180
-rw-r--r--lib/ldpc/peg/peg-128-80-reg3.code51
-rw-r--r--lib/ldpc/peg/peg-128-80-reg4.alist180
-rw-r--r--lib/ldpc/peg/peg-128-80-reg4.code51
-rw-r--r--lib/ldpc/peg/peg-144-72-reg4.alist220
-rw-r--r--lib/ldpc/peg/peg-144-72-reg4.code75
-rwxr-xr-xlib/ldpc/peg/peg2alist37
-rw-r--r--lib/ldpc/peg/peg_128_80.pchk51
-rw-r--r--lib/ldpc/peg/sfpeg1.code51
-rw-r--r--lib/ldpc/peg/sfpeg1.deg3
-rw-r--r--lib/ldpc/peg/sfpeg2.alist180
-rw-r--r--lib/ldpc/peg/sfpeg2.code51
-rw-r--r--lib/ldpc/peg/sfpeg2.deg3
-rw-r--r--lib/ldpc/peg/sfpeg3.alist180
-rw-r--r--lib/ldpc/peg/sfpeg3.code51
-rw-r--r--lib/ldpc/peg/sfpeg3.deg3
39 files changed, 3417 insertions, 0 deletions
diff --git a/lib/ldpc/peg/128-64-reg4.deg b/lib/ldpc/peg/128-64-reg4.deg
new file mode 100644
index 00000000..7b72d067
--- /dev/null
+++ b/lib/ldpc/peg/128-64-reg4.deg
@@ -0,0 +1,4 @@
+1
+4
+1.0
+
diff --git a/lib/ldpc/peg/BigGirth.C b/lib/ldpc/peg/BigGirth.C
new file mode 100644
index 00000000..ad8b54a1
--- /dev/null
+++ b/lib/ldpc/peg/BigGirth.C
@@ -0,0 +1,573 @@
+#include <cstdio>
+#include <cstdlib>
+#include <iostream>
+#include <fstream>
+#include "BigGirth.h"
+#include "Random.h"
+
+using namespace std;
+
+NodesInGraph::NodesInGraph(void) {
+ connectionParityBit=NULL;
+ connectionSymbolBit=NULL;
+}
+
+void NodesInGraph::setNumOfConnectionSymbolBit(int deg) {
+ if(deg<=0) {cout<<"Wrong NodesInGraph::setNumOfConnectionSymbolBit()"<<endl;exit(-1);}
+ numOfConnectionSymbolBit=deg;
+ connectionSymbolBit=new int[deg];
+}
+void NodesInGraph::initConnectionParityBit(void) {
+ maxDegParity=10000;
+ numOfConnectionParityBit=0;
+ connectionParityBit=new int[1];//dummy memory, actually not used
+}
+void NodesInGraph::initConnectionParityBit(int deg) {
+ maxDegParity=deg;
+ numOfConnectionParityBit=0;
+ connectionParityBit=new int[1];//dummy memory, actually not used
+}
+NodesInGraph::~NodesInGraph(void) {
+ delete [] connectionParityBit;
+ delete [] connectionSymbolBit;
+}
+
+BigGirth::BigGirth(void) : H(NULL), verbose(true) { }
+
+BigGirth::BigGirth(int M, int N, int *symbolDegSequence, const char *filename, int sglConcent, int tgtGirth, bool verbose_) : H(NULL), verbose(verbose_) {
+ int i, j, k, m, index, localDepth=100;
+ int *mid;
+
+ EXPAND_DEPTH=(tgtGirth-4)/2;
+ if(EXPAND_DEPTH<0) EXPAND_DEPTH=0;
+
+ // corresponds to depth l in the PEG paper;
+ // the target girth = 2*EXPAND_DEPTH+4
+ // if set large, then GREEDY algorithm
+
+ myrandom=new Random(); //(12345678l, 987654321lu);
+
+ this->M=M;
+ this->N=N;
+ this->filename=filename;
+
+ mid=new int[M];
+
+ localGirth=new int[N];
+
+ nodesInGraph=new NodesInGraph [N];
+ for(i=0;i<N;i++)
+ nodesInGraph[i].setNumOfConnectionSymbolBit(symbolDegSequence[i]);
+
+ j=0;
+ for(k=0;k<N;k++) j+=symbolDegSequence[k];
+ k=j/M;
+ for(i=0;i<M;i++) mid[i]=k;
+ for(i=0;i<j-k*M;i++) mid[i]++;
+ k=0; for(i=0;i<M;i++) k+=mid[i];
+ if(k!=j) {cout<<"Wrong in computing maxDegParity!"<<endl;exit(-1);}
+
+ for(i=0;i<M;i++) {
+ if(sglConcent==0) nodesInGraph[i].initConnectionParityBit(mid[i]);
+ else nodesInGraph[i].initConnectionParityBit();
+ }
+
+ for(k=0;k<N;k++){
+ m=1000000;index=-1;
+ for(i=0;i<M;i++){
+ if(nodesInGraph[i].numOfConnectionParityBit<m && nodesInGraph[i].numOfConnectionParityBit<nodesInGraph[i].maxDegParity) {
+ m=nodesInGraph[i].numOfConnectionParityBit;
+ index=i;
+ }
+ }
+ nodesInGraph[k].connectionSymbolBit[0]=index;//least connections of parity bit
+
+ int iter=0;
+ ITER:
+ localGirth[k]=100;
+ for(m=1;m<nodesInGraph[k].numOfConnectionSymbolBit;m++){
+ nodesInGraph[k].connectionSymbolBit[m]=selectParityConnect(k, m, localDepth);
+ localGirth[k]=(localGirth[k]>localDepth)?localDepth:localGirth[k];
+ if(k>0 && localGirth[k]<localGirth[k-1] && iter<20) {iter++; goto ITER;}
+ if(localGirth[k]==0 && iter<30) {iter++; goto ITER;}
+ }
+ //if((k+1)%100==0) {
+ if(verbose) {
+ cout<<"k="<<k<<" ";
+ for(m=0;m<nodesInGraph[k].numOfConnectionSymbolBit;m++)
+ cout<<nodesInGraph[k].connectionSymbolBit[m]<<" ";
+ cout<<"LocalGirth="<<2*localGirth[k]+4;
+ cout<<endl;
+ }
+ updateConnection(k);
+ }
+
+ if(verbose) {
+ cout<<"Showing the row weight distribution..."<<endl;
+ for(i=0;i<M;i++)
+ cout<<nodesInGraph[i].numOfConnectionParityBit<<" ";
+ cout<<endl;
+ }
+ delete [] mid;
+
+ ofstream cycleFile;
+ cycleFile.open("leftHandGirth.log", ios::out);
+ localDepth=100;
+ for(k=0;k<N;k++) {
+ if(localGirth[k]<localDepth) localDepth=localGirth[k];
+ if(localDepth==100) cycleFile<<"inf ";
+ else cycleFile<<2*localDepth+4<<" ";
+ }
+ cycleFile<<endl;
+ cycleFile.close();
+
+ if(verbose) {
+ cout<<"*************************************************************"<<endl;
+ cout<<" The global girth of the PEG Tanner graph :="<< 2*localDepth+4<<endl;
+ cout<<"*************************************************************"<<endl;
+ }
+
+ loadH();
+
+}
+
+BigGirth::~BigGirth(void) {
+ if(H!=NULL) {
+ for(int i=0;i<M;i++)
+ delete [] H[i];
+ delete [] H;
+ H=NULL;
+ }
+ delete [] localGirth;
+ delete [] nodesInGraph;
+ nodesInGraph=NULL;
+ delete myrandom;
+}
+
+int BigGirth::selectParityConnect(int kthSymbol, int mthConnection, int & cycle) {
+ int i, j, k, index, mincycles, numCur, cpNumCur;
+ int *tmp, *med;
+ int *current;//take note of the covering parity bits
+
+ mincycles=0;
+ tmp=new int[M]; med=new int[M];
+
+ numCur=mthConnection;
+ current=new int[mthConnection];
+ for(i=0;i<mthConnection;i++) current[i]=nodesInGraph[kthSymbol].connectionSymbolBit[i];
+
+LOOP:
+ mincycles++;
+ for(i=0;i<M;i++) tmp[i]=0;
+ //maintain
+ for(i=0;i<mthConnection;i++) tmp[nodesInGraph[kthSymbol].connectionSymbolBit[i]]=1;
+ for(i=0;i<numCur;i++){
+ for(j=0;j<nodesInGraph[current[i]].numOfConnectionParityBit;j++){
+ for(k=0;k<nodesInGraph[nodesInGraph[current[i]].connectionParityBit[j]].numOfConnectionSymbolBit;k++){
+ tmp[nodesInGraph[nodesInGraph[current[i]].connectionParityBit[j]].connectionSymbolBit[k]]=1;
+ }
+ }
+ }
+
+ index=0; cpNumCur=0;
+ for(i=0;i<M;i++) {
+ if(tmp[i]==1) cpNumCur++;
+ if(tmp[i]==1 || nodesInGraph[i].numOfConnectionParityBit>=nodesInGraph[i].maxDegParity)
+ index++;
+ }
+ if(cpNumCur==numCur) {//can not expand any more
+ //additional handlement to select one having least connections
+ j=10000000; //dummy number
+ for(i=0;i<M;i++){
+ if(tmp[i]==0 && nodesInGraph[i].numOfConnectionParityBit<j && nodesInGraph[i].numOfConnectionParityBit<nodesInGraph[i].maxDegParity)
+ j=nodesInGraph[i].numOfConnectionParityBit;
+ }
+ for(i=0;i<M;i++){
+ if(tmp[i]==0){
+ if(nodesInGraph[i].numOfConnectionParityBit!=j || nodesInGraph[i].numOfConnectionParityBit>=nodesInGraph[i].maxDegParity){
+ tmp[i]=1;
+ }
+ }
+ }
+ index=0;
+ for(i=0;i<M;i++) if(tmp[i]==1) index++;
+ //----------------------------------------------------------------
+ j=(*myrandom).uniform(0, M-index)+1; //randomly selected
+ index=0;
+ for(i=0;i<M;i++){
+ if(tmp[i]==0) index++;
+ if(index==j) break;
+ }
+ delete [] tmp; tmp=NULL;
+ delete [] current; current=NULL;
+ return(i);
+ }
+ else if(index==M || mincycles>EXPAND_DEPTH){//covering all parity nodes or meet the upper bound on cycles
+
+ cycle=mincycles-1;
+ for(i=0;i<M;i++) tmp[i]=0;
+ for(i=0;i<numCur;i++) tmp[current[i]]=1;
+ index=0;
+ for(i=0;i<M;i++) if(tmp[i]==1) index++;
+ if(index!=numCur) {cout<<"Error in the case of (index==M)"<<endl;exit(-1);}
+ //additional handlement to select one having least connections
+ j=10000000;
+ for(i=0;i<M;i++){
+ if(tmp[i]==0 && nodesInGraph[i].numOfConnectionParityBit<j && nodesInGraph[i].numOfConnectionParityBit<nodesInGraph[i].maxDegParity)
+ j=nodesInGraph[i].numOfConnectionParityBit;
+ }
+ for(i=0;i<M;i++){
+ if(tmp[i]==0){
+ if(nodesInGraph[i].numOfConnectionParityBit!=j || nodesInGraph[i].numOfConnectionParityBit>=nodesInGraph[i].maxDegParity){
+ tmp[i]=1;
+ }
+ }
+ }
+
+ index=0;
+ for(i=0;i<M;i++) if(tmp[i]==1) index++;
+
+ j=(*myrandom).uniform(0, M-index)+1;
+ index=0;
+ for(i=0;i<M;i++){
+ if(tmp[i]==0) index++;
+ if(index==j) break;
+ }
+ delete [] tmp; tmp=NULL;
+ delete [] current; current=NULL;
+ return(i);
+ }
+ else if(cpNumCur>numCur && index!=M){
+ delete [] current;
+ current=NULL;
+ numCur=cpNumCur;
+ current=new int[numCur];
+ index=0;
+ for(i=0;i<M;i++) {
+ if(tmp[i]==1) {current[index]=i; index++;}
+ }
+ goto LOOP;
+ }
+ else {
+ cout<<"Should not come to this point..."<<endl;
+ cout<<"Error in BigGirth::selectParityConnect()"<<endl;
+ return(-1);
+ }
+}
+
+
+void BigGirth::updateConnection(int kthSymbol){
+ int i, j, m;
+ int *tmp;
+
+ for(i=0;i<nodesInGraph[kthSymbol].numOfConnectionSymbolBit;i++){
+ m=nodesInGraph[kthSymbol].connectionSymbolBit[i];//m [0, M) parity node
+ tmp=new int[nodesInGraph[m].numOfConnectionParityBit+1];
+ for(j=0;j<nodesInGraph[m].numOfConnectionParityBit;j++)
+ tmp[j]=nodesInGraph[m].connectionParityBit[j];
+ tmp[nodesInGraph[m].numOfConnectionParityBit]=kthSymbol;
+
+ delete [] nodesInGraph[m].connectionParityBit;
+ nodesInGraph[m].connectionParityBit=NULL;
+ nodesInGraph[m].numOfConnectionParityBit++; //increase by 1
+ nodesInGraph[m].connectionParityBit=new int[nodesInGraph[m].numOfConnectionParityBit];
+ for(j=0;j<nodesInGraph[m].numOfConnectionParityBit;j++)
+ nodesInGraph[m].connectionParityBit[j]=tmp[j];
+ delete [] tmp;
+ tmp=NULL;
+ }
+}
+
+void BigGirth::loadH(void){
+ int i, j;
+ if(H==NULL) {
+ H=new int*[M];
+ for(i=0;i<M;i++) H[i]=new int[N];
+ }
+
+ for(i=0;i<M;i++){
+ for(j=0;j<N;j++){
+ H[i][j]=0;
+ }
+ }
+ for(i=0;i<M;i++){
+ for(j=0;j<nodesInGraph[i].numOfConnectionParityBit;j++){
+ H[i][nodesInGraph[i].connectionParityBit[j]]=1;
+ }
+ }
+}
+
+void BigGirth::writeToFile_Hmatrix(void){
+ int i, j;
+
+ loadH();
+
+ //cout<<"---------------code format--------------------------"<<endl;
+ //cout<<"- Block length N -"<<endl;
+ //cout<<"- Num of Check Nodex M -"<<endl;
+ //cout<<"- H matrix -"<<endl;
+ //cout<<"----------------------------------------------------"<<endl;
+
+ ofstream codefile;
+ codefile.open(filename,ios::out);
+ codefile<<N<<" "<<M<<endl;
+
+ for(i=0;i<M;i++){
+ for(j=0;j<N;j++){
+ codefile<<H[i][j]<<" ";
+ }
+ codefile<<endl;
+ }
+ codefile.close();
+}
+
+void BigGirth::writeToFile_Hcompressed(void){
+ int i, j, max_col;
+ int *(*parityCheck_compressed);
+
+ //cout<<"---------------code format--------------------------"<<endl;
+ //cout<<"- Block length N -"<<endl;
+ //cout<<"- Num of Check Nodex M -"<<endl;
+ //cout<<"- Num of column in the compressed H -"<<endl;
+ //cout<<"- H matrix (compressed) -"<<endl;
+ //cout<<"----------------------------------------------------"<<endl;
+
+ //finding the num of columns, l, of the compressed parity-check matrix
+
+ max_col=0;
+ for(i=0;i<M;i++)
+ if(nodesInGraph[i].numOfConnectionParityBit>max_col)
+ max_col=nodesInGraph[i].numOfConnectionParityBit;
+
+ parityCheck_compressed=new int * [M];
+ for(i=0;i<M;i++)
+ parityCheck_compressed[i]=new int[max_col];
+ for(i=0;i<M;i++){
+ for(j=0;j<max_col;j++) parityCheck_compressed[i][j]=0;
+ for(j=0;j<nodesInGraph[i].numOfConnectionParityBit;j++){
+ parityCheck_compressed[i][j]=nodesInGraph[i].connectionParityBit[j]+1;
+ }
+ }
+
+ ofstream codefile;
+ codefile.open(filename,ios::out);
+ codefile<<N<<endl;
+ codefile<<M<<endl;
+ codefile<<max_col<<endl;
+ for(i=0;i<M;i++){
+ for(j=0;j<max_col;j++)
+ codefile<<parityCheck_compressed[i][j]<<" ";
+ codefile<<endl;
+ }
+ codefile.close();
+
+ for(i=0;i<M;i++){
+ delete [] parityCheck_compressed[i];
+ parityCheck_compressed[i]=NULL;
+ }
+ delete [] parityCheck_compressed;
+ parityCheck_compressed=NULL;
+}
+
+void BigGirth::writeToFile(void){
+ int i, j, k, d, redun;
+ int imed, max_row, index, max_col;
+ int *Index, *J, *itmp, *(*generator), *(*generator_compressed), *(*parityCheck_compressed);
+ //Gaussian Ellimination
+ Index=new int[M];
+ J=new int[N];
+ itmp=new int[N];
+ for(i=0;i<M;i++) Index[i]=0; //indicator of redudant rows
+ for(j=0;j<N;j++) J[j]=j; //column permutation
+ redun=0;//the number of redundant rows
+
+ loadH();
+
+ for(k=0;k<M;k++){
+ if(H[k][J[k-redun]]==0) {
+ d=k;
+ for(i=k+1-redun;i<N;i++)
+ if(H[k][J[i]]!=0) {d=i;break;}
+ if(d==k) {//full-zero row:delete this row
+ redun++;
+ Index[k]=1;
+ continue;
+ }
+ else {//SWAP d column and k column in H matrix
+ imed=J[k-redun];
+ J[k-redun]=J[d];
+ J[d]=imed;
+ }
+ }
+ if(H[k][J[k-redun]]==0) {
+ cout<<"ERROR: should not come to this point"<<endl;
+ exit(-1);
+ }
+ else {
+ for(i=k+1;i<M;i++){
+ if(H[i][J[k-redun]]!=0){
+ for(j=k-redun;j<N;j++)
+ H[i][J[j]]=(H[i][J[j]]+H[k][J[j]])%2;
+ }
+ }
+ }
+ }
+
+ if(verbose)
+ cout<<"Row rank of parity check matrix="<<M-redun<<endl;
+
+ K=N-M+redun;//num of the information bits
+
+ index=0;
+ for(i=0;i<M;i++){
+ if(Index[i]==0){ // all-zero row
+ for(j=0;j<N;j++)
+ itmp[j]=H[i][J[j]];
+ for(j=0;j<N;j++)
+ H[index][j]=itmp[j]; //Note: itmp can not be omitted here!!!
+ index++;
+ }
+ }
+ if(index!=M-redun) {cout<<"ERROR...if(index!=M-redun)"<<endl;exit(-1);}
+
+ for(k=index-1;k>0;k--){
+ for(i=k-1;i>=0;i--){
+ if(H[i][k]==1)
+ for(j=k;j<N;j++)
+ H[i][j]=(H[i][j]+H[k][j])%2;
+ }
+ }
+
+ if(verbose) {
+ cout<<"****************************************************"<<endl;
+ cout<<" Computing the compressed generator"<<endl;
+ cout<<"****************************************************"<<endl;
+ }
+ generator=new int * [K];
+ for(i=0;i<K;i++)
+ generator[i]=new int[N-K];
+ for(i=0;i<K;i++){
+ for(j=0;j<N-K;j++)
+ generator[i][j]=H[j][i+N-K];
+ //for(j=N-K;j<N;j++)
+ //generator[i][j]=0;
+ //generator[i][i+N-K]=1;
+ }
+ max_row=0;
+ for(j=0;j<N-K;j++){
+ imed=0;
+ for(i=0;i<K;i++)
+ imed+=generator[i][j];
+ if(imed>max_row) max_row=imed;
+ }
+ generator_compressed=new int * [max_row];
+ for(i=0;i<max_row;i++)
+ generator_compressed[i]=new int[N];
+ for(j=0;j<N-K;j++){
+ index=0;
+ for(i=0;i<max_row;i++) generator_compressed[i][j]=0;
+ for(i=0;i<K;i++){
+ if(generator[i][j]==1) {
+ generator_compressed[index][j]=i+1;
+ if(index>=max_row-1) break;
+ index++;
+ }
+ }
+ }
+ for(j=0;j<K;j++){
+ for(i=0;i<max_row;i++) generator_compressed[i][j+N-K]=0;
+ generator_compressed[0][j+N-K]=j+1;
+ }
+ if(verbose) {
+ cout<<"*****************************************************"<<endl;
+ cout<<" Computing the compressed parity-check matrix"<<endl;
+ cout<<"*****************************************************"<<endl;
+ }
+ //finding the num of columns, l, of the compressed parity-check matrix
+ loadH(); //loading parity check matrix again
+ max_col=0;
+ for(i=0;i<M;i++){
+ imed=0;
+ for(j=0;j<N;j++)
+ imed+=H[i][j];
+ if(imed>max_col) max_col=imed;
+ }
+ parityCheck_compressed=new int * [M];
+ for(i=0;i<M;i++)
+ parityCheck_compressed[i]=new int[max_col];
+ for(i=0;i<M;i++){
+ for(j=0;j<max_col;j++) parityCheck_compressed[i][j]=0;
+ index=0;
+ for(j=0;j<N;j++){
+ if(H[i][J[j]]==1) {
+ parityCheck_compressed[i][index]=j+1;
+ if(index>=max_col-1) break;
+ index++;
+ }
+ }
+ }
+ if(verbose) {
+ cout<<"****************************************************"<<endl;
+ cout<<" Write to file (TEXT!) "<<endl;
+ cout<<"****************************************************"<<endl;
+ }
+ ofstream codefile;
+ codefile.open(filename,ios::out);
+ codefile<<N<<endl;
+ codefile<<K<<endl;
+ codefile<<M<<endl;
+ codefile<<max_row<<endl;
+ codefile<<max_col<<endl;
+ for(i=0;i<max_row;i++){
+ for(j=0;j<N;j++)
+ codefile<<generator_compressed[i][j]<<" ";
+ codefile<<endl;
+ }
+ for(i=0;i<M;i++){
+ for(j=0;j<max_col;j++)
+ codefile<<parityCheck_compressed[i][j]<<" ";
+ codefile<<endl;
+ }
+ for(i=N-K;i<N;i++)
+ codefile<<i+1<<" ";
+ codefile<<endl;
+
+ codefile.close();
+ if(verbose) {
+ cout<<"****************************************************"<<endl;
+ cout<<" Free memory"<<endl;
+ cout<<"****************************************************"<<endl;
+ }
+ delete [] Index;
+ Index=NULL;
+ delete [] J;
+ J=NULL;
+ delete [] itmp;
+ itmp=NULL;
+ for(i=0;i<M;i++){
+ delete [] parityCheck_compressed[i];
+ parityCheck_compressed[i]=NULL;
+ }
+ delete [] parityCheck_compressed;
+ parityCheck_compressed=NULL;
+ for(i=0;i<max_row;i++){
+ delete [] generator_compressed[i];
+ generator_compressed[i]=NULL;
+ }
+ delete [] generator_compressed;
+ generator_compressed=NULL;
+ for(i=0;i<K;i++){
+ delete [] generator[i];
+ generator[i]=NULL;
+ }
+ delete [] generator;
+ generator=NULL;
+
+ if(verbose) {
+ cout<<"****************************************************"<<endl;
+ cout<<" OK!"<<endl;
+ cout<<"****************************************************"<<endl;
+ }
+
+}
+
diff --git a/lib/ldpc/peg/BigGirth.h b/lib/ldpc/peg/BigGirth.h
new file mode 100644
index 00000000..d30a05a1
--- /dev/null
+++ b/lib/ldpc/peg/BigGirth.h
@@ -0,0 +1,54 @@
+#ifndef BIGGIRTH
+#define BIGGIRTH 1
+
+#include <cstdlib>
+#include <iostream> // C++ I/O library header
+#include "Random.h"
+
+class NodesInGraph{
+ public:
+ int numOfConnectionParityBit;
+ int *connectionParityBit;
+ int numOfConnectionSymbolBit;
+ int *connectionSymbolBit;
+ int maxDegParity;
+
+ NodesInGraph(void);
+ ~NodesInGraph(void);
+ void setNumOfConnectionSymbolBit(int deg);
+ void initConnectionParityBit(void);
+ void initConnectionParityBit(int deg);
+};
+
+class BigGirth {
+ public:
+ int M, N;
+ int K;
+ int EXPAND_DEPTH;
+ const char *filename;
+ int *(*H);
+
+ int *localGirth;
+
+ NodesInGraph *nodesInGraph;
+ Random *myrandom;
+
+ BigGirth(int m, int n, int *symbolDegSequence, const char *filename, int sglConcent, int tgtGirth, bool verbose_ = true);
+ BigGirth(void);
+
+ void writeToFile_Hcompressed(void);
+ void writeToFile_Hmatrix(void);
+ void writeToFile(void);
+
+ void loadH(void);
+
+ ~BigGirth(void);
+
+ private:
+ int selectParityConnect(int kthSymbol, int mthConnection, int & cycle);
+ void updateConnection(int kthSymbol);
+ bool verbose;
+
+};
+
+#endif
diff --git a/lib/ldpc/peg/CodeName b/lib/ldpc/peg/CodeName
new file mode 100644
index 00000000..118a6382
--- /dev/null
+++ b/lib/ldpc/peg/CodeName
@@ -0,0 +1,68 @@
+64
+16
+48
+14
+5
+3 1 3 6 1 4 1 1 1 1 2 1 1 1 1 6 6 2 2 1 1 2 2 1 2 6 2 6 1 1 2 1 1 6 3 2 6 2 1 1 6 1 1 2 1 1 1 7 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+4 2 4 9 3 6 2 2 3 2 4 2 3 3 3 7 9 6 4 3 2 6 6 2 4 9 6 7 2 2 4 3 3 7 4 4 7 4 3 3 7 2 2 6 3 2 2 8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+6 3 6 10 4 9 4 4 4 4 5 4 4 4 4 8 10 8 5 4 3 7 7 4 6 13 9 9 4 4 5 4 4 8 6 5 8 5 4 4 9 4 4 8 4 3 4 9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+7 4 12 12 6 12 5 5 6 5 6 5 5 6 6 9 11 9 6 5 4 11 9 5 7 0 10 10 5 5 6 6 5 9 8 6 11 6 5 5 11 5 5 9 6 4 5 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+9 5 16 15 9 15 6 6 7 6 7 6 6 9 7 10 12 11 8 6 5 13 13 6 8 0 11 11 6 6 9 8 6 11 11 8 12 7 6 6 13 6 6 12 10 5 6 11 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+10 6 0 16 11 16 8 7 9 8 8 7 7 12 8 11 13 13 9 11 6 14 14 8 9 0 13 12 8 9 11 9 7 12 12 10 13 8 8 7 0 8 7 15 12 6 8 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+13 8 0 0 13 0 10 8 13 9 10 10 9 13 9 12 14 15 11 13 7 16 16 9 13 0 15 13 10 11 16 11 11 13 16 12 14 9 11 10 0 9 11 0 13 12 9 13 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+15 12 0 0 14 0 11 10 15 11 12 11 10 15 11 13 15 0 13 14 12 0 0 12 14 0 0 14 14 13 0 14 13 0 0 15 0 11 12 13 0 10 12 0 15 13 10 14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 13 0 0 15 0 12 12 16 12 14 14 14 16 14 14 0 0 15 15 14 0 0 13 0 0 0 15 15 15 0 15 14 0 0 16 0 13 13 14 0 12 14 0 16 14 11 15 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 15 0 0 16 0 14 14 0 13 15 0 16 0 16 16 0 0 16 16 15 0 0 14 0 0 0 16 0 16 0 16 16 0 0 0 0 14 15 16 0 14 15 0 0 15 12 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 16 0 0 0 0 15 15 0 15 16 0 0 0 0 0 0 0 0 0 16 0 0 15 0 0 0 0 0 0 0 0 0 0 0 0 0 15 16 0 0 15 0 0 0 16 13 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 16 0 0 16 0 0 0 0 0 0 0 0 0 0 0 0 0 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 16 0 0 0 0 14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 15 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+1 9 49 58 64
+2 39 50 59 0
+3 6 51 57 63
+4 6 52 58 0
+5 20 53 57 0
+4 37 48 60 0
+7 36 49 59 62
+8 29 55 60 0
+9 14 55 60 0
+10 30 56 60 0
+11 31 48 61 64
+12 24 48 62 0
+13 40 57 61 0
+1 35 48 62 0
+15 32 55 63 0
+16 28 56 63 0
+17 28 55 64 0
+18 27 56 58 0
+19 31 56 61 63
+5 32 56 61 0
+21 43 51 59 64
+22 23 57 59 0
+22 44 48 58 0
+12 43 58 60 63
+25 38 53 59 63
+26 41 55 59 0
+18 44 59 60 61
+17 27 50 60 62
+29 42 57 60 64
+8 30 48 63 0
+19 38 55 62 64
+15 45 48 64 0
+20 33 55 63 0
+34 41 56 60 0
+14 45 57 58 0
+11 36 55 62 0
+34 37 57 62 0
+7 47 57 61 0
+2 46 56 62 0
+33 40 58 59 0
+3 35 56 59 0
+10 47 58 62 0
+21 46 55 61 0
+23 25 52 56 64
+13 39 48 64 0
+26 54 57 61 0
+24 42 58 61 0
+16 48 54 63 0
+49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
diff --git a/lib/ldpc/peg/CyclesOfGraph.C b/lib/ldpc/peg/CyclesOfGraph.C
new file mode 100644
index 00000000..77c98b59
--- /dev/null
+++ b/lib/ldpc/peg/CyclesOfGraph.C
@@ -0,0 +1,237 @@
+#include "CyclesOfGraph.h"
+
+NodesOfGraph::NodesOfGraph(void) { parityConnections=NULL;symbolConnections=NULL;
+}
+NodesOfGraph::~NodesOfGraph(void) {
+ delete [] parityConnections;
+ delete [] symbolConnections;
+ delete [] symbolMapping;
+
+}
+
+void NodesOfGraph::setParityConnections(int num, int *value) {
+ numOfParityConnections=num;
+ parityConnections=new int[num];
+ for(int i=0;i<numOfParityConnections;i++){
+ parityConnections[i]=value[i];
+ //cout<<parityConnections[i]<<" ";
+ }
+ //cout<<endl;
+}
+void NodesOfGraph::setSymbolConnections(int num, int *value) {
+ numOfSymbolConnections=num;
+ symbolConnections=new int[num];
+ for(int i=0;i<numOfSymbolConnections;i++){
+ symbolConnections[i]=value[i];
+ //cout<<symbolConnections[i]<<" ";
+ }
+ //cout<<endl;
+}
+void NodesOfGraph::setSymbolMapping(int num, int *value) {
+ numOfSymbolMapping=num;
+ //cout<<num<<endl;
+ symbolMapping=new int[num];
+ for(int i=0;i<numOfSymbolMapping;i++){
+ symbolMapping[i]=value[i];
+ //cout<<symbolMapping[i]<<" ";
+ }
+ //cout<<endl;
+}
+
+CyclesOfGraph::CyclesOfGraph(int mm, int n, int *(*h)){
+ int i, j, k, m, index;
+ M=mm;
+ N=n;
+ H=h;
+
+ tmp=new int [N];
+ med=new int [N];
+ tmpCycles=new int [N];
+ cyclesTable=new int [N];
+ nodesOfGraph=new NodesOfGraph [N];
+
+ //cout<<M<<" "<<N<<endl;
+ /*
+ for(i=0;i<M;i++){
+ for(j=0;j<N;j++)
+ cout<<H[i][j]<<" ";
+ cout<<endl;
+ }
+ */
+ for(i=0;i<N;i++){
+ index=0;
+ for(j=0;j<M;j++){
+ if(H[j][i]==1){
+ tmp[index]=j;
+ index++;
+ }
+ }
+ nodesOfGraph[i].setSymbolConnections(index, tmp);
+ }
+ for(i=0;i<M;i++){
+ index=0;
+ for(j=0;j<N;j++){
+ if(H[i][j]==1){
+ tmp[index]=j;
+ index++;
+ }
+ }
+ nodesOfGraph[i].setParityConnections(index, tmp);
+ }
+ for(i=0;i<N;i++){
+ index=0;
+ for(j=0;j<nodesOfGraph[i].numOfSymbolConnections;j++){
+ for(k=0;k<nodesOfGraph[nodesOfGraph[i].symbolConnections[j]].numOfParityConnections;k++){
+ int t=0;
+ for(m=0;m<index;m++){
+ if(nodesOfGraph[nodesOfGraph[i].symbolConnections[j]].parityConnections[k]==tmp[m]){
+ t=1; break;
+ }
+ }
+ if(nodesOfGraph[nodesOfGraph[i].symbolConnections[j]].parityConnections[k]==i) t=1;
+ if(t==0) {
+ tmp[index]=nodesOfGraph[nodesOfGraph[i].symbolConnections[j]].parityConnections[k];
+ index++;
+ }
+ }
+ }
+ nodesOfGraph[i].setSymbolMapping(index, tmp);
+ }
+}
+
+CyclesOfGraph::~CyclesOfGraph(void){
+ delete [] tmp;
+ tmp=NULL;
+ delete [] med;
+ med=NULL;
+ delete [] tmpCycles;
+ tmpCycles=NULL;
+ delete [] cyclesTable;
+ cyclesTable=NULL;
+ delete [] nodesOfGraph;
+ nodesOfGraph=NULL;
+}
+
+void CyclesOfGraph::getCyclesTable(void) {
+ int i, j, k, m, n, t, imed;
+ for(i=0;i<N;i++){
+ //special handlement for nodes having only one or zero connections
+ if(nodesOfGraph[i].numOfSymbolConnections<=1) {
+ cyclesTable[i]=2*N;
+ continue;
+ }
+ for(j=0;j<nodesOfGraph[i].numOfSymbolConnections-1;j++){ //-1 because the graph is undirected
+ for(k=0;k<nodesOfGraph[nodesOfGraph[i].symbolConnections[j]].numOfParityConnections;k++){
+ tmp[k]=nodesOfGraph[nodesOfGraph[i].symbolConnections[j]].parityConnections[k];
+ //cout<<tmp[k]<<" ";
+ }
+ //cout<<endl;
+ int cycles=2;
+ int index=nodesOfGraph[nodesOfGraph[i].symbolConnections[j]].numOfParityConnections;
+ LOOP:
+ imed=0;
+ for(k=0;k<index;k++){
+ if(tmp[k]==i) continue;
+ //cout<<"k="<<k<<" "<<tmp[k]<<endl;
+ for(m=0;m<nodesOfGraph[tmp[k]].numOfSymbolConnections;m++){
+ for(n=0;n<nodesOfGraph[i].numOfSymbolConnections;n++){
+ if((n!=j)&&(nodesOfGraph[tmp[k]].symbolConnections[m]==nodesOfGraph[i].symbolConnections[n])){
+ cycles+=2;
+ goto OUTLOOP;
+ }
+ }
+ }
+ for(m=0;m<nodesOfGraph[tmp[k]].numOfSymbolMapping;m++){
+ t=0;
+ for(int l=0;l<imed;l++) {
+ if(nodesOfGraph[tmp[k]].symbolMapping[m]==med[l]){
+ t=1; break;
+ }
+ }
+ if(t==0){
+ med[imed]=nodesOfGraph[tmp[k]].symbolMapping[m];
+ //cout<<med[imed]<<endl;
+ imed++;
+ }
+ }
+ }
+ index=imed;//cout<<index<<" "<<endl;
+ for(k=0;k<index;k++) {
+ tmp[k]=med[k];//cout<<tmp[k]<<" ";
+ }
+ //cout<<"j="<<j<<endl;
+ cycles+=2;
+ if(cycles>=2*N) //dead lock
+ goto OUTLOOP;
+ else
+ goto LOOP;
+ OUTLOOP:
+ tmpCycles[j]=cycles;
+ }
+ //for(j=0;j<nodesOfGraph[i].numOfSymbolConnections-1;j++) cout<<tmpCycles[j]<<" ";
+ //cout<<endl;
+ cyclesTable[i]=tmpCycles[0];
+ for(j=1;j<nodesOfGraph[i].numOfSymbolConnections-1;j++){
+ if(cyclesTable[i]>tmpCycles[j])
+ cyclesTable[i]=tmpCycles[j];
+ }
+ //OUTPUT cycles per symbol node
+ //cout<<"i="<<i<<" "<<cyclesTable[i]<<endl;
+ }
+}
+
+int CyclesOfGraph::girth(void) {
+ int girth=2*N;
+ for(int i=0;i<N;i++)
+ if(girth>cyclesTable[i]) girth=cyclesTable[i];
+ return(girth);
+}
+
+void CyclesOfGraph::printCyclesTable(void){
+ using namespace std;
+ int i, temp[20];
+ /*
+ for(i=0;i<N;i++)
+ cout<<cyclesTable[i]<<" ";
+ cout<<endl;
+ */
+ for(i=0;i<20;i++) temp[i]=0;
+ for(i=0;i<N;i++){
+ if(cyclesTable[i]==4) temp[0]++;
+ else if(cyclesTable[i]==6) temp[1]++;
+ else if(cyclesTable[i]==8) temp[2]++;
+ else if(cyclesTable[i]==10) temp[3]++;
+ else if(cyclesTable[i]==12) temp[4]++;
+ else if(cyclesTable[i]==14) temp[5]++;
+ else if(cyclesTable[i]==16) temp[6]++;
+ else if(cyclesTable[i]==18) temp[7]++;
+ else if(cyclesTable[i]==20) temp[8]++;
+ else if(cyclesTable[i]==22) temp[9]++;
+ else if(cyclesTable[i]==24) temp[10]++;
+ else if(cyclesTable[i]==26) temp[11]++;
+ else if(cyclesTable[i]==28) temp[12]++;
+ else if(cyclesTable[i]==30) temp[13]++;
+ else {
+ cout<<"Wrong cycles calculation "<<cyclesTable[i]<<endl;
+ exit(-1);
+ }
+ }
+ cout<<endl;
+ cout<<"Num of Nodes with local girth 4: "<< temp[0]<<endl;
+ cout<<"Num of Nodes with local girth 6: "<< temp[1]<<endl;
+ cout<<"Num of Nodes with local girth 8: "<< temp[2]<<endl;
+ cout<<"Num of Nodes with local girth 10: "<< temp[3]<<endl;
+ cout<<"Num of Nodes with local girth 12: "<< temp[4]<<endl;
+ cout<<"Num of Nodes with local girth 14: "<< temp[5]<<endl;
+ cout<<"Num of Nodes with local girth 16: "<< temp[6]<<endl;
+ cout<<"Num of Nodes with local girth 18: "<< temp[7]<<endl;
+ cout<<"Num of Nodes with local girth 20: "<< temp[8]<<endl;
+ cout<<"Num of Nodes with local girth 22: "<< temp[9]<<endl;
+ cout<<"Num of Nodes with local girth 24: "<< temp[10]<<endl;
+ cout<<"Num of Nodes with local girth 26: "<< temp[11]<<endl;
+ cout<<"Num of Nodes with local girth 28: "<< temp[12]<<endl;
+ cout<<"Num of Nodes with local girth 30: "<< temp[13]<<endl;
+}
+
+
+
diff --git a/lib/ldpc/peg/CyclesOfGraph.h b/lib/ldpc/peg/CyclesOfGraph.h
new file mode 100644
index 00000000..9105537b
--- /dev/null
+++ b/lib/ldpc/peg/CyclesOfGraph.h
@@ -0,0 +1,40 @@
+#ifndef CYCLESOFGRAPH
+#define CYCLESOFGRAPH 1
+
+#include <cstdlib>
+#include <iostream> // C++ I/O library header
+//#include <iomanip.h>
+
+class NodesOfGraph{
+ public:
+ int numOfParityConnections;
+ int *parityConnections;
+ int numOfSymbolConnections;
+ int *symbolConnections;
+ int numOfSymbolMapping;
+ int *symbolMapping;
+ NodesOfGraph(void);
+ ~NodesOfGraph(void);
+ void setParityConnections(int num, int *value);
+ void setSymbolConnections(int num, int *value);
+ void setSymbolMapping(int num, int *values);
+}; //Why this is necessary?
+
+class CyclesOfGraph {
+ public:
+ int M, N;
+ int *(*H);
+ int *cyclesTable;
+ NodesOfGraph *nodesOfGraph;
+ CyclesOfGraph(int mm, int n, int *(*h));
+ ~CyclesOfGraph(void);
+ void getCyclesTable(void);
+ void printCyclesTable(void);
+ int girth(void);
+ private:
+ int *tmp, *med, *tmpCycles;
+};
+
+#endif
+
+
diff --git a/lib/ldpc/peg/DenEvl_11.deg b/lib/ldpc/peg/DenEvl_11.deg
new file mode 100644
index 00000000..18a77197
--- /dev/null
+++ b/lib/ldpc/peg/DenEvl_11.deg
@@ -0,0 +1,3 @@
+4
+ 2 3 4 11
+0.450013 0.370771 0.0307238 0.1484922
diff --git a/lib/ldpc/peg/DenEvl_15.deg b/lib/ldpc/peg/DenEvl_15.deg
new file mode 100644
index 00000000..3af8369d
--- /dev/null
+++ b/lib/ldpc/peg/DenEvl_15.deg
@@ -0,0 +1,3 @@
+7
+2 3 4 5 7 14 15
+0.477081 0.280572 0.0349963 0.0963301 0.0090884 0.00137443 0.10055777
diff --git a/lib/ldpc/peg/DenEvl_20.deg b/lib/ldpc/peg/DenEvl_20.deg
new file mode 100644
index 00000000..174d6465
--- /dev/null
+++ b/lib/ldpc/peg/DenEvl_20.deg
@@ -0,0 +1,4 @@
+9
+2 3 4 6 7 8 9 19 20
+0.457827 0.323775 0.0214226 0.0592851 0.0389015 0.0248109 0.00884569
+0.0176697 0.04746251
diff --git a/lib/ldpc/peg/DenEvl_7.deg b/lib/ldpc/peg/DenEvl_7.deg
new file mode 100644
index 00000000..feb53aee
--- /dev/null
+++ b/lib/ldpc/peg/DenEvl_7.deg
@@ -0,0 +1,3 @@
+3
+ 2 3 7
+0.521814 0.271293 0.206893
diff --git a/lib/ldpc/peg/DenEvl_9.deg b/lib/ldpc/peg/DenEvl_9.deg
new file mode 100644
index 00000000..3072b205
--- /dev/null
+++ b/lib/ldpc/peg/DenEvl_9.deg
@@ -0,0 +1,3 @@
+3
+ 2 3 9
+0.491281 0.335305 0.173414
diff --git a/lib/ldpc/peg/MainPEG.C b/lib/ldpc/peg/MainPEG.C
new file mode 100644
index 00000000..18600139
--- /dev/null
+++ b/lib/ldpc/peg/MainPEG.C
@@ -0,0 +1,200 @@
+/************************************************************************/
+/* */
+/* Free software: Progressive edge-growth (PEG) algorithm */
+/* Created by Xiaoyu Hu */
+/* Evangelos Eletheriou */
+/* Dieter Arnold */
+/* IBM Research, Zurich Research Lab., Switzerland */
+/* */
+/* The C++ sources files have been compiled using xlC compiler */
+/* at IBM RS/6000 running AIX. For other compilers and platforms,*/
+/* minor changes might be needed. */
+/* */
+/* Bug reporting to: xhu@zurich.ibm.com */
+/**********************************************************************/
+
+////
+// Modified by F. P. Beekhof; 2008 / 08 / 19
+////
+
+#include <cstdlib>
+#include <cstring>
+#include <string>
+#include <iostream>
+#include <iomanip>
+#include <fstream>
+#include <cmath>
+#include <vector>
+#include "BigGirth.h"
+#include "Random.h"
+#include "CyclesOfGraph.h"
+
+const double EPS = 1e-6;
+
+using namespace std;
+
+void usage()
+{
+ cout<<"*******************************************************************************************"<<endl;
+ cout<<" Usage Reminder: MainPEG -numM M -numN N -codeName CodeName -degFileName DegFileName " <<endl;
+ cout<<" option: -sglConcent SglConcent " <<endl;
+ cout<<" sglConcent==0 ----- strictly concentrated parity-check " <<endl;
+ cout<<" degree distribution (including regular graphs)" <<endl;
+ cout<<" sglConcent==1 ----- Best-effort concentrated (DEFAULT) " <<endl;
+ cout<<" option: -tgtGirth TgtGirth " <<endl;
+ cout<<" TgtGirth==4, 6 ...; if very large, then greedy PEG (DEFAULT) " <<endl;
+ cout<<" IF sglConcent==0, TgtGirth is recommended to be set relatively small" <<endl;
+ cout<<" option: -q " <<endl;
+ cout<<" Quiet mode. Produces less output to the screen. " <<endl;
+ cout<<" option: -outputMode <0,1,2> " <<endl;
+ cout<<" Specifies output format. " <<endl;
+ cout<<" '0': H in compressed format (default) " <<endl;
+ cout<<" '1': H in un-compressed format " <<endl;
+ cout<<" '2': G and H in compressed format " <<endl;
+ cout<<" " <<endl;
+ cout<<" Remarks: File CodeName stores the generated PEG Tanner graph. The first line contains"<<endl;
+ cout<<" the block length, N. The second line defines the number of parity-checks, M."<<endl;
+ cout<<" The third line defines the number of columns of the compressed parity-check "<<endl;
+ cout<<" matrix. The following M lines are then the compressed parity-check matrix. "<<endl;
+ cout<<" Each of the M rows contains the indices (1 ... N) of 1's in the compressed "<<endl;
+ cout<<" row of parity-check matrix. If not all column entries are used, the column "<<endl;
+ cout<<" is filled up with 0's. "<<endl;
+ cout<<" "<<endl;
+ cout<<" If both G and H are in the output, (outMode 2), the first line contains"<<endl;
+ cout<<" N, the 2nd line K, the number of message bits, the 3rd line M, the 4th line"<<endl;
+ cout<<" contains the number of rows of the compressed generator matrix; the 5th"<<endl;
+ cout<<" defines the number of columns of the compressed parity-check matrix. The"<<endl;
+ cout<<" format of G is almost like that of H, but vertical -- i.e. the padding"<<endl;
+ cout<<" zeroes are on the bottom. "<<endl;
+
+ cout<<" "<<endl;
+ cout<<" File DegFileName is the input file to specify the degree distribution (node "<<endl;
+ cout<<" perspective). The first line contains the number of various degrees. The second"<<endl;
+ cout<<" defines the row vector of degree sequence in the increasing order. The vector"<<endl;
+ cout<<" of fractions of the corresponding degree is defined in the last line. "<<endl;
+ cout<<" "<<endl;
+ cout<<" A log file called 'leftHandGirth.dat' will also be generated and stored in the"<<endl;
+ cout<<" current directory, which gives the girth of the left-hand subgraph of j, where"<<endl;
+ cout<<" 1<=j<=N. The left-hand subgraph of j is defined as all the edges emanating from"<<endl;
+ cout<<" bit nodes {1 ... j} and their associated nodes. "<<endl;
+ cout<<" "<<endl;
+ cout<<" The last point is, when strictly concentrated parity-check degree distribution"<<endl;
+ cout<<" is invoked, i.e. sglConcent==0, the girth might be weaken to some extent as "<<endl;
+ cout<<" compared to the generic PEG algorithm. "<<endl;
+ cout<<"**********************************************************************************************"<<endl;
+ exit(-1);
+}
+
+int main(int argc, char * argv[]){
+ int sglConcent=1; // default to non-strictly concentrated parity-check distribution
+ int targetGirth=100000; // default to greedy PEG version
+ std::string codeName, degFileName;
+ int M = -1, N = -1;
+ bool verbose = true;
+
+ const int OUTPUT_MODE_H_COMPRESSED = 0;
+ const int OUTPUT_MODE_H = 1;
+ const int OUTPUT_MODE_G_H_COMPRESSED = 2;
+ int output_mode = OUTPUT_MODE_H_COMPRESSED; // default
+
+ if (argc<9) {
+ usage();
+ }else {
+ for(int i=1;i<argc;++i){
+ if (strcmp(argv[i], "-numM")==0) {
+ if (++i >= argc) usage();
+ M=atoi(argv[i]);
+ } else if(strcmp(argv[i], "-numN")==0) {
+ if (++i >= argc) usage();
+ N=atoi(argv[i]);
+ } else if(strcmp(argv[i], "-codeName")==0) {
+ if (++i >= argc) usage();
+ codeName = argv[i];
+ } else if(strcmp(argv[i], "-degFileName")==0) {
+ if (++i >= argc) usage();
+ degFileName = argv[i];
+ } else if(strcmp(argv[i], "-sglConcent")==0) {
+ if (++i >= argc) usage();
+ sglConcent=atoi(argv[i]);
+ } else if(strcmp(argv[i], "-tgtGirth")==0) {
+ if (++i >= argc) usage();
+ targetGirth=atoi(argv[i]);
+ } else if(strcmp(argv[i], "-outputMode")==0) {
+ if (++i >= argc) usage();
+ output_mode=atoi(argv[i]);
+ } else if(strcmp(argv[i], "-q")==0) {
+ verbose=false;
+ } else{
+ usage();
+ }
+ }
+ if (M == -1 || N == -1) {
+ cout<<"Error: M or N not specified!"<<endl;
+ exit(-1);
+ }
+ if (M>N) {
+ cout<<"Error: M must be smaller than N!"<<endl;
+ exit(-1);
+ }
+ }
+
+ std::vector<int> degSeq(N);
+
+ ifstream infn(degFileName.c_str());
+ if (!infn) {cout << "\nCannot open file " << degFileName << endl; exit(-1); }
+ int m;
+ infn >>m;
+ std::vector<int> deg(m);
+ std::vector<double> degFrac(m);
+ for(int i=0;i<m;i++) infn>>deg[i];
+ for(int i=0;i<m;i++) infn>>degFrac[i];
+ infn.close();
+ double dtmp=0.0;
+ for(int i=0;i<m;i++) dtmp+=degFrac[i];
+ cout.setf(ios::fixed, ios::floatfield);
+ if(abs(dtmp-1.0)>EPS) {
+ cout.setf(ios::fixed, ios::floatfield);
+ cout <<"\n Invalid degree distribution (node perspective): sum != 1.0 but "<<setprecision(10)<<dtmp<<endl; exit(-1);
+ }
+ for(int i=1;i<m;++i) degFrac[i]+=degFrac[i-1];
+ for(int i=0;i<N;++i) {
+ dtmp=double(i)/double(N);
+ int j;
+ for(j=m-1;j>=0;--j) {
+ if(dtmp>degFrac[j]) break;
+ }
+ if(dtmp<degFrac[0]) degSeq[i]=deg[0];
+ else degSeq[i]=deg[j+1];
+ }
+
+ BigGirth bigGirth(M, N, &degSeq[0], codeName.c_str(),
+ sglConcent, targetGirth, verbose);
+
+ switch(output_mode)
+ {
+ case OUTPUT_MODE_H_COMPRESSED: bigGirth.writeToFile_Hcompressed(); break;
+ case OUTPUT_MODE_H: // different output format
+ bigGirth.writeToFile_Hmatrix(); break;
+ case OUTPUT_MODE_G_H_COMPRESSED:
+ // different output format: including generator matrix (compressed)
+ bigGirth.writeToFile(); break;
+ default:
+ cout << "Error: invalid output mode specified." << endl << endl;
+ usage();
+ }
+
+ //computing local girth distribution
+
+ if (verbose && N<10000) {
+ cout<<" Now computing the local girth on the global Tanner graph setting. "<<endl;
+ cout<<" might take a bit long time. Please wait ... "<<endl;
+ bigGirth.loadH();
+ CyclesOfGraph cog(M, N, bigGirth.H);
+ cog.getCyclesTable();
+ cog.printCyclesTable();
+ }
+}
+
+
+
+
diff --git a/lib/ldpc/peg/Makefile b/lib/ldpc/peg/Makefile
new file mode 100644
index 00000000..7d6aa5ae
--- /dev/null
+++ b/lib/ldpc/peg/Makefile
@@ -0,0 +1,29 @@
+# GCC Makefile for: PEG-ECC by Xiao-Yu Hu.
+# http://www.inference.phy.cam.ac.uk/mackay/PEG_ECC.html
+#
+# Tested with on Linux 2.4 and 2.6 (i686) with
+# GCC versions 3.2.2, 3.3.5 and GNU Make version 3.80.
+#
+# Simeon Miteff <simeon@up.ac.za>
+# Thu May 12 12:38:41 SAST 2005
+
+PROGRAM = MainPEG
+OBJECTS = MainPEG.o Random.o CyclesOfGraph.o BigGirth.o
+
+CXX = g++
+CXXFLAGS = -g -ansi -pedantic -Wno-deprecated -Wall -O2
+#CXXFLAGS = -g -ansi -pedantic -Wall -march=native -ftree-vectorize -O3
+
+.SUFFIXES: .o .C
+
+all: ${OBJECTS}
+ $(CXX) -o ${PROGRAM} ${OBJECTS}
+
+.C.o: $<
+ $(CXX) ${CXXFLAGS} -c $< -o $@
+
+.PHONY : clean
+
+clean:
+ rm -f ${OBJECTS} ${PROGRAM} *~ *.log
+
diff --git a/lib/ldpc/peg/Random.C b/lib/ldpc/peg/Random.C
new file mode 100644
index 00000000..3c5d5438
--- /dev/null
+++ b/lib/ldpc/peg/Random.C
@@ -0,0 +1,101 @@
+
+#include <cmath>
+#include <algorithm>
+#include "Random.h"
+
+void Random::bubbleSort(int a[], int size)
+{
+ for(int pass=1; pass<size; pass++) {
+ for(int i=0;i<size-pass;i++)
+ if(a[i]>a[i+1]){
+ std::swap(a[i], a[i+1]);
+ }
+ }
+}
+
+double Random::gauss(double sdev, double mean)
+{
+ double sum=0.0;
+ for (int i=1;i<=12;++i)
+ {
+ seed_u = 1664525lu * seed_u + 123456789lu;
+ sum+=double(seed_u);
+ }
+ return (sum/4.29497e9-6.0)*sdev+mean;
+}
+
+double Random::uniform(double a, double b)
+{
+ double t;
+ for(int i=0; i<10;i++){
+ seed=2045*seed+1;
+ //seed=seed -(seed/1048576)*1048576;
+ seed%=1048576;
+ }
+ t=seed/1048576.0;
+ t=a+(b-a)*t;
+ return(t);
+}
+
+int Random::uniform(int a, int b) // [a, b-1]
+{
+ double t;
+ int i, tt;
+ if(b==a+1) return(a);
+ for(i=0; i<10;i++){
+ seed=2045*seed+1;
+ //seed=seed -(seed/1048576)*1048576;
+ seed%=1048576;
+ }
+ t=seed/1048576.0;
+ t=a+(b-a)*t;
+ tt=(int)t;
+ if(tt<a) tt=a;
+ else if(tt>=b) tt=b-1;
+ return(tt);
+}
+
+int Random::nonUniform(int a, int b) // [a, b-1]
+{
+ double t;
+ int i, tt;
+ if(b==a+1) return(a);
+ for(i=0; i<10;i++){
+ seed=2045*seed+1;
+ //seed=seed -(seed/1048576)*1048576;
+ seed%=1048576;
+ }
+ t=seed/1048576.0;
+ t=a+(b-a)*pow(t, 0.6667); //t^1.5
+ tt=(int)t;
+ if(tt<a) tt=a;
+ else if(tt>=b) tt=b-1;
+ return(tt);
+}
+
+/*
+void m_uniform(int a , int b, long int *seed, int *itmp, int num)
+{
+ int index, imed, i, k;
+
+ index=0;
+ itmp[0]=uniform(a, b, seed);
+ Loop1:
+ imed=uniform(a, b, seed);
+ k=0;
+ for(i=0;i<=index;i++)
+ if(imed==itmp[i]) {k=1; break;}
+ if(k==0) {index++; itmp[index]=imed;}
+ if(index<num-1) goto Loop1;
+ bubble(itmp, num); //bubble sorting
+}
+*/
+
+
+
+
+
+
+
+
+
diff --git a/lib/ldpc/peg/Random.h b/lib/ldpc/peg/Random.h
new file mode 100644
index 00000000..ef22bfd3
--- /dev/null
+++ b/lib/ldpc/peg/Random.h
@@ -0,0 +1,29 @@
+
+#ifndef RANDOM
+#define RANDOM 1
+
+#include <cstdlib>
+// #include <iostream>
+
+class Random{
+ private:
+
+ unsigned long int seed; //previously LONG INT
+ unsigned long int seed_u;
+
+ public:
+
+ Random(void) {
+ this->seed=987654321u;
+ this->seed_u=123456789lu;
+ }
+ ~Random(void){;}
+ void bubbleSort(int a[], int size);
+ double gauss(double sdev, double mean);
+ double uniform(double a, double b);
+ int uniform(int a, int b); // [a, b)
+ int nonUniform(int a, int b);
+
+};
+
+#endif
diff --git a/lib/ldpc/peg/Reg_2.deg b/lib/ldpc/peg/Reg_2.deg
new file mode 100644
index 00000000..28d2c8f1
--- /dev/null
+++ b/lib/ldpc/peg/Reg_2.deg
@@ -0,0 +1,3 @@
+1
+2
+1.0
diff --git a/lib/ldpc/peg/Reg_3.deg b/lib/ldpc/peg/Reg_3.deg
new file mode 100644
index 00000000..0fb5a574
--- /dev/null
+++ b/lib/ldpc/peg/Reg_3.deg
@@ -0,0 +1,3 @@
+1
+3
+1.0
diff --git a/lib/ldpc/peg/Reg_4.deg b/lib/ldpc/peg/Reg_4.deg
new file mode 100644
index 00000000..b42df500
--- /dev/null
+++ b/lib/ldpc/peg/Reg_4.deg
@@ -0,0 +1,3 @@
+1
+4
+1.0
diff --git a/lib/ldpc/peg/ldpc-peg-128-80.alist b/lib/ldpc/peg/ldpc-peg-128-80.alist
new file mode 100644
index 00000000..a25da9a3
--- /dev/null
+++ b/lib/ldpc/peg/ldpc-peg-128-80.alist
@@ -0,0 +1,180 @@
+48 128
+9 4
+9 9 9 9 9 8 8 8 8 8 9 9 8 8 9 9 8 8 8 8 9 9 9 8 9 9 9 9 9 9 8 8 8 9 8 9 9 9 8 9 8 8 8 9 8 8 8 9
+3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
+1 17 34 51 66 81 99 111 124
+2 18 35 50 67 82 100 112 125
+3 19 36 52 68 82 101 111 126
+2 20 36 51 69 83 102 113 127
+4 19 37 53 66 84 103 114 128
+5 21 38 54 70 85 92 114 0
+6 22 39 55 66 85 96 110 0
+7 23 32 56 71 86 103 115 0
+8 20 40 55 72 86 104 116 0
+9 19 41 57 73 87 105 116 0
+10 24 36 56 74 88 105 117 125
+10 17 33 47 75 89 106 118 128
+11 21 42 51 76 87 107 119 0
+1 25 40 58 74 84 107 113 0
+12 22 42 49 77 90 108 118 125
+13 26 43 59 68 89 104 120 124
+13 22 44 57 75 91 109 113 0
+12 23 37 46 78 88 107 112 0
+3 27 34 60 65 87 109 118 0
+6 27 45 61 79 89 98 112 0
+14 28 34 62 72 92 106 112 127
+8 27 42 59 71 92 110 121 126
+15 20 46 57 79 93 101 115 124
+9 29 45 62 74 94 108 121 0
+8 30 38 63 73 95 109 111 128
+16 29 47 64 69 96 109 117 126
+16 23 48 63 76 94 110 116 125
+7 25 39 52 70 97 106 117 124
+4 26 45 63 67 83 90 119 123
+15 28 39 50 76 88 103 121 123
+15 26 33 58 65 97 102 122 0
+14 31 47 52 77 81 93 116 0
+14 24 37 61 71 82 99 122 0
+4 31 40 54 80 91 106 115 122
+5 32 41 58 77 98 104 117 0
+9 18 49 65 79 85 104 119 128
+10 30 43 60 69 84 108 115 123
+1 18 43 48 73 91 98 114 127
+3 21 46 64 67 86 108 113 0
+5 24 48 55 75 93 107 120 126
+2 32 44 62 80 95 99 114 0
+16 28 41 59 80 83 100 118 0
+11 33 35 53 72 96 105 111 0
+11 25 44 60 78 90 100 120 122
+6 31 35 56 70 95 102 121 0
+12 17 50 54 68 94 105 119 0
+13 29 38 53 78 97 110 123 0
+7 30 49 61 64 81 101 120 127
+1 14 38 0
+2 4 41 0
+3 19 39 0
+5 29 34 0
+6 35 40 0
+7 20 45 0
+8 28 48 0
+9 22 25 0
+10 24 36 0
+11 12 37 0
+13 43 44 0
+15 18 46 0
+16 17 47 0
+21 32 33 0
+23 30 31 0
+26 27 42 0
+1 12 46 0
+2 36 38 0
+3 5 10 0
+4 9 23 0
+6 13 39 0
+7 15 17 0
+8 18 27 0
+11 33 40 0
+14 28 44 0
+16 29 31 0
+19 20 22 0
+21 30 42 0
+24 26 47 0
+25 37 48 0
+32 34 45 0
+8 35 41 0
+12 31 43 0
+1 19 21 0
+2 43 45 0
+3 4 11 0
+5 18 33 0
+6 25 47 0
+7 28 30 0
+9 14 34 0
+10 35 42 0
+13 15 22 0
+16 37 38 0
+17 41 44 0
+20 24 29 0
+18 23 39 0
+12 26 32 0
+27 38 40 0
+15 36 48 0
+2 30 46 0
+1 4 13 0
+3 28 32 0
+5 43 47 0
+6 34 46 0
+7 9 40 0
+8 11 45 0
+10 17 23 0
+14 31 35 0
+16 22 42 0
+19 37 44 0
+20 33 48 0
+21 24 41 0
+25 27 29 0
+26 39 48 0
+19 31 36 0
+1 5 7 0
+2 29 39 0
+3 16 46 0
+4 26 37 0
+6 28 45 0
+8 22 33 0
+9 21 43 0
+10 25 38 0
+11 14 24 0
+12 17 40 0
+13 27 30 0
+15 32 35 0
+18 44 47 0
+20 23 36 0
+34 41 42 0
+1 32 48 0
+2 3 33 0
+4 29 42 0
+5 14 37 0
+6 7 36 0
+8 9 39 0
+10 13 19 0
+11 18 30 0
+12 16 20 0
+15 29 44 0
+17 34 38 0
+6 21 22 0
+23 32 40 0
+24 27 46 0
+25 41 45 0
+7 26 43 0
+28 31 47 0
+20 35 38 0
+1 33 41 0
+2 42 44 0
+3 23 48 0
+4 31 45 0
+5 8 30 0
+9 16 35 36
+10 11 43 46
+12 21 28 34
+13 14 18 40
+15 24 37 39
+17 19 25 26
+7 22 27 47
+1 3 25 43
+2 18 20 21
+4 14 17 39
+5 6 38 41
+8 23 34 37
+9 10 27 32
+11 26 28 35
+12 15 19 42
+13 29 36 46
+16 40 44 48
+22 24 30 45
+31 33 34 44
+29 30 37 47
+1 16 23 28
+2 11 15 27
+3 22 26 40
+4 21 38 48
+5 12 25 36
diff --git a/lib/ldpc/peg/peg-128-64-reg4.alist b/lib/ldpc/peg/peg-128-64-reg4.alist
new file mode 100644
index 00000000..30c8edf9
--- /dev/null
+++ b/lib/ldpc/peg/peg-128-64-reg4.alist
@@ -0,0 +1,196 @@
+64 128
+9 4
+8 8 8 8 9 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 7 8 8 8 8 7 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 9 8 8 8 8 8 8 8
+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
+1 17 33 50 67 83 98 114 0
+2 18 34 50 68 84 99 115 0
+3 19 35 51 69 85 100 115 0
+4 20 36 52 70 86 101 115 0
+2 20 35 53 71 87 102 113 128
+5 21 33 54 64 88 103 116 0
+6 19 37 55 72 89 98 117 0
+7 22 38 56 73 90 96 116 0
+8 23 34 57 72 91 104 118 0
+7 24 39 58 74 84 100 119 0
+9 22 40 59 74 92 105 120 0
+9 25 41 55 75 91 106 114 0
+10 25 36 51 67 74 107 121 0
+11 22 36 54 72 93 102 122 0
+12 25 42 60 76 89 103 123 0
+8 26 38 51 77 93 105 124 0
+13 27 40 61 77 94 99 119 0
+13 17 43 54 73 85 108 124 0
+1 28 40 62 71 84 108 125 0
+12 29 38 53 67 86 108 126 0
+14 28 43 51 78 94 96 117 0
+11 17 42 62 79 92 104 126 0
+4 29 39 57 65 87 109 116 0
+2 27 38 55 78 79 107 127 0
+13 24 44 53 66 83 103 117 0
+15 30 43 55 67 90 105 128 0
+6 22 45 48 78 88 106 119 0
+14 25 33 63 65 73 99 118 0
+6 31 46 64 80 95 102 125 0
+5 18 37 65 79 94 110 113 0
+14 23 44 59 71 88 111 123 0
+13 32 47 62 70 91 109 128 0
+15 23 41 56 76 95 112 0 0
+11 29 41 47 68 69 105 117 0
+10 30 37 64 73 86 111 119 0
+5 32 45 60 69 96 101 127 0
+15 24 48 62 65 96 97 115 0
+3 23 42 64 77 83 109 0 0
+16 18 40 52 69 89 102 112 0
+9 20 49 63 76 94 109 121 0
+15 20 33 66 77 84 110 127 0
+10 21 44 60 80 82 112 126 0
+16 26 41 58 81 92 107 125 0
+3 27 48 59 82 95 110 118 0
+10 27 49 57 71 89 101 124 0
+4 26 42 61 68 90 100 122 0
+6 26 44 50 75 85 101 118 0
+7 28 37 47 66 76 82 114 0
+12 19 43 52 80 88 104 121 0
+2 31 47 56 75 93 108 123 0
+1 31 36 59 81 87 104 124 0
+3 32 39 50 81 97 106 121 0
+12 24 34 54 79 90 98 120 0
+1 19 49 56 82 92 103 122 0
+7 21 35 61 70 93 106 125 0
+14 18 46 60 70 97 107 122 0
+8 31 39 61 63 86 98 127 128
+4 28 34 45 75 97 110 126 0
+16 30 45 63 72 95 100 113 0
+8 21 48 52 74 87 111 114 0
+9 32 46 58 68 83 113 123 0
+11 30 46 53 81 91 99 116 0
+5 29 49 58 78 85 112 120 0
+16 17 35 57 66 80 111 120 0
+1 19 51 54
+2 5 24 50
+3 38 44 52
+4 23 46 58
+6 30 36 63
+7 27 29 47
+8 10 48 55
+9 16 57 60
+11 12 40 61
+13 35 42 45
+14 22 34 62
+15 20 49 53
+17 18 25 32
+21 28 31 56
+26 33 37 41
+39 43 59 64
+1 18 22 64
+2 30 39 56
+3 7 49 54
+4 5 40 41
+6 42 55 60
+8 11 14 27
+9 31 33 38
+10 25 37 53
+12 13 15 28
+16 43 46 47
+17 24 44 45
+19 21 48 58
+20 23 34 63
+26 35 59 62
+29 50 51 57
+32 36 52 61
+1 6 28 41
+2 9 53 58
+3 5 55 64
+4 13 14 51
+7 30 35 48
+8 16 20 24
+10 23 52 57
+11 17 19 39
+12 33 34 43
+15 22 38 46
+18 21 26 49
+25 31 42 47
+27 36 58 59
+29 56 61 62
+32 34 48 50
+27 37 44 60
+40 45 54 63
+1 2 47 52
+3 13 16 21
+4 39 49 60
+5 20 25 62
+6 14 18 53
+7 12 24 26
+8 33 50 54
+9 23 45 64
+10 43 61 63
+11 31 44 51
+15 36 42 56
+17 46 55 57
+19 22 32 37
+28 40 57 59
+6 29 35 38
+23 28 30 37
+25 41 48 64
+1 13 20 26
+2 34 46 61
+3 34 36 39
+4 32 55 56
+5 19 31 45
+7 9 14 59
+8 18 28 35
+10 11 13 60
+12 47 50 58
+15 33 40 48
+16 17 38 41
+21 24 27 63
+22 24 30 53
+29 42 49 64
+43 51 52 62
+42 44 48 54
+1 25 38 61
+2 10 19 41
+3 18 47 63
+4 20 35 57
+5 23 51 60
+6 27 31 49
+7 15 39 45
+8 26 46 53
+9 12 32 62
+11 22 43 54
+14 16 50 55
+17 21 30 40
+29 33 44 59
+8 21 36 37
+37 52 56 58
+1 7 53 57
+2 17 28 62
+3 10 46 59
+4 36 45 47
+5 14 29 39
+6 15 25 54
+9 22 49 51
+11 16 26 34
+12 27 52 55
+13 24 43 56
+18 19 20 50
+23 32 38 40
+30 41 44 58
+31 35 60 64
+33 39 42 63
+5 30 59 61
+1 12 48 60
+2 3 4 37
+6 8 23 62
+7 21 25 34
+9 28 44 47
+10 17 27 35
+11 53 63 64
+13 40 49 52
+14 46 54 56
+15 31 50 61
+16 18 45 51
+19 29 43 55
+20 22 42 58
+24 36 41 57
+5 26 32 57
diff --git a/lib/ldpc/peg/peg-128-64-reg4.code b/lib/ldpc/peg/peg-128-64-reg4.code
new file mode 100644
index 00000000..5e99ac6a
--- /dev/null
+++ b/lib/ldpc/peg/peg-128-64-reg4.code
@@ -0,0 +1,67 @@
+128
+64
+9
+1 17 33 50 67 83 98 114 0
+2 18 34 50 68 84 99 115 0
+3 19 35 51 69 85 100 115 0
+4 20 36 52 70 86 101 115 0
+2 20 35 53 71 87 102 113 128
+5 21 33 54 64 88 103 116 0
+6 19 37 55 72 89 98 117 0
+7 22 38 56 73 90 96 116 0
+8 23 34 57 72 91 104 118 0
+7 24 39 58 74 84 100 119 0
+9 22 40 59 74 92 105 120 0
+9 25 41 55 75 91 106 114 0
+10 25 36 51 67 74 107 121 0
+11 22 36 54 72 93 102 122 0
+12 25 42 60 76 89 103 123 0
+8 26 38 51 77 93 105 124 0
+13 27 40 61 77 94 99 119 0
+13 17 43 54 73 85 108 124 0
+1 28 40 62 71 84 108 125 0
+12 29 38 53 67 86 108 126 0
+14 28 43 51 78 94 96 117 0
+11 17 42 62 79 92 104 126 0
+4 29 39 57 65 87 109 116 0
+2 27 38 55 78 79 107 127 0
+13 24 44 53 66 83 103 117 0
+15 30 43 55 67 90 105 128 0
+6 22 45 48 78 88 106 119 0
+14 25 33 63 65 73 99 118 0
+6 31 46 64 80 95 102 125 0
+5 18 37 65 79 94 110 113 0
+14 23 44 59 71 88 111 123 0
+13 32 47 62 70 91 109 128 0
+15 23 41 56 76 95 112 0 0
+11 29 41 47 68 69 105 117 0
+10 30 37 64 73 86 111 119 0
+5 32 45 60 69 96 101 127 0
+15 24 48 62 65 96 97 115 0
+3 23 42 64 77 83 109 0 0
+16 18 40 52 69 89 102 112 0
+9 20 49 63 76 94 109 121 0
+15 20 33 66 77 84 110 127 0
+10 21 44 60 80 82 112 126 0
+16 26 41 58 81 92 107 125 0
+3 27 48 59 82 95 110 118 0
+10 27 49 57 71 89 101 124 0
+4 26 42 61 68 90 100 122 0
+6 26 44 50 75 85 101 118 0
+7 28 37 47 66 76 82 114 0
+12 19 43 52 80 88 104 121 0
+2 31 47 56 75 93 108 123 0
+1 31 36 59 81 87 104 124 0
+3 32 39 50 81 97 106 121 0
+12 24 34 54 79 90 98 120 0
+1 19 49 56 82 92 103 122 0
+7 21 35 61 70 93 106 125 0
+14 18 46 60 70 97 107 122 0
+8 31 39 61 63 86 98 127 128
+4 28 34 45 75 97 110 126 0
+16 30 45 63 72 95 100 113 0
+8 21 48 52 74 87 111 114 0
+9 32 46 58 68 83 113 123 0
+11 30 46 53 81 91 99 116 0
+5 29 49 58 78 85 112 120 0
+16 17 35 57 66 80 111 120 0
diff --git a/lib/ldpc/peg/peg-128-72-reg4.alist b/lib/ldpc/peg/peg-128-72-reg4.alist
new file mode 100644
index 00000000..6bb420a5
--- /dev/null
+++ b/lib/ldpc/peg/peg-128-72-reg4.alist
@@ -0,0 +1,188 @@
+56 128
+10 4
+9 9 9 9 9 9 9 9 10 9 9 9 9 9 9 9 9 10 9 9 9 9 10 9 10 9 9 9 9 9 10 9 9 9 9 9 9 9 9 9 9 9 10 9 9 9 10 10 9 9 9 10 9 9 9 8
+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
+1 15 30 44 58 71 84 100 115 0
+2 16 31 44 59 72 86 101 116 0
+3 17 31 45 60 73 87 102 117 0
+2 18 32 46 58 73 85 103 112 0
+4 19 32 47 61 74 88 104 118 0
+5 20 33 48 62 75 88 105 116 0
+6 19 34 49 63 76 89 105 119 0
+7 15 27 45 64 77 88 106 120 0
+8 15 35 50 59 75 90 107 121 127
+7 21 33 51 65 73 91 108 114 0
+9 22 30 46 59 78 92 99 122 0
+9 19 35 52 60 71 93 109 120 0
+10 20 31 53 63 79 93 107 123 0
+11 15 36 53 66 78 85 110 124 0
+8 23 37 49 67 71 86 111 118 0
+12 22 34 54 68 80 94 109 114 0
+1 24 34 52 65 75 87 97 123 0
+13 25 29 43 69 81 85 100 121 128
+12 17 38 55 63 82 90 101 125 0
+11 26 39 47 56 76 95 106 117 0
+2 27 40 49 69 74 94 108 117 0
+4 16 30 55 64 76 91 103 126 0
+13 17 28 47 65 80 96 111 124 126
+6 18 36 51 70 83 94 111 121 0
+13 16 34 48 57 82 95 112 120 127
+6 28 40 48 58 79 90 113 122 0
+5 27 41 46 67 83 91 109 127 0
+14 16 42 54 63 78 97 100 118 0
+13 27 39 52 70 84 90 114 118 0
+10 22 42 47 64 81 98 110 116 0
+11 22 29 55 60 84 97 108 111 127
+5 26 37 55 57 74 96 98 128 0
+3 21 35 54 62 82 98 104 113 0
+14 21 43 50 68 77 93 110 117 0
+9 24 33 56 69 72 89 110 112 0
+12 26 42 53 62 73 89 99 121 0
+10 25 35 41 57 76 97 101 122 0
+10 18 39 44 66 77 99 102 119 0
+3 29 40 44 61 83 93 106 125 0
+4 23 39 45 65 85 89 107 113 0
+6 26 30 43 61 80 86 108 123 0
+7 19 31 57 69 83 99 113 124 0
+3 24 37 43 66 84 92 105 120 126
+2 24 38 50 70 71 88 102 122 0
+1 20 32 51 68 81 86 102 124 0
+12 23 41 51 59 74 87 106 115 0
+14 28 37 46 62 72 95 114 115 125
+1 28 41 49 61 82 92 103 116 128
+7 25 38 56 60 75 98 103 115 0
+8 29 33 45 58 78 96 109 119 0
+4 25 36 54 67 77 96 105 123 0
+14 20 38 52 66 80 91 104 112 128
+8 18 42 56 68 79 87 104 125 0
+9 23 40 53 70 81 95 101 126 0
+11 21 32 48 67 72 94 107 119 0
+5 17 36 50 64 79 92 100 0 0
+1 17 45 48
+2 4 21 44
+3 33 39 43
+5 22 40 51
+6 27 32 56
+7 24 26 41
+8 10 42 49
+9 15 50 53
+11 12 35 54
+13 30 37 38
+14 20 31 55
+16 19 36 46
+18 23 25 29
+28 34 47 52
+1 8 9 14
+2 22 25 28
+3 19 23 56
+4 24 38 53
+5 7 12 42
+6 13 45 52
+10 33 34 55
+11 16 30 31
+15 40 46 54
+17 35 43 44
+18 37 49 51
+20 32 36 41
+8 21 27 29
+23 26 47 48
+18 31 39 50
+1 11 22 41
+2 3 13 42
+4 5 45 55
+6 10 35 50
+7 16 17 25
+9 12 33 37
+14 24 51 56
+15 32 43 47
+19 44 49 52
+20 29 38 40
+21 26 39 54
+27 37 46 48
+28 30 36 53
+18 34 41 43
+1 2 38 39
+3 8 40 50
+4 11 27 47
+5 20 23 30
+6 25 26 55
+7 15 21 48
+9 34 44 56
+10 24 45 46
+12 17 29 52
+13 14 36 54
+16 28 33 51
+19 22 31 32
+20 35 49 53
+25 32 37 42
+1 4 26 50
+2 9 11 46
+3 12 31 49
+5 39 41 48
+6 33 36 47
+7 13 19 28
+8 22 30 56
+10 17 23 40
+14 38 43 52
+15 27 51 55
+16 34 45 53
+18 21 35 42
+24 29 44 54
+1 12 15 44
+2 35 47 55
+3 4 10 36
+5 21 32 46
+6 9 17 49
+7 20 22 37
+8 34 38 51
+11 14 28 50
+13 26 53 56
+16 23 41 52
+18 30 45 54
+19 25 33 48
+24 27 39 42
+1 29 31 43
+4 14 18 40
+2 15 41 45
+3 17 46 53
+5 6 8 44
+7 35 36 40
+9 19 26 29
+10 22 27 52
+11 43 48 56
+12 13 34 39
+16 21 24 55
+20 25 47 54
+23 32 50 51
+17 28 31 37
+30 32 33 49
+11 36 38 42
+1 18 28 56
+2 19 37 54
+3 38 44 45
+4 22 48 49
+5 33 52 53
+6 7 43 51
+8 20 39 46
+9 13 40 55
+10 21 31 41
+12 16 27 50
+14 30 34 35
+15 23 24 31
+4 25 35 52
+26 33 40 42
+10 16 29 47
+1 46 47 49
+2 6 30 48
+3 20 21 34
+5 15 28 29
+7 38 50 55
+8 12 25 43
+9 18 24 36
+11 26 37 44
+13 17 41 51
+14 23 42 45
+19 39 47 53
+22 23 43 54
+9 25 27 31
+18 32 48 52
diff --git a/lib/ldpc/peg/peg-128-72-reg4.code b/lib/ldpc/peg/peg-128-72-reg4.code
new file mode 100644
index 00000000..09108dbf
--- /dev/null
+++ b/lib/ldpc/peg/peg-128-72-reg4.code
@@ -0,0 +1,59 @@
+128
+56
+10
+1 15 30 44 58 71 84 100 115 0
+2 16 31 44 59 72 86 101 116 0
+3 17 31 45 60 73 87 102 117 0
+2 18 32 46 58 73 85 103 112 0
+4 19 32 47 61 74 88 104 118 0
+5 20 33 48 62 75 88 105 116 0
+6 19 34 49 63 76 89 105 119 0
+7 15 27 45 64 77 88 106 120 0
+8 15 35 50 59 75 90 107 121 127
+7 21 33 51 65 73 91 108 114 0
+9 22 30 46 59 78 92 99 122 0
+9 19 35 52 60 71 93 109 120 0
+10 20 31 53 63 79 93 107 123 0
+11 15 36 53 66 78 85 110 124 0
+8 23 37 49 67 71 86 111 118 0
+12 22 34 54 68 80 94 109 114 0
+1 24 34 52 65 75 87 97 123 0
+13 25 29 43 69 81 85 100 121 128
+12 17 38 55 63 82 90 101 125 0
+11 26 39 47 56 76 95 106 117 0
+2 27 40 49 69 74 94 108 117 0
+4 16 30 55 64 76 91 103 126 0
+13 17 28 47 65 80 96 111 124 126
+6 18 36 51 70 83 94 111 121 0
+13 16 34 48 57 82 95 112 120 127
+6 28 40 48 58 79 90 113 122 0
+5 27 41 46 67 83 91 109 127 0
+14 16 42 54 63 78 97 100 118 0
+13 27 39 52 70 84 90 114 118 0
+10 22 42 47 64 81 98 110 116 0
+11 22 29 55 60 84 97 108 111 127
+5 26 37 55 57 74 96 98 128 0
+3 21 35 54 62 82 98 104 113 0
+14 21 43 50 68 77 93 110 117 0
+9 24 33 56 69 72 89 110 112 0
+12 26 42 53 62 73 89 99 121 0
+10 25 35 41 57 76 97 101 122 0
+10 18 39 44 66 77 99 102 119 0
+3 29 40 44 61 83 93 106 125 0
+4 23 39 45 65 85 89 107 113 0
+6 26 30 43 61 80 86 108 123 0
+7 19 31 57 69 83 99 113 124 0
+3 24 37 43 66 84 92 105 120 126
+2 24 38 50 70 71 88 102 122 0
+1 20 32 51 68 81 86 102 124 0
+12 23 41 51 59 74 87 106 115 0
+14 28 37 46 62 72 95 114 115 125
+1 28 41 49 61 82 92 103 116 128
+7 25 38 56 60 75 98 103 115 0
+8 29 33 45 58 78 96 109 119 0
+4 25 36 54 67 77 96 105 123 0
+14 20 38 52 66 80 91 104 112 128
+8 18 42 56 68 79 87 104 125 0
+9 23 40 53 70 81 95 101 126 0
+11 21 32 48 67 72 94 107 119 0
+5 17 36 50 64 79 92 100 0 0
diff --git a/lib/ldpc/peg/peg-128-80-reg3.alist b/lib/ldpc/peg/peg-128-80-reg3.alist
new file mode 100644
index 00000000..e2d9e15f
--- /dev/null
+++ b/lib/ldpc/peg/peg-128-80-reg3.alist
@@ -0,0 +1,180 @@
+48 128
+8 3
+8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8
+3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
+1 17 34 51 66 81 99 113
+2 18 35 50 67 82 100 114
+3 19 36 52 68 82 101 115
+2 20 36 51 69 83 102 116
+4 19 37 53 66 84 103 117
+5 21 38 54 70 85 92 114
+6 22 39 55 66 85 96 118
+7 23 32 56 71 86 103 119
+8 20 40 55 72 86 104 120
+9 19 41 57 73 87 105 121
+10 24 36 56 74 88 106 122
+10 17 33 47 75 89 107 119
+11 21 42 51 76 87 108 123
+1 25 40 58 74 84 109 124
+12 22 42 49 77 90 110 122
+13 26 43 59 68 89 104 113
+13 22 44 57 75 91 106 125
+12 23 37 46 78 88 109 113
+3 27 34 60 65 87 111 126
+6 27 45 61 79 89 98 114
+14 28 34 62 72 92 107 125
+8 27 42 59 71 92 112 117
+15 20 46 57 79 93 101 117
+9 29 45 62 74 94 108 127
+8 30 38 63 73 95 110 125
+16 29 47 64 69 96 110 128
+16 23 48 63 76 94 111 121
+7 25 39 52 70 97 108 116
+4 26 45 63 67 83 90 126
+15 28 39 50 76 88 103 115
+15 26 33 58 65 97 102 127
+14 31 47 52 77 81 93 121
+14 24 37 61 71 82 99 116
+4 31 40 54 80 91 107 122
+5 32 41 58 77 98 111 120
+9 18 49 65 79 85 104 123
+10 30 43 60 69 84 112 123
+1 18 43 48 73 91 98 119
+3 21 46 64 67 86 112 118
+5 24 48 55 75 93 105 128
+2 32 44 62 80 95 99 124
+16 28 41 59 80 83 100 118
+11 33 35 53 72 96 109 115
+11 25 44 60 78 90 100 128
+6 31 35 56 70 95 102 126
+12 17 50 54 68 94 106 120
+13 29 38 53 78 97 105 124
+7 30 49 61 64 81 101 127
+1 14 38
+2 4 41
+3 19 39
+5 29 34
+6 35 40
+7 20 45
+8 28 48
+9 22 25
+10 24 36
+11 12 37
+13 43 44
+15 18 46
+16 17 47
+21 32 33
+23 30 31
+26 27 42
+1 12 46
+2 36 38
+3 5 10
+4 9 23
+6 13 39
+7 15 17
+8 18 27
+11 33 40
+14 28 44
+16 29 31
+19 20 22
+21 30 42
+24 26 47
+25 37 48
+32 34 45
+8 35 41
+12 31 43
+1 19 21
+2 43 45
+3 4 11
+5 18 33
+6 25 47
+7 28 30
+9 14 34
+10 35 42
+13 15 22
+16 37 38
+17 41 44
+20 24 29
+18 23 39
+12 26 32
+27 38 40
+15 36 48
+2 30 46
+1 4 13
+3 28 32
+5 43 47
+6 34 46
+7 9 40
+8 11 45
+10 17 23
+14 31 35
+16 22 42
+19 37 44
+20 33 48
+21 24 41
+25 27 29
+26 39 48
+19 31 36
+1 5 7
+2 29 39
+3 16 46
+4 26 37
+6 28 45
+8 22 33
+9 21 43
+10 25 38
+11 14 24
+12 17 40
+13 27 30
+15 32 35
+18 44 47
+20 23 36
+34 41 42
+1 32 48
+2 3 33
+4 29 42
+5 14 37
+6 7 36
+8 9 39
+10 13 19
+11 18 30
+12 16 20
+15 29 44
+17 34 38
+6 21 22
+23 32 40
+24 27 46
+25 41 45
+7 26 43
+28 31 47
+20 35 38
+1 33 41
+2 42 44
+3 23 48
+4 31 45
+5 8 30
+9 16 36
+10 40 47
+11 17 46
+12 21 34
+13 24 28
+14 18 43
+15 25 26
+19 27 35
+22 37 39
+1 16 18
+2 6 20
+3 30 43
+4 28 33
+5 22 23
+7 39 42
+8 12 38
+9 35 46
+10 27 32
+11 15 34
+13 36 37
+14 41 47
+17 21 25
+19 29 45
+24 31 48
+26 40 44
diff --git a/lib/ldpc/peg/peg-128-80-reg3.code b/lib/ldpc/peg/peg-128-80-reg3.code
new file mode 100644
index 00000000..10064e07
--- /dev/null
+++ b/lib/ldpc/peg/peg-128-80-reg3.code
@@ -0,0 +1,51 @@
+128
+48
+8
+1 17 34 51 66 81 99 113
+2 18 35 50 67 82 100 114
+3 19 36 52 68 82 101 115
+2 20 36 51 69 83 102 116
+4 19 37 53 66 84 103 117
+5 21 38 54 70 85 92 114
+6 22 39 55 66 85 96 118
+7 23 32 56 71 86 103 119
+8 20 40 55 72 86 104 120
+9 19 41 57 73 87 105 121
+10 24 36 56 74 88 106 122
+10 17 33 47 75 89 107 119
+11 21 42 51 76 87 108 123
+1 25 40 58 74 84 109 124
+12 22 42 49 77 90 110 122
+13 26 43 59 68 89 104 113
+13 22 44 57 75 91 106 125
+12 23 37 46 78 88 109 113
+3 27 34 60 65 87 111 126
+6 27 45 61 79 89 98 114
+14 28 34 62 72 92 107 125
+8 27 42 59 71 92 112 117
+15 20 46 57 79 93 101 117
+9 29 45 62 74 94 108 127
+8 30 38 63 73 95 110 125
+16 29 47 64 69 96 110 128
+16 23 48 63 76 94 111 121
+7 25 39 52 70 97 108 116
+4 26 45 63 67 83 90 126
+15 28 39 50 76 88 103 115
+15 26 33 58 65 97 102 127
+14 31 47 52 77 81 93 121
+14 24 37 61 71 82 99 116
+4 31 40 54 80 91 107 122
+5 32 41 58 77 98 111 120
+9 18 49 65 79 85 104 123
+10 30 43 60 69 84 112 123
+1 18 43 48 73 91 98 119
+3 21 46 64 67 86 112 118
+5 24 48 55 75 93 105 128
+2 32 44 62 80 95 99 124
+16 28 41 59 80 83 100 118
+11 33 35 53 72 96 109 115
+11 25 44 60 78 90 100 128
+6 31 35 56 70 95 102 126
+12 17 50 54 68 94 106 120
+13 29 38 53 78 97 105 124
+7 30 49 61 64 81 101 127
diff --git a/lib/ldpc/peg/peg-128-80-reg4.alist b/lib/ldpc/peg/peg-128-80-reg4.alist
new file mode 100644
index 00000000..2487ea9b
--- /dev/null
+++ b/lib/ldpc/peg/peg-128-80-reg4.alist
@@ -0,0 +1,180 @@
+48 128
+12 4
+11 11 11 11 11 11 11 11 11 11 11 11 11 10 11 11 11 10 10 11 10 11 10 11 10 10 10 10 10 11 10 12 11 11 10 11 11 11 11 11 10 10 11 10 10 11 11 10
+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
+1 13 26 38 51 62 75 86 99 111 124 0
+2 13 27 39 49 63 76 87 100 112 121 0
+3 14 27 40 52 64 74 88 101 104 123 0
+2 15 28 41 53 65 77 89 102 113 125 0
+4 16 26 41 54 66 71 90 101 114 122 0
+5 15 29 40 55 67 78 91 98 110 126 0
+6 17 30 42 56 63 79 90 103 115 124 0
+7 18 25 43 56 68 80 87 104 113 122 0
+7 13 29 44 52 69 81 92 102 114 127 0
+8 14 29 42 57 66 77 86 97 116 119 0
+9 19 26 45 56 69 76 93 97 110 128 0
+9 14 28 46 54 68 82 91 99 112 118 0
+8 20 31 47 49 69 78 88 105 109 124 0
+1 20 32 42 52 70 76 94 106 117 0 0
+10 15 33 48 52 62 80 93 100 118 119 0
+11 18 31 39 48 67 83 94 97 114 125 0
+12 15 34 37 49 64 73 85 99 116 127 0
+2 21 25 45 55 64 83 92 103 119 0 0
+4 22 33 46 55 65 84 86 107 108 0 0
+11 16 27 45 53 70 79 95 107 111 126 0
+6 13 33 45 57 68 85 96 101 120 0 0
+12 17 25 38 58 67 76 96 107 118 123 0
+5 18 30 44 59 71 77 93 106 120 0 0
+6 20 28 43 50 72 83 86 95 121 127 0
+11 23 28 38 59 73 81 88 108 115 0 0
+10 19 32 49 60 67 75 89 101 108 0 0
+5 22 27 48 54 69 73 96 103 113 0 0
+12 23 35 47 50 62 79 97 106 122 0 0
+3 18 26 47 53 61 82 85 98 108 0 0
+9 22 31 41 58 60 72 87 106 115 116 0
+10 16 30 50 58 65 73 91 104 109 0 0
+10 24 36 41 57 61 78 94 103 111 123 127
+4 17 29 43 59 74 85 89 109 112 128 0
+3 21 34 38 60 63 77 95 105 114 128 0
+7 24 37 46 53 71 74 96 105 110 0 0
+6 19 34 47 51 70 81 91 100 123 125 0
+2 24 31 40 56 66 81 84 95 118 120 0
+1 14 30 37 48 72 78 92 107 122 128 0
+3 23 24 42 55 68 75 93 109 121 125 0
+12 22 32 43 51 71 82 88 102 119 126 0
+1 23 36 44 58 64 80 90 110 112 0 0
+7 19 35 40 59 65 82 90 111 117 0 0
+9 17 36 39 50 66 75 92 105 117 126 0
+4 21 35 39 57 70 80 98 99 115 0 0
+8 25 33 37 54 60 79 94 98 121 0 0
+8 16 34 46 61 62 83 87 102 117 120 0
+11 21 32 44 61 72 74 84 100 113 124 0
+5 20 35 36 51 63 84 89 104 116 0 0
+1 14 38 41
+2 4 18 37
+3 29 34 39
+5 19 33 44
+6 23 27 48
+7 21 24 36
+8 9 35 42
+10 13 45 46
+11 12 30 43
+15 26 31 32
+16 20 25 47
+17 22 28 40
+1 2 9 21
+3 10 12 38
+4 6 15 17
+5 20 31 46
+7 22 33 43
+8 16 23 29
+11 26 36 42
+13 14 24 48
+18 34 44 47
+19 27 30 40
+25 28 39 41
+32 35 37 39
+8 18 22 45
+1 5 11 29
+2 3 20 27
+4 12 24 25
+6 9 10 33
+7 23 31 38
+13 16 30 37
+14 26 40 47
+15 19 21 45
+17 34 36 46
+28 42 44 48
+32 41 43 48
+17 35 38 45
+1 22 25 34
+2 16 43 44
+3 6 37 42
+4 5 30 32
+7 10 14 39
+8 24 33 40
+9 23 41 47
+11 18 20 21
+12 19 35 46
+13 28 29 36
+15 16 27 38
+2 13 17 26
+24 28 31 43
+1 36 40 48
+3 9 14 15
+4 20 29 35
+5 12 27 45
+6 18 19 39
+7 8 11 37
+10 21 32 44
+22 30 31 41
+23 25 33 42
+26 30 34 45
+29 32 46 47
+1 15 28 46
+2 7 34 48
+3 17 18 41
+4 19 31 42
+5 10 37 43
+6 16 22 26
+8 12 21 39
+9 11 13 27
+14 20 36 44
+5 23 35 40
+24 30 38 47
+17 25 27 31
+3 33 35 47
+1 26 39 43
+2 11 14 22
+4 10 23 34
+6 13 32 38
+7 20 28 45
+8 15 41 44
+9 25 36 37
+12 29 40 42
+16 18 24 46
+19 37 47 48
+17 21 29 33
+1 10 19 24
+2 8 30 46
+3 13 25 40
+4 26 33 48
+5 7 41 42
+6 12 31 36
+9 18 38 43
+11 15 23 39
+14 16 32 45
+20 24 34 37
+21 22 27 35
+10 11 16 28
+6 29 44 45
+1 12 17 44
+2 15 36 47
+3 5 21 26
+4 9 40 46
+7 18 27 32
+3 8 31 48
+13 34 35 43
+14 23 28 30
+19 20 22 38
+19 25 26 29
+13 31 33 39
+6 11 35 41
+1 20 32 42
+2 12 33 41
+4 8 27 47
+5 9 16 34
+7 25 30 44
+10 17 30 48
+14 42 43 46
+12 15 22 37
+10 15 18 40
+21 23 37 46
+2 24 39 45
+5 8 28 38
+3 22 32 36
+1 7 13 47
+4 16 36 39
+6 20 40 43
+9 17 24 32
+11 33 34 38
diff --git a/lib/ldpc/peg/peg-128-80-reg4.code b/lib/ldpc/peg/peg-128-80-reg4.code
new file mode 100644
index 00000000..572e6221
--- /dev/null
+++ b/lib/ldpc/peg/peg-128-80-reg4.code
@@ -0,0 +1,51 @@
+128
+48
+12
+1 13 26 38 51 62 75 86 99 111 124 0
+2 13 27 39 49 63 76 87 100 112 121 0
+3 14 27 40 52 64 74 88 101 104 123 0
+2 15 28 41 53 65 77 89 102 113 125 0
+4 16 26 41 54 66 71 90 101 114 122 0
+5 15 29 40 55 67 78 91 98 110 126 0
+6 17 30 42 56 63 79 90 103 115 124 0
+7 18 25 43 56 68 80 87 104 113 122 0
+7 13 29 44 52 69 81 92 102 114 127 0
+8 14 29 42 57 66 77 86 97 116 119 0
+9 19 26 45 56 69 76 93 97 110 128 0
+9 14 28 46 54 68 82 91 99 112 118 0
+8 20 31 47 49 69 78 88 105 109 124 0
+1 20 32 42 52 70 76 94 106 117 0 0
+10 15 33 48 52 62 80 93 100 118 119 0
+11 18 31 39 48 67 83 94 97 114 125 0
+12 15 34 37 49 64 73 85 99 116 127 0
+2 21 25 45 55 64 83 92 103 119 0 0
+4 22 33 46 55 65 84 86 107 108 0 0
+11 16 27 45 53 70 79 95 107 111 126 0
+6 13 33 45 57 68 85 96 101 120 0 0
+12 17 25 38 58 67 76 96 107 118 123 0
+5 18 30 44 59 71 77 93 106 120 0 0
+6 20 28 43 50 72 83 86 95 121 127 0
+11 23 28 38 59 73 81 88 108 115 0 0
+10 19 32 49 60 67 75 89 101 108 0 0
+5 22 27 48 54 69 73 96 103 113 0 0
+12 23 35 47 50 62 79 97 106 122 0 0
+3 18 26 47 53 61 82 85 98 108 0 0
+9 22 31 41 58 60 72 87 106 115 116 0
+10 16 30 50 58 65 73 91 104 109 0 0
+10 24 36 41 57 61 78 94 103 111 123 127
+4 17 29 43 59 74 85 89 109 112 128 0
+3 21 34 38 60 63 77 95 105 114 128 0
+7 24 37 46 53 71 74 96 105 110 0 0
+6 19 34 47 51 70 81 91 100 123 125 0
+2 24 31 40 56 66 81 84 95 118 120 0
+1 14 30 37 48 72 78 92 107 122 128 0
+3 23 24 42 55 68 75 93 109 121 125 0
+12 22 32 43 51 71 82 88 102 119 126 0
+1 23 36 44 58 64 80 90 110 112 0 0
+7 19 35 40 59 65 82 90 111 117 0 0
+9 17 36 39 50 66 75 92 105 117 126 0
+4 21 35 39 57 70 80 98 99 115 0 0
+8 25 33 37 54 60 79 94 98 121 0 0
+8 16 34 46 61 62 83 87 102 117 120 0
+11 21 32 44 61 72 74 84 100 113 124 0
+5 20 35 36 51 63 84 89 104 116 0 0
diff --git a/lib/ldpc/peg/peg-144-72-reg4.alist b/lib/ldpc/peg/peg-144-72-reg4.alist
new file mode 100644
index 00000000..cad34471
--- /dev/null
+++ b/lib/ldpc/peg/peg-144-72-reg4.alist
@@ -0,0 +1,220 @@
+72 144
+9 4
+8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 9 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 7 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8
+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
+1 19 38 57 74 94 110 128 0
+2 20 39 58 75 95 111 129 0
+3 21 40 59 76 95 108 130 0
+4 22 41 60 69 96 112 131 0
+2 19 42 60 77 97 113 132 0
+5 20 43 61 78 98 114 133 0
+6 22 44 62 79 99 115 127 0
+7 23 41 58 73 100 113 134 0
+8 23 45 63 80 101 114 135 0
+7 24 46 64 81 98 112 136 0
+9 25 47 64 75 102 116 130 0
+9 22 48 59 82 98 117 137 0
+10 25 49 65 80 99 118 132 0
+11 26 50 66 75 96 119 127 0
+12 27 43 67 82 103 120 136 0
+13 28 50 68 82 97 121 138 0
+8 29 47 62 83 104 121 132 0
+13 25 38 53 61 100 111 135 0
+14 22 38 63 83 95 122 133 0
+15 30 41 63 81 105 123 129 0
+1 28 51 64 80 104 119 126 0
+12 24 40 69 84 100 124 133 0
+16 23 52 65 77 106 110 139 0
+11 31 37 55 85 101 118 140 0
+13 32 48 70 77 94 122 140 0
+2 27 53 71 78 101 110 131 0
+4 29 46 71 77 88 124 130 0
+14 24 49 56 86 107 119 130 144
+14 33 47 70 87 108 115 137 0
+6 32 52 69 78 91 125 141 0
+15 26 51 61 76 86 117 140 0
+17 33 51 59 88 109 113 142 0
+6 31 40 54 88 102 111 136 0
+5 33 54 62 86 103 118 141 0
+13 24 44 72 75 103 114 142 0
+15 34 47 67 85 99 110 143 0
+18 28 49 58 89 92 122 131 0
+18 21 38 68 85 91 115 129 0
+11 33 36 58 84 106 121 128 0
+10 20 50 59 90 94 120 135 0
+5 29 42 55 89 106 117 136 0
+3 30 45 61 84 104 115 144 0
+15 20 52 57 89 102 126 142 0
+16 35 53 72 80 102 125 143 0
+9 26 39 71 74 105 125 139 0
+16 30 44 71 85 90 112 134 0
+17 25 55 69 76 105 119 134 0
+10 35 37 63 91 108 113 144 0
+17 27 44 57 87 92 123 143 0
+3 32 46 67 92 96 109 0 0
+10 36 46 60 93 107 111 133 0
+4 35 54 56 74 100 117 138 0
+6 34 39 66 87 93 118 138 0
+7 34 48 55 83 96 120 139 0
+12 35 42 68 79 105 112 141 0
+2 31 51 67 79 107 116 128 0
+1 29 40 73 90 101 125 138 0
+3 19 37 72 87 99 122 139 0
+12 26 45 65 73 92 121 137 0
+14 30 42 66 74 109 114 140 0
+1 36 48 56 81 97 116 134 0
+7 19 50 62 91 107 109 143 0
+17 23 56 70 78 93 120 129 0
+8 36 53 68 86 108 123 142 0
+4 21 39 70 89 98 123 132 0
+18 27 54 66 81 104 106 137 0
+8 31 49 57 82 93 124 127 0
+9 37 43 73 84 95 126 131 0
+18 34 45 72 88 94 116 141 0
+11 21 52 64 79 103 124 135 0
+5 32 41 65 90 97 126 128 0
+16 28 43 60 76 83 127 144 0
+1 21 57 61
+2 5 26 56
+3 42 50 58
+4 27 52 65
+6 34 41 71
+7 30 33 53
+8 10 54 62
+9 17 64 67
+11 12 45 68
+13 40 48 51
+14 24 39 70
+15 22 55 59
+16 18 25 35
+19 28 29 60
+20 31 36 43
+23 44 46 72
+32 47 49 63
+37 38 66 69
+1 5 58 62
+2 6 40 43
+3 38 65 70
+4 7 12 19
+8 9 23 63
+10 22 28 35
+11 13 18 47
+14 31 45 59
+15 26 49 66
+16 21 37 72
+17 27 41 57
+20 42 46 60
+24 33 56 67
+25 30 50 71
+29 32 34 39
+36 53 54 69
+44 48 52 55
+39 51 61 64
+24 48 58 68
+1 18 19 38
+2 45 53 65
+3 22 33 57
+4 8 20 71
+5 41 55 60
+6 15 68 72
+7 35 46 49
+9 42 59 69
+10 27 50 51
+11 17 29 36
+12 25 54 61
+13 28 37 67
+14 16 40 62
+21 31 32 56
+23 30 43 70
+18 26 44 64
+33 34 52 66
+24 41 47 54
+28 52 61 63
+1 43 49 67
+2 8 37 39
+3 12 32 40
+4 5 51 72
+6 18 31 42
+7 17 34 62
+9 19 20 48
+10 11 21 70
+13 23 59 71
+14 53 60 66
+15 36 50 56
+16 38 55 64
+4 22 30 47
+25 29 63 65
+26 27 45 46
+35 44 58 69
+8 57 59 68
+1 45 52 60
+2 11 14 35
+3 31 47 72
+5 23 25 27
+6 26 30 63
+7 55 56 70
+9 13 21 44
+10 20 61 66
+12 15 16 67
+17 19 54 72
+22 39 42 68
+24 36 38 46
+28 31 34 64
+29 49 53 58
+27 32 33 69
+37 41 43 65
+40 46 57 71
+30 38 48 62
+37 49 50 59
+51 53 63 67
+1 25 40 69
+2 3 19 68
+4 14 50 54
+5 16 61 71
+6 10 12 65
+7 13 36 58
+8 18 22 52
+9 24 26 57
+11 33 43 44
+15 34 35 70
+17 21 42 66
+20 45 47 55
+23 39 41 66
+28 51 56 62
+3 29 48 64
+32 50 60 62
+1 23 26 36
+2 18 33 51
+4 10 46 55
+5 8 32 48
+6 9 35 60
+7 29 38 42
+11 56 61 69
+12 31 41 52
+13 24 34 53
+14 21 28 47
+15 40 54 63
+16 17 39 59
+19 25 37 58
+20 49 64 65
+22 27 67 70
+30 44 45 57
+21 43 68 71
+7 14 67 72
+1 39 56 71
+2 20 38 63
+3 11 27 28
+4 26 37 68
+5 13 17 65
+6 19 22 51
+8 46 47 61
+9 18 40 70
+10 15 33 41
+12 29 59 66
+16 52 53 57
+23 45 54 58
+24 25 31 60
+30 34 55 69
+32 35 43 64
+36 44 49 62
+28 42 48 72
diff --git a/lib/ldpc/peg/peg-144-72-reg4.code b/lib/ldpc/peg/peg-144-72-reg4.code
new file mode 100644
index 00000000..78747e92
--- /dev/null
+++ b/lib/ldpc/peg/peg-144-72-reg4.code
@@ -0,0 +1,75 @@
+144
+72
+9
+1 19 38 57 74 94 110 128 0
+2 20 39 58 75 95 111 129 0
+3 21 40 59 76 95 108 130 0
+4 22 41 60 69 96 112 131 0
+2 19 42 60 77 97 113 132 0
+5 20 43 61 78 98 114 133 0
+6 22 44 62 79 99 115 127 0
+7 23 41 58 73 100 113 134 0
+8 23 45 63 80 101 114 135 0
+7 24 46 64 81 98 112 136 0
+9 25 47 64 75 102 116 130 0
+9 22 48 59 82 98 117 137 0
+10 25 49 65 80 99 118 132 0
+11 26 50 66 75 96 119 127 0
+12 27 43 67 82 103 120 136 0
+13 28 50 68 82 97 121 138 0
+8 29 47 62 83 104 121 132 0
+13 25 38 53 61 100 111 135 0
+14 22 38 63 83 95 122 133 0
+15 30 41 63 81 105 123 129 0
+1 28 51 64 80 104 119 126 0
+12 24 40 69 84 100 124 133 0
+16 23 52 65 77 106 110 139 0
+11 31 37 55 85 101 118 140 0
+13 32 48 70 77 94 122 140 0
+2 27 53 71 78 101 110 131 0
+4 29 46 71 77 88 124 130 0
+14 24 49 56 86 107 119 130 144
+14 33 47 70 87 108 115 137 0
+6 32 52 69 78 91 125 141 0
+15 26 51 61 76 86 117 140 0
+17 33 51 59 88 109 113 142 0
+6 31 40 54 88 102 111 136 0
+5 33 54 62 86 103 118 141 0
+13 24 44 72 75 103 114 142 0
+15 34 47 67 85 99 110 143 0
+18 28 49 58 89 92 122 131 0
+18 21 38 68 85 91 115 129 0
+11 33 36 58 84 106 121 128 0
+10 20 50 59 90 94 120 135 0
+5 29 42 55 89 106 117 136 0
+3 30 45 61 84 104 115 144 0
+15 20 52 57 89 102 126 142 0
+16 35 53 72 80 102 125 143 0
+9 26 39 71 74 105 125 139 0
+16 30 44 71 85 90 112 134 0
+17 25 55 69 76 105 119 134 0
+10 35 37 63 91 108 113 144 0
+17 27 44 57 87 92 123 143 0
+3 32 46 67 92 96 109 0 0
+10 36 46 60 93 107 111 133 0
+4 35 54 56 74 100 117 138 0
+6 34 39 66 87 93 118 138 0
+7 34 48 55 83 96 120 139 0
+12 35 42 68 79 105 112 141 0
+2 31 51 67 79 107 116 128 0
+1 29 40 73 90 101 125 138 0
+3 19 37 72 87 99 122 139 0
+12 26 45 65 73 92 121 137 0
+14 30 42 66 74 109 114 140 0
+1 36 48 56 81 97 116 134 0
+7 19 50 62 91 107 109 143 0
+17 23 56 70 78 93 120 129 0
+8 36 53 68 86 108 123 142 0
+4 21 39 70 89 98 123 132 0
+18 27 54 66 81 104 106 137 0
+8 31 49 57 82 93 124 127 0
+9 37 43 73 84 95 126 131 0
+18 34 45 72 88 94 116 141 0
+11 21 52 64 79 103 124 135 0
+5 32 41 65 90 97 126 128 0
+16 28 43 60 76 83 127 144 0
diff --git a/lib/ldpc/peg/peg2alist b/lib/ldpc/peg/peg2alist
new file mode 100755
index 00000000..da710f92
--- /dev/null
+++ b/lib/ldpc/peg/peg2alist
@@ -0,0 +1,37 @@
+#!/opt/local/bin/octave -qf
+# read a parity check matrix produced by the peg algorithm and
+# convert to alist format so that it can be read using alist_to_pcheck
+arg_list=argv();
+filename=arg_list{1};
+fid=fopen(filename,"r");
+N=fscanf(fid,"%d",[1]);
+M=fscanf(fid,"%d",[1]);
+pcheck=zeros(M,N);
+max_bits_in_check=fscanf(fid,"%d",[1]);
+for i=1:M
+ vec=fscanf(fid,"%d",[max_bits_in_check]);
+ pcheck(i,vec(vec>0))=1;
+endfor
+
+max_bits_in_check2=max(sum(pcheck'));
+max_checks_per_bit=max(sum(pcheck));
+printf("%d %d\n",M,N);
+printf("%d %d\n",max_bits_in_check2,max_checks_per_bit);
+printf("%d ",sum(pcheck'));
+printf("\n");
+printf("%d ",sum(pcheck));
+printf("\n");
+for i=1:M
+ vec=find(pcheck(i,:)>0);
+ pr=zeros(1,max_bits_in_check2);
+ pr(1:size(vec)(2))=vec;
+ printf("%d ",pr);
+ printf("\n");
+endfor
+for i=1:N
+ vec=find(pcheck(:,i)>0);
+ pr=zeros(1,max_checks_per_bit);
+ pr(1:size(vec)(1))=vec;
+ printf("%d ",pr)
+ printf("\n");
+endfor
diff --git a/lib/ldpc/peg/peg_128_80.pchk b/lib/ldpc/peg/peg_128_80.pchk
new file mode 100644
index 00000000..c3dc1b1b
--- /dev/null
+++ b/lib/ldpc/peg/peg_128_80.pchk
@@ -0,0 +1,51 @@
+128
+48
+9
+1 17 34 51 66 81 99 111 124
+2 18 35 50 67 82 100 112 125
+3 19 36 52 68 82 101 111 126
+2 20 36 51 69 83 102 113 127
+4 19 37 53 66 84 103 114 128
+5 21 38 54 70 85 92 114 0
+6 22 39 55 66 85 96 110 0
+7 23 32 56 71 86 103 115 0
+8 20 40 55 72 86 104 116 0
+9 19 41 57 73 87 105 116 0
+10 24 36 56 74 88 105 117 125
+10 17 33 47 75 89 106 118 128
+11 21 42 51 76 87 107 119 0
+1 25 40 58 74 84 107 113 0
+12 22 42 49 77 90 108 118 125
+13 26 43 59 68 89 104 120 124
+13 22 44 57 75 91 109 113 0
+12 23 37 46 78 88 107 112 0
+3 27 34 60 65 87 109 118 0
+6 27 45 61 79 89 98 112 0
+14 28 34 62 72 92 106 112 127
+8 27 42 59 71 92 110 121 126
+15 20 46 57 79 93 101 115 124
+9 29 45 62 74 94 108 121 0
+8 30 38 63 73 95 109 111 128
+16 29 47 64 69 96 109 117 126
+16 23 48 63 76 94 110 116 125
+7 25 39 52 70 97 106 117 124
+4 26 45 63 67 83 90 119 123
+15 28 39 50 76 88 103 121 123
+15 26 33 58 65 97 102 122 0
+14 31 47 52 77 81 93 116 0
+14 24 37 61 71 82 99 122 0
+4 31 40 54 80 91 106 115 122
+5 32 41 58 77 98 104 117 0
+9 18 49 65 79 85 104 119 128
+10 30 43 60 69 84 108 115 123
+1 18 43 48 73 91 98 114 127
+3 21 46 64 67 86 108 113 0
+5 24 48 55 75 93 107 120 126
+2 32 44 62 80 95 99 114 0
+16 28 41 59 80 83 100 118 0
+11 33 35 53 72 96 105 111 0
+11 25 44 60 78 90 100 120 122
+6 31 35 56 70 95 102 121 0
+12 17 50 54 68 94 105 119 0
+13 29 38 53 78 97 110 123 0
+7 30 49 61 64 81 101 120 127
diff --git a/lib/ldpc/peg/sfpeg1.code b/lib/ldpc/peg/sfpeg1.code
new file mode 100644
index 00000000..c3dc1b1b
--- /dev/null
+++ b/lib/ldpc/peg/sfpeg1.code
@@ -0,0 +1,51 @@
+128
+48
+9
+1 17 34 51 66 81 99 111 124
+2 18 35 50 67 82 100 112 125
+3 19 36 52 68 82 101 111 126
+2 20 36 51 69 83 102 113 127
+4 19 37 53 66 84 103 114 128
+5 21 38 54 70 85 92 114 0
+6 22 39 55 66 85 96 110 0
+7 23 32 56 71 86 103 115 0
+8 20 40 55 72 86 104 116 0
+9 19 41 57 73 87 105 116 0
+10 24 36 56 74 88 105 117 125
+10 17 33 47 75 89 106 118 128
+11 21 42 51 76 87 107 119 0
+1 25 40 58 74 84 107 113 0
+12 22 42 49 77 90 108 118 125
+13 26 43 59 68 89 104 120 124
+13 22 44 57 75 91 109 113 0
+12 23 37 46 78 88 107 112 0
+3 27 34 60 65 87 109 118 0
+6 27 45 61 79 89 98 112 0
+14 28 34 62 72 92 106 112 127
+8 27 42 59 71 92 110 121 126
+15 20 46 57 79 93 101 115 124
+9 29 45 62 74 94 108 121 0
+8 30 38 63 73 95 109 111 128
+16 29 47 64 69 96 109 117 126
+16 23 48 63 76 94 110 116 125
+7 25 39 52 70 97 106 117 124
+4 26 45 63 67 83 90 119 123
+15 28 39 50 76 88 103 121 123
+15 26 33 58 65 97 102 122 0
+14 31 47 52 77 81 93 116 0
+14 24 37 61 71 82 99 122 0
+4 31 40 54 80 91 106 115 122
+5 32 41 58 77 98 104 117 0
+9 18 49 65 79 85 104 119 128
+10 30 43 60 69 84 108 115 123
+1 18 43 48 73 91 98 114 127
+3 21 46 64 67 86 108 113 0
+5 24 48 55 75 93 107 120 126
+2 32 44 62 80 95 99 114 0
+16 28 41 59 80 83 100 118 0
+11 33 35 53 72 96 105 111 0
+11 25 44 60 78 90 100 120 122
+6 31 35 56 70 95 102 121 0
+12 17 50 54 68 94 105 119 0
+13 29 38 53 78 97 110 123 0
+7 30 49 61 64 81 101 120 127
diff --git a/lib/ldpc/peg/sfpeg1.deg b/lib/ldpc/peg/sfpeg1.deg
new file mode 100644
index 00000000..7d208a69
--- /dev/null
+++ b/lib/ldpc/peg/sfpeg1.deg
@@ -0,0 +1,3 @@
+2
+3 4
+.8 .2
diff --git a/lib/ldpc/peg/sfpeg2.alist b/lib/ldpc/peg/sfpeg2.alist
new file mode 100644
index 00000000..410bae7e
--- /dev/null
+++ b/lib/ldpc/peg/sfpeg2.alist
@@ -0,0 +1,180 @@
+48 128
+9 4
+9 9 8 8 8 8 8 8 8 8 8 9 8 9 8 8 8 9 8 8 9 8 8 9 8 8 8 9 8 8 9 8 8 8 9 8 9 8 8 8 8 8 8 8 9 8 8 8
+3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
+1 17 34 51 66 81 99 113 127
+2 18 35 50 67 82 100 114 128
+3 19 36 52 68 82 101 115 0
+2 20 36 51 69 83 102 116 0
+4 19 37 53 66 84 103 117 0
+5 21 38 54 70 85 92 114 0
+6 22 39 55 66 85 96 118 0
+7 23 32 56 71 86 103 119 0
+8 20 40 55 72 86 104 120 0
+9 19 41 57 73 87 105 118 0
+10 24 36 56 74 88 106 120 0
+10 17 33 47 75 89 107 121 126
+11 21 42 51 76 87 108 122 0
+1 25 40 58 74 84 109 122 126
+12 22 42 49 77 90 110 123 0
+13 26 43 59 68 89 104 113 0
+13 22 44 57 75 91 106 124 0
+12 23 37 46 78 88 109 113 128
+3 27 34 60 65 87 111 123 0
+6 27 45 61 79 89 98 114 0
+14 28 34 62 72 92 107 122 125
+8 27 42 59 71 92 112 117 0
+15 20 46 57 79 93 101 117 0
+9 29 45 62 74 94 108 119 128
+8 30 38 63 73 95 110 124 0
+16 29 47 64 69 96 110 125 0
+16 23 48 63 76 94 111 120 0
+7 25 39 52 70 97 108 116 127
+4 26 45 63 67 83 90 121 0
+15 28 39 50 76 88 103 115 0
+15 26 33 58 65 97 102 125 128
+14 31 47 52 77 81 93 120 0
+14 24 37 61 71 82 99 116 0
+4 31 40 54 80 91 107 119 0
+5 32 41 58 77 98 111 124 127
+9 18 49 65 79 85 104 124 0
+10 30 43 60 69 84 112 119 127
+1 18 43 48 73 91 98 121 0
+3 21 46 64 67 86 112 118 0
+5 24 48 55 75 93 105 122 0
+2 32 44 62 80 95 99 118 0
+16 28 41 59 80 83 100 123 0
+11 33 35 53 72 96 109 115 0
+11 25 44 60 78 90 100 117 0
+6 31 35 56 70 95 102 123 126
+12 17 50 54 68 94 106 125 0
+13 29 38 53 78 97 105 121 0
+7 30 49 61 64 81 101 126 0
+1 14 38 0
+2 4 41 0
+3 19 39 0
+5 29 34 0
+6 35 40 0
+7 20 45 0
+8 28 48 0
+9 22 25 0
+10 24 36 0
+11 12 37 0
+13 43 44 0
+15 18 46 0
+16 17 47 0
+21 32 33 0
+23 30 31 0
+26 27 42 0
+1 12 46 0
+2 36 38 0
+3 5 10 0
+4 9 23 0
+6 13 39 0
+7 15 17 0
+8 18 27 0
+11 33 40 0
+14 28 44 0
+16 29 31 0
+19 20 22 0
+21 30 42 0
+24 26 47 0
+25 37 48 0
+32 34 45 0
+8 35 41 0
+12 31 43 0
+1 19 21 0
+2 43 45 0
+3 4 11 0
+5 18 33 0
+6 25 47 0
+7 28 30 0
+9 14 34 0
+10 35 42 0
+13 15 22 0
+16 37 38 0
+17 41 44 0
+20 24 29 0
+18 23 39 0
+12 26 32 0
+27 38 40 0
+15 36 48 0
+2 30 46 0
+1 4 13 0
+3 28 32 0
+5 43 47 0
+6 34 46 0
+7 9 40 0
+8 11 45 0
+10 17 23 0
+14 31 35 0
+16 22 42 0
+19 37 44 0
+20 33 48 0
+21 24 41 0
+25 27 29 0
+26 39 48 0
+19 31 36 0
+1 5 7 0
+2 29 39 0
+3 16 46 0
+4 26 37 0
+6 28 45 0
+8 22 33 0
+9 21 43 0
+10 25 38 0
+11 14 24 0
+12 17 40 0
+13 27 30 0
+15 32 35 0
+18 44 47 0
+20 23 36 0
+34 41 42 0
+1 32 48 0
+2 3 33 0
+4 29 42 0
+5 14 37 0
+6 7 36 0
+8 9 39 0
+10 13 19 0
+11 18 30 0
+12 16 20 0
+15 29 44 0
+17 34 38 0
+6 21 22 0
+23 32 40 0
+24 27 46 0
+25 41 45 0
+7 26 43 0
+28 31 47 0
+20 35 38 0
+1 33 41 0
+2 42 44 0
+3 23 48 0
+4 31 45 0
+5 8 30 0
+9 16 36 0
+10 40 47 0
+11 17 46 0
+12 21 34 0
+13 24 28 0
+14 18 43 0
+15 25 26 0
+19 27 35 0
+22 37 39 0
+1 16 18 0
+2 6 20 0
+3 30 43 0
+4 28 33 0
+5 22 23 44
+7 10 39 41
+8 24 34 37
+9 11 27 32
+12 29 38 47
+13 14 21 40
+15 19 42 45
+17 25 35 36
+21 26 31 46
+12 14 45 48
+1 28 35 37
+2 18 24 31
diff --git a/lib/ldpc/peg/sfpeg2.code b/lib/ldpc/peg/sfpeg2.code
new file mode 100644
index 00000000..0082bd37
--- /dev/null
+++ b/lib/ldpc/peg/sfpeg2.code
@@ -0,0 +1,51 @@
+128
+48
+9
+1 17 34 51 66 81 99 113 127
+2 18 35 50 67 82 100 114 128
+3 19 36 52 68 82 101 115 0
+2 20 36 51 69 83 102 116 0
+4 19 37 53 66 84 103 117 0
+5 21 38 54 70 85 92 114 0
+6 22 39 55 66 85 96 118 0
+7 23 32 56 71 86 103 119 0
+8 20 40 55 72 86 104 120 0
+9 19 41 57 73 87 105 118 0
+10 24 36 56 74 88 106 120 0
+10 17 33 47 75 89 107 121 126
+11 21 42 51 76 87 108 122 0
+1 25 40 58 74 84 109 122 126
+12 22 42 49 77 90 110 123 0
+13 26 43 59 68 89 104 113 0
+13 22 44 57 75 91 106 124 0
+12 23 37 46 78 88 109 113 128
+3 27 34 60 65 87 111 123 0
+6 27 45 61 79 89 98 114 0
+14 28 34 62 72 92 107 122 125
+8 27 42 59 71 92 112 117 0
+15 20 46 57 79 93 101 117 0
+9 29 45 62 74 94 108 119 128
+8 30 38 63 73 95 110 124 0
+16 29 47 64 69 96 110 125 0
+16 23 48 63 76 94 111 120 0
+7 25 39 52 70 97 108 116 127
+4 26 45 63 67 83 90 121 0
+15 28 39 50 76 88 103 115 0
+15 26 33 58 65 97 102 125 128
+14 31 47 52 77 81 93 120 0
+14 24 37 61 71 82 99 116 0
+4 31 40 54 80 91 107 119 0
+5 32 41 58 77 98 111 124 127
+9 18 49 65 79 85 104 124 0
+10 30 43 60 69 84 112 119 127
+1 18 43 48 73 91 98 121 0
+3 21 46 64 67 86 112 118 0
+5 24 48 55 75 93 105 122 0
+2 32 44 62 80 95 99 118 0
+16 28 41 59 80 83 100 123 0
+11 33 35 53 72 96 109 115 0
+11 25 44 60 78 90 100 117 0
+6 31 35 56 70 95 102 123 126
+12 17 50 54 68 94 106 125 0
+13 29 38 53 78 97 105 121 0
+7 30 49 61 64 81 101 126 0
diff --git a/lib/ldpc/peg/sfpeg2.deg b/lib/ldpc/peg/sfpeg2.deg
new file mode 100644
index 00000000..fb023b77
--- /dev/null
+++ b/lib/ldpc/peg/sfpeg2.deg
@@ -0,0 +1,3 @@
+2
+3 4
+.9 .1
diff --git a/lib/ldpc/peg/sfpeg3.alist b/lib/ldpc/peg/sfpeg3.alist
new file mode 100644
index 00000000..e2d9e15f
--- /dev/null
+++ b/lib/ldpc/peg/sfpeg3.alist
@@ -0,0 +1,180 @@
+48 128
+8 3
+8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8
+3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
+1 17 34 51 66 81 99 113
+2 18 35 50 67 82 100 114
+3 19 36 52 68 82 101 115
+2 20 36 51 69 83 102 116
+4 19 37 53 66 84 103 117
+5 21 38 54 70 85 92 114
+6 22 39 55 66 85 96 118
+7 23 32 56 71 86 103 119
+8 20 40 55 72 86 104 120
+9 19 41 57 73 87 105 121
+10 24 36 56 74 88 106 122
+10 17 33 47 75 89 107 119
+11 21 42 51 76 87 108 123
+1 25 40 58 74 84 109 124
+12 22 42 49 77 90 110 122
+13 26 43 59 68 89 104 113
+13 22 44 57 75 91 106 125
+12 23 37 46 78 88 109 113
+3 27 34 60 65 87 111 126
+6 27 45 61 79 89 98 114
+14 28 34 62 72 92 107 125
+8 27 42 59 71 92 112 117
+15 20 46 57 79 93 101 117
+9 29 45 62 74 94 108 127
+8 30 38 63 73 95 110 125
+16 29 47 64 69 96 110 128
+16 23 48 63 76 94 111 121
+7 25 39 52 70 97 108 116
+4 26 45 63 67 83 90 126
+15 28 39 50 76 88 103 115
+15 26 33 58 65 97 102 127
+14 31 47 52 77 81 93 121
+14 24 37 61 71 82 99 116
+4 31 40 54 80 91 107 122
+5 32 41 58 77 98 111 120
+9 18 49 65 79 85 104 123
+10 30 43 60 69 84 112 123
+1 18 43 48 73 91 98 119
+3 21 46 64 67 86 112 118
+5 24 48 55 75 93 105 128
+2 32 44 62 80 95 99 124
+16 28 41 59 80 83 100 118
+11 33 35 53 72 96 109 115
+11 25 44 60 78 90 100 128
+6 31 35 56 70 95 102 126
+12 17 50 54 68 94 106 120
+13 29 38 53 78 97 105 124
+7 30 49 61 64 81 101 127
+1 14 38
+2 4 41
+3 19 39
+5 29 34
+6 35 40
+7 20 45
+8 28 48
+9 22 25
+10 24 36
+11 12 37
+13 43 44
+15 18 46
+16 17 47
+21 32 33
+23 30 31
+26 27 42
+1 12 46
+2 36 38
+3 5 10
+4 9 23
+6 13 39
+7 15 17
+8 18 27
+11 33 40
+14 28 44
+16 29 31
+19 20 22
+21 30 42
+24 26 47
+25 37 48
+32 34 45
+8 35 41
+12 31 43
+1 19 21
+2 43 45
+3 4 11
+5 18 33
+6 25 47
+7 28 30
+9 14 34
+10 35 42
+13 15 22
+16 37 38
+17 41 44
+20 24 29
+18 23 39
+12 26 32
+27 38 40
+15 36 48
+2 30 46
+1 4 13
+3 28 32
+5 43 47
+6 34 46
+7 9 40
+8 11 45
+10 17 23
+14 31 35
+16 22 42
+19 37 44
+20 33 48
+21 24 41
+25 27 29
+26 39 48
+19 31 36
+1 5 7
+2 29 39
+3 16 46
+4 26 37
+6 28 45
+8 22 33
+9 21 43
+10 25 38
+11 14 24
+12 17 40
+13 27 30
+15 32 35
+18 44 47
+20 23 36
+34 41 42
+1 32 48
+2 3 33
+4 29 42
+5 14 37
+6 7 36
+8 9 39
+10 13 19
+11 18 30
+12 16 20
+15 29 44
+17 34 38
+6 21 22
+23 32 40
+24 27 46
+25 41 45
+7 26 43
+28 31 47
+20 35 38
+1 33 41
+2 42 44
+3 23 48
+4 31 45
+5 8 30
+9 16 36
+10 40 47
+11 17 46
+12 21 34
+13 24 28
+14 18 43
+15 25 26
+19 27 35
+22 37 39
+1 16 18
+2 6 20
+3 30 43
+4 28 33
+5 22 23
+7 39 42
+8 12 38
+9 35 46
+10 27 32
+11 15 34
+13 36 37
+14 41 47
+17 21 25
+19 29 45
+24 31 48
+26 40 44
diff --git a/lib/ldpc/peg/sfpeg3.code b/lib/ldpc/peg/sfpeg3.code
new file mode 100644
index 00000000..10064e07
--- /dev/null
+++ b/lib/ldpc/peg/sfpeg3.code
@@ -0,0 +1,51 @@
+128
+48
+8
+1 17 34 51 66 81 99 113
+2 18 35 50 67 82 100 114
+3 19 36 52 68 82 101 115
+2 20 36 51 69 83 102 116
+4 19 37 53 66 84 103 117
+5 21 38 54 70 85 92 114
+6 22 39 55 66 85 96 118
+7 23 32 56 71 86 103 119
+8 20 40 55 72 86 104 120
+9 19 41 57 73 87 105 121
+10 24 36 56 74 88 106 122
+10 17 33 47 75 89 107 119
+11 21 42 51 76 87 108 123
+1 25 40 58 74 84 109 124
+12 22 42 49 77 90 110 122
+13 26 43 59 68 89 104 113
+13 22 44 57 75 91 106 125
+12 23 37 46 78 88 109 113
+3 27 34 60 65 87 111 126
+6 27 45 61 79 89 98 114
+14 28 34 62 72 92 107 125
+8 27 42 59 71 92 112 117
+15 20 46 57 79 93 101 117
+9 29 45 62 74 94 108 127
+8 30 38 63 73 95 110 125
+16 29 47 64 69 96 110 128
+16 23 48 63 76 94 111 121
+7 25 39 52 70 97 108 116
+4 26 45 63 67 83 90 126
+15 28 39 50 76 88 103 115
+15 26 33 58 65 97 102 127
+14 31 47 52 77 81 93 121
+14 24 37 61 71 82 99 116
+4 31 40 54 80 91 107 122
+5 32 41 58 77 98 111 120
+9 18 49 65 79 85 104 123
+10 30 43 60 69 84 112 123
+1 18 43 48 73 91 98 119
+3 21 46 64 67 86 112 118
+5 24 48 55 75 93 105 128
+2 32 44 62 80 95 99 124
+16 28 41 59 80 83 100 118
+11 33 35 53 72 96 109 115
+11 25 44 60 78 90 100 128
+6 31 35 56 70 95 102 126
+12 17 50 54 68 94 106 120
+13 29 38 53 78 97 105 124
+7 30 49 61 64 81 101 127
diff --git a/lib/ldpc/peg/sfpeg3.deg b/lib/ldpc/peg/sfpeg3.deg
new file mode 100644
index 00000000..0fb5a574
--- /dev/null
+++ b/lib/ldpc/peg/sfpeg3.deg
@@ -0,0 +1,3 @@
+1
+3
+1.0