function convolveComplex(xreal, ximag, yreal, yimag, outreal, outimag) {
    if (xreal.length !== ximag.length || xreal.length !== yreal.length || yreal.length !== yimag.length || xreal.length !== outreal.length || outreal.length !== outimag.length)
        throw "Mismatched lengths";
    var i;
    var n = xreal.length;
    xreal = xreal.slice();
    ximag = ximag.slice();
    yreal = yreal.slice();
    yimag = yimag.slice();

    transform(xreal, ximag);
    transform(yreal, yimag);
    for (i = 0; i < n; i++) {
        var temp = xreal[i] * yreal[i] - ximag[i] * yimag[i];
        ximag[i] = ximag[i] * yreal[i] + xreal[i] * yimag[i];
        xreal[i] = temp;
    }
    inverseTransform(xreal, ximag);
    for (i = 0; i < n; i++) { // Scaling (because this FFT implementation omits it)
        outreal[i] = xreal[i] / n;
        outimag[i] = ximag[i] / n;
    }
}
/* 
 * Computes the circular convolution of the given complex vectors. Each vector's length must be the same.
 */
Computes the circular convolution of the given complex vectors. Each vector's length must be the same.
Computes the circular convolution of the given complex vectors . Each vector ' s length must be the same .
function convolveComplex(xreal, ximag, yreal, yimag, outreal, outimag) {
    if (xreal.length !== ximag.length || xreal.length !== yreal.length || yreal.length !== yimag.length || xreal.length !== outreal.length || outreal.length !== outimag.length)
        throw "Mismatched lengths";
    var i;
    var n = xreal.length;
    xreal = xreal.slice();
    ximag = ximag.slice();
    yreal = yreal.slice();
    yimag = yimag.slice();
    transform(xreal, ximag);
    transform(yreal, yimag);
    for (i = 0; i < n; i++) {
        var temp = xreal[i] * yreal[i] - ximag[i] * yimag[i];
        ximag[i] = ximag[i] * yreal[i] + xreal[i] * yimag[i];
        xreal[i] = temp;
    }
    inverseTransform(xreal, ximag);
    for (i = 0; i < n; i++) { 
        outreal[i] = xreal[i] / n;
        outimag[i] = ximag[i] / n;
    }
}
function convolveComplex ( xreal , ximag , yreal , yimag , outreal , outimag ) { if ( xreal . length !== ximag . length || xreal . length !== yreal . length || yreal . length !== yimag . length || xreal . length !== outreal . length || outreal . length !== outimag . length ) throw "Mismatched lengths" ; var i ; var n = xreal . length ; xreal = xreal . slice ( ) ; ximag = ximag . slice ( ) ; yreal = yreal . slice ( ) ; yimag = yimag . slice ( ) ; transform ( xreal , ximag ) ; transform ( yreal , yimag ) ; for ( i = 0 ; i < n ; i ++ ) { var temp = xreal [ i ] * yreal [ i ] - ximag [ i ] * yimag [ i ] ; ximag [ i ] = ximag [ i ] * yreal [ i ] + xreal [ i ] * yimag [ i ] ; xreal [ i ] = temp ; } inverseTransform ( xreal , ximag ) ; for ( i = 0 ; i < n ; i ++ ) { outreal [ i ] = xreal [ i ] / n ; outimag [ i ] = ximag [ i ] / n ; } }
Computes the circular convolution of the given complex vectors.
Computes the circular convolution of the given complex vectors .
// Scaling (because this FFT implementation omits it)