function p = isdiag(x)
%MATLAB Code Generation Library Function

%   Copyright 2013-2014 The MathWorks, Inc.
%#codegen

narginchk(1,1);
eml_invariant(isnumeric(x), ...
    'Coder:toolbox:unsupportedClass',mfilename,class(x));
p = ismatrix(x);
if p && ~isempty(x)
    m = coder.internal.indexInt(size(x,1));
    n = coder.internal.indexInt(size(x,2));
    for j = 1:n
        for i = 1:m
            if i ~= j && ~(x(i,j) == 0)
                p = false;
                if ~coder.target('HDL')
                    return
                end
            end
        end
    end
end
