Skip to content

Instantly share code, notes, and snippets.

@antonl
Last active August 29, 2015 14:17
Show Gist options
  • Save antonl/0c8ab2b6a23a0ff3c551 to your computer and use it in GitHub Desktop.
Save antonl/0c8ab2b6a23a0ff3c551 to your computer and use it in GitHub Desktop.
# tags for phase cycles
phase_cycles = [0, 1, 0.6, 1.6, 1.3, 2.3]
# subspaces
sub1, sub2 = np.zeros((3,3), dtype=complex), np.zeros((3,3), dtype=complex)
sub1 = np.array([[np.exp(1j*np.pi*(x)), np.exp(1j*np.pi*(-x)), 1] for x in phase_cycles[0::2]])
sub2 = np.array([[np.exp(1j*np.pi*(x)), np.exp(1j*np.pi*(-x)), 1] for x in phase_cycles[1::2]])
# Full matrix
C = np.kron(np.array([[1, 0], [0, 0]]), sub1) + np.kron(np.array([[0, 0], [0, 1]]), sub2)
# permutation matrix, because data taking is actually interleaved
perm = np.array([[1, 0, 0, 0, 0, 0],
[0, 0, 0, 1, 0, 0],
[0, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 0],
[0, 0, 1, 0, 0, 0],
[0, 0, 0, 0, 0, 1]])
Cperm = np.dot(perm, C)
# final phase cycling matrix
Cperm_inv = np.linalg.inv(Cperm)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment