function imax = intmax(classname)
%MATLAB Code Generation Library Function

%   Copyright 2002-2014 The MathWorks, Inc.
%#codegen
coder.internal.allowHalfInputs;
if nargin == 0
    imax = int32(2147483647);
elseif eml_ambiguous_types && ~coder.internal.isCharOrScalarString(classname)
    % This case is to prevent spurious errors with fi inputs.
    imax = int32(0);
else
    eml_invariant(coder.internal.isCharOrScalarString(classname), ...
        'MATLAB:intmax:inputMustBeString', ...
        'IfNotConst','Fail');
    switch (classname)
        case 'int8'
            imax = int8(127);
        case 'uint8'
            imax = uint8(255);
        case 'int16'
            imax = int16(32767);
        case 'uint16'
            imax = uint16(65535);
        case 'int32'
            imax = int32(2147483647);
        case 'uint32'
            imax = uint32(4294967295);
        case 'int64'
            imax = int64(9223372036854775807);
        case 'uint64'
            imax = uint64(18446744073709551615);
        case 'coder.internal.indexInt'
            imax = coder.internal.indexInt(coder.internal.intMax(classname)); 
        otherwise
            eml_invariant(false, ...
                'MATLAB:intmax:invalidClassName', ...
                'IfNotConst','Fail');
    end
end
