uniqc.algorithms.core.circuits.entangled_states module¶
Entangled state preparation circuits: GHZ, W, and Cluster states.
All three follow the circuit fragment design (see the design notes in the project README). The canonical APIs are:
ghz_state_circuit(n_qubits, qubits=None) -> Circuitw_state_circuit(n_qubits, qubits=None) -> Circuitcluster_state_circuit(n_qubits, qubits=None, edges=None) -> Circuit
The shorter names ghz_state, w_state and cluster_state are
fragment-style aliases: pass an integer n_qubits to get a fresh fragment.
- uniqc.algorithms.core.circuits.entangled_states.cluster_state(n_qubits=None, qubits=None, edges=None)[source]¶
Prepare a cluster (graph) state via \(H^{\otimes n}\) + CZ on each edge.
See
ghz_state()for the signature contract.edgesdefaults to a linear nearest-neighbour chain.
- uniqc.algorithms.core.circuits.entangled_states.cluster_state_circuit(n_qubits, qubits=None, edges=None)[source]¶
Fragment-style alias of
cluster_state().
- uniqc.algorithms.core.circuits.entangled_states.entangled_states_example()[source]¶
Return a dict
{ 'ghz': Circuit, 'w': Circuit, 'cluster': Circuit }for tests/docs.
- uniqc.algorithms.core.circuits.entangled_states.ghz_state(n_qubits=None, qubits=None)[source]¶
Prepare a GHZ state \((|0\ldots0\rangle + |1\ldots1\rangle)/\sqrt 2\).
c = ghz_state(3) # returns Circuit c = ghz_state(3, qubits=[1, 2, 4]) # use offset qubits
- Parameters:
n_qubits – Number of qubits. May be
Noneifqubitsis given, in which case it is inferred asmax(qubits) + 1.qubits – Qubit indices.
- Returns:
A fresh
Circuitcontaining the preparation fragment.
- uniqc.algorithms.core.circuits.entangled_states.ghz_state_circuit(n_qubits, qubits=None)[source]¶
Fragment-style alias of
ghz_state()(always returns a freshCircuit).
- uniqc.algorithms.core.circuits.entangled_states.w_state(n_qubits=None, qubits=None)[source]¶
Prepare a W state — equal superposition of single-excitation basis states.
See
ghz_state()for the signature contract.