function tf = isreal(X)
%ISREAL True for real codistributed array
%   TF = ISREAL(X)
%   
%   Example:
%   spmd
%       N = 1000;
%       rp = 3 * codistributed.ones(N);
%       ip = 4 * codistributed.ones(N);
%       D = complex(rp, ip);
%       f = isreal(D)
%   end
%   
%   returns f = false.
%   
%   See also ISREAL, CODISTRIBUTED, CODISTRIBUTED/COMPLEX, CODISTRIBUTED/ONES.


%   Copyright 2006-2022 The MathWorks, Inc.

% See if we already know the answer
if X.Metadata.IsReal.isKnown()
    % Get the answer from metadata
    tf = X.Metadata.IsReal.get();
    return
end

% Check that isreal is true on all workers.
xDist = getCodistributor(X);
localX = getLocalPart(X);
tf = xDist.hIsrealImpl(localX);

% Remember the result
X.Metadata.IsReal.set(tf);