Skip to content

Instantly share code, notes, and snippets.

@RyanMarcus
Created December 4, 2016 00:41
Show Gist options
  • Save RyanMarcus/f48acac19a1088398e0b7c7cdd856b6f to your computer and use it in GitHub Desktop.
Save RyanMarcus/f48acac19a1088398e0b7c7cdd856b6f to your computer and use it in GitHub Desktop.
import numpy as np
from matplotlib import pyplot as plt
import itertools
np.set_printoptions(precision=4, suppress=True)
def all_waves(N):
for i in itertools.count():
k = i + 1
for func in [np.cos, np.sin]:
quant = func(2 * np.pi * k/N * (np.arange(N)))
quant = quant / np.linalg.norm(quant)
yield quant
def all_basis(N):
comps = list(itertools.islice(all_waves(N), N-1))
for w1, w2 in itertools.product(comps, comps):
yield np.reshape(w1, (N, 1)) @ np.reshape(w2, (1, N))
bases = all_basis(10)
for b1, b2 in itertools.combinations(bases, 2):
print(b1.flatten() @ b2.flatten())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment