You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create a function that allows the user to take all tensor combinations of a set of states of size k:
deftensor_comb(states: list[np.ndarray], k: int) ->dict:
""" Create a tensor combination (quantum sequence) from a set of states. Args: states: A dictionary of states where keys are state identifiers and values are state vectors. k: The length of the sequence. Returns: A dictionary of tensor products representing the quantum sequence. """# Generate all possible functions σ from [k] to [n]. This is equivalent to# generating all possible sequences of length k.possible_sequences=list(itertools.product(range(len(states)), repeat=k))
# Convert sequences of state identifiers to sequences of state vectors.sequences_of_states= {}
forseqinpossible_sequences:
state_sequence= [states[i] foriinseq]
# Calculate the tensor product of the state vectors.sequence_tensor_product=np.array(state_sequence[0])
forstateinstate_sequence[1:]:
sequence_tensor_product=np.kron(sequence_tensor_product, state)
sequences_of_states[seq] =vector_to_density_matrix(sequence_tensor_product)
returnsequences_of_states
This can be placed within matrix_ops/ and would require appropriate testing coverage as well.
The text was updated successfully, but these errors were encountered:
Create a function that allows the user to take all tensor combinations of a set of states of size
k
:This can be placed within
matrix_ops/
and would require appropriate testing coverage as well.The text was updated successfully, but these errors were encountered: