function localColumn = hGetColumn(codistr, LP, globalColumnIndex)
% hGetColumn Return the local column of a 2D matrix with global index 
% globalColumnIndex
        
%   Copyright 2017 The MathWorks, Inc.

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

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