目录
有错误欢迎指正
公式来源
Design of a Modified Interleaving Algorithm Based on Golden Section Theory Enhancing the Performance of Turbo Codes
Dithered golden interleaver
(*---------Dithered golden interleaver---------*)
Clear["Global`*"];
g = g /. Solve[g/1 == (1 - g)/g && g > 0, g,
Reals][[1]];(*golden section value*)
varN = 1024;(* the length of the data sequence *)
r = 1;(* a preselected non-zero integer defining a spacing between \
any pair of input elements thaat are to be maximally spread*)
j = 0;(* a preselected integer modulo r*)
j = Floor[g*r];
m = 2;(* a preselected non-zero positive integer preferably set to 1 \
or 2*)
varC = varN*(g^m + j)/r;
varD = 0.01;(*the normalized width of the dither distribution \
\mathbf{d}(n) and is set to 0.01 *)
vecd = RandomReal[{0, varD*varN}, varN]; (*a dither vector*)
s = 0; (*any real starting value, usually set to 0, but other real \
values can be selected*)
vecv = Table[
Floor[s + n*varC + vecd[[n]]]~Mod~varN, {n, 1,
Length@vecd}];(* the dithered golden vector v*)
(vecZ = Ordering[vecv]) // ListPlot
(vecAlpha = InversePermutation[vecZ]) // ListPlot
Print["---Verification---"]
veca = Sort[vecv]; (*Sorted vecv*)
veca == Table[vecv[[vecZ[[n]]]], {n, 1, varN}]
And @@ Table[vecZ[[vecAlpha[[n]]]] == n, {n, 1, varN}]
And @@ Table[vecAlpha[[vecZ[[n]]]] == n, {n, 1, varN}]
when varD = 0.01; (*the normalized width of the dither distribution \mathbf{d}(n) *)
when varD = 0.1; (*the normalized width of the dither distribution \mathbf{d}(n) *)
The Matrix-Dithered Golden Interleaving Algorithm
(*--------The Matrix-Dithered Golden Interleaving Algorithm--------*)
ClearAll["Global`*"];
SetAttributes[MyDebugPrint, HoldFirst];
MyDebugPrint[var_] :=
Module[{varName, value}, varName = SymbolName[Unevaluated[var]];
value = Evaluate[var];
Print[varName, " = ", MatrixForm[value]];]
s = 0; m = 1; varD = 0.001; j = 9;
r = 15;
varN = 4096;
g = g /. Solve[g/1 == (1 - g)/g && g > 0, g,
Reals][[1]];(*golden section value*)vecDRow =
RandomReal[{1, varN*varD}, varN];
vecDColumn = RandomReal[{1, varN*varD}, varN];
If[varN < 512, Nr = Floor[varN^(1/2)], Nr = Floor[varN^(1/3)]];
MyDebugPrint[Nr];
Nc = Ceiling[varN/Nr];
MyDebugPrint[Nc];
varCrow = Nr*(g^m + j)/r;
varCcolumn = Nc*(g^m + j)/r;
Din = Array[Subscript[x, #] &, varN];
Din = Array[# &, varN];
(M = ArrayReshape[Din, {Nr, Nc}]); MyDebugPrint[M];
(Mdrow = ArrayReshape[vecDRow, {Nr, Nc}]); MyDebugPrint[Mdrow];
(Mdcolumn =
Transpose@
ArrayReshape[vecDColumn, {Nc, Nr}]); MyDebugPrint[Mdcolumn];
matrixVrow = Table[0, {ii, 1, Nr}, {jj, 1, Nc}];
For[ii = 1, ii <= Nr,
ii++, {For[jj = 1, jj <= Nc,
jj++, {matrixVrow[[ii, jj]] = (s + ii*varCrow + Mdrow[[ii, jj]])~
Mod~Nr;}]}]
MyDebugPrint[matrixVrow]
matrixZrow = Map[Ordering, matrixVrow];
MyDebugPrint[matrixZrow]
matrixMrow = Table[0, {ii, 1, Nr}, {jj, 1, Nc}];
For[ii = 1, ii <= Nr,
ii++, {For[jj = 1, jj <= Nc,
jj++, {matrixMrow[[ii, jj]] = M[[ii, matrixZrow[[ii, jj]]]];}]}]
MyDebugPrint[matrixMrow]
(matrixVcolumn = Table[0, {ii, 1, Nr}, {jj, 1, Nc}]);
For[jj = 1, jj <= Nc,
jj++, {For[ii = 1, ii <= Nr,
ii++, {matrixVcolumn[[ii,
jj]] = (s + jj*varCcolumn + Mdcolumn[[ii, jj]])~Mod~Nc;}]}]
MyDebugPrint[matrixVcolumn]
matrixZcolumn = Transpose[Ordering /@ Transpose[matrixVcolumn]];
MyDebugPrint[matrixZcolumn]
matrixMcolumn = Table[0, {ii, 1, Nr}, {jj, 1, Nc}];
For[jj = 1, jj <= Nc,
jj++, {For[ii = 1, ii <= Nr,
ii++, {matrixMcolumn[[ii, jj]] =
matrixMrow[[matrixZcolumn[[ii, jj]], jj]];}]}]
MyDebugPrint[matrixMcolumn]
Dout = ArrayReshape[Transpose@matrixMcolumn, {1, Nr*Nc}];
MyDebugPrint[Dout]
Dout // ListPlot
标签:golden,Nc,interleaver,Dithered,varD,Nr,varN
From: https://www.cnblogs.com/yhm138/p/17964903