<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Demo dftmatrixexamples
Demonstrate the kernel matrix for the DFT Transform.
Imports
Step1:  Função iadftmatrix
Synopse
Kernel matrix for the 1-D Discrete Fourier Transform DFT.
A = iadftmatrix(N)
N
Step2:  Kernel images generated
Imaginary and real parts of the DFT kernel.
Step3:  Four first lines
Four first lines from real and imaginary parts of the kernel matrix. Observe the increasing frequencies of the senoidals
(imaginary part) and cossenoidals (real part).
Step4:  Showing complex conjugates
<ASSISTANT_TASK:>
Python Code:
import sys,os
%matplotlib inline
ia898path = os.path.abspath('/etc/jupyterhub/ia898_1s2017/')
if ia898path not in sys.path:
    sys.path.append(ia898path)
import ia898.src as ia
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
from numpy.fft import fft2
from numpy.fft import ifft2
Explanation: Demo dftmatrixexamples
Demonstrate the kernel matrix for the DFT Transform.
Imports
End of explanation
def iadftmatrix(N):
    x = np.arange(N).reshape(N,1)
    u = x
    Wn = np.exp(-1j*2*np.pi/N)
    A = (1./np.sqrt(N)) * (Wn ** np.dot(u, x.T))
    return A
Explanation: Função iadftmatrix
Synopse
Kernel matrix for the 1-D Discrete Fourier Transform DFT.
A = iadftmatrix(N)
N:Input: Integer, number of points of the DFT.
A:Output image, square N x N, complex
End of explanation
A = iadftmatrix(128)
plt.figure(1)
plt.imshow((A.real),cmap='gray')
plt.title('A.real')
plt.colorbar()
plt.figure(2)
plt.imshow((A.imag),cmap='gray')
plt.title('A.imag')
plt.colorbar()
Explanation: Kernel images generated
Imaginary and real parts of the DFT kernel.
End of explanation
plt.figure(1, figsize=(10,10))
plt.subplot(2,2,1)
plt.title('u = 0')
plt.plot(A.real[0,:], 'r')
plt.plot(A.imag[0,:], 'g')
plt.subplot(2,2,2)
plt.title('u = 1')
plt.plot(A.real[1,:], 'r')
plt.plot(A.imag[1,:], 'g')
plt.subplot(2,2,3)
plt.title('u = 2')
plt.plot(A.real[2,:], 'r')
plt.plot(A.imag[2,:], 'g')
plt.subplot(2,2,4)
plt.title('u = 3')
plt.plot(A.real[3,:], 'r')
plt.plot(A.imag[3,:], 'g')
plt.show()
Explanation: Four first lines
Four first lines from real and imaginary parts of the kernel matrix. Observe the increasing frequencies of the senoidals
(imaginary part) and cossenoidals (real part).
End of explanation
plt.figure(1, figsize=(10,10))
plt.subplot(2,2,1)
plt.title('u = 0')
plt.plot(A.real[ 0,:], 'r')
plt.plot(A.imag[ 0,:], 'g')
plt.subplot(2,2,2)
plt.title('u = -1')
plt.plot(A.real[-1,:], 'r')
plt.plot(A.imag[-1,:], 'g')
plt.subplot(2,2,3)
plt.title('u = -2')
plt.plot(A.real[-2,:], 'r')
plt.plot(A.imag[-2,:], 'g')
plt.subplot(2,2,4)
plt.title('u = -3')
plt.plot(A.real[-3,:], 'r')
plt.plot(A.imag[-3,:], 'g')
plt.show()
Explanation: Showing complex conjugates
End of explanation
<END_TASK>