function tf = ishermitian( A, skew )
%ISHERMITIAN  Determine whether a codistributed matrix is real symmetric or complex Hermitian.
%   ISHERMITIAN(X)
%   ISHERMITIAN(X,'skew')
%   ISHERMITIAN(X,'nonskew')
%   
%   Example:
%   spmd
%      T = codistributed(triu(gallery('moler',1000)));
%      X = T*(1+1i) - T'*(1-1i);
%      ISHERMITIAN(X)
%      ISHERMITIAN(X, 'skew')
%   end
%   
%   See also ISHERMITIAN, MAGIC, CODISTRIBUTED.
%   


%   Copyright 2014-2022 The MathWorks, Inc.

% This function works for numerics, logicals and chars
if ~isfloat(A) && ~islogical(A)
    error(message('MATLAB:isHermitian:inputType'))
end

if nargin<2
    skew = false;
else
    skew = iGetSkewOptionOrError(skew);
end

doConj = true;
tf = checkSymmetry( A, doConj, skew );

end

function skew = iGetSkewOptionOrError(skew)
if matlab.internal.datatypes.isScalarText(skew, false)
    isFlag = startsWith(["skew","nonskew"], skew, "ignoreCase", true);
    if isFlag(1)
        skew = true;
        return
    elseif isFlag(2)
        skew = false;
        return
    end
end
throwAsCaller(MException(message('MATLAB:isHermitian:inputFlag')));
end