function p = all_in_integer_range(x,minval,maxval)
%MATLAB Code Generation Private function.

%   Return true iff both
%   1. minval <= x(k) <= minval
%   2. x(k) == floor(x(k))
%   hold for k = 1:numel(x)

%   Copyright 1984-2019 The MathWorks, Inc.
%#codegen

coder.internal.allowEnumInputs;
coder.internal.allowHalfInputs;
p = true;
ISINTEGER = isinteger(x);
ISLOGICAL = islogical(x);
if ISLOGICAL && minval <= 0 && maxval >= 1
    return
end
if ISINTEGER && ...
        minval <= intmin(coder.internal.builtinClass(x)) && ...
        maxval >= intmax(coder.internal.builtinClass(x))
    return
end
HDL = coder.target('HDL');
for k = 1:numel(x)
    if ~(x(k) >= minval && x(k) <= maxval && ...
            (ISINTEGER || ISLOGICAL || x(k) == floor(x(k))))
        p = false;
        if ~HDL
            return
        end
    end
end
