# Microsoft.Quantum.Primitive

## Operations

Assert |
Asserts that measuring the given qubits in the given Pauli basis will always have the given result. |

AssertProb |
Asserts that measuring the given qubits in the given Pauli basis will have the given result with the given probability, within some tolerance. |

CCNOT |
Applies the doubly controlledâ€“NOT (CCNOT) gate to three qubits. |

CNOT |
Applies the controlled-NOT (CNOT) gate to a pair of qubits, \begin{align} \operatorname{CNOT} \mathrel{:=} \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \end{bmatrix}, \end{align} where rows and columns are ordered as in the quantum concepts guide. |

Exp |
Applies the exponential of a multi-qubit Pauli operator
\begin{align}
e^{i \theta [P_0 \otimes P_1 \cdots P_N]},
\end{align}
where $P_i$ is the $i$th element of |

ExpFrac |
Applies the exponential of a multi-qubit Pauli operator
with an argument given by a dyadic fraction,
\begin{align}
e^{i \theta \pi k [P_0 \otimes P_1 \cdots P_N] / 2^n},
\end{align}
where $P_i$ is the $i$th element of |

H |
Applies the Hadamard transformation to a single qubit, \begin{align} H \mathrel{:=} \frac{1}{\sqrt{2}} \begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix}. \end{align} |

I |
Performs the identity operation (no-op) on a single qubit. |

M |
Performs a measurement of a single qubit in the Pauli $Z$ basis, such that the output result is given by the distribution \begin{align} \Pr(\texttt{Zero} | \ket{\psi}) = \braket{\psi | 0} \braket{0 | \psi}. \end{align} |

Measure |
Performs a joint measurement of one or more qubits in the
specified Pauli bases, such that the output result is given by
the distribution
\begin{align}
\Pr(\texttt{Zero} | \ket{\psi}) =
\frac12 \braket{
\psi \mid|
\left(
\boldone + P_0 \otimes P_1 \otimes \cdots \otimes P_{N-1}
\right) \mid|
\psi
},
\end{align}
where $P_i$ is the $i$th element of |

MultiX |
Applies the gate $X \otimes X \otimes \cdots \otimes X$ to a register of qubits. |

R |
Applies a rotation about the given Pauli axis, \begin{align} R_{\mu}(\theta) \mathrel{:=} e^{-i \theta \sigma_{\mu} / 2}, \end{align} where $\mu \in {I, X, Y, Z}$. |

R1 |
Applies a rotation about the $\ket{1}$ state by a given angle, \begin{align} R_1(\theta) \mathrel{:=} \operatorname{diag}(1, e^{i\theta}). \end{align} |

R1Frac |
Applies a rotation about the $\ket{1}$ state by an angle specified as a dyadic fraction, \begin{align} R_1(n, k) \mathrel{:=} \operatorname{diag}(1, e^{i \pi k / 2^n}). \end{align} |

Random |
The random operation takes an array of doubles as input, and returns
a randomly-selected index into the array as an |

Reset |
Given a single qubit, measures it and ensure it is in the $\ket{0}$ state such that it can be safely released. |

ResetAll |
Given an array of qubits, measure them and ensure they are in the $\ket{0}$ state such that they can be safely released. |

RFrac |
Applies a rotation about the given Pauli axis by an angle specified as a dyadic fraction, \begin{align} R_{\mu}(n, k) \mathrel{:=} e^{i \pi n \sigma_{\mu} / 2^k}, \end{align} where $\mu \in {I, X, Y, Z}$. Warning This operation uses the |

Rx |
Applies a rotation about the $x$-axis by a given angle, \begin{align} R_x(\theta) \mathrel{:=} e^{-i \theta \sigma_x / 2}. \end{align} |

Ry |
Applies a rotation about the $y$-axis by a given angle, \begin{align} R_y(\theta) \mathrel{:=} e^{-i \theta \sigma_y / 2}. \end{align} |

Rz |
Applies a rotation about the $z$-axis by a given angle, \begin{align} R_z(\theta) \mathrel{:=} e^{-i \theta \sigma_z / 2}. \end{align} |

S |
Applies the $\pi / 4$ phase gate to a single qubit, \begin{align} S \mathrel{:=} \begin{bmatrix} 1 & 0 \\ 0 & i \end{bmatrix}. \end{align} |

SWAP |
Applies the SWAP gate to a pair of qubits \begin{align} \operatorname{SWAP} \mathrel{:=} \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \end{bmatrix}, \end{align} where rows and columns are ordered as in the quantum concepts guide. |

T |
Applies the $\pi / 8$ gate to a single qubit, \begin{align} T \mathrel{:=} \begin{bmatrix} 1 & 0 \\ 0 & e^{i \pi / 4} \end{bmatrix}. \end{align} |

X |
Applies the Pauli $X$ gate, \begin{align} \sigma_x \mathrel{:=} \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix}. \end{align} |

Y |
Applies the Pauli $Y$ gate, \begin{align} \sigma_y \mathrel{:=} \begin{bmatrix} 0 & -i \\ i & 0 \end{bmatrix}. \end{align} |

Z |
Applies the Pauli $Z$ gate, \begin{align} \sigma_z \mathrel{:=} \begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix}. \end{align} |

## Functions

Message |
Logs a message. |