共用方式為


ApplyPauliFromBitString 作業

完整名稱:Std.Canon.ApplyPauliFromBitString

operation ApplyPauliFromBitString(pauli : Pauli, bitApply : Bool, bits : Bool[], qubits : Qubit[]) : Unit is Adj + Ctl

總結

如果布爾陣列的對應位符合指定的輸入,則套用陣列中每個量子位的Pauli運算元。

輸入

保利

Pauli 運算子要套用至 qubits[idx]bitApply == bits[idx]

bitApply

如果 bit 為此值,請套用 Pauli

布爾緩存器,指定應該在 qubits 中操作哪個對應的量子位

量子比特

要選擇性地套用指定Pauli運算子的量子緩存器

言論

布爾值陣列和量子緩存器長度必須相等。

下列在量子位 0 和 2 上套用 X 作業,以及量子位 1 和 3 上的 Z 作業。

use qubits = Qubit[4];
let bits = [true, false, true, false];
// Apply when index in `bits` is `true`.
ApplyPauliFromBitString(PauliX, true, bits, qubits);
// Apply when index in `bits` is `false`.
ApplyPauliFromBitString(PauliZ, false, bits, qubits);