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
preserved as dual-mode dispatchers: pass an integer to get a fresh fragment;
pass an existing Circuit (deprecated) to mutate it in place.
- uniqc.algorithms.core.circuits.entangled_states.cluster_state(first_arg=None, qubits=None, edges=None)[source]¶
Prepare a cluster (graph) state via \(H^{\otimes n}\) + CZ on each edge.
See
ghz_state()for the dual-mode 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.- Return type:
- uniqc.algorithms.core.circuits.entangled_states.ghz_state(first_arg=None, qubits=None)[source]¶
Prepare a GHZ state \((|0\ldots0\rangle + |1\ldots1\rangle)/\sqrt 2\).
Two calling conventions:
# Fragment style (recommended): c = ghz_state(3) # returns Circuit c = ghz_state(3, qubits=[1, 2, 4]) # use offset qubits # Legacy in-place style (deprecated): c = Circuit(3) ghz_state(c) # mutates c in place
- 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(first_arg=None, qubits=None)[source]¶
Prepare a W state — equal superposition of single-excitation basis states.
See
ghz_state()for the dual-mode signature contract.