image thumbnail

Java implantation of LDPC decoding with Matlab interface for both AWGN and BSC

by

 

This is a Java implantation of LDPC decoding with Matlab interface for both AWGN and BSC channels

demo001_BSC.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;
addMyPath_BP();
p = mfilename('fullpath'); p = p(1:numel(p)-numel(mfilename)); cd(p);
if(strcmp(getenv('OS'), 'Windows_NT'))   
    javarmpath('.\JavaBPForMatlab.jar');
else    
    javarmpath('./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.jar');
else
    pegFile = './PCHK/Reg3_6_10000.dat';
    initializeJava('./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.BSC;
channelNoise = ones(n,1)*0.074;
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_y = source_x;
    randNoise = rand(n,1);
    source_y(randNoise <= channelNoise) = bitxor(source_y(randNoise <= channelNoise), 1);
    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