function y = ifft2(x,varargin)
%MATLAB Code Generation Library Function

%   Limitations:
%     The 'symmetric' option is not supported.

%   Copyright 1984-2020 The MathWorks, Inc.
%#codegen
narginchk(1,4);
coder.internal.prefer_const(varargin);
coder.internal.allowHalfInputs;

% Input must be a non-sparse numeric or logical array/scalar
coder.internal.assert((coder.internal.isBuiltInNumeric(x) || islogical(x) || ...
    isa(x,'half')) && ~issparse(x) && ~isa(x, 'int64') && ~isa(x, 'uint64'), ...
    'Coder:toolbox:unsupportedClass','eml_fft',class(x));

% We convert non float types (like ints and logicals) to doubles
if(~isfloat(x))
    y = ifft2(double(x),varargin{:});
    return;
end

if nargin >= 2 && coder.internal.isCharOrScalarString(varargin{end})
    coder.internal.assert(strcmp(varargin{end},'nonsymmetric'), ...
                          'Coder:toolbox:ifft2_3', ...
                          'IfNotConst','Fail');
    nonFlagArgs = nargin - 1;
else
    nonFlagArgs = nargin;
end

% Either 1 input or all 3 are permitted
if nonFlagArgs == 2
    coder.internal.assert(false, ...
                          'Coder:toolbox:ifft2_4', ...
                          'IfNotConst','Fail');
end

dims = coder.internal.indexInt([1 2]);

if nonFlagArgs == 3
    nrowsin = varargin{1};
    ncolsin = varargin{2};
    if isempty(nrowsin)
        nrows = size(x, 1);
    else
        nrows = nrowsin(1);
    end
    if isempty(ncolsin)
        ncols = size(x, 2);
    else
        ncols = ncolsin(1);
    end

    coder.internal.assert(isscalar(nrows) && isreal(nrows) && ...
                          coder.internal.isBuiltInNumeric(nrows) && ...
                          nrows >= 0 && nrows == floor(nrows), ...
                          'MATLAB:fftfcn:lengthNotNonNegInt');
    coder.internal.assert(nrows <= intmax(coder.internal.indexIntClass), ...
                          'MATLAB:pmaxsize');
    coder.internal.assert(isscalar(ncols) && isreal(ncols) && ...
                          coder.internal.isBuiltInNumeric(ncols) && ...
                          ncols >= 0 && ncols == floor(ncols), ...
                          'MATLAB:fftfcn:lengthNotNonNegInt');
    coder.internal.assert(ncols <= intmax(coder.internal.indexIntClass), ...
                          'MATLAB:pmaxsize');

    lens = coder.internal.indexInt([nrows ncols]);
else
    lens = coder.internal.indexInt(size(x, dims));
end
y = coder.internal.fft.fft(x, lens, dims, true);

% LocalWords:  nonsymmetric fftfcn pmaxsize
