Skip to content

Commit

Permalink
switched to dumpregister (#1456)
Browse files Browse the repository at this point in the history
Switched dumpMachine to dumpRegister to have one-qubit states #1388
@cesarzc

---------

Co-authored-by: Joshua Aragon <[email protected]>
  • Loading branch information
goshua13 and Joshua Aragon authored May 1, 2024
1 parent 2db62e5 commit baa771f
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions samples/algorithms/Teleportation.qs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ namespace Sample {

@EntryPoint()
operation Main() : Result[] {
// Allocate the message and target qubits.
use (message, target) = (Qubit(), Qubit());

// Use the `Teleport` operation to send different quantum states.
let stateInitializerBasisTuples = [
("|0〉", I, PauliZ),
Expand All @@ -29,17 +26,20 @@ namespace Sample {

mutable results = [];
for (state, initializer, basis) in stateInitializerBasisTuples {
// Allocate the message and target qubits.
use (message, target) = (Qubit(), Qubit());

// Initialize the message and show its state using the `DumpMachine`
// function.
initializer(message);
Message($"Teleporting state {state}");
DumpMachine();
DumpRegister([message]);

// Teleport the message and show the quantum state after
// teleportation.
Teleport(message, target);
Message($"Received state {state}");
DumpMachine();
DumpRegister([target]);

// Measure target in the corresponding basis and reset the qubits to
// continue teleporting more messages.
Expand Down Expand Up @@ -77,13 +77,14 @@ namespace Sample {
// Measure the qubits to extract the classical data we need to decode
// the message by applying the corrections on the target qubit
// accordingly.
if M(message) == One {
Z(target);
}
if M(auxiliary) == One {
X(target);
}

if M(message) == One {
Z(target);
}

// Reset auxiliary qubit before releasing.
Reset(auxiliary);
}
Expand Down

0 comments on commit baa771f

Please sign in to comment.