diff --git a/samples/algorithms/BellState.qs b/samples/algorithms/BellState.qs index 851b3f3664..c6ae047991 100644 --- a/samples/algorithms/BellState.qs +++ b/samples/algorithms/BellState.qs @@ -12,9 +12,6 @@ namespace Sample { @EntryPoint() operation BellStates() : (Result, Result)[] { - // Allocate the two qubits that will be used to create a Bell state. - use register = Qubit[2]; - // This array contains a label and a preparation operation for each one // of the four Bell states. let bellStateTuples = [ @@ -28,6 +25,8 @@ namespace Sample { // and measure the Bell state qubits. mutable measurements = []; for (label, prepare) in bellStateTuples { + // Allocate the two qubits that will be used to create a Bell state. + use register = Qubit[2]; prepare(register); Message($"Bell state {label}:"); DumpMachine(); @@ -37,27 +36,23 @@ namespace Sample { } operation PreparePhiPlus(register : Qubit[]) : Unit { - ResetAll(register); // |00〉 H(register[0]); // |+0〉 CNOT(register[0], register[1]); // 1/sqrt(2)(|00〉 + |11〉) } operation PreparePhiMinus(register : Qubit[]) : Unit { - ResetAll(register); // |00〉 H(register[0]); // |+0〉 Z(register[0]); // |-0〉 CNOT(register[0], register[1]); // 1/sqrt(2)(|00〉 - |11〉) } operation PreparePsiPlus(register : Qubit[]) : Unit { - ResetAll(register); // |00〉 H(register[0]); // |+0〉 X(register[1]); // |+1〉 CNOT(register[0], register[1]); // 1/sqrt(2)(|01〉 + |10〉) } operation PreparePsiMinus(register : Qubit[]) : Unit { - ResetAll(register); // |00〉 H(register[0]); // |+0〉 Z(register[0]); // |-0〉 X(register[1]); // |-1〉