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

% Limitations:
%  1. siz must be fixed-size

%   Copyright 1984-2020 The MathWorks, Inc.
%#codegen
narginchk(1,2);
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 = fftn(double(x), varargin{:});
    return;
end

if nargin == 2
    sizin = varargin{1};
    if isempty(sizin)
        siz = size(x);
    else
        siz = sizin;
    end
    coder.internal.prefer_const(siz);
    coder.internal.assert(numel(siz) >= numel(size(x)), ...
                          'Coder:MATLAB:fftfcn_outputSizeLessThanNdimsElements');
    coder.unroll();
    for i = 1:numel(siz)
        coder.internal.assert(isscalar(siz(i)) && isreal(siz(i)) && ...
                              coder.internal.isBuiltInNumeric(siz(i)) && ...
                              siz(i) >= 0 && siz(i) == floor(siz(i)), ...
                              'MATLAB:fftfcn:lengthNotNonNegInt');
        coder.internal.assert(siz(i) <= intmax(coder.internal.indexIntClass), ...
                              'MATLAB:pmaxsize');
    end

    rank = coder.internal.indexInt(numel(siz));
    dims = coder.internal.indexInt(1:rank);
    lens = coder.internal.indexInt(siz);
else
    xSize = size(x);
    rank = coder.internal.indexInt(numel(xSize));
    dims = coder.internal.indexInt(1:rank);
    lens = coder.internal.indexInt(xSize);
end

y = coder.internal.fft.fft(x, lens, dims, false);

% LocalWords:  siz fftfcn pmaxsize
