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

loadPCHK( pegFile)
% 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.
%
function [m, n, pchk, pchk_java] = loadPCHK( pegFile)
% if(~exist('pegFile','var') || isempty(pegFile))
%     pegFile = 'Reg3_6.dat';
% end

%% load peg file
fid = fopen( pegFile, 'r' );
n = fscanf(fid, '%d', 1);
m = fscanf(fid, '%d', 1);
maxDegree = fscanf(fid, '%d', 1);
pchk = sparse(m, n);
for i = 1:m
    rowLocations = fscanf(fid, '%d', maxDegree)';
    rowLocations(rowLocations == 0) = [];    
    pchk(i, rowLocations) = 1; %#ok<SPRIX>   
end
fclose(fid);
%%  generate edge index for BP decoder
[i, j, s] = find(pchk);
n_msg = numel(s);
s = 1:n_msg;
pchk = sparse(i,j,s);
%%  create edge index and pchk for BP decoder
cols_java = javaArray('javabpformatlab.SparseArrayType', m);
rows_java = javaArray('javabpformatlab.SparseArrayType', n);
for i = 1:m
    rowLocations = find(pchk(i, :));
    edgeLocations = pchk(i, rowLocations);
    cols_java(i) = javabpformatlab.SparseArrayType((rowLocations - 1), (edgeLocations - 1));  % -1 since java array starts from zero;
end

for j = 1:n
    colLocations = find(pchk(:, j));
    edgeLocations = pchk(colLocations, j);
    rows_java(j) = javabpformatlab.SparseArrayType((colLocations - 1), (edgeLocations - 1));  % -1 since java array starts from zero;
end

pchk_java = javabpformatlab.PCHKType(m, n, n_msg, cols_java, rows_java);

Contact us