mindquantum.algorithm.library.general_w_state

View Source On Gitee
mindquantum.algorithm.library.general_w_state(qubits)[source]

General W State.

The W State is defined as the equality superposition of bases that only one qubit is in \(\left|1\right>\) while others qubits are in \(\left|0\right>\). For example, a three qubits W state is defined as:

\[\left|\rm W\right> = (\left|001\right> + \left|010\right> + \left|100\right>)/\sqrt(3)\]

Here in this API, we can define a W state on any sub hilbert space of any total number qubits.

Parameters

qubits (list[int]) – Qubits you want to apply general W state.

Examples

>>> from mindquantum.algorithm.library import general_w_state
>>> print(general_w_state(range(3)).get_qs(ket=True))
0.5773502691896257¦001⟩
0.5773502691896258¦010⟩
0.5773502691896257¦100⟩
Returns

Circuit, circuit that can prepare w state.