Beispiel #1
0
        private List <double> FastCrossCorrelation(List <double> X1, List <double> X2, int N)
        {
            FastFourier           ff = new FastFourier();
            List <List <double> > x1 = new List <List <double> >();
            List <List <double> > x2 = new List <List <double> >();

            x1 = ff.fastFourier(X1, X1.Count);//iam in frequency domain now
            x2 = ff.fastFourier(X2, X2.Count);
            List <List <double> > result      = new List <List <double> >();
            List <double>         finalResult = new List <double>();
            List <List <double> > conj        = new List <List <double> >();
            List <List <double> > mul         = new List <List <double> >();

            if (convolution == true)
            {
                conj = x1;
            }
            else
            {
                conj = conjunction(x1);
            }
            for (int i = 0; i < N; i++) //multiplication
            {
                List <double> mulTmp = new List <double>();
                mulTmp.Add(conj[i][0] * x2[i][0]);
                mulTmp.Add((conj[i][1] * x2[i][0]) + (conj[i][1] * x2[i][1]) + (conj[i][0] * x2[i][1]));
                mul.Add(mulTmp);
                if (conj[i][1] != 0 && x2[i][1] != 0)
                {
                    mul[i][0] += -(conj[i][1] * x2[i][1]);
                }
            }
            Inverse_Fast_Fourier iff = new Inverse_Fast_Fourier();

            result = iff.InvFastFourier(mul, N);
            for (int i = 0; i < result.Count; i++)
            {
                result[i][0] = result[i][0] / N;
                result[i][1] = result[i][1] / N;
            }
            for (int i = 0; i < result.Count; i++) //if you convolution
            {
                finalResult.Add(result[i][0]);
            }
            if (convolution == false)
            {
                for (int i = 0; i < N; i++)
                {
                    finalResult[i] = finalResult[i] / N;
                }
            }
            return(finalResult);
        }
Beispiel #2
0
        private void btnIFFT_Click(object sender, EventArgs e)
        {
            Inverse_Fast_Fourier i = new Inverse_Fast_Fourier();

            i.Show();
        }