function out = constructEmpty(egType,m,n)

%MATLAB Code Generation Library Function

% CONSTRUCTEMPTY Construct an mx n empty with the same type as egType
% Only supports types that can be passes from an extrinsic function call to
% coder

%   Copyright 2021 The MathWorks, Inc.
%#codegen


coder.inline('always');
coder.internal.prefer_const(egType);
coder.internal.assert(m == 0 || n == 0, 'MATLAB:class:emptyMustBeZero');
if n ~= 0
    templateEmpty = coder.const(feval([class(egType) '.empty'],0,1));
    out_ = repmat(templateEmpty,m,n);
elseif m ~= 0
    templateEmpty = coder.const(feval([class(egType) '.empty'],1,0));
    out_ = repmat(templateEmpty,m,n);
else
    % size = [0 0]
    out_ = coder.const(feval([class(egType) '.empty'],0,0));
end

if ~isnumeric(egType) || isreal(egType)
    out = out_;
else
    % Empties returned from MATLAB are typically not complex
    out = complex(out_);
end
end