function D = empty( varargin )
%DISTRIBUTED.EMPTY Create empty array of class DISTRIBUTED
%   A = DISTRIBUTED.EMPTY returns an empty 0-by-0 DISTRIBUTED.
%   
%   A = DISTRIBUTED.EMPTY(M,N,P,...) returns an empty DISTRIBUTED of doubles
%   with the specified dimensions. At least one of the dimensions must be 0.
%   
%   A = DISTRIBUTED.EMPTY([M,N,P,...]) returns an empty DISTRIBUTED of doubles 
%   with the specified dimensions. At least one of the dimensions must be 0.
%   
%   A = DISTRIBUTED.EMPTY(...,CLASSNAME) returns an empty DISTRIBUTED with 
%   the specified dimensions and underlying type.
%   
%   Examples:
%       A = distributed.empty                 % 0-by-0 distributed matrix
%       B = distributed.empty(0,3)            % 0-by-3 distributed matrix
%       C = distributed.empty([2,0,4],'int8') % underlying class 'int8'
%   
%   See also DISTRIBUTED, DISTRIBUTED/ZEROS.


%   Copyright 2012-2020 The MathWorks, Inc.

% static method of distributed

if length(varargin) >= 1 && matlab.internal.datatypes.isScalarText(varargin{end})
    className = varargin{end};
    varargin(end) = [];
else
    className = 'double';
end

% Use double.empty to verify size arguments. This will throw the right
% errors if incorrect.
try
    d = double.empty(varargin{:});
catch E
    throw(E);
end

D = distributed.sBuild(@codistributed.zeros, 'zeros', size(d), className);