Exemplo n.º 1
0
        public static complex operator *(complex a, complex b)
        {
            complex data = new complex((a.real * b.real) - (a.imag * b.imag),
                                       (a.real * b.imag) + (a.imag * b.real));

            return(data);
        }
Exemplo n.º 2
0
        public static complex frompolar(double r, double theta)
        {
            complex data;

            data = new complex(r * Math.Cos(theta), r * Math.Sin(theta));
            return(data);
        }
Exemplo n.º 3
0
        /// <summary>
        /// calcul de DFT (discrete Fourier Transform)
        /// version avec argument en entree de " type complex[] "
        /// </summary>
        /// <param name="x"> x[] : array of complex values </param>
        /// <returns>  DFT[] array of complex values  </returns>
        public static complex[] DFTv1(complex[] x)
        {
            int N = x.Length;

            complex[] X = new complex[N];
            for (int k = 0; k < N; k++)
            {
                X[k] = new complex(0, 0);
                for (int n = 0; n < N; n++)
                {
                    complex temp = complex.frompolar(1, -2 * Math.PI * n * k / N);
                    temp *= x[n];
                    X[k] += temp;
                }
            }
            return(X);
        }
Exemplo n.º 4
0
        public static complex operator -(complex a, complex b)
        {
            complex data = new complex(a.real - b.real, a.imag - b.imag);

            return(data);
        }