您现在的位置:首页 >> ★免费资源 >> 源码下载 >> 内容

MATLAB代做|FPGA代做|Python代做--球形译码

时间:2019-1-5 15:19:16 点击:

  核心提示:MATLAB代做|FPGA代做|Python代做--球形译码...
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Tittle: Sphere decoding
% Date: Nov 12, 2007
% Author: ........
% .......
% ........
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function [sHat,dist] = sphere(m,sMax,x,H,d,cplx)
% Sphere decoding estimate arg min ||x - Hs||^2
% m is input y 's dimension, that is, the decoded symbol number
% sMax is the maximum value of possible transmitter symbol
% x is pertubed signal
% H is Channel transfer matric
% cplx shows the complex system or real system 0 for real, 1 for complex
% d is the radius of sphere centered at x
% some global definition

%global sHat;    % the estimation value of s (transfered signals)
%global dist;    % the distance from s to x
%global counter; % counter the No. of solution

counter = 1;
sHat = [];
dist = [];

% A small number
EPS = 0.001;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Basic error checking
% make sure the input is correct
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% make sure H's column no. equals m
[n,mChk] = size(H);
if n ~= length(x) || mChk ~= m   % input pertubed data dim is not the same as the column of H
  fprintf('Error: Decoding failed, invalid dimensions for H. (n < m)\n');
  return;
end

% n should be no less than m
if n < m  
  fprintf('Error: Cannot solve under-determined problem, n (%i) < m (%i).\n', n, m);
  return;
end

% define the lattice (spanned by the modulation pattern)
if length(sMax) == 1
  sMax = [-sMax:-1, 1:sMax];
elseif size(sMax,2) == m  % this is for complexed expression.
  sMax = sMax.';          % such as{1+j, 1-j, -1-j, 1-j}
elseif size(sMax,1) ~= m
  fprintf('Error: Decoding failed, invalid dimensions for xMax.\n');
  return;
end

% Complex -> real conversion if necessary
if cplx == 1
  m = 2*m;
  n = 2*n;
  x = [real(x);imag(x)];
  H = [[real(H),imag(H)];[-imag(H),real(H)]]; % refer to the paper "MIMO Receive Algorithms"
  if isreal(sMax)
    sMax = [sMax;sMax]';
  else
    sMax = [real(sMax);imag(sMax)]';
  end
end

% Special handling to allow xMax == 0
noBCind = find(sMax==0);
sMax(noBCind) = Inf; % when xMax ==0, set it as infinite

% Q R factorization
[Q,R] = qr(H);
r = R; % compatible with Babak Hassibi and Haris Vikalo's paper
Q2X = 0;    % R is an uper triangular matrix without eigenvalue of zero
QX = Q'*x;  % QX = Q'* X = [Q1 Q2]'*X = [Q1*X Q2*X] = [y Q2*X]
y = QX(1:m); % y = Q1*X
if m < n
  r = R(1:m, 1:m); % compatible with Babak Hassibi and Haris Vikalo's paper
  Q2X = QX(m+1:n);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% preprocessing ends here
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% search the tree and find the estimation of s
% sphere decoding begin
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% defining some variables
dp   = zeros(m,1); % d primary (d')
yres = zeros(m+1,m+1);  % the residue of the equaltion yk|k+1
s = zeros(m,1); % s is the estimate symbols
% defining some variables

% initialization (step 1)
k = m;    %  denoting the k level tree m is the column of H
dp(m) = d^2 - norm(Q2X,2)^2;
yres(k,k+1) = y(m);
% step 1 ends

% initial the root bound
if r(k,k) > 0
    UB(k) = floor( (dp(k) + yres(k,k+1)) / r(k,k) );
    s(k)  = ceil( (-dp(k)+yres(k,k+1)) / r(k,k) ) - 1;
elseif r(k,k) < 0
    UB(k) = floor( (-dp(k)+yres(k,k+1)) / r(k,k) );
    s(k)  = ceil( (dp(k) + yres(k,k+1)) / r(k,k) ) - 1;
else
     fprintf('Error: Oh, man, the diagonal element of R should bu nonzero.\n');
end
% initialization ends

%searching the sphere begins
while k<=m
    % step 3 begins
    s(k) = s(k) + 1;  % sk + 1 begin to search the tree
    if s(k) <= UB(k)  % step 3 condition holds
        % step 5 begins
       if (~(size(find(sMax==s(k)),2)==0))
            if(k ~= 1)    
                % step 5 condition holds
                % ------> should go to step 2
                k = k - 1;
                yres(k,k+1) = y(k) - sum( r(k,k+1:m)*s(k+1:m) );  % the residue
                dp(k) = dp(k+1) - ( yres(k+1,k+2) - r(k+1,k+1)*s(k+1) )^2;
                % ------> should go to step 2

                % step 2 ends ------> should go to step 3
    %           UB(k) = floor( (dp(k) + yres(k,k+1)) / r(k,k) );
    %           s(k)  = ceil( (-dp(k)+yres(k,k+1)) / r(k,k) ) - 1;
                if r(k,k) > 0
                    UB(k) = floor( (dp(k) + yres(k,k+1)) / r(k,k) );
                    s(k)  = ceil( (-dp(k)+yres(k,k+1)) / r(k,k) ) - 1;  
                    elseif r(k,k) < 0
                    UB(k) = floor( (-dp(k)+yres(k,k+1)) / r(k,k) );
                    s(k)  = ceil( (dp(k) + yres(k,k+1)) / r(k,k) ) - 1;
                else
                    fprintf('Error: Oh, man, the diagonal element of R should be nonzero.\n');
                end
                % step 2 ends ------> should go to step 3
            else % step 5 condition doesn't holds
                % step 6 begins ------> should go to step 3
                sHat(counter,:) = s'; % output one group of solution;  
                dist(counter) = dp(m)-dp(1) + (y(1) - sum(r(1,1:m)*s(1:m)))^2; % output the distance s from x 
                counter = counter + 1;
                % step 6 ends ------> should go to step 3
            end
            % step 5 end
       end
    else  
        % step 4 begins
         k = k + 1;
         if(k == m + 1)
             break;
         end
    end
    %setp 3 ends
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% sphere decoding ends
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

return

联系:highspeedlogic

QQ :1224848052

微信:HuangL1121

邮箱:1224848052@qq.com

网站:http://www.mat7lab.com/

网站:http://www.hslogic.com/

微信扫一扫:

作者:球形译码 来源:球形译码
  • 您是如何找到本站的?
  • 百度搜索
  • Google搜索
  • 查阅资料过程中
  • 论坛发现
  • 百度贴吧发现
  • 朋友介绍
本站最新成功开发工程项目案例
相关评论
发表我的评论
  • 大名:
  • 内容:
  • matlab代做|matlab专业代做|matlab淘宝代做|matlab代写(www.hslogic.com) © 2019 版权所有 All Rights Reserved.
  • Email:highspeed_logic@163.com 站长QQ: 1224848052

    专业代做/代写/承接、MATLAB、SIMULINK、FPGA项目、博士/硕士/本科毕业设计、课题设计、论文,毕业论文,Coursework、Eassy、Assignment