📄 loadbasicmatrix.cpp
字号:
/**********************************************/
/* Basic Check Matrix Loader
/* int LoadBasicMatrixF(struct BasicParaS * ctrl)
/* Written by: Ouyang Ziyue,
/* Date: Jun 6st, 2007,
/* Function: It loads the basic check matrix to initialize the LDPC evaluation platform,
/* Input parameter:
/* The input basic check matrices of WiMAX16e are all stored in the file of
/* "BasicMatrix_wimax16e.ini".
/* The type of basic check matrices is needed.
/* Output parameter:
/* ctrl is a predefined struct which includes the basic check matrices,
/* The return value is a flag to indicate that whether this function is executed successfully.
/* Note:
/* ctrl should be built before this function is called, and the files stored the basic check
/* matrices should be set correctly ahead.
/**********************************************/
#include "parameter_sets.h"
int LoadBasicMatrixF(struct BasicParaS * ctrl)
{
//////////////////////////////////////////////////////////////////
//Declaration
FILE * fpBasicMatrix;
char buffer[120];
int i,j;
//////////////////////////////////////////////////////////////////
//Initialization
if ((fpBasicMatrix=fopen("BasicMatrix_wimax16e.ini","r"))==NULL)
{
printf("Can't open the file 'BasicMatrix_wimax164.ini'\n");
exit(0);
}
switch(ctrl->typeH) {
case 0:
for (i=0; i<1; i++)
fgets(buffer, 120, fpBasicMatrix);
for (i=0; i<ctrl->numRows; i++)
{
for (j=0; j<ctrl->numCols; j++)
{
fscanf(fpBasicMatrix, "%d" ,&ctrl->basicH[i][j]);
}
}
break;
case 1:
for (i=0; i<1+13; i++)
{
fgets(buffer, 120, fpBasicMatrix);
}
for (i=0; i<ctrl->numRows; i++)
{
for (j=0; j<ctrl->numCols; j++)
{
fscanf(fpBasicMatrix, "%d" ,&ctrl->basicH[i][j]);
}
}
break;
case 2:
for (i=0; i<1+13+9; i++)
{
fgets(buffer, 120, fpBasicMatrix);
}
for (i=0; i<ctrl->numRows; i++)
{
for (j=0; j<ctrl->numCols; j++)
{
fscanf(fpBasicMatrix, "%d" ,&ctrl->basicH[i][j]);
}
}
break;
case 3:
for (i=0; i<1+13+9+9; i++)
{
fgets(buffer, 120, fpBasicMatrix);
}
for (i=0; i<ctrl->numRows; i++)
{
for (j=0; j<ctrl->numCols; j++)
{
fscanf(fpBasicMatrix, "%d" ,&ctrl->basicH[i][j]);
}
}
break;
case 4:
for (i=0; i<1+13+9+9+7; i++)
{
fgets(buffer, 120, fpBasicMatrix);
}
for (i=0; i<ctrl->numRows; i++)
{
for (j=0; j<ctrl->numCols; j++)
{
fscanf(fpBasicMatrix, "%d" ,&ctrl->basicH[i][j]);
}
}
break;
case 5:
for (i=0; i<1+13+9+9+7+7; i++)
{
fgets(buffer, 120, fpBasicMatrix);
}
for (i=0; i<ctrl->numRows; i++)
{
for (j=0; j<ctrl->numCols; j++)
{
fscanf(fpBasicMatrix, "%d" ,&ctrl->basicH[i][j]);
}
}
break;
default:
exit(0);
}
//////////////////////////////////////////////////////////////////
//DEBUG
#ifdef DEBUG
printf("The Basic Matrix is: \n");
for (i=0; i<ctrl->numRows; i++)
{
for (j=0; j<ctrl->numCols; j++)
{
printf("%2d ",ctrl->basicH[i][j]);
}
printf("\n");
}
#endif
//////////////////////////////////////////////////////////////////
fclose(fpBasicMatrix);
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -