function localRow = hGetRow(codistr, LP, globalRowIndex)
% hGetRow Return the row of a 2D matrix with global index 
% globalRowIndex
        
%   Copyright 2017 The MathWorks, Inc.

assert(numel(codistr.Cached.GlobalSize)==2, ...
    'HGETCOLUMN for 1d distributors supports only 2D.')

if codistr.Dimension==2
    localRow = LP(globalRowIndex, :);
else
    [~, localIndex] = find(globalRowIndex==codistr.globalIndices(1));
    if localIndex
        localRow = LP(localIndex, :);
    else
        localRow = zeros(0, codistr.Cached.GlobalSize(2), 'like', LP);
    end
end
end
