ApplyPauliFromBitString operation
Namespace: Microsoft.Quantum.Canon
Package: Microsoft.Quantum.Standard
Applies a Pauli operator on each qubit in an array if the corresponding bit of a Boolean array matches a given input.
operation ApplyPauliFromBitString (pauli : Pauli, bitApply : Bool, bits : Bool[], qubits : Qubit[]) : Unit is Adj + Ctl
Input
pauli : Pauli
Pauli operator to apply to qubits[idx] where bitsApply == bits[idx]
bitApply : Bool
apply Pauli if bit is this value
bits : Bool[]
Boolean register specifying which corresponding qubit in qubits should be operated on
qubits : Qubit[]
Quantum register on which to selectively apply the specified Pauli operator
Output : Unit
Example
The following applies an X operation on qubits 0 and 2, and a Z operation on qubits 1 and 3.
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);
Remarks
The Boolean array and the quantum register must be of equal length.
反馈
提交和查看相关反馈