1 回答
TA貢獻1898條經驗 獲得超8個贊
如果我正確理解你的描述,量子開發工具包提供的資源估計器準確地報告你的操作沒有使用任何量子位或量子指令。這是因為 Q# 操作使用的 qubits 恰好是usingorborrowing語句顯式使用的 qubits,加上調用的任何其他操作使用的 qubits。
例如,如果你在 Q# 中編寫傳送操作,你可能會喜歡以下內容:
operation PrepareEntangledPair(left : Qubit, right : Qubit) : Unit {
body (...) {
H(left);
CNOT(left, right);
}
adjoint auto;
}
operation ApplyCorrection(here : Qubit, msg : Qubit, there : Qubit) : Unit {
if (M(msg) == One) { Z(there); }
if (M(here) == One) { X(there); }
}
operation TeleportMessage(msg : Qubit, there : Qubit) : Unit {
using (here = Qubit()) {
// Create some entanglement that we can use to send our message.
PrepareEntangledPair(here, there);
// Move our message into the entangled pair by using a Bell
// measurement.
Adjoint PrepareEntangledPair(msg, here);
// Measure out the entanglement.
ApplyCorrection(here, msg, there);
// Reset our "here" qubit before releasing it.
Reset(here);
}
}
operation TeleportClassicalFlag() : Unit {
using ((msg, there) = (Qubit(), Qubit())) {
X(msg);
TeleportMessage(msg, there);
ApplyToEach(Reset, [msg, there]);
}
}
在此報告上運行資源估算器,使用了三個量子位(兩個TeleportClassicalFlag直接使用,一個使用TeleportMessage,被調用TeleportClassicalFlag):

相比之下,經典邏輯始終保持經典。這旨在使混合經典邏輯和量子邏輯變得容易,例如在實現迭代相位估計算法時。在上面的示例中,使用的if語句和==運算符用于ApplyCorrection描述隱形傳態算法的經典部分。
添加回答
舉報
