Accord.Math.Transforms.FourierTransform2.Convolve C# (CSharp) Method

Convolve() public static method

Computes the circular convolution of the given complex vectors. All vectors must have the same length.
public static Convolve ( Complex x, Complex y, Complex result ) : void
x Complex
y Complex
result Complex
return void
        public static void Convolve(Complex[] x, Complex[] y, Complex[] result)
        {
            FFT(x, FourierTransform.Direction.Forward);
            FFT(y, FourierTransform.Direction.Forward);

            for (int i = 0; i < x.Length; i++)
            {
                double xreal = x[i].Real;
                double ximag = x[i].Imaginary;
                double yreal = y[i].Real;
                double yimag = y[i].Imaginary;

                double re = xreal * yreal - ximag * yimag;
                double im = ximag * yreal + xreal * yimag;

                x[i] = new Complex(re, im);
            }

            IDFT(x);

            // Scaling (because this FFT implementation omits it)
            for (int i = 0; i < x.Length; i++)
            {
                result[i] = x[i] / x.Length;
            }
        }

Same methods

FourierTransform2::Convolve ( double x, double y, double result ) : void
FourierTransform2::Convolve ( double xreal, double ximag, double yreal, double yimag, double outreal, double outimag ) : void