共用方式為


重新標記作業

完整名稱:Std.Canon.Relabel

operation Relabel(current : Qubit[], updated : Qubit[]) : Unit is Adj

總結

Relabels the qubits in the current array with the qubits in the updated array. updated 陣列必須是 current 陣列的有效排列。

輸入

當前

要重新標記的量子位數組。

更新

要重新標記 current 陣列的量子位數組。

言論

當您需要以不產生任何量子作業的方式重新標記量子位時,這項作業很有用。 請注意,在具有有限量子位連線的硬體上編譯執行時,這項作業可能不會造成量子位相鄰的任何變更,而且可能仍然需要一或多個 SWAP 網關。

下列範例示範如何在緩存器中重新標記量子位:

use qubits = Qubit[3];
let newOrder = [qubits[2], qubits[0], qubits[1]];
Relabel(qubits, newOrder);

此作業之後,任何使用 qubits[0] 都會參考原本 qubits[2]的量子位等等。 若要在兩個量子位上交換標籤,SWAP 閘道的虛擬對等專案,您可以使用下列程式代碼:

use (q0, q1) = (Qubit(), Qubit());
Relabel([q0, q1], [q1, q0]);

請注意,此作業的相鄰實際上會變更自變數的順序,因此 Adjoint Relabel(qubits, newOrder) 相當於 Relabel(newOrder, qubits)