import numpy as np
import matplotlib.pyplot as plt
N = 8
W = np.exp(2.j*np.pi/N)
W**8
(W**3)
(W**3)**8
def dftMatrix(N):
W = np.exp(2.j*np.pi/N)
M = np.zeros((N,N), dtype=np.csingle)
for n in range(N):
for k in range(N):
M[k,n] = W**(-n*k)
return M
N = 5
M = dftMatrix(N)
print( np.round(M, decimals=3) )
Minv = np.conj(M) / N
print(np.round(M@Minv, decimals=1))
N = 128
M = dftMatrix(N)
k = 1
plt.figure(figsize=(12,4));
plt.plot(np.real(M[:,k]), 'bo-');
plt.plot(np.imag(M[:,k]), 'o-', color='lightblue');
plt.title(r'$W_{'+str(N)+'}('+str(k)+')$');
k = 2
plt.figure(figsize=(12,4));
plt.plot(np.real(M[:,k]), 'bo-');
plt.plot(np.imag(M[:,k]), 'o-', color='lightblue');
plt.title(r'$W_{'+str(N)+'}('+str(k)+')$');
k = 9
plt.figure(figsize=(12,4));
plt.plot(np.real(M[:,k]), 'bo-');
plt.plot(np.imag(M[:,k]), 'o-', color='lightblue');
plt.title(r'$W_{'+str(N)+'}('+str(k)+')$');
# Fourier basis vectors of DIFFERENT frequencies
M[:,3]@np.conj(M[:,17])
# Fourier basis vectors of the SAME frequencie
M[:,17]@np.conj(M[:,17])