mirror of
				https://github.com/saitohirga/WSJT-X.git
				synced 2025-10-29 20:10:28 -04:00 
			
		
		
		
	Apply Nico's QRA changes as of 2016/06/23
git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@6801 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
		
							parent
							
								
									83a1308f52
								
							
						
					
					
						commit
						22bba3ad37
					
				| @ -74,6 +74,7 @@ unsigned GetTickCount(void) { | |||||||
| 
 | 
 | ||||||
| #include <stdlib.h> | #include <stdlib.h> | ||||||
| #include <stdio.h> | #include <stdio.h> | ||||||
|  | #include <string.h> | ||||||
| 
 | 
 | ||||||
| #include "qra65.h" | #include "qra65.h" | ||||||
| #include "../qracodes/normrnd.h"		   // gaussian numbers generator | #include "../qracodes/normrnd.h"		   // gaussian numbers generator | ||||||
| @ -209,7 +210,7 @@ int test_proc_1(int channel_type, float EbNodB, int mode) | |||||||
| 
 | 
 | ||||||
| 	int x[QRA65_K], xdec[QRA65_K]; | 	int x[QRA65_K], xdec[QRA65_K]; | ||||||
| 	int y[QRA65_N]; | 	int y[QRA65_N]; | ||||||
| 	float *r; | 	float *rx; | ||||||
| 	int rc; | 	int rc; | ||||||
| 
 | 
 | ||||||
| 	// each simulated station must use its own codec
 | 	// each simulated station must use its own codec
 | ||||||
| @ -222,40 +223,40 @@ int test_proc_1(int channel_type, float EbNodB, int mode) | |||||||
| 	printf("IV3NWV tx: CQ IV3NWV\n"); | 	printf("IV3NWV tx: CQ IV3NWV\n"); | ||||||
| 	encodemsg_jt65(x,CALL_CQ,CALL_IV3NWV,GRID_BLANK); | 	encodemsg_jt65(x,CALL_CQ,CALL_IV3NWV,GRID_BLANK); | ||||||
| 	qra65_encode(codec_iv3nwv, y, x); | 	qra65_encode(codec_iv3nwv, y, x); | ||||||
| 	r = mfskchannel(y,channel_type,EbNodB); | 	rx = mfskchannel(y,channel_type,EbNodB); | ||||||
| 
 | 
 | ||||||
| 	// K1JT attempts to decode
 | 	// K1JT attempts to decode
 | ||||||
| 	rc = qra65_decode(codec_k1jt, xdec,r); | 	rc = qra65_decode(codec_k1jt, xdec,rx); | ||||||
| 	if (rc>=0) { // decoded
 | 	if (rc>=0) { // decoded
 | ||||||
| 		printf("K1JT   rx: received with apcode=%d %s\n",rc, decode_type[rc]); | 		printf("K1JT   rx: received with apcode=%d %s\n",rc, decode_type[rc]); | ||||||
| 		// K1JT replies to IV3NWV (with no grid)
 | 		// K1JT replies to IV3NWV (with no grid)
 | ||||||
| 		printf("K1JT   tx: IV3NWV K1JT\n"); | 		printf("K1JT   tx: IV3NWV K1JT\n"); | ||||||
| 		encodemsg_jt65(x,CALL_IV3NWV,CALL_K1JT, GRID_BLANK); | 		encodemsg_jt65(x,CALL_IV3NWV,CALL_K1JT, GRID_BLANK); | ||||||
| 		qra65_encode(codec_k1jt, y, x); | 		qra65_encode(codec_k1jt, y, x); | ||||||
| 		r = mfskchannel(y,channel_type,EbNodB); | 		rx = mfskchannel(y,channel_type,EbNodB); | ||||||
| 
 | 
 | ||||||
| 		// IV3NWV attempts to decode
 | 		// IV3NWV attempts to decode
 | ||||||
| 		rc = qra65_decode(codec_iv3nwv, xdec,r); | 		rc = qra65_decode(codec_iv3nwv, xdec,rx); | ||||||
| 		if (rc>=0) { // decoded
 | 		if (rc>=0) { // decoded
 | ||||||
| 			printf("IV3NWV rx: received with apcode=%d %s\n",rc, decode_type[rc]); | 			printf("IV3NWV rx: received with apcode=%d %s\n",rc, decode_type[rc]); | ||||||
| 			// IV3NWV replies to K1JT with a 73
 | 			// IV3NWV replies to K1JT with a 73
 | ||||||
| 			printf("IV3NWV tx: K1JT   IV3NWV 73\n"); | 			printf("IV3NWV tx: K1JT   IV3NWV 73\n"); | ||||||
| 			encodemsg_jt65(x,CALL_K1JT,CALL_IV3NWV, GRID_73); | 			encodemsg_jt65(x,CALL_K1JT,CALL_IV3NWV, GRID_73); | ||||||
| 			qra65_encode(codec_iv3nwv, y, x); | 			qra65_encode(codec_iv3nwv, y, x); | ||||||
| 			r = mfskchannel(y,channel_type,EbNodB); | 			rx = mfskchannel(y,channel_type,EbNodB); | ||||||
| 
 | 
 | ||||||
| 			// K1JT attempts to decode
 | 			// K1JT attempts to decode
 | ||||||
| 			rc = qra65_decode(codec_k1jt, xdec,r); | 			rc = qra65_decode(codec_k1jt, xdec,rx); | ||||||
| 			if (rc>=0) { // decoded
 | 			if (rc>=0) { // decoded
 | ||||||
| 				printf("K1JT   rx: received with apcode=%d %s\n",rc, decode_type[rc]); | 				printf("K1JT   rx: received with apcode=%d %s\n",rc, decode_type[rc]); | ||||||
| 				// K1JT replies to IV3NWV with a 73
 | 				// K1JT replies to IV3NWV with a 73
 | ||||||
| 				printf("K1JT   tx: IV3NWV K1JT   73\n"); | 				printf("K1JT   tx: IV3NWV K1JT   73\n"); | ||||||
| 				encodemsg_jt65(x,CALL_IV3NWV,CALL_K1JT, GRID_73); | 				encodemsg_jt65(x,CALL_IV3NWV,CALL_K1JT, GRID_73); | ||||||
| 				qra65_encode(codec_k1jt, y, x); | 				qra65_encode(codec_k1jt, y, x); | ||||||
| 				r = mfskchannel(y,channel_type,EbNodB); | 				rx = mfskchannel(y,channel_type,EbNodB); | ||||||
| 
 | 
 | ||||||
| 				// IV3NWV attempts to decode
 | 				// IV3NWV attempts to decode
 | ||||||
| 				rc = qra65_decode(codec_iv3nwv, xdec,r); | 				rc = qra65_decode(codec_iv3nwv, xdec,rx); | ||||||
| 				if (rc>=0) { // decoded
 | 				if (rc>=0) { // decoded
 | ||||||
| 					printf("IV3NWV rx: received with apcode=%d %s\n",rc, decode_type[rc]); | 					printf("IV3NWV rx: received with apcode=%d %s\n",rc, decode_type[rc]); | ||||||
| 					return 0; | 					return 0; | ||||||
| @ -292,7 +293,7 @@ int test_proc_2(int channel_type, float EbNodB, int mode) | |||||||
| 
 | 
 | ||||||
| 	int x[QRA65_K], xdec[QRA65_K]; | 	int x[QRA65_K], xdec[QRA65_K]; | ||||||
| 	int y[QRA65_N]; | 	int y[QRA65_N]; | ||||||
| 	float *r; | 	float *rx; | ||||||
| 	int rc,k; | 	int rc,k; | ||||||
| 
 | 
 | ||||||
| 	int ndecok[6] = { 0, 0, 0, 0, 0, 0}; | 	int ndecok[6] = { 0, 0, 0, 0, 0, 0}; | ||||||
| @ -315,8 +316,8 @@ int test_proc_2(int channel_type, float EbNodB, int mode) | |||||||
| 
 | 
 | ||||||
| 	for (k=0;k<ntx;k++) { | 	for (k=0;k<ntx;k++) { | ||||||
| 		printf("."); | 		printf("."); | ||||||
| 		r = mfskchannel(y,channel_type,EbNodB); | 		rx = mfskchannel(y,channel_type,EbNodB); | ||||||
| 		rc = qra65_decode(codec_k1jt, xdec,r); | 		rc = qra65_decode(codec_k1jt, xdec,rx); | ||||||
| 		if (rc>=0)  | 		if (rc>=0)  | ||||||
| 			ndecok[rc]++; | 			ndecok[rc]++; | ||||||
| 		} | 		} | ||||||
| @ -369,7 +370,7 @@ int main(int argc, char* argv[]) | |||||||
| 			} | 			} | ||||||
| 		else | 		else | ||||||
| 		if (strncmp(*argv,"-a",2)==0) { | 		if (strncmp(*argv,"-a",2)==0) { | ||||||
| 			mode = (unsigned int)atoi((*argv)+2); | 			mode = ( int)atoi((*argv)+2); | ||||||
| 			if (mode>1) { | 			if (mode>1) { | ||||||
| 				printf("Invalid decoding mode\n"); | 				printf("Invalid decoding mode\n"); | ||||||
| 				syntax(); | 				syntax(); | ||||||
| @ -387,7 +388,7 @@ int main(int argc, char* argv[]) | |||||||
| 			} | 			} | ||||||
| 		else | 		else | ||||||
| 		if (strncmp(*argv,"-t",2)==0) { | 		if (strncmp(*argv,"-t",2)==0) { | ||||||
| 			testtype = (unsigned int)atoi((*argv)+2); | 			testtype = ( int)atoi((*argv)+2); | ||||||
| 			if (testtype>1) { | 			if (testtype>1) { | ||||||
| 				printf("Invalid test type\n"); | 				printf("Invalid test type\n"); | ||||||
| 				syntax(); | 				syntax(); | ||||||
| @ -396,7 +397,7 @@ int main(int argc, char* argv[]) | |||||||
| 			} | 			} | ||||||
| 		else | 		else | ||||||
| 		if (strncmp(*argv,"-c",2)==0) { | 		if (strncmp(*argv,"-c",2)==0) { | ||||||
| 			channel = (unsigned int)atoi((*argv)+2); | 			channel = ( int)atoi((*argv)+2); | ||||||
| 			if (channel>CHANNEL_RAYLEIGH) { | 			if (channel>CHANNEL_RAYLEIGH) { | ||||||
| 				printf("Invalid channel type\n"); | 				printf("Invalid channel type\n"); | ||||||
| 				syntax(); | 				syntax(); | ||||||
| @ -412,6 +413,10 @@ int main(int argc, char* argv[]) | |||||||
| 
 | 
 | ||||||
| 	EbNodB = SNRdB+29.1f; | 	EbNodB = SNRdB+29.1f; | ||||||
| 
 | 
 | ||||||
|  | #if defined(__linux__) || defined(__unix__) | ||||||
|  | 	srand48(GetTickCount()); | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
| 	if (testtype==0) { | 	if (testtype==0) { | ||||||
| 		for (k=0;k<nqso;k++) { | 		for (k=0;k<nqso;k++) { | ||||||
| 			printf("\n\n------------------------\n"); | 			printf("\n\n------------------------\n"); | ||||||
|  | |||||||
| @ -152,7 +152,7 @@ void qra65_encode(qra65codec *pcodec, int *y, const int *x) | |||||||
| 
 | 
 | ||||||
| int qra65_decode(qra65codec *pcodec, int *x, const float *rxen) | int qra65_decode(qra65codec *pcodec, int *x, const float *rxen) | ||||||
| { | { | ||||||
| 	uint k; | 	int k; | ||||||
| 	float *srctmp, *dsttmp; | 	float *srctmp, *dsttmp; | ||||||
| 	float ix[QRA65_NC*QRA65_M];		// (depunctured) intrisic information to the decoder
 | 	float ix[QRA65_NC*QRA65_M];		// (depunctured) intrisic information to the decoder
 | ||||||
| 	int rc; | 	int rc; | ||||||
| @ -276,7 +276,7 @@ static void ix_mask(float *dst, const float *src, const int *mask, const int *x) | |||||||
| { | { | ||||||
| 	// mask intrinsic information (channel observations) with a priori knowledge
 | 	// mask intrinsic information (channel observations) with a priori knowledge
 | ||||||
| 	 | 	 | ||||||
| 	uint k,kk, smask; | 	int k,kk, smask; | ||||||
| 	float *row; | 	float *row; | ||||||
| 
 | 
 | ||||||
| 	memcpy(dst,src,(QRA65_NC*QRA65_M)*sizeof(float)); | 	memcpy(dst,src,(QRA65_NC*QRA65_M)*sizeof(float)); | ||||||
|  | |||||||
| @ -60,9 +60,9 @@ | |||||||
| #include <unistd.h> | #include <unistd.h> | ||||||
| #include <time.h> | #include <time.h> | ||||||
| 
 | 
 | ||||||
| unsigned GetTickCount(void) { |  GetTickCount(void) { | ||||||
|     struct timespec ts; |     struct timespec ts; | ||||||
|     unsigned theTick = 0U; |      theTick = 0U; | ||||||
|     clock_gettime( CLOCK_REALTIME, &ts ); |     clock_gettime( CLOCK_REALTIME, &ts ); | ||||||
|     theTick  = ts.tv_nsec / 1000000; |     theTick  = ts.tv_nsec / 1000000; | ||||||
|     theTick += ts.tv_sec * 1000; |     theTick += ts.tv_sec * 1000; | ||||||
| @ -116,7 +116,7 @@ const char fnameout_sfx[4][64] = { | |||||||
| 	"-ap56.txt" | 	"-ap56.txt" | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| const uint ap_masks_jt65[4][13] = {  | const int ap_masks_jt65[4][13] = {  | ||||||
| // Each row must be 13 entries long (to handle puntc. codes 13,64)
 | // Each row must be 13 entries long (to handle puntc. codes 13,64)
 | ||||||
| // The mask of 13th symbol (crc) is alway initializated to 0
 | // The mask of 13th symbol (crc) is alway initializated to 0
 | ||||||
| 	// AP0  - no a-priori knowledge
 | 	// AP0  - no a-priori knowledge
 | ||||||
| @ -150,8 +150,8 @@ typedef struct { | |||||||
| 	volatile int done; | 	volatile int done; | ||||||
| 	int		ap_index;		// index to the a priori knowledge mask
 | 	int		ap_index;		// index to the a priori knowledge mask
 | ||||||
| 	const qracode	*pcode;	// pointer to the code descriptor
 | 	const qracode	*pcode;	// pointer to the code descriptor
 | ||||||
| 	uint	*x;				//[qra_K];		    input message buffer
 | 	int	*x;				//[qra_K];		    input message buffer
 | ||||||
| 	uint	*y, *ydec;		//[qra_N];			encoded/decoded codewords buffers
 | 	int	*y, *ydec;		//[qra_N];			encoded/decoded codewords buffers
 | ||||||
| 	float	*qra_v2cmsg;	//[qra_NMSG*qra_M]; MP decoder v->c msg buffer 
 | 	float	*qra_v2cmsg;	//[qra_NMSG*qra_M]; MP decoder v->c msg buffer 
 | ||||||
| 	float	*qra_c2vmsg;	//[qra_NMSG*qra_M]; MP decoder c->v msg buffer
 | 	float	*qra_c2vmsg;	//[qra_NMSG*qra_M]; MP decoder c->v msg buffer
 | ||||||
| 	float	*rp;			// [qra_N*qra_M];	received samples (real component) buffer
 | 	float	*rp;			// [qra_N*qra_M];	received samples (real component) buffer
 | ||||||
| @ -194,11 +194,11 @@ int calc_crc6(int *x, int sz) | |||||||
| void wer_test_thread(wer_test_ds *pdata) | void wer_test_thread(wer_test_ds *pdata) | ||||||
| { | { | ||||||
| 	const qracode *pcode=pdata->pcode; | 	const qracode *pcode=pdata->pcode; | ||||||
| 	const uint qra_K = pcode->K; | 	const int qra_K = pcode->K; | ||||||
| 	const uint qra_N = pcode->N; | 	const int qra_N = pcode->N; | ||||||
| 	const uint qra_M = pcode->M; | 	const int qra_M = pcode->M; | ||||||
| 	const uint qra_m = pcode->m; | 	const int qra_m = pcode->m; | ||||||
| 	const uint NSAMPLES = pcode->N*pcode->M; | 	const int NSAMPLES = pcode->N*pcode->M; | ||||||
| 
 | 
 | ||||||
| 	const float No = 1.0f;		// noise spectral density
 | 	const float No = 1.0f;		// noise spectral density
 | ||||||
| 	const float sigma   = (float)sqrt(No/2.0f);	// std dev of noise I/Q components
 | 	const float sigma   = (float)sqrt(No/2.0f);	// std dev of noise I/Q components
 | ||||||
| @ -208,7 +208,7 @@ void wer_test_thread(wer_test_ds *pdata) | |||||||
| 	const float EbNodBMetric = 2.8f;  | 	const float EbNodBMetric = 2.8f;  | ||||||
| 	const float EbNoMetric   = (float)pow(10,EbNodBMetric/10); | 	const float EbNoMetric   = (float)pow(10,EbNodBMetric/10); | ||||||
| 
 | 
 | ||||||
| 	uint k,t,j,diff; | 	int k,t,j,diff; | ||||||
| 	float R; | 	float R; | ||||||
| 	float EsNoMetric; | 	float EsNoMetric; | ||||||
| 	float EbNo, EsNo, Es, A; | 	float EbNo, EsNo, Es, A; | ||||||
| @ -220,8 +220,8 @@ void wer_test_thread(wer_test_ds *pdata) | |||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 	// inizialize pointer to required buffers
 | 	// inizialize pointer to required buffers
 | ||||||
| 	uint *x=pdata->x;			// message buffer
 | 	int *x=pdata->x;			// message buffer
 | ||||||
| 	uint *y=pdata->y, *ydec=pdata->ydec;	// encoded/decoded codeword buffers
 | 	int *y=pdata->y, *ydec=pdata->ydec;	// encoded/decoded codeword buffers
 | ||||||
| 	float *qra_v2cmsg=pdata->qra_v2cmsg; // table of the v->c messages
 | 	float *qra_v2cmsg=pdata->qra_v2cmsg; // table of the v->c messages
 | ||||||
| 	float *qra_c2vmsg=pdata->qra_c2vmsg; // table of the c->v messages
 | 	float *qra_c2vmsg=pdata->qra_c2vmsg; // table of the c->v messages
 | ||||||
| 	float *rp=pdata->rp;		// received samples (real component)
 | 	float *rp=pdata->rp;		// received samples (real component)
 | ||||||
| @ -374,10 +374,10 @@ void ix_mask(const qracode *pcode, float *r, const int *mask, const int *x) | |||||||
| { | { | ||||||
| 	// mask intrinsic information (channel observations) with a priori knowledge
 | 	// mask intrinsic information (channel observations) with a priori knowledge
 | ||||||
| 	 | 	 | ||||||
| 	uint k,kk, smask; | 	int k,kk, smask; | ||||||
| 	const uint qra_K=pcode->K; | 	const int qra_K=pcode->K; | ||||||
| 	const uint qra_M=pcode->M; | 	const int qra_M=pcode->M; | ||||||
| 	const uint qra_m=pcode->m; | 	const int qra_m=pcode->m; | ||||||
| 
 | 
 | ||||||
| 	for (k=0;k<qra_K;k++) { | 	for (k=0;k<qra_K;k++) { | ||||||
| 		smask = mask[k]; | 		smask = mask[k]; | ||||||
| @ -392,10 +392,10 @@ void ix_mask(const qracode *pcode, float *r, const int *mask, const int *x) | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| int wer_test_proc(const qracode *pcode, uint nthreads, int chtype, uint ap_index, float *EbNodB, uint *nerrstgt, uint nitems) | int wer_test_proc(const qracode *pcode, int nthreads, int chtype, int ap_index, float *EbNodB, int *nerrstgt, int nitems) | ||||||
| { | { | ||||||
| 	uint k,nn,j,nt,nerrs,nerrsu,nd; | 	int k,nn,j,nt,nerrs,nerrsu,nd; | ||||||
| 	uint cini,cend;  | 	int cini,cend;  | ||||||
| 	char fnameout[128]; | 	char fnameout[128]; | ||||||
| 	FILE *fout; | 	FILE *fout; | ||||||
| 	wer_test_ds wt[NTHREADS_MAX]; | 	wer_test_ds wt[NTHREADS_MAX]; | ||||||
| @ -427,9 +427,9 @@ int wer_test_proc(const qracode *pcode, uint nthreads, int chtype, uint ap_index | |||||||
| 			wt[j].channel_type=chtype; | 			wt[j].channel_type=chtype; | ||||||
| 			wt[j].ap_index = ap_index; | 			wt[j].ap_index = ap_index; | ||||||
| 			wt[j].pcode    = pcode; | 			wt[j].pcode    = pcode; | ||||||
| 			wt[j].x        = (uint*)malloc(pcode->K*sizeof(uint)); | 			wt[j].x        = (int*)malloc(pcode->K*sizeof(int)); | ||||||
| 			wt[j].y        = (uint*)malloc(pcode->N*sizeof(uint)); | 			wt[j].y        = (int*)malloc(pcode->N*sizeof(int)); | ||||||
| 			wt[j].ydec     = (uint*)malloc(pcode->N*sizeof(uint)); | 			wt[j].ydec     = (int*)malloc(pcode->N*sizeof(int)); | ||||||
| 			wt[j].qra_v2cmsg = (float*)malloc(pcode->NMSG*pcode->M*sizeof(float)); | 			wt[j].qra_v2cmsg = (float*)malloc(pcode->NMSG*pcode->M*sizeof(float)); | ||||||
| 			wt[j].qra_c2vmsg = (float*)malloc(pcode->NMSG*pcode->M*sizeof(float)); | 			wt[j].qra_c2vmsg = (float*)malloc(pcode->NMSG*pcode->M*sizeof(float)); | ||||||
| 			wt[j].rp       = (float*)malloc(pcode->N*pcode->M*sizeof(float)); | 			wt[j].rp       = (float*)malloc(pcode->N*pcode->M*sizeof(float)); | ||||||
| @ -570,17 +570,17 @@ int main(int argc, char* argv[]) | |||||||
| { | { | ||||||
| 
 | 
 | ||||||
| 	float EbNodB[SIM_POINTS_MAX]; | 	float EbNodB[SIM_POINTS_MAX]; | ||||||
| 	uint  nerrstgt[SIM_POINTS_MAX]; | 	int  nerrstgt[SIM_POINTS_MAX]; | ||||||
| 	FILE *fin; | 	FILE *fin; | ||||||
| 
 | 
 | ||||||
| 	char fnamein[128]= "ebnovalues.txt"; | 	char fnamein[128]= "ebnovalues.txt"; | ||||||
| 	char buf[128]; | 	char buf[128]; | ||||||
| 
 | 
 | ||||||
| 	uint nitems   = 0; | 	int nitems   = 0; | ||||||
| 	uint code_idx = 1; | 	int code_idx = 1; | ||||||
| 	uint nthreads = 8; | 	int nthreads = 8; | ||||||
| 	uint ch_type  = CHANNEL_AWGN; | 	int ch_type  = CHANNEL_AWGN; | ||||||
| 	uint ap_index = AP_NONE; | 	int ap_index = AP_NONE; | ||||||
| 
 | 
 | ||||||
| 	// parse command line
 | 	// parse command line
 | ||||||
| 	while(--argc) { | 	while(--argc) { | ||||||
| @ -591,7 +591,7 @@ int main(int argc, char* argv[]) | |||||||
| 			} | 			} | ||||||
| 		else | 		else | ||||||
| 		if (strncmp(*argv,"-q",2)==0) { | 		if (strncmp(*argv,"-q",2)==0) { | ||||||
| 			code_idx = (uint)atoi((*argv)+2); | 			code_idx = (int)atoi((*argv)+2); | ||||||
| 			if (code_idx>1) { | 			if (code_idx>1) { | ||||||
| 				printf("Invalid code index\n"); | 				printf("Invalid code index\n"); | ||||||
| 				syntax(); | 				syntax(); | ||||||
| @ -600,7 +600,7 @@ int main(int argc, char* argv[]) | |||||||
| 			} | 			} | ||||||
| 		else | 		else | ||||||
| 		if (strncmp(*argv,"-t",2)==0) { | 		if (strncmp(*argv,"-t",2)==0) { | ||||||
| 			nthreads = (uint)atoi((*argv)+2); | 			nthreads = (int)atoi((*argv)+2); | ||||||
| 			if (nthreads>NTHREADS_MAX) { | 			if (nthreads>NTHREADS_MAX) { | ||||||
| 				printf("Invalid number of threads\n"); | 				printf("Invalid number of threads\n"); | ||||||
| 				syntax(); | 				syntax(); | ||||||
| @ -609,7 +609,7 @@ int main(int argc, char* argv[]) | |||||||
| 			} | 			} | ||||||
| 		else | 		else | ||||||
| 		if (strncmp(*argv,"-c",2)==0) { | 		if (strncmp(*argv,"-c",2)==0) { | ||||||
| 			ch_type = (uint)atoi((*argv)+2); | 			ch_type = (int)atoi((*argv)+2); | ||||||
| 			if (ch_type>CHANNEL_RAYLEIGH) { | 			if (ch_type>CHANNEL_RAYLEIGH) { | ||||||
| 				printf("Invalid channel type\n"); | 				printf("Invalid channel type\n"); | ||||||
| 				syntax(); | 				syntax(); | ||||||
| @ -618,7 +618,7 @@ int main(int argc, char* argv[]) | |||||||
| 			} | 			} | ||||||
| 		else | 		else | ||||||
| 		if (strncmp(*argv,"-a",2)==0) { | 		if (strncmp(*argv,"-a",2)==0) { | ||||||
| 			ap_index = (uint)atoi((*argv)+2); | 			ap_index = (int)atoi((*argv)+2); | ||||||
| 			if (ap_index>AP_56) { | 			if (ap_index>AP_56) { | ||||||
| 				printf("Invalid a-priori information index\n"); | 				printf("Invalid a-priori information index\n"); | ||||||
| 				syntax(); | 				syntax(); | ||||||
|  | |||||||
| @ -29,19 +29,22 @@ | |||||||
| #if _WIN32 // note the underscore: without it, it's not msdn official!
 | #if _WIN32 // note the underscore: without it, it's not msdn official!
 | ||||||
| 	// Windows (x64 and x86)
 | 	// Windows (x64 and x86)
 | ||||||
| 	#include <windows.h>   // required only for GetTickCount(...) | 	#include <windows.h>   // required only for GetTickCount(...) | ||||||
|  | 	#define K_RAND_MAX UINT_MAX | ||||||
| #elif __unix__ // all unices, not all compilers
 | #elif __unix__ // all unices, not all compilers
 | ||||||
| 	#define rand_s rand_r |  | ||||||
| 	#include <stdlib.h> | 	#include <stdlib.h> | ||||||
| 	#include <limits.h> // for UINT_MAX | 	#define rand_s(x) (*x)=(unsigned int)lrand48()	// returns unsigned integers in the range 0..0x7FFFFFFF
 | ||||||
|  | 	#define K_RAND_MAX 0x7FFFFFFF					// that's the max number generated by lrand48
 | ||||||
| 	// Unix
 | 	// Unix
 | ||||||
| #elif __linux__ | #elif __linux__ | ||||||
|  | 	#include <stdlib.h> | ||||||
|  | 	#define rand_s(x) (*x)=(unsigned int)lrand48()	// returns unsigned integers in the range 0..0x7FFFFFFF
 | ||||||
|  | 	#define K_RAND_MAX 0x7FFFFFFF					// that's the max number generated by lrand48
 | ||||||
| 	// linux
 | 	// linux
 | ||||||
| #elif __APPLE__ | #elif __APPLE__ | ||||||
| 	// Mac OS, not sure if this is covered by __posix__ and/or __unix__ though...
 | 	// Mac OS, not sure if this is covered by __posix__ and/or __unix__ though...
 | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| // use MS rand_s(...) function
 | // use MS rand_s(...) function
 | ||||||
| void normrnd_s(float *dst, int nitems, float mean, float stdev) | void normrnd_s(float *dst, int nitems, float mean, float stdev) | ||||||
| { | { | ||||||
| @ -55,13 +58,14 @@ void normrnd_s(float *dst, int nitems, float mean, float stdev) | |||||||
| 			set = 0; | 			set = 0; | ||||||
| 			} | 			} | ||||||
| 		else { | 		else { | ||||||
| 			rand_s(&r); phi = (M_2PI/(1.0f+UINT_MAX))*r; | 			rand_s((unsigned int*)&r); phi = (M_2PI/(1.0f+K_RAND_MAX))*r; | ||||||
| 			rand_s(&r); u   = (float)sqrt(-2.0f* log( (1.0f/(1.0f+UINT_MAX))*(1.0f+r) ) ); | 			rand_s((unsigned int*)&r); u   = (float)sqrt(-2.0f* log( (1.0f/(1.0f+K_RAND_MAX))*(1.0f+r) ) ); | ||||||
| 			*dst++ = (float)cos(phi)*u*stdev+mean; | 			*dst++ = (float)cos(phi)*u*stdev+mean; | ||||||
| 			set=1; | 			set=1; | ||||||
| 			} | 			} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | /* NOT USED
 | ||||||
| // use MS rand() function
 | // use MS rand() function
 | ||||||
| void normrnd(float *dst, int nitems, float mean, float stdev) | void normrnd(float *dst, int nitems, float mean, float stdev) | ||||||
| { | { | ||||||
| @ -80,4 +84,4 @@ void normrnd(float *dst, int nitems, float mean, float stdev) | |||||||
| 			set=1; | 			set=1; | ||||||
| 			} | 			} | ||||||
| } | } | ||||||
| 
 | */ | ||||||
|  | |||||||
| @ -37,9 +37,11 @@ void normrnd_s(float *dst, int nitems, float mean, float stdev); | |||||||
| // generate a random array of numbers with a gaussian distribution of given mean and stdev
 | // generate a random array of numbers with a gaussian distribution of given mean and stdev
 | ||||||
| // use MS rand_s(...) function
 | // use MS rand_s(...) function
 | ||||||
| 
 | 
 | ||||||
|  | /* not used
 | ||||||
| void normrnd(float *dst, int nitems, float mean, float stdev); | void normrnd(float *dst, int nitems, float mean, float stdev); | ||||||
| // generate a random array of numbers with a gaussian distribution of given mean and stdev
 | // generate a random array of numbers with a gaussian distribution of given mean and stdev
 | ||||||
| // use MS rand() function
 | // use MS rand() function
 | ||||||
|  | */ | ||||||
| 
 | 
 | ||||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||||
| } | } | ||||||
|  | |||||||
| @ -331,14 +331,14 @@ void pd_memset(float *dst, const float *src, int ndim, int nitems) | |||||||
| 		} | 		} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void  pd_fwdperm(float *dst, float *src, const unsigned int *perm, int ndim) | void  pd_fwdperm(float *dst, float *src, const  int *perm, int ndim) | ||||||
| { | { | ||||||
| 	// TODO: non-loop implementation
 | 	// TODO: non-loop implementation
 | ||||||
| 	while (ndim--)  | 	while (ndim--)  | ||||||
| 		dst[ndim] = src[perm[ndim]]; | 		dst[ndim] = src[perm[ndim]]; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void  pd_bwdperm(float *dst, float *src, const unsigned int *perm, int ndim) | void  pd_bwdperm(float *dst, float *src, const  int *perm, int ndim) | ||||||
| { | { | ||||||
| 	// TODO: non-loop implementation
 | 	// TODO: non-loop implementation
 | ||||||
| 	while (ndim--)  | 	while (ndim--)  | ||||||
|  | |||||||
| @ -57,12 +57,12 @@ float        pd_norm(float *pd, int nlogdim); | |||||||
| // are replaced with a uniform distribution
 | // are replaced with a uniform distribution
 | ||||||
| // Returns the norm of the distribution prior to the normalization
 | // Returns the norm of the distribution prior to the normalization
 | ||||||
| 
 | 
 | ||||||
| void         pd_fwdperm(float *dst, float *src, const unsigned int *perm, int ndim); | void         pd_fwdperm(float *dst, float *src, const  int *perm, int ndim); | ||||||
| // Forward permutation of a distribution
 | // Forward permutation of a distribution
 | ||||||
| // Computes dst[k] = src[perm[k]] for every element in the distribution
 | // Computes dst[k] = src[perm[k]] for every element in the distribution
 | ||||||
| // perm must be a pointer to an array of integers of length ndim
 | // perm must be a pointer to an array of integers of length ndim
 | ||||||
| 
 | 
 | ||||||
| void         pd_bwdperm(float *dst, float *src, const unsigned int *perm, int ndim); | void         pd_bwdperm(float *dst, float *src, const  int *perm, int ndim); | ||||||
| // Backward permutation of a distribution
 | // Backward permutation of a distribution
 | ||||||
| // Computes dst[perm[k]] = src[k] for every element in the distribution
 | // Computes dst[perm[k]] = src[k] for every element in the distribution
 | ||||||
| // perm must be a pointer to an array of integers of length ndim
 | // perm must be a pointer to an array of integers of length ndim
 | ||||||
|  | |||||||
| @ -52,7 +52,7 @@ static const int qra_acc_input_idx[qra_NC+1] = { | |||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| // table of the systematic symbols weight logarithms over GF(M)
 | // table of the systematic symbols weight logarithms over GF(M)
 | ||||||
| static const unsigned int qra_acc_input_wlog[qra_NC+1] = { | static const  int qra_acc_input_wlog[qra_NC+1] = { | ||||||
|  39,   0,  34,  16,  25,   0,  34,  48,  19,  13,  |  39,   0,  34,  16,  25,   0,  34,  48,  19,  13,  | ||||||
|  29,  56,   0,   5,  39,  42,  31,   0,  10,   0,  |  29,  56,   0,   5,  39,  42,  31,   0,  10,   0,  | ||||||
|  57,  62,  33,  43,   0,  14,  22,  48,  28,  20,  |  57,  62,  33,  43,   0,  14,  22,  48,  28,  20,  | ||||||
| @ -73,7 +73,7 @@ static const int qra_log[qra_M] = { | |||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| // table of GF(M) elements given their logarithm
 | // table of GF(M) elements given their logarithm
 | ||||||
| static const unsigned int qra_exp[qra_M-1] = { | static const  int qra_exp[qra_M-1] = { | ||||||
|   1,   2,   4,   8,  16,  32,   3,   6,  12,  24,  |   1,   2,   4,   8,  16,  32,   3,   6,  12,  24,  | ||||||
|  48,  35,   5,  10,  20,  40,  19,  38,  15,  30,  |  48,  35,   5,  10,  20,  40,  19,  38,  15,  30,  | ||||||
|  60,  59,  53,  41,  17,  34,   7,  14,  28,  56,  |  60,  59,  53,  41,  17,  34,   7,  14,  28,  56,  | ||||||
| @ -84,7 +84,7 @@ static const unsigned int qra_exp[qra_M-1] = { | |||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| // table of the messages weight logarithms over GF(M)
 | // table of the messages weight logarithms over GF(M)
 | ||||||
| static const unsigned int qra_msgw[qra_NMSG] = { | static const  int qra_msgw[qra_NMSG] = { | ||||||
|   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,  | ||||||
| @ -110,7 +110,7 @@ static const unsigned int qra_msgw[qra_NMSG] = { | |||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| // table of the degrees of the variable nodes
 | // table of the degrees of the variable nodes
 | ||||||
| static const unsigned int qra_vdeg[qra_V] = { | static const  int qra_vdeg[qra_V] = { | ||||||
|   4,   4,   4,   4,   5,   5,   5,   6,   6,   6,  |   4,   4,   4,   4,   5,   5,   5,   6,   6,   6,  | ||||||
|   7,   8,   3,   3,   3,   3,   3,   3,   3,   3,  |   7,   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,  | ||||||
| @ -121,7 +121,7 @@ static const unsigned int qra_vdeg[qra_V] = { | |||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| // table of the degrees of the factor nodes
 | // table of the degrees of the factor nodes
 | ||||||
| static const unsigned int qra_cdeg[qra_C] = { | static const  int qra_cdeg[qra_C] = { | ||||||
|   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,  |   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,  | ||||||
|   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,  |   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,  | ||||||
|   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,  |   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,  | ||||||
| @ -237,7 +237,7 @@ static const int qra_c2vmidx[qra_C*qra_MAXCDEG] = { | |||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| // permutation matrix to compute Prob(x*alfa^logw)
 | // permutation matrix to compute Prob(x*alfa^logw)
 | ||||||
| static const unsigned int qra_pmat[qra_M*qra_M] = { | static const  int qra_pmat[qra_M*qra_M] = { | ||||||
|   0,   1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11,  12,  13,  14,  15,  |   0,   1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11,  12,  13,  14,  15,  | ||||||
|  16,  17,  18,  19,  20,  21,  22,  23,  24,  25,  26,  27,  28,  29,  30,  31,  |  16,  17,  18,  19,  20,  21,  22,  23,  24,  25,  26,  27,  28,  29,  30,  31,  | ||||||
|  32,  33,  34,  35,  36,  37,  38,  39,  40,  41,  42,  43,  44,  45,  46,  47,  |  32,  33,  34,  35,  36,  37,  38,  39,  40,  41,  42,  43,  44,  45,  46,  47,  | ||||||
|  | |||||||
| @ -51,7 +51,7 @@ static const int qra_acc_input_idx[qra_NC+1] = { | |||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| // table of the systematic symbols weight logarithms over GF(M)
 | // table of the systematic symbols weight logarithms over GF(M)
 | ||||||
| static const unsigned int qra_acc_input_wlog[qra_NC+1] = { | static const  int qra_acc_input_wlog[qra_NC+1] = { | ||||||
|   0,  27,   0,   0,   0,  31,  28,  61,  31,   0,  |   0,  27,   0,   0,   0,  31,  28,  61,  31,   0,  | ||||||
|   0,  52,  22,   7,  19,  47,  44,  62,  32,  50,  |   0,  52,  22,   7,  19,  47,  44,  62,  32,  50,  | ||||||
|  52,  42,  48,  56,  40,  50,  51,  37,  37,   0,  |  52,  42,  48,  56,  40,  50,  51,  37,  37,   0,  | ||||||
| @ -72,7 +72,7 @@ static const int qra_log[qra_M] = { | |||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| // table of GF(M) elements given their logarithm
 | // table of GF(M) elements given their logarithm
 | ||||||
| static const unsigned int qra_exp[qra_M-1] = { | static const  int qra_exp[qra_M-1] = { | ||||||
|   1,   2,   4,   8,  16,  32,   3,   6,  12,  24,  |   1,   2,   4,   8,  16,  32,   3,   6,  12,  24,  | ||||||
|  48,  35,   5,  10,  20,  40,  19,  38,  15,  30,  |  48,  35,   5,  10,  20,  40,  19,  38,  15,  30,  | ||||||
|  60,  59,  53,  41,  17,  34,   7,  14,  28,  56,  |  60,  59,  53,  41,  17,  34,   7,  14,  28,  56,  | ||||||
| @ -83,7 +83,7 @@ static const unsigned int qra_exp[qra_M-1] = { | |||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| // table of the messages weight logarithms over GF(M)
 | // table of the messages weight logarithms over GF(M)
 | ||||||
| static const unsigned int qra_msgw[qra_NMSG] = { | static const  int qra_msgw[qra_NMSG] = { | ||||||
|   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,  | ||||||
| @ -109,7 +109,7 @@ static const unsigned int qra_msgw[qra_NMSG] = { | |||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| // table of the degrees of the variable nodes
 | // table of the degrees of the variable nodes
 | ||||||
| static const unsigned int qra_vdeg[qra_V] = { | static const  int qra_vdeg[qra_V] = { | ||||||
|   4,   4,   4,   4,   5,   5,   5,   5,   7,   4,  |   4,   4,   4,   4,   5,   5,   5,   5,   7,   4,  | ||||||
|   4,   6,   8,   3,   3,   3,   3,   3,   3,   3,  |   4,   6,   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,  | ||||||
| @ -120,7 +120,7 @@ static const unsigned int qra_vdeg[qra_V] = { | |||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| // table of the degrees of the factor nodes
 | // table of the degrees of the factor nodes
 | ||||||
| static const unsigned int qra_cdeg[qra_C] = { | static const  int qra_cdeg[qra_C] = { | ||||||
|   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,  |   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,  | ||||||
|   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,  |   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,  | ||||||
|   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,  |   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,  | ||||||
| @ -237,7 +237,7 @@ static const int qra_c2vmidx[qra_C*qra_MAXCDEG] = { | |||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| // permutation matrix to compute Prob(x*alfa^logw)
 | // permutation matrix to compute Prob(x*alfa^logw)
 | ||||||
| static const unsigned int qra_pmat[qra_M*qra_M] = { | static const int qra_pmat[qra_M*qra_M] = { | ||||||
|   0,   1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11,  12,  13,  14,  15,  |   0,   1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11,  12,  13,  14,  15,  | ||||||
|  16,  17,  18,  19,  20,  21,  22,  23,  24,  25,  26,  27,  28,  29,  30,  31,  |  16,  17,  18,  19,  20,  21,  22,  23,  24,  25,  26,  27,  28,  29,  30,  31,  | ||||||
|  32,  33,  34,  35,  36,  37,  38,  39,  40,  41,  42,  43,  44,  45,  46,  47,  |  32,  33,  34,  35,  36,  37,  38,  39,  40,  41,  42,  43,  44,  45,  46,  47,  | ||||||
|  | |||||||
| @ -29,22 +29,22 @@ | |||||||
| 
 | 
 | ||||||
| #define QRA_DEBUG  | #define QRA_DEBUG  | ||||||
| 
 | 
 | ||||||
| int qra_encode(const qracode *pcode, uint *y, const uint *x) | int qra_encode(const qracode *pcode, int *y, const int *x) | ||||||
| { | { | ||||||
| 	uint k,j,kk,jj; | 	int k,j,kk,jj; | ||||||
| 	uint t, chk = 0; | 	int t, chk = 0; | ||||||
| 
 | 
 | ||||||
| 	const uint K = pcode->K; | 	const int K = pcode->K; | ||||||
| 	const uint M = pcode->M; | 	const int M = pcode->M; | ||||||
| 	const uint NC= pcode->NC; | 	const int NC= pcode->NC; | ||||||
| 	const uint a = pcode->a; | 	const int a = pcode->a; | ||||||
| 	const int  *acc_input_idx  = pcode->acc_input_idx; | 	const int  *acc_input_idx  = pcode->acc_input_idx; | ||||||
| 	const uint *acc_input_wlog = pcode->acc_input_wlog; | 	const int *acc_input_wlog = pcode->acc_input_wlog; | ||||||
| 	const int  *gflog		   = pcode->gflog; | 	const int  *gflog		   = pcode->gflog; | ||||||
| 	const uint *gfexp          = pcode->gfexp; | 	const int *gfexp          = pcode->gfexp; | ||||||
| 
 | 
 | ||||||
| 	// copy the systematic symbols to destination
 | 	// copy the systematic symbols to destination
 | ||||||
| 	memcpy(y,x,K*sizeof(uint)); | 	memcpy(y,x,K*sizeof(int)); | ||||||
| 
 | 
 | ||||||
| 	y = y+K;	// point to check symbols
 | 	y = y+K;	// point to check symbols
 | ||||||
| 
 | 
 | ||||||
| @ -144,7 +144,7 @@ static void qra_ioapprox(float *src, float C, int nitems) | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| void qra_mfskbesselmetric(float *pix, const float *rsq, const uint m, const uint N, float EsNoMetric) | void qra_mfskbesselmetric(float *pix, const float *rsq, const int m, const int N, float EsNoMetric) | ||||||
| { | { | ||||||
| 	// Computes the codeword symbols intrinsic probabilities
 | 	// Computes the codeword symbols intrinsic probabilities
 | ||||||
| 	// given the square of the received input amplitudes.
 | 	// given the square of the received input amplitudes.
 | ||||||
| @ -167,12 +167,12 @@ void qra_mfskbesselmetric(float *pix, const float *rsq, const uint m, const uint | |||||||
| 	// nevertheless it is usually better than a generic parameter-free metric which
 | 	// nevertheless it is usually better than a generic parameter-free metric which
 | ||||||
| 	// makes no assumptions on the input Es/No.
 | 	// makes no assumptions on the input Es/No.
 | ||||||
| 
 | 
 | ||||||
| 	uint k; | 	int k; | ||||||
| 	float rsum = 0.f; | 	float rsum = 0.f; | ||||||
| 	float sigmaest, cmetric; | 	float sigmaest, cmetric; | ||||||
| 
 | 
 | ||||||
| 	const uint M = 1<<m; | 	const int M = 1<<m; | ||||||
| 	const uint nsamples = M*N; | 	const int nsamples = M*N; | ||||||
| 
 | 
 | ||||||
| 	// compute total power and modulus of input signal
 | 	// compute total power and modulus of input signal
 | ||||||
| 	for (k=0;k<nsamples;k++) { | 	for (k=0;k<nsamples;k++) { | ||||||
| @ -226,29 +226,29 @@ int qra_extrinsic(const qracode *pcode, | |||||||
| 				  float *qra_v2cmsg, | 				  float *qra_v2cmsg, | ||||||
| 				  float *qra_c2vmsg) | 				  float *qra_c2vmsg) | ||||||
| { | { | ||||||
| 	const uint qra_M		= pcode->M; | 	const int qra_M		= pcode->M; | ||||||
| 	const uint qra_m		= pcode->m; | 	const int qra_m		= pcode->m; | ||||||
| 	const uint qra_V		= pcode->V; | 	const int qra_V		= pcode->V; | ||||||
| 	const uint qra_MAXVDEG  = pcode->MAXVDEG; | 	const int qra_MAXVDEG  = pcode->MAXVDEG; | ||||||
| 	const int  *qra_vdeg    = pcode->vdeg; | 	const int  *qra_vdeg    = pcode->vdeg; | ||||||
| 	const uint qra_C		= pcode->C; | 	const int qra_C		= pcode->C; | ||||||
| 	const uint qra_MAXCDEG  = pcode->MAXCDEG; | 	const int qra_MAXCDEG  = pcode->MAXCDEG; | ||||||
| 	const uint *qra_cdeg    = pcode->cdeg; | 	const int *qra_cdeg    = pcode->cdeg; | ||||||
| 	const int  *qra_v2cmidx = pcode->v2cmidx; | 	const int  *qra_v2cmidx = pcode->v2cmidx; | ||||||
| 	const int  *qra_c2vmidx = pcode->c2vmidx; | 	const int  *qra_c2vmidx = pcode->c2vmidx; | ||||||
| 	const int  *qra_pmat    = pcode->gfpmat; | 	const int  *qra_pmat    = pcode->gfpmat; | ||||||
| 	const uint *qra_msgw    = pcode->msgw; | 	const int *qra_msgw    = pcode->msgw; | ||||||
| 
 | 
 | ||||||
| //	float msgout[qra_M];		 // buffer to store temporary results
 | //	float msgout[qra_M];		 // buffer to store temporary results
 | ||||||
| 	float msgout[QRACODE_MAX_M]; // we use a fixed size in order to avoid mallocs
 | 	float msgout[QRACODE_MAX_M]; // we use a fixed size in order to avoid mallocs
 | ||||||
| 
 | 
 | ||||||
| 	float totex;	// total extrinsic information
 | 	float totex;	// total extrinsic information
 | ||||||
| 	int nit;		// current iteration
 | 	int nit;		// current iteration
 | ||||||
| 	uint nv;		// current variable
 | 	int nv;		// current variable
 | ||||||
| 	uint nc;		// current check
 | 	int nc;		// current check
 | ||||||
| 	uint k,kk;		// loop indexes
 | 	int k,kk;		// loop indexes
 | ||||||
| 
 | 
 | ||||||
| 	uint ndeg;		// current node degree
 | 	int ndeg;		// current node degree
 | ||||||
| 	int msgbase;	// current offset in the table of msg indexes
 | 	int msgbase;	// current offset in the table of msg indexes
 | ||||||
| 	int imsg;		// current message index
 | 	int imsg;		// current message index
 | ||||||
| 	int wmsg;		// current message weight
 | 	int wmsg;		// current message weight
 | ||||||
| @ -448,7 +448,7 @@ int qra_extrinsic(const qracode *pcode, | |||||||
| 	return rc; | 	return rc; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void qra_mapdecode(const qracode *pcode, uint *xdec, float *pex, const float *pix) | void qra_mapdecode(const qracode *pcode, int *xdec, float *pex, const float *pix) | ||||||
| { | { | ||||||
| // Maximum a posteriori probability decoding.
 | // Maximum a posteriori probability decoding.
 | ||||||
| // Given the intrinsic information (pix) and extrinsic information (pex) (computed with qra_extrinsic(...))
 | // Given the intrinsic information (pix) and extrinsic information (pex) (computed with qra_extrinsic(...))
 | ||||||
| @ -460,11 +460,11 @@ void qra_mapdecode(const qracode *pcode, uint *xdec, float *pex, const float *pi | |||||||
| 
 | 
 | ||||||
| //  Note: pex is destroyed and overwritten with mapp
 | //  Note: pex is destroyed and overwritten with mapp
 | ||||||
| 
 | 
 | ||||||
| 	const uint qra_M		= pcode->M; | 	const int qra_M		= pcode->M; | ||||||
| 	const uint qra_m		= pcode->m; | 	const int qra_m		= pcode->m; | ||||||
| 	const uint qra_K		= pcode->K; | 	const int qra_K		= pcode->K; | ||||||
| 
 | 
 | ||||||
| 	uint k; | 	int k; | ||||||
| 
 | 
 | ||||||
| 	for (k=0;k<qra_K;k++) { | 	for (k=0;k<qra_K;k++) { | ||||||
| 		// compute a posteriori prob
 | 		// compute a posteriori prob
 | ||||||
|  | |||||||
| @ -22,8 +22,6 @@ | |||||||
| #ifndef _qracodes_h_ | #ifndef _qracodes_h_ | ||||||
| #define _qracodes_h_ | #define _qracodes_h_ | ||||||
| 
 | 
 | ||||||
| typedef unsigned int uint; |  | ||||||
| 
 |  | ||||||
| // type of codes
 | // type of codes
 | ||||||
| #define QRATYPE_NORMAL			0x00 // normal code 
 | #define QRATYPE_NORMAL			0x00 // normal code 
 | ||||||
| #define QRATYPE_CRC 			0x01 // code with crc - last information symbol is a CRC
 | #define QRATYPE_CRC 			0x01 // code with crc - last information symbol is a CRC
 | ||||||
| @ -32,29 +30,29 @@ typedef unsigned int uint; | |||||||
| 
 | 
 | ||||||
| typedef struct { | typedef struct { | ||||||
| 	// code parameters
 | 	// code parameters
 | ||||||
| 	const uint K;			// number of information symbols
 | 	const int K;			// number of information symbols
 | ||||||
| 	const uint N;			// codeword length in symbols
 | 	const int N;			// codeword length in symbols
 | ||||||
| 	const uint m;			// bits/symbol
 | 	const int m;			// bits/symbol
 | ||||||
| 	const uint M;			// Symbol alphabet cardinality (2^m)
 | 	const int M;			// Symbol alphabet cardinality (2^m)
 | ||||||
| 	const uint a;			// code grouping factor
 | 	const int a;			// code grouping factor
 | ||||||
| 	const uint NC;			// number of check symbols (N-K)
 | 	const int NC;			// number of check symbols (N-K)
 | ||||||
| 	const uint V;			// number of variables in the code graph (N)
 | 	const int V;			// number of variables in the code graph (N)
 | ||||||
| 	const uint C;			// number of factors in the code graph (N +(N-K)+1)
 | 	const int C;			// number of factors in the code graph (N +(N-K)+1)
 | ||||||
| 	const uint NMSG;		// number of msgs in the code graph
 | 	const int NMSG;		// number of msgs in the code graph
 | ||||||
| 	const uint MAXVDEG;		// maximum variable degree 
 | 	const int MAXVDEG;		// maximum variable degree 
 | ||||||
| 	const uint MAXCDEG;		// maximum factor degree
 | 	const int MAXCDEG;		// maximum factor degree
 | ||||||
| 	const uint type;		// see QRATYPE_xx defines
 | 	const int type;		// see QRATYPE_xx defines
 | ||||||
| 	const float R;			// code rate (K/N)
 | 	const float R;			// code rate (K/N)
 | ||||||
| 	const char  name[64];	// code name
 | 	const char  name[64];	// code name
 | ||||||
| 	// tables used by the encoder
 | 	// tables used by the encoder
 | ||||||
| 	const int	 *acc_input_idx;	 | 	const int	 *acc_input_idx;	 | ||||||
| 	const uint   *acc_input_wlog; | 	const int   *acc_input_wlog; | ||||||
| 	const int	 *gflog; | 	const int	 *gflog; | ||||||
| 	const uint   *gfexp; | 	const int   *gfexp; | ||||||
| 	// tables used by the decoder -------------------------
 | 	// tables used by the decoder -------------------------
 | ||||||
| 	const uint *msgw; | 	const int *msgw; | ||||||
| 	const uint *vdeg; | 	const int *vdeg; | ||||||
| 	const uint *cdeg; | 	const int *cdeg; | ||||||
| 	const int  *v2cmidx; | 	const int  *v2cmidx; | ||||||
| 	const int  *c2vmidx; | 	const int  *c2vmidx; | ||||||
| 	const int  *gfpmat; | 	const int  *gfpmat; | ||||||
| @ -69,10 +67,10 @@ typedef struct { | |||||||
| extern "C" { | extern "C" { | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| int  qra_encode(const qracode *pcode, uint *y, const uint *x); | int  qra_encode(const qracode *pcode, int *y, const int *x); | ||||||
| void qra_mfskbesselmetric(float *pix, const float *rsq, const uint m, const uint N, float EsNoMetric); | void qra_mfskbesselmetric(float *pix, const float *rsq, const int m, const int N, float EsNoMetric); | ||||||
| int  qra_extrinsic(const qracode *pcode, float *pex, const float *pix, int maxiter,float *qra_v2cmsg,float *qra_c2vmsg); | int  qra_extrinsic(const qracode *pcode, float *pex, const float *pix, int maxiter,float *qra_v2cmsg,float *qra_c2vmsg); | ||||||
| void qra_mapdecode(const qracode *pcode, uint *xdec, float *pex, const float *pix); | void qra_mapdecode(const qracode *pcode, int *xdec, float *pex, const float *pix); | ||||||
| 
 | 
 | ||||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user