-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathQRD_based_Method.m
98 lines (81 loc) · 2.63 KB
/
QRD_based_Method.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
% Made by Woosung 2020.Jan.14th
function [F, index] = QRD_based_Method(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] QRD_Precoder_Selection : Default set H, K');
nT = 2; nR = 4;
K = 2;
H = 1/sqrt(K)*sqrt(1/2)*(randn(nR,nR)+1i*randn(nR,nR));
elseif nargin < 2
disp('[Message] QRD_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 diag(R)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];
elseif K == 4
precoder_idx = [1, 2, 5, 6, 13];
end
min_dist_per_precoder = zeros(length(precoder_idx), 1);
curr_precoder_idx = 1;
for i = precoder_idx
% curr_min = realmax;
if K == 2
Hp = H * F2(:, :, i);
elseif K == 4
Hp = H * F4(:, :, i);
end
% Perform the QR Decomposition
[~, R] = qr(Hp);
min_dist_per_precoder(curr_precoder_idx) = min(diag(R).^2);
curr_precoder_idx = curr_precoder_idx + 1;
end
%% Find the precoder having mini-max distance from the candidate error vectors
[~, 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