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
Add TensorProductState, a state-vector-like object (#3171)
This is factored out of #2781 with @Strilanc 's initial comments addressed, per comments on that PR.
`cirq.STATE_VECTOR_LIKE` accepts basis-state indices, sequences of per-qudit basis indices, or arrays of amplitudes. This PR extends this union type to accept `TensorProductState` -- an object representing a state vector which can be decomposed into a tensor product of single-qubit states. The structure shares a lot of similarity with `PauliString`. Whereas PauliString is a dictionary from qubits to (single-qubit) `Pauli` objects; here it is a mapping from qubits to single-qubit named states. Here we include `|0>, |1>, |+>, |->, |i>, |-i>`. As an example:
```python
# start from the |+++> state
q = cirq.LineQubit.range(3)
initial_state = cirq.KET_PLUS(q[0]) * cirq.KET_PLUS(q[1]) * cirq.KET_PLUS(q[2])
```
Since most things already use `STATE_VECTOR_LIKE` and its associated helper function `to_valid_state_vector`, only minor modifications to this function was necessary to enable specification of a tensor product state wherever initial states are sold.
0 commit comments