New Show Starting TODAY! π
Come join me on #twitchtv and ask me your burning questions about #QSharp, #QuantumComputing more generally, or what its like working in a quantum optics lab or as a quantum software developer!
πTuesdays 10am-12pm PDT: twitch.tv/crazy4pi314
ApplyUnitaryOperation
operation that takes a Complex[][]
input to describe a unitary and a LittleEndian
register to apply it to would be a nice parallel to the existing PrepareArbitraryState
operation.
When I have two using blocks one after another, I notice some odd behavior w/ Reset() by looking at the output of DumpRegister(). Ex:
using (q1 = Qubit()) {
X(q1);
Rz(PI() / 2.0, q1);
DumpRegister((), [q1]);
let m1 = M(q1);
Reset(q1);
}
using (q1 = Qubit()) {
ResetAll([q1]);
DumpRegister((), [q1]);
Reset(q1);
}
Output:
# wave function for qubits with ids (least to most significant): 0
β£0β: 0.000000 + 0.000000 i == [ 0.000000 ]
β£1β: 0.707107 + 0.707107 i == ********************* [ 1.000000 ] / [ 0.78540 rad ]
# wave function for qubits with ids (least to most significant): 0
β£0β: 0.707107 + 0.707107 i == ********************* [ 1.000000 ] / [ 0.78540 rad ]
β£1β: 0.000000 + 0.000000 i == [ 0.000000 ]
It did reset back to |0>, but looks like the state isn't reflecting that correctly. Any idea why?
DumpRegister((), _)
shows that the register is in fact in the |0β© state following the call to the ResetAll
operation.
What's the easiest way to create a phased operator (e.g. -XZ)? Ideally, I'd like to make it generic like ApplyPauli, but I haven't figured out the syntax yet. A function doesn't work because it seems I can only return one operation and can't apply many in sequence.
For example:
function FixedR(theta : Double, op : ((Double, Qubit) => Unit is Adj+Ctl)) : (Qubit => Unit is Adj+Ctl) {
return op(theta, _);
}
allowed me to create a testing harness for A5 from the Q# challenge.
operation negXZ (qubit : Qubit) : Unit is Adj+Ctl {
body (...) {
R(PauliI, PI(), qubit);
X(qubit);
Z(qubit);
}
}
Controlled
functor can turn what were global phases into locally observable phases.
Bound
can be used to return a single operation representing a sequence of operations without needing to wrap them in a new operation. For example, your negXZ
could be written as let negXZ = BoundCA([R(PauliI, PI(), _), X, Z]);
.
ApplyToEach
, ApplyToFirst
, and so forth can be really useful operations for cases like op(qubits[0]);
. If you want lambda support in Q#, @bettinaheim has been discussing that feature request at microsoft/qsharp-compiler#181.
LittleEndian
is a single atomic value. If you have an array of little-endian registers (that is, LittleEndian[]
), then ApplyToEach
works great over that array. On the other hand, if you want to apply an operation to each qubit making up a single LittleEndian
register, you can unwrap it with the unwrap operator (!
) to get an array of type Qubit[]
.
LittleEndian
UDT marks that a register of qubits should be interpreted where πβ is the least-significant (little end) bit in the expansion of π. From that perspective, a big-endian paper can be converted to a little-endian one by reversing the convention used to order qubits.