I wrote a code to read the parity check matrix named "tannergraph" which is stores in a sparse format to save space. It is in the following form:
Line 1: Number of Variable Nodes(VN) Number of Check Nodes(CN)
Line 2: Column weight Row weight
Next VN lines: degree of the variable node followed by the check node neighbors
Next CN lines: degree of the check node followed by the variable node neighbors.
Now I need help writing a code that create a binary matrix file with the same number of rows and columns to simulate the binary symmetric channel with a probability error alpha between 0.01 - 0.1, 1 been the error. Please put some comment on the response to make it easier to understand. Thank you
here is my code
#include <stdio.h>
#include <math.h>
#include <errno.h>
int errno;
int main(int argc, char *argv[]){
FILE *fp;
int currentNumb =0;
int checknode, vnode, col_degree, row_degree, numb, i, j, k, l, M, N, zi, Imax;
int status; // take it out later
double ri, Li, Mcv, Mvc, Zi, SumOf, rij;
fp = fopen("TannerMatrix.dat", "r");
// if(fp == NULL){
// perrror(argv[1]);
// return 1;
// exit(1);
//}
fscanf(fp, "%d", &checknode);
fscanf(fp, "%d", &vnode);
fscanf(fp, "%d", &col_degree);
fscanf(fp, "%d", &row_degree);
int arr[checknode][vnode];
int countOnesInChecknodes = 0;
int countOnesInVnodes = 0;
printf("%d\n", vnode);
printf("%d\n", checknode);
printf("%d\n", col_degree);
printf("%d\n", row_degree);
for(i = 0; i<vnode; i++)
{
for(j=0; j<col_degree+1; j++)
{
if(j == 0)
fscanf(fp, "%d", &numb);
else{
fscanf(fp, "%d", &numb);
arr[i][numb] = 1;
countOnesInVnodes++;
}
}
//fscanf(fp, "%d", &numb);
}
for(i = 0; i<checknode; i++)
{
for(j=0; j<row_degree+1; j++)
{
if(j == 0)
fscanf(fp, "%d", &numb);
else
{
fscanf(fp, "%d", &numb);
arr[numb][i];
}
}
//fscanf(fp, "%d", &numb);
}
fclose(fp);
int n,m;
for(n = 0; n<93; n++){
for(m = 0; m<155; m++){
printf("%d", arr[n][m]);
}
printf("\n");
}
scanf("%d", &status);
// for(i = 0; i<N; i++)
// {
// for(j=0; j<M; j++)
// mvc = rij
// {
// }
// }
return 0;
}
//looking through an array