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

demo001_AWGN.m
% 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.
%
close all; warning off all; clearvars; % clear java; 
clear import; warning on; %#ok<WNON>   % clear java;
clear import; warning off all;
addpath(genpath('.'));
p = mfilename('fullpath'); p = p(1:numel(p)-numel(mfilename)); cd(p);
if(strcmp(getenv('OS'), 'Windows_NT'))   
    javarmpath('.\JavaBPForMatlab\dist\JavaBPForMatlab.jar');
else    
    javarmpath('./JavaBPForMatlab/dist/JavaBPForMatlab.jar');
end
warning on;  %#ok<WNON>

% if( matlabpool('size') == 0)
%     matlabpool;
% end

if(strcmp(getenv('OS'), 'Windows_NT'))
    pegFile = '.\PCHK\Reg3_6_10000.dat';
    initializeJava('./JavaBPForMatlab/dist/JavaBPForMatlab.jar');
else
    pegFile = './PCHK/Reg3_6_10000.dat';
    initializeJava('./JavaBPForMatlab/dist/JavaBPForMatlab.jar');
end
%%
RandStream.setDefaultStream(RandStream('mt19937ar','seed',1));
fprintf('Initializing and loading pchk data\n');
[m, n, pchk, pchk_java] = loadPCHK(pegFile);
codeRate = m/n;
max_num_codeword = 1000;
max_iters = 100;
numThreads = 12;
channelType_java = javabpformatlab.ChannelType.AWGN;
channelNoise = ones(n,1)*snr2sigma(1.3, codeRate);
decodingError = [];
fprintf('Start Decoding\n');
bpDecoder_java = javabpformatlab.BPDecoder(numThreads, pchk_java, channelType_java);
for iter_codeword = 1: max_num_codeword
    fprintf('%05d/%d  ',iter_codeword, max_num_codeword);
    source_x = zeros(n,1);
    source_x_map = source_x;
    source_x_map(source_x == 0) = -1; % map 0 to -1 for AWGN
    source_y = source_x_map + randn(n,1).*channelNoise;
    bpDecoder_java.initialization(source_y, channelNoise);
        
    h = progressBar([], [], max_iters);
    for iter_BP = 1:max_iters
        h = progressBar(h, iter_BP);
        bpDecoder_java.decode(iter_BP, bpDecoder_java);
        decodingError = sum(bitxor(bpDecoder_java.decodedWord, source_x)); 
        if((decodingError == 0) || iter_BP == max_iters)
            decodingError_codeword(iter_codeword) = decodingError; %#ok<SAGROW>
            iter_BP_codeword(iter_codeword) = iter_BP; %#ok<SAGROW>
            h = progressBar(h, max_iters);
            fprintf('err: %5d; Ave err: %e; Ave Iter %4.2f\n', decodingError, mean(decodingError_codeword)/n, mean(iter_BP_codeword));
            break;
        end
    end
end






Contact us