image thumbnail

Channel Noise Estimation Using Particle based Belief Propagation for LDPC decoding in AWGN and BSC

by

 

Channel Noise Estimation Using Particle based Belief Propagation for LDPC decoding in AWGN and BSC

Arrays
% Authors:
% 
% Shuang Wang, Lijuan Cui and Samuel Cheng
% 
% Copyright:
% 
% Copyright ? 2007-2011 Shuang Wang
% 
% Questions:
% 
% For any questions, please contact me by shuangwang AT ou dot edu
%
% reference
%  L. Cui, S. Wang, S. Cheng, M. Yeary, "Adaptive Binary Slepian-Wolf Decoding using Particle Based Belief Propagation", Communications, IEEE Transactions on, to appear.
%  S. Wang, L. Cui, S. Cheng, Y. Zhai, M. Yeary, Q. Wu, "Noise Adaptive LDPC Decoding Using Particle Filtering," Communications, IEEE Transactions on, Vol 59. pp. 913 - 916, April 2011.
%
classdef Arrays
    %UNTITLED3 Summary of this class goes here
    %   Detailed explanation goes here
    
    properties
    end
    
    methods (Static = true)
        %%
        % input a long array e.g [1:1:12]; it will be shrinked to a short array according to the connectionRatio,
        % e.g, 3, which results in a shrinked Array [1, 4, 7, 10]
        function res = shrinkArrayByTakeFirstElement(array, connectionRatio)
            len_original = numel(array);
            len_shrink = floor((len_original - 1)/connectionRatio) + 1;
            res = array([1:connectionRatio:(connectionRatio * (len_shrink - 1) + 1)]);           
        end
        %%
        % input a long array e.g [1:1:13]; it will be shrinked to a short array according to the connectionRatio,
        % e.g, 3, which results in a reshaped Cell {[1:3]; [4:6]; [7:9]; [10:12]; [13]}
        function res = reshapeArray2Cell(array, connectionRatio)
            len_original = numel(array);
            len_shrink = floor((len_original - 1)/connectionRatio) + 1;              
            res = mat2cell(reshape(array(1:(connectionRatio * (len_shrink - 1))), connectionRatio, [])', ones(1, len_shrink-1), connectionRatio);
            res{len_shrink} = array((connectionRatio * (len_shrink - 1) + 1):len_original);                  
        end
        
        function res = shrinkArrayByTakeMean(array, connectionRatio)
            len_original = numel(array);
            len_shrink = floor((len_original - 1)/connectionRatio) + 1;
            tmp_len = (len_shrink - 1)* connectionRatio;
            
            res = mean(reshape(array(1:tmp_len), connectionRatio, []))';
            if(tmp_len < len_original)
                res = [res; mean(array(tmp_len+1 : len_original))];
            end
        end
        
        function res = shrinkArrayByTakeVariance(array, connectionRatio)
            len_original = numel(array);
            len_shrink = floor((len_original - 1)/connectionRatio) + 1;
            tmp_len = (len_shrink - 1)* connectionRatio;          
            res = var(reshape(array(1:tmp_len), connectionRatio, []))';
            if(tmp_len < len_original)
                res = [res; var(array(tmp_len+1 : len_original))];
            end
        end
        
        function shrinkedID = shrinkID(id_longArray, connectionRatio)
            shrinkedID = floor((id_longArray - 1)/connectionRatio) + 1;
            
        end
        
        function expandID = expandID_first(id_shortArray, connectionRatio)
            expandID = (id_shortArray - 1) * connectionRatio + 1;
        end
        
        function res = shrinkArrayByTakeCrossOverProbability(array, connectionRatio)
            len_original = numel(array);
            len_shrink = floor((len_original - 1)/connectionRatio) + 1;
            tmp_len = (len_shrink - 1)* connectionRatio;                 
            res = Arrays.calcCrossOverProbability(reshape(array(1:tmp_len), connectionRatio, []))';
            if(tmp_len < len_original)
                res = [res; Arrays.calcCrossOverProbability(array(tmp_len+1 : len_original))];
            end
        end
        
        function res = calcCrossOverProbability(a)            
            assert(sum(a(a(:) ~= 0) ~= 1) == 0, 'binary input is required');
            if(isempty(a))
                res = [];
            else
                res = sum(a) / size(a, 1);
            end
        end
        
        % input a short array e.g [1:1:4]; it will be expand to a long array according to the connectionRatio
        % (e.g. 3) and len_expand (e.g. 11), where  (5 - 1) * connectionRation < len_expand < 5*connectionRation;
        % which results in a shrinked Array [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4]
        function res = expandArray(array, connectionRatio, len_expand)   
            assert(len_expand <= (numel(array) * connectionRatio), 'len_expand <= (numel(array) * connectionRatio - connectionRatio)');
            assert(len_expand >= ((numel(array) - 1) * connectionRatio + 1), 'len_expand >= ((numel(array) - 1) * connectionRatio + 1)');
            res = reshape(repmat(array(:), 1, connectionRatio)', [], 1);
            res((len_expand + 1) : numel(res)) = [];
        end
    end
    
end

Contact us