src/fftlib.js
function ifft2d(re, im) {
    var tre = [],
        tim = [],
        i = 0;
    // x-axis
    for (var y = 0; y < _n; y++) {
        i = y * _n;
        for (var x1 = 0; x1 < _n; x1++) {
            tre[x1] = re[x1 + i];
            tim[x1] = im[x1 + i];
        }
        ifft1d(tre, tim);
        for (var x2 = 0; x2 < _n; x2++) {
            re[x2 + i] = tre[x2];
            im[x2 + i] = tim[x2];
        }
    }
    // y-axis
    for (var x = 0; x < _n; x++) {
        for (var y1 = 0; y1 < _n; y1++) {
            i = x + y1 * _n;
            tre[y1] = re[i];
            tim[y1] = im[i];
        }
        ifft1d(tre, tim);
        for (var y2 = 0; y2 < _n; y2++) {
            i = x + y2 * _n;
            re[i] = tre[y2];
            im[i] = tim[y2];
        }
    }
}
function ifft2d(re, im) {
    var tre = [],
        tim = [],
        i = 0;
    // x-axis
    for (var y = 0; y < _n; y++) {
        i = y * _n;
        for (var x1 = 0; x1 < _n; x1++) {
            tre[x1] = re[x1 + i];
            tim[x1] = im[x1 + i];
        }
        ifft1d(tre, tim);
        for (var x2 = 0; x2 < _n; x2++) {
            re[x2 + i] = tre[x2];
            im[x2 + i] = tim[x2];
        }
    }
    // y-axis
    for (var x = 0; x < _n; x++) {
        for (var y1 = 0; y1 < _n; y1++) {
            i = x + y1 * _n;
            tre[y1] = re[i];
            tim[y1] = im[i];
        }
        ifft1d(tre, tim);
        for (var y2 = 0; y2 < _n; y2++) {
            i = x + y2 * _n;
            re[i] = tre[y2];
            im[i] = tim[y2];
        }
    }
}
function ifft2d ( re , im ) { var tre = [ ] , tim = [ ] , i = 0 ; // x-axis for ( var y = 0 ; y < _n ; y ++ ) { i = y * _n ; for ( var x1 = 0 ; x1 < _n ; x1 ++ ) { tre [ x1 ] = re [ x1 + i ] ; tim [ x1 ] = im [ x1 + i ] ; } ifft1d ( tre , tim ) ; for ( var x2 = 0 ; x2 < _n ; x2 ++ ) { re [ x2 + i ] = tre [ x2 ] ; im [ x2 + i ] = tim [ x2 ] ; } } // y-axis for ( var x = 0 ; x < _n ; x ++ ) { for ( var y1 = 0 ; y1 < _n ; y1 ++ ) { i = x + y1 * _n ; tre [ y1 ] = re [ i ] ; tim [ y1 ] = im [ i ] ; } ifft1d ( tre , tim ) ; for ( var y2 = 0 ; y2 < _n ; y2 ++ ) { i = x + y2 * _n ; re [ i ] = tre [ y2 ] ; im [ i ] = tim [ y2 ] ; } } }
2D-IFFT
2D - IFFT