File:Visualization of the matrix of the discrete Fourier transform for n=8.svg

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

Original file (SVG file, nominally 729 × 728 pixels, file size: 208 KB)

Captions

Captions

The matrix of the discrete Fourier transform for n=8.

Summary

[edit]
Description
English: Depiction of the matrix of the DFT for n=8. Each element is represented by a picture of its location in the complex plane in relation to the unit circle. See also https://commons.wikimedia.org/wiki/File:Visualization_of_the_matrix_of_the_discrete_Fourier_transform_for_n%3D4.svg. Generated by the following Python code.
from numpy import linspace,ones_like,real,imag,cos,sin,pi,exp,arange
import matplotlib.pyplot as plt  
from matplotlib import cm

def fft_matrix_viz(n):
	 L = 1.
	 vsep = -1.
	 markersize = 75./float(n)
	 i = complex(0.,1.)
	 t = linspace(0,L,501,endpoint=True)
	 kvals = range(0,n)#-n//2,n)
	 colormap = cm.get_cmap('hsv') # a cyclic colormap
	 nc = len(kvals)
	 colors = colormap( linspace(0,1,nc,endpoint=False) )  # get nc colors from the colormap
	 # pastelize colors
	 p = 0.5
	 colors = (1-p)*colors + p*ones_like(colors)
	 # darken colors
	 d = 0.9
	 colors *= [d,d,d,1]
	 fontsize = 20*4/n
	 plt.figure(figsize=(12, 12))

	 theta = linspace(0,2*pi,100)
	 c = cos(theta)
	 s = sin(theta)
	 def plotZ(x,y,Z):
	     radius = 0.3
	     plt.plot(x+radius*c, y+radius*s,'k',alpha=0.35)  # draw unit circle
	     plt.plot([x,x+radius*real(Z)],[y,y+radius*imag(Z)],'k',alpha=0.35) # draw radius
	     plt.plot(x+radius*real(Z),y+radius*imag(Z),'o',markersize=markersize,color=colors[(j*k)%len(kvals)]) # mark Z

	 plt.subplot(1,1,1,aspect=1,frameon=False)
	 for k in kvals:
	     zd = exp(-2*pi*i*k*arange(n)/float(n))
	     for j,Z in enumerate(zd): plotZ(j,vsep*k,Z)
	     plt.text(-0.5,vsep*k,str(k),va='center',ha='right',fontsize=fontsize)

	 for j in range(n):
	     plt.text(j,vsep*(min(kvals)-0.45),str(j),ha='center',fontsize=fontsize)
	 plt.xlim(-.5,n+.5)
	 plt.ylim(vsep*(max(kvals)+1),vsep*(min(kvals)-1))
	 plt.xticks([])
	 plt.yticks([])

	 plt.savefig('dft_visualization_'+'n'+str(n).zfill(4)+'.svg',bbox_inches='tight')

fft_matrix_viz(8)
Date
Source Own work
Author John Ringland

Licensing

[edit]
I, the copyright holder of this work, hereby publish it under the following license:
w:en:Creative Commons
attribution share alike
This file is licensed under the Creative Commons Attribution-Share Alike 4.0 International license.
You are free:
  • to share – to copy, distribute and transmit the work
  • to remix – to adapt the work
Under the following conditions:
  • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
  • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current18:51, 27 April 2021Thumbnail for version as of 18:51, 27 April 2021729 × 728 (208 KB)Darnling (talk | contribs)Uploaded own work with UploadWizard

There are no pages that use this file.

Metadata