-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetTrellisGF4Strip.m
65 lines (51 loc) · 2.41 KB
/
getTrellisGF4Strip.m
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
% Weilei Zeng, 07/19/2018
% construct syndrome trellis for strip codes P
%return a cell of trellisGF4, whose elements are the trellisGF4 for each
%column.
function trellisGF4Strip = getTrellisGF4Strip(P,strip,numInputSymbolsP)
numLayers=size(P,2);
trellisGF4Strip =cell(1,numLayers); % the output which contains the trellis for each layer/lolumn in P
%initialize for the first layer
lastStateIsOccupied=[1];
layer = 1;
shiftLength = strip(1,layer+1)-strip(1,layer);
initialStateIsOccupied = last2initial(lastStateIsOccupied,...
0,2^(strip(2,layer)-strip(1,layer)+1));
trellisLayer=getTrellisGF4(P(strip(1,layer):strip(2,layer),layer),...
numInputSymbolsP(layer),initialStateIsOccupied,shiftLength);
trellisGF4Strip{layer}=trellisLayer;
lastStateIsOccupied=trellisLayer.stateIsOccupied(:,2);
for layer=2:numLayers-1
shiftLength = strip(1,layer+1)-strip(1,layer);
initialStateIsOccupied = last2initial(lastStateIsOccupied,...
strip(1,layer)-strip(1,layer-1),2^(strip(2,layer)-strip(1,layer)+1));
trellisLayer=getTrellisGF4(P(strip(1,layer):strip(2,layer),layer),...
numInputSymbolsP(layer),initialStateIsOccupied,shiftLength);
trellisGF4Strip{layer}=trellisLayer;
lastStateIsOccupied=trellisLayer.stateIsOccupied(:,2);
end
%last layer
layer=numLayers;
shiftLength = size(P,1)-strip(1,layer);
initialStateIsOccupied = last2initial(lastStateIsOccupied,...
strip(1,layer)-strip(1,layer-1),2^(strip(2,layer)-strip(1,layer)+1));
trellisLayer=getTrellisGF4(P(strip(1,layer):strip(2,layer),layer),...
numInputSymbolsP(layer),initialStateIsOccupied,shiftLength);
trellisGF4Strip{layer}=trellisLayer;
end
function initialStateIsOccupied = last2initial(lastStateIsOccupied,shiftLength,initialStateLength)
%1 means occupied, and 0 otherwise
%only those in the lastStates, whose positions to lose has zero value
%will be transimitted into the inital state in the next layer
%initialStateLength=size(lastState,1)=2^(size(G,1);
%shift length in binary
initialStateIsOccupied=zeros(initialStateLength,1);
lastStateLength=size(lastStateIsOccupied,1);
for i_initial = 1:lastStateLength/(2^shiftLength)
state=i_initial-1;
i_last=state*(2^shiftLength)+1;
if sum( lastStateIsOccupied(i_last:(i_last+2^shiftLength-1)) )
initialStateIsOccupied(i_initial)=1;
end
end
end