├── BLAS ├── khatri_pro.m ├── model1.m ├── gen_tensor.m └── BLAS.m ├── channel_generation ├── gen_DFTmatrix.m ├── array_response.m ├── gen_noise.m ├── generate_channel.m └── generate_channel_LOS.m ├── README.md └── mian_SNR_BLAS.m /BLAS/khatri_pro.m: -------------------------------------------------------------------------------- 1 | function M = khatri_pro(A,B) 2 | 3 | [a, K] = size(A); 4 | [b, ~] = size(B); 5 | M = zeros(a * b, K); 6 | for k = 1 : K 7 | M(:, k) = kron(A(:,k), B(:,k)); 8 | end -------------------------------------------------------------------------------- /channel_generation/gen_DFTmatrix.m: -------------------------------------------------------------------------------- 1 | function W = gen_DFTmatrix() 2 | 3 | global B NI 4 | 5 | M = B; 6 | N = NI; 7 | W = zeros(M, N); 8 | for m = 1: M 9 | for n = 1: N 10 | W(m, n) = exp(-1j*2*pi*(m-1)*(n-1)/N); 11 | end 12 | end -------------------------------------------------------------------------------- /BLAS/model1.m: -------------------------------------------------------------------------------- 1 | function Y = model1(X, m) 2 | 3 | Y = []; 4 | for i = 1 : size(X, 3) 5 | if m == 1 6 | tmp = squeeze(X(:,:, i)); 7 | else 8 | tmp = squeeze(X(:,:, i)).'; 9 | end 10 | Y = [Y, tmp]; 11 | end 12 | 13 | -------------------------------------------------------------------------------- /channel_generation/array_response.m: -------------------------------------------------------------------------------- 1 | function y = array_response(phi,theta, N) 2 | for m= 0:sqrt(N)-1 3 | for n= 0:sqrt(N)-1 4 | y(m*(sqrt(N))+n+1) = exp( 1i* pi* ( m*sin(phi)*sin(theta) + n*cos(theta) ) ); 5 | end 6 | end 7 | y = y.'/sqrt(N); 8 | end -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # reproduction_of_BALS 2 | This is the reproduction codes for the BALS algorithm proposed in "PARAFAC-Based Channel Estimation for Intelligent 3 | Reflective Surface Assisted MIMO System". 4 | 5 | Availabel: [https://arxiv.org/pdf/2001.06554.pdf](https://arxiv.org/pdf/2001.06554.pdf) 6 | -------------------------------------------------------------------------------- /channel_generation/gen_noise.m: -------------------------------------------------------------------------------- 1 | function [N1, N2] = gen_noise(SNR) 2 | 3 | global B Nr Nt 4 | 5 | N1 = zeros(B*Nr, Nt); 6 | N2 = zeros(B*Nt, Nr); 7 | 8 | for i = 1:B 9 | n = sqrt(1/2 / SNR) * (randn(Nr, Nt) + 1j* randn(Nr, Nt)); 10 | N1((i-1)*Nr+1:i*Nr,:) = n; 11 | N2((i-1)*Nt+1:i*Nt,:) = n.'; 12 | end -------------------------------------------------------------------------------- /BLAS/gen_tensor.m: -------------------------------------------------------------------------------- 1 | function Y = gen_tensor(G, Z, S) 2 | 3 | [L, N] = size(G); 4 | T = size(Z, 1); 5 | K = size(S, 1); 6 | 7 | Y = zeros(L, T, K); 8 | for l = 1: L 9 | for t = 1: T 10 | for k = 1:K 11 | for n = 1 : N 12 | Y(l,t,k) = Y(l,t,k) + G(l,n) * Z(t,n) * S(k,n); 13 | end 14 | end 15 | end 16 | end -------------------------------------------------------------------------------- /channel_generation/generate_channel.m: -------------------------------------------------------------------------------- 1 | function H = generate_channel(Nt, Nr, L) 2 | 3 | AOD = pi*rand(L, 2) - pi/2; %-2/pi~2/pi 4 | AOA = pi*rand(L, 2) - pi/2; %-2/pi~2/pi 5 | alpha = (randn(1,L)+1i*randn(1,L))/sqrt(2); 6 | H = zeros(Nr, Nt); 7 | for l=1:1:L 8 | ar = array_response(AOA(l,1),AOA(l,2), Nr); 9 | at = array_response(AOD(l,1),AOD(l,2), Nt); 10 | H = H + sqrt(Nr * Nt/L)*alpha(l)*ar*at'; 11 | end -------------------------------------------------------------------------------- /channel_generation/generate_channel_LOS.m: -------------------------------------------------------------------------------- 1 | function [H] = generate_channel_LOS(Nt, Nr, L) 2 | 3 | AOD = pi*rand(L, 2) - pi/2; %-2/pi~2/pi 4 | AOA = pi*rand(L, 2) - pi/2; %-2/pi~2/pi 5 | alpha(1) = (randn(1) + 1j * randn(1)) / sqrt(2); % gain of the LoS 6 | alpha(2:L) = 10^(-0.5)*(randn(1,L-1)+1i*randn(1,L-1))/sqrt(2); 7 | H = zeros(Nr, Nt); 8 | for l=1:1:L 9 | ar = array_response(AOA(l,1),AOA(l,2), Nr); 10 | at = array_response(AOD(l,1),AOD(l,2), Nt); 11 | H = H + sqrt(Nr * Nt)*alpha(l)*ar*at'; 12 | end 13 | 14 | H = H / sqrt(L); 15 | -------------------------------------------------------------------------------- /BLAS/BLAS.m: -------------------------------------------------------------------------------- 1 | function [G, H, def_e, e] = BLAS(S, X, Y) 2 | 3 | Y1 = model1(Y, 1); 4 | Y2 = model1(Y, 2); 5 | N = size(S, 2); 6 | M = size(X, 2); 7 | 8 | i = 0; 9 | H = randn(N, M) + 1j * randn(N, M); 10 | 11 | def_e = 1; 12 | old_e = 1; 13 | while(def_e > 10^-2) 14 | tmp = khatri_pro(S, X * H.'); 15 | G = Y1 * pinv(tmp.'); 16 | tmp = khatri_pro(S, G); 17 | tmp = pinv(X) * Y2 * pinv(tmp.'); 18 | H = tmp.'; 19 | Z = X * H.'; 20 | construct_Y = gen_tensor(G, Z, S); 21 | construct_Y1 = model1(construct_Y,1); 22 | e = norm(construct_Y1 - Y1, 'fro'); 23 | def_e = abs(e - old_e); 24 | old_e = e; 25 | end 26 | 27 | 28 | -------------------------------------------------------------------------------- /mian_SNR_BLAS.m: -------------------------------------------------------------------------------- 1 | addpath('channel_generation', 'BLAS') 2 | clear all; 3 | global Nr B Nt NI P 4 | 5 | Nr = 9; 6 | B = 25; 7 | Nt = 16; 8 | NI = 25; 9 | P = 3; %paths 10 | SNR_set = -15:3:15; 11 | Nloop = 10; 12 | 13 | for snr_idx = 1 : length(SNR_set) 14 | SNR = 10^(SNR_set(snr_idx)/10) 15 | mse = zeros(1, Nloop); 16 | for n = 1:Nloop 17 | n 18 | 19 | G = generate_channel_LOS(NI, Nr, P); 20 | H = generate_channel_LOS(Nt, NI, P); 21 | S = gen_DFTmatrix(); 22 | Z = H.'; 23 | Y = gen_tensor(G, Z, S); 24 | Y1 = model1(Y,1); 25 | Noise = (randn(Nr, Nt, B) + 1j * randn(Nr, Nt, B)); 26 | Noise = Noise / sqrt(2 * SNR); 27 | Y = Y + Noise; 28 | [G_est, H_est, diff, e] = BLAS(S, eye(Nt), Y); 29 | Hc = G * H; 30 | Hc_est = G_est * H_est; 31 | mseG(n) = (norm(G - G_est, 'fro') / norm(G, 'fro'))^2; 32 | mseH(n) = (norm(H - H_est, 'fro') / norm(H, 'fro'))^2; 33 | mse(n) = (norm(Hc - Hc_est, 'fro') / norm(Hc, 'fro'))^2; 34 | end 35 | Mse(snr_idx) = mean(mse) 36 | MseG(snr_idx) = mean(mseG) 37 | 38 | end 39 | semilogy(SNR_set, Mse) 40 | 41 | 42 | 43 | 44 | --------------------------------------------------------------------------------