function [dlist, rlist, offsetWeight, columnIndexMap] = commblkldpcdecode(blk, ParityCheckMat)
%

%   Copyright 1996-2019 The MathWorks, Inc.

if ~matlab.system.isSystemObject(blk)
  if strcmp(ParityCheckMat, 'updatemask')
    Vis  = get_param(blk, 'MaskVisibilities');
    Vals = get_param(blk, 'MaskValues');

    % --- Field numbers
    DecisionType        = 3;
    OutputDataType      = 4;

    if strcmp(Vals{DecisionType},'Soft decision')
      Vis{OutputDataType} = 'off';
    else
      Vis{OutputDataType} = 'on';
    end

    set_param(blk, 'MaskVisibilities', Vis);
    return;
  end
end

% Generate internal representation for the parity-check matrix.
[m n] = size(ParityCheckMat);
if ( m >= n )
    error(message('comm:commblkldpcdecode:InvalidParityChkMtxSize'));
end
check = nonzeros(ParityCheckMat);
if ~isempty(check(check ~= 1))
    error(message('comm:commblkldpcdecode:NonBinParityChkMtx'));
end
[i, ~] = find(ParityCheckMat);
j = [full(sum(ParityCheckMat, 1)) -1];
if ~isempty(find(j==0, 1))
    error(message('comm:commblkldpcdecode:InvalidParityChkMtx'));
end
x = find(j(2:end)-j(1:end-1));
y = j(x);

rlist = int32(i-1);
dlist = reshape([filter([1 -1],1,x);y],1,[]);

[offsetWeight, columnIndexMap] = ...
    comm.internal.ldpc.getDecoderParameters(ParityCheckMat, ~issparse(ParityCheckMat));

% [EOF]
