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) -> Circuit

  • w_state_circuit(n_qubits, qubits=None) -> Circuit

  • cluster_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. edges defaults to a linear nearest-neighbour chain.

Parameters:
uniqc.algorithms.core.circuits.entangled_states.cluster_state_circuit(n_qubits, qubits=None, edges=None)[source]

Fragment-style alias of cluster_state().

Parameters:
Return type:

Circuit

uniqc.algorithms.core.circuits.entangled_states.entangled_states_example()[source]

Return a dict { 'ghz': Circuit, 'w': Circuit, 'cluster': Circuit } for tests/docs.

Return type:

dict

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
Parameters:
  • first_arg – Either an integer n_qubits (fragment mode) or a Circuit (deprecated in-place mode).

  • qubits (list[int] | None) – Qubit indices.

Returns:

A fresh Circuit in fragment mode; None in legacy mode.

uniqc.algorithms.core.circuits.entangled_states.ghz_state_circuit(n_qubits, qubits=None)[source]

Fragment-style alias of ghz_state() (always returns a fresh Circuit).

Parameters:
Return type:

Circuit

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.

Parameters:

qubits (list[int] | None)

uniqc.algorithms.core.circuits.entangled_states.w_state_circuit(n_qubits, qubits=None)[source]

Fragment-style alias of w_state().

Parameters:
Return type:

Circuit