Created
November 19, 2014 03:47
-
-
Save shoyer/92f8beb8bf9b0a66da69 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def transform_state_vector(rho, U): | |
N = len(U) | |
if rho.shape[-1] == N: | |
# rho is in Hilbert space | |
pass | |
elif rho.shape[-1] == N ** 2: | |
# rho is in Liouville space | |
U = np.kron(U, U) | |
else: | |
raise ValueError('basis transformation incompatible with ' | |
'operator dimensions') | |
return np.einsum('ij,...j->...i', U.T.conj(), rho) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment