/// <summary> /// Performs a cyclic correlation 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 CyclicCorrelation( double[] datare, double[] dataim, double[] responsere, double[] responseim, double[] resultre, double[] resultim, int n) { int msize = GetNecessaryCorrelationSize(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 immediatly after the data Array.Copy(responsere, rspre, n); Array.Copy(responsere, 0, rspre, n, n - 1); Array.Copy(responseim, rspim, n); Array.Copy(responseim, 0, rspim, n, n - 1); FastHartleyTransform.CyclicCorrelationDestructive(srcre, srcim, rspre, rspim, srcre, srcim, msize); Array.Copy(srcre, resultre, n); Array.Copy(srcim, resultim, n); }
void MyCorrelationRoutine(double[] src1real, double[] src2real, double[] resultreal, int n) { double[] inp1re = new double[n]; double[] inp2re = new double[n]; Array.Copy(src1real, inp1re, n); Array.Copy(src2real, inp2re, n); FastHartleyTransform.CyclicCorrelationDestructive(inp1re, inp2re, resultreal, n); }