mindquantum.algorithm.library.general_w_state
- 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
while others qubits are in . For example, a three qubits W state is defined as:Here in this API, we can define a W state on any sub hilbert space of any total number qubits.
Note
Please refer to https://quantumcomputing.stackexchange.com/questions/4350/general-construction-of-w-n-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.