⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 expandmatrix.cpp

📁 这个是数据打孔重传程序的源代码
💻 CPP
字号:
/**********************************************/
/* Generator of Expand Check Matri   
/* int LoadBasicMatrixF(struct BasicParaS * ctrl)
/*      Written by: Ouyang Ziyue,
/*            Date: Jun 6st, 2007,
/*        Function: It expands the basic check matrix to the large check matrix using the expanding
/*                  factor Z,
/* Input parameter:
/*        The input is the basic check matrix and the expanding factor Z
/* Output parameter:
/*        ctrl is a predefined struct which includes the expand check matrices,the R matrix and the Q matrix
/*        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 basic check matrices should
/*        be loaded ahead and the Z factor is also needed to be calculated ahead.
/**********************************************/

#include "parameter_sets.h"

int ExpandMatrixF(struct BasicParaS * ctrl)
{
	/////////////////////////////////////////////////////////////////////////////////
	//Declaration
	int i, j, k, temp;
	int z0; // z0 is the maximum value of z factor
	struct LinkNode * * * currentNode = new struct LinkNode * *[ctrl->zfactor];
	struct LinkNode * c;
	z0 = 96;


	////////////////////////////////////////////////////////////////////////////////
	//Generate the expand matrix
		if (ctrl->typeH == 1) {
			for (i=0; i<ctrl->numRows; i++) {
				for (j=0; j<ctrl->numCols; j++) {
					if (ctrl->basicH[i][j] <= 0) {
						ctrl->expandedH[i][j] = ctrl->basicH[i][j];
					} else {
						ctrl->expandedH[i][j] = ctrl->basicH[i][j]%ctrl->zfactor;
					}
				}
			}	
		} else {
			for (i=0; i<ctrl->numRows; i++) {
				for (j=0; j<ctrl->numCols; j++) {
					if (ctrl->basicH[i][j] <= 0) {
						ctrl->expandedH[i][j] = ctrl->basicH[i][j];
					} else {
						ctrl->expandedH[i][j] = (ctrl->basicH[i][j]*ctrl->zfactor)/z0;
					}
				}
			}		
		}

#ifdef DEBUG
		printf("The expanded matrix is ..\n");
		for (i=0; i<ctrl->numRows; i++) {
			for (j=0; j<ctrl->numCols; j++) {
				printf(" %2d", ctrl->expandedH[i][j]);
			}
			printf("\n");
		}
#endif

	// Build a cross-link to record the H matrix
	ctrl->rowLink = new struct LinkNode *[ctrl->numChk];
	ctrl->colLink = new struct LinkNode *[ctrl->numOutBits];

	// Insert the head node per row into the row link
	for (i=0; i<ctrl->numRows; i++) {
		for (k=0; k<ctrl->zfactor; k++) {
			*(currentNode+k) = ctrl->rowLink+i*ctrl->zfactor+k;
		}
		for (j=0; j<ctrl->numCols; j++) {
			if (ctrl->expandedH[i][j] >= 0) {
				for (k=0; k<ctrl->zfactor; k++) {
					temp = (k+ctrl->expandedH[i][j])%ctrl->zfactor;
					*(*(currentNode+k)) = new struct LinkNode;
					(*(*(currentNode+k)))->rowIdx = i*ctrl->zfactor+k;
					(*(*(currentNode+k)))->colIdx = j*ctrl->zfactor+temp;
					(*(*(currentNode+k)))->rowPtr = NULL;
					(*(*(currentNode+k)))->colPtr = NULL;
					(*(*(currentNode+k)))->rMsg[0] = 0;
					(*(*(currentNode+k)))->rMsg[1] = 0;
					(*(*(currentNode+k)))->qMsg[0] = 0;
					(*(*(currentNode+k)))->qMsg[1] = 0;
					*(currentNode+k) = &((*(*(currentNode+k)))->rowPtr);
				}
			}
		}
	}

	// Link the nodes in the same column
	for (i=0; i<ctrl->numCols; i++) {
		for (k=0; k<ctrl->zfactor; k++) {
			*(currentNode+k) = ctrl->colLink+i*ctrl->zfactor+k;
		}
		for (j=0; j<ctrl->numRows; j++) {
			if (ctrl->expandedH[j][i] >= 0) {
				for (k=0; k<ctrl->zfactor; k++) {
					temp = (k+ctrl->zfactor-ctrl->expandedH[j][i])%ctrl->zfactor;
					c = *(ctrl->rowLink+j*ctrl->zfactor+temp);
					while (c->colIdx != (i*ctrl->zfactor+k)) {
						c = c->rowPtr;
					}
					*(*(currentNode+k)) = c;
					*(currentNode+k) = &(c->colPtr);
				}
			}
		}
	}

	delete [] currentNode;
#ifdef DEBUG
		printf("This is the cross link per row ..\n");
		for (i=0; i<ctrl->numChk; i++) {
			c = *(ctrl->rowLink+i);
			while (c != NULL) {
				printf("(%d,%d)->", c->rowIdx, c->colIdx);
				c = c->rowPtr;
			}
			printf("End of Row\n");
		}

		printf("This is the cross link per col ..\n");
		for (i=0; i<ctrl->numOutBits; i++) {
			c = *(ctrl->colLink+i);
			while (c != NULL) {
				printf("(%d,%d)->", c->rowIdx, c->colIdx);
				c = c->colPtr;
			}
			printf("End of Col\n");
		}

#endif

	return 0;
 }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -