pub fn prepare_w(n_qubits: usize) -> QuantumResult<StateVector>Expand description
Prepare the n-qubit W state Σ_{i} |0…1_i…0⟩ / √n.
Construction (Cabello 2002 cascade): qubit 0 is rotated so that the
excitation either stays on qubit 0 with amplitude 1/√n or is forwarded.
Successive controlled Y-rotations split the remaining amplitude evenly, and
CNOTs move the excitation down the chain. The net result places exactly one
|1⟩ with equal amplitude on every qubit.
§Errors
QuantumError::InvalidQubitCount if n_qubits is 0 or > 30.