示例#1
0
        /// <summary>
        /// Performs a cyclic convolution of splitted complex data of arbitrary length.
        /// </summary>
        /// <param name="datare">Real part of the data array (first input array).</param>
        /// <param name="dataim">Imaginary part of the data array (first input array).</param>
        /// <param name="responsere">Real part of the response array (second input array).</param>
        /// <param name="responseim">Imaginary part of the response array (second input array).</param>
        /// <param name="resultre">The real part of the resulting array.</param>
        /// <param name="resultim">The imaginary part of the resulting array.</param>
        /// <param name="n">The convolution size. The input and result arrays may be larger, but of course not smaller than this number.</param>
        public static void CyclicConvolution(
            double[] datare, double[] dataim,
            double[] responsere, double[] responseim,
            double[] resultre, double[] resultim,
            int n)
        {
            int msize = GetNecessaryConvolutionSize(n);

            // System.Diagnostics.Trace.WriteLine(string.Format("Enter chirp convolution with n={0}, m={1}",n,msize));

            double[] srcre = new double[msize];
            double[] srcim = new double[msize];
            double[] rspre = new double[msize];
            double[] rspim = new double[msize];


            Array.Copy(datare, srcre, n);
            Array.Copy(dataim, srcim, n);

            // Copy the response not only to the beginning, but also to the end of the scratch array
            Array.Copy(responsere, rspre, n);
            Array.Copy(responsere, 1, rspre, msize - (n - 1), n - 1);
            Array.Copy(responseim, rspim, n);
            Array.Copy(responseim, 1, rspim, msize - (n - 1), n - 1);

            FastHartleyTransform.CyclicDestructiveConvolution(srcre, srcim, rspre, rspim, srcre, srcim, msize);

            Array.Copy(srcre, resultre, n);
            Array.Copy(srcim, resultim, n);
        }
示例#2
0
 void MyConvolution(double[] re1, double[] re2, double[] re, int n)
 {
     double[] inp1 = new double[n];
     double[] inp2 = new double[n];
     Array.Copy(re1, inp1, n);
     Array.Copy(re2, inp2, n);
     FastHartleyTransform.CyclicDestructiveConvolution(inp1, inp2, re, n);
 }