public Fourier multiply(Fourier four) { if (cArray.Length != four.getZ().Length) { Console.WriteLine("Not equal length signals."); return(null); } Complex[] newZ = new Complex[cArray.Length]; for (int i = 0; i < cArray.Length; i++) { newZ[i] = cArray[i].multiply(four.getZ()[i]); } return(new Fourier(newZ)); }
public Fourier correlationNormalized(Fourier four) { Fourier X = this.fft(1); Fourier X_star = X.conjugate(); Fourier Y = four.fft(1); Fourier Y_star = Y.conjugate(); Fourier correlation = X.multiply(Y_star).fft(-1); Fourier autoCorrelationX = X.multiply(X_star).fft(-1); Fourier autoCorrelationY = Y.multiply(Y_star).fft(-1); Complex[] norm = new Complex[cArray.Length]; for (int i = 0; i < cArray.Length; i++) { norm[i] = new Complex(correlation.getZ()[i].getReal() / Math.Sqrt(autoCorrelationX.getZ()[0].getReal() * autoCorrelationY.getZ()[0].getReal()), 0); } return(new Fourier(norm)); }
public Fourier[] fft2d() { int N = c2DArray.Length; int M = c2DArray[0].Length; Fourier[] Y = new Fourier[N]; Fourier[] Z = new Fourier[N]; for (int k = 0; k <= M - 1; k++) { Complex[] col = new Complex[N]; for (int i = 0; i < N; i++) { col[i] = c2DArray[i][k]; } Y[k] = new Fourier(col).fft(1); } for (int n = 0; n <= N - 1; n++) { Z[n] = Y[n].fft(1); } return(Z); }