Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function for tensor combination #831

Open
vprusso opened this issue Oct 5, 2024 · 0 comments · May be fixed by #832
Open

Function for tensor combination #831

vprusso opened this issue Oct 5, 2024 · 0 comments · May be fixed by #832
Assignees

Comments

@vprusso
Copy link
Owner

vprusso commented Oct 5, 2024

Create a function that allows the user to take all tensor combinations of a set of states of size k:

def tensor_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 = {}
    for seq in possible_sequences:
        state_sequence = [states[i] for i in seq]
        # Calculate the tensor product of the state vectors.
        sequence_tensor_product = np.array(state_sequence[0])
        for state in state_sequence[1:]:
            sequence_tensor_product = np.kron(sequence_tensor_product, state)
        sequences_of_states[seq] = vector_to_density_matrix(sequence_tensor_product)

    return sequences_of_states

This can be placed within matrix_ops/ and would require appropriate testing coverage as well.

@vprusso vprusso self-assigned this Oct 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant