-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathConventional_Precoder_Selection.m
157 lines (139 loc) · 3.89 KB
/
Conventional_Precoder_Selection.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
% Made by Woosung 2020.Jan.14th
function [F, index] = Conventional_Precoder_Selection(H, K)
% < Input >
% K : The number of the bit streams
% H : Channel, the size of nR X nT
% < Output >
% F : Selected Sub-optimal Precoder
% index : And its index
%% Default Value
if nargin < 1
disp('[Message] Conventional_Selection : Default set H, K');
nT = 4; nR = 4;
K = 4;
H = 1/sqrt(K)*sqrt(1/2)*(randn(nT,nR)+1i*randn(nT,nR));
elseif nargin < 2
disp('[Message] Conventional_Precoder_Selection : Default set only K');
K = 4;
end
%% Create Precoder based on the LTE-A Codebook
j = sqrt(-1);
u=[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1;
-1, -j, 1, j, (-1-j)/sqrt(2), (1-j)/sqrt(2), (1+j)/sqrt(2), (-1+j)/sqrt(2), -1, -j, 1, j, -1, -1, 1, 1;
-1, 1, -1, 1, -j, j, -j, j, 1, -1, 1, -1, -1, 1, -1, 1;
-1, j, 1, -j, (1-j)/sqrt(2), (-1-j)/sqrt(2),(-1+j)/sqrt(2),(1+j)/sqrt(2), 1, -j, -1, j, 1, -1, -1, 1];
W=zeros(4,4,16);
for i=1:length(W)
a = u(:, i) * u(:, i)';
b = u(:, i)' * u(:, i);
W(:, :, i) = eye(4) - (2 * a) / b;
end
F4_matrix_order = ...
[[1 2 3 4];[1 2 3 4];[3 2 1 4];[3 2 1 4];
[1 2 3 4];[1 2 3 4];[1 3 2 4];[1 3 2 4];
[1 2 3 4];[1 2 3 4];[1 3 2 4];[1 3 2 4];
[1 2 3 4];[1 3 2 4];[3 2 1 4];[1 2 3 4]];
% Precoder Matrix 'F4' For QAM-16
F4=zeros(4,4,16);
for i=1:length(W)
F4(:, :, i) = W(:, F4_matrix_order(i,:), i) / 2 ;
end
F2_matrix_order = ...
[[1 4];[1 2];[1 2];[1 2];
[1 4];[1 4];[1 3];[1 3];
[1 2];[1 4];[1 3];[1 3];
[1 2];[1 3];[1 3];[1 2]];
% Precoder Matrix 'F2' For QAM-16
F2=zeros(4,2,16);
for i=1:length(W)
F2(:, :, i) = W(:, F2_matrix_order(i,:), i) / sqrt(2) ;
end
% In case of K == 4, note that we only consider 5 precoder
% because the rest of them are identical : F0, F1, F4, F5, F12
%% Basic Setup For searching the minimum distance
if K == 2
precoder_idx = 1:1:16;
omega_possible = [-1, 1];
half_omega_possible = [1];
mapped_x = zeros(1, 4);
half_mapped_x = zeros(1, 2);
xq = zeros(K, 4^4);
xp = zeros(K, 4^3 * 2);
elseif K == 4
precoder_idx = [1, 2, 5, 6, 13];
omega_possible = [-3, -1, 1, 3];
half_omega_possible = [1, 3];
mapped_x = zeros(1, 16);
half_mapped_x = zeros(1, 8);
xq = zeros(K, 16^4);
xp = zeros(K, 16^3 * 8);
end
min_dist_per_precoder = zeros(length(precoder_idx), 1);
curr_precoder_idx = 1;
curr_idx = 1;
% mapped_x
for a = omega_possible
for b = omega_possible
mapped_x(:, curr_idx) = a + b*j;
curr_idx = curr_idx + 1;
end
end
curr_idx = 1;
% half_mapped_x
for a = half_omega_possible
for b = omega_possible
half_mapped_x(:, curr_idx) = a + b*j;
curr_idx = curr_idx + 1;
end
end
% make xq
curr_idx = 1;
for a = mapped_x
for b = mapped_x
for c = mapped_x
for d = mapped_x
xq(:, curr_idx) = [a, b, c, d];
curr_idx = curr_idx + 1;
end
end
end
end
% make xp
curr_idx = 1;
for a = half_mapped_x
for b = mapped_x
for c = mapped_x
for d = mapped_x
xp(:, curr_idx) = [a, b, c, d];
curr_idx = curr_idx + 1;
end
end
end
end
for i = precoder_idx
d_squared_min = realmax;
if K == 2
Hp = H * F2(:, :, i);
elseif K == 4
Hp = H * F4(:, :, i);
end
tic
for xp_ins = xp
for xq_ins = xq
if xp_ins ~= xq_ins
d_squared_min = min(d_squared_min, (norm(Hp * (xp_ins - xq_ins)))^2);
end
end
end
toc
min_dist_per_precoder(curr_precoder_idx) = d_squared_min;
curr_precoder_idx = curr_precoder_idx + 1;
end
[~, max_idx] = max(min_dist_per_precoder);
if K == 2
F = F2(:, :, precoder_idx(max_idx));
elseif K == 4
F = F4(:, :, precoder_idx(max_idx));
end
index = max_idx;
end