function p = eml_is_permutation(perm)
%MATLAB Code Generation Library Function

%   Returns true if perm has all integer elements and the elements
%   1:numel(perm), false otherwise.

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

coder.internal.allowHalfInputs;
coder.internal.prefer_const(perm);
p = false;
n = numel(perm);
b = false(n,1);
for k = 1:n
    j = perm(k);
    if j < 1 || j > n || coder.internal.scalar.floor(j) ~= j
        return
    end
    b(j) = true;
end
p = all(b);
