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); }
public static complex frompolar(double r, double theta) { complex data; data = new complex(r * Math.Cos(theta), r * Math.Sin(theta)); return(data); }
/// <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); }
public static complex operator -(complex a, complex b) { complex data = new complex(a.real - b.real, a.imag - b.imag); return(data); }