function x = ifft2(f, mrows, ncols)
%IFFT2 Two-dimensional inverse discrete Fourier transform.
%   IFFT2(F) returns the two-dimensional inverse Fourier transform
%   of matrix F.  If F is a vector, the result will have the same
%   orientation.
%
%   IFFT2(F,MROWS,NCOLS) pads matrix F with zeros to size MROWS-by-NCOLS
%   before transforming.
%
%   See also FFT2, IFFT, FFTSHIFT.

%   J.N. Little 12-18-85
%   Revised 4-15-87 JNL
%   Revised 5-3-90 CRD
%   Copyright 1984-2000 The MathWorks, Inc. 
%   $Revision: 5.14 $  $Date: 2000/08/15 16:49:31 $

if (~isa(f, 'double'))
    f = double(f);
end

if ndims(f)==2
    if nargin==1
        x = ifftn(f);
    else
        x = ifftn(f,[mrows ncols]);
    end
else
    f = conj(f);
    mn = size(f,1)*size(f,2);
    if nargin==1
        x = conj(fft(fft(f,[],2),[],1))/mn;
    else
        x = conj(fft(fft(f,ncols,2),mrows,1))/(mrows*ncols);
    end
end   


