function ia = setfunGetIndices(uniqueIx, lia)
%SETFUNGETINDICES Get numerical locations from logical arrays

%   Copyright 2023 The MathWorks, Inc.
if isempty(uniqueIx)  % 'stable' returns an empty double, but distributed empty C.
    ia = uniqueIx;
else
    if isrow(lia)
        lia = lia';
    end
    fullia = find(lia);
    
    if iscodistributed(uniqueIx)
        ia = subsref(fullia, substruct('()', {uniqueIx}));
    else
        ia = fullia(uniqueIx);
    end
end

if ~iscodistributed(ia)
    ia = codistributed.pConstructFromReplicated(ia);
end
end
