def IDFT(X): """ Input: X (numpy array) = frequency spectrum (length N) Output: The function should return a numpy array of length N x (numpy array) = The N point IDFT of the frequency spectrum X """ N = len(X) ans = np.arange(0) for k in range(N): cs=np.conj(gcs(k,N)) ans = np.append(ans,dotProduct(X,cs)/(1.0*N)) return ans
def DFT(x): """ Input: x (numpy array) = input sequence of length N Output: The function should return a numpy array of length N X (numpy array) = The N point DFT of the input sequence x """ N = len(x) ans = np.arange(0) for k in range(N): cs = gcs(k, N) ans = np.append(ans, dotProduct(x, cs)) return ans