from __future__ import division
import numpy as np
import matplotlib.pyplot as pt
n = 64
omega = exp(2*pi*1j*1./n)
opowers = omega**[1,2,3,4,5]
xlim([-1.2, 1.2]); xlabel("Real")
ylim([-1.2, 1.2]); ylabel("Imaginary")
grid()
gca().set_aspect("equal")
plot(opowers.real, opowers.imag, "o")
opowers = omega**arange(n)
plot(opowers.imag)
plot((opowers**2).imag)
plot((opowers**5).imag)
dot(opowers, opowers**3)
dot(opowers**17, opowers**3)
dot(opowers**3, opowers**3)
dot((opowers**3).conj(), opowers**3)
vdot(opowers**3, opowers**3)
mat = np.vstack(
[opowers**0, opowers**1, opowers**2,
opowers**3, opowers**4, opowers**5]).T
mat.shape
plot(np.dot(mat, [0, 1, 0,0, 0.3, 0.7]))
mat = opowers[:, newaxis] ** arange(n)
mat.shape
weights = zeros(n)
weights[1] = 1
weights[4] = 0.3
weights[5] = 0.7
plot(dot(mat, weights))
mat
?dot(mat[:,3].conj(), mat[3])