# Microsoft.Quantum.Canon namespace

This namespace contains a variety of useful operations and functions.

## Description

To learn more about the operations in this namespace, see Higher-Order Control Flow and Quantum Fourier Transform.

## Operations

Name | Summary |
---|---|

AndLadder | Performs a controlled "AND ladder" on a register of target qubits. |

ApplyAnd | Inverts a given target qubit if and only if both control qubits are in the 1 state, using measurement to perform the adjoint operation. |

ApplyCCNOTChain | Implements a cascade of CCNOT gates controlled on corresponding bits of two qubit registers, acting on the next qubit of one of the registers. Starting from the qubits at position 0 in both registers as controls, CCNOT is applied to the qubit at position 1 of the target register, then controlled by the qubits at position 1 acting on the qubit at position 2 in the target register, etc., ending with an action on the target qubit in position `Length(nQubits)-1` . |

ApplyCNOTChain | Computes the parity of a register of qubits in-place. |

ApplyCNOTChainWithTarget | Computes the parity of an array of qubits into a target qubit. |

ApplyControlledOnBitString | Applies a unitary operation on the target register, controlled on a a state specified by a given bit mask. |

ApplyControlledOnInt | Applies a unitary operation on the target register if the control register state corresponds to a specified nonnegative integer. |

ApplyDiagonalUnitary | Applies an array of complex phases to numeric basis states of a register of qubits. |

ApplyFermionicSWAP | Applies the Fermionic SWAP. |

ApplyIf | Applies an operation conditioned on a classical bit. |

ApplyIfA | Applies a adjointable operation conditioned on a classical bit. |

ApplyIfC | Applies a controllable operation conditioned on a classical bit. |

ApplyIfCA | Applies a unitary operation conditioned on a classical bit. |

ApplyIfElseB | Applies one of two operations, depending on the value of a classical bit. |

ApplyIfElseBA | Applies one of two adjointable operations, depending on the value of a classical bit. |

ApplyIfElseBC | Applies one of two controllable operations, depending on the value of a classical bit. |

ApplyIfElseBCA | Applies one of two unitary operations, depending on the value of a classical bit. |

ApplyIfElseR | Applies one of two operations, depending on the value of a classical result. |

ApplyIfElseRA | Applies one of two adjointable operations, depending on the value of a classical result. |

ApplyIfElseRC | Applies one of two controllable operations, depending on the value of a classical result. |

ApplyIfElseRCA | Applies one of two unitary operations, depending on the value of a classical result. |

ApplyIfOne | Applies an operation conditioned on a classical result value being one. |

ApplyIfOneA | Applies an adjointable operation conditioned on a classical result value being one. |

ApplyIfOneC | Applies a controllable operation conditioned on a classical result value being one. |

ApplyIfOneCA | Applies a unitary operation conditioned on a classical result value being one. |

ApplyIfZero | Applies an operation conditioned on a classical result value being zero. |

ApplyIfZeroA | Applies an adjointable operation conditioned on a classical result value being zero. |

ApplyIfZeroC | Applies a controllable operation conditioned on a classical result value being zero. |

ApplyIfZeroCA | Applies a unitary operation conditioned on a classical result value being zero. |

ApplyLowDepthAnd | Inverts a given target qubit if and only if both control qubits are in the 1 state, with T-depth 1, using measurement to perform the adjoint operation. |

ApplyMultiControlledC | Applies a multiply controlled version of a singly controlled operation. The modifier `C` indicates that the single-qubit operation is controllable. |

ApplyMultiControlledCA | Applies a multiply controlled version of a singly controlled operation. The modifier `CA` indicates that the single-qubit operation is controllable and adjointable. |

ApplyOpRepeatedlyOver | Applies the same op over a qubit register multiple times. |

ApplyOpRepeatedlyOverA | Applies the same op over a qubit register multiple times. |

ApplyOpRepeatedlyOverC | Applies the same op over a qubit register multiple times. |

ApplyOpRepeatedlyOverCA | Applies the same op over a qubit register multiple times. |

ApplyP | Given a single-qubit Pauli operator, applies the corresponding operation to a single qubit. |

ApplyPauli | Given a multi-qubit Pauli operator, applies the corresponding operation to a register. |

ApplyPauliFromBitString | Applies a Pauli operator on each qubit in an array if the corresponding bit of a Boolean array matches a given input. |

ApplyQuantumFourierTransform | Performs the Quantum Fourier Transform on a quantum register containing an integer in the little-endian representation. |

ApplyReversedOpBigEndianA | > [!WARNING] |

ApplyReversedOpBigEndianC | > [!WARNING] |

ApplyReversedOpBigEndianCA | > [!WARNING] |

ApplyReversedOpLittleEndianA | > [!WARNING] |

ApplyReversedOpLittleEndianC | > [!WARNING] |

ApplyReversedOpLittleEndianCA | > [!WARNING] |

ApplyRippleCarryComparatorLE | > [!WARNING] |

ApplySeriesOfOps | Applies a list of ops and their targets sequentially on an array. |

ApplySeriesOfOpsA | Applies a list of ops and their targets sequentially on an array. (Adjoint) |

ApplySeriesOfOpsC | Applies a list of ops and their targets sequentially on an array. (Controlled) |

ApplySeriesOfOpsCA | Applies a list of ops and their targets sequentially on an array. (Adjoint + Controlled) |

ApplyToEach | Applies a single-qubit operation to each element in a register. |

ApplyToEachA | Applies a single-qubit operation to each element in a register. The modifier `A` indicates that the single-qubit operation is adjointable. |

ApplyToEachC | Applies a single-qubit operation to each element in a register. The modifier `C` indicates that the single-qubit operation is controllable. |

ApplyToEachCA | Applies a single-qubit operation to each element in a register. The modifier `CA` indicates that the single-qubit operation is controllable and adjointable. |

ApplyToEachIndex | Applies a single-qubit operation to each indexed element in a register. |

ApplyToEachIndexA | Applies a single-qubit operation to each indexed element in a register. The modifier `A` indicates that the single-qubit operation is adjointable. |

ApplyToEachIndexC | Applies a single-qubit operation to each indexed element in a register. The modifier `C` indicates that the single-qubit operation is controllable. |

ApplyToEachIndexCA | Applies a single-qubit operation to each indexed element in a register. The modifier `CA` indicates that the single-qubit operation is adjointable and controllable. |

ApplyToElement | Applies an operation to a given element of an array. |

ApplyToElementA | Applies an operation to a given element of an array. |

ApplyToElementC | Applies an operation to a given element of an array. |

ApplyToElementCA | Applies an operation to a given element of an array. |

ApplyToFirstQubit | Applies an operation to the first qubit in the register. |

ApplyToFirstQubitA | Applies an operation to the first qubit in the register. The modifier `A` indicates that the operation is adjointable. |

ApplyToFirstQubitC | Applies operation op to the first qubit in the register. The modifier `C` indicates that the operation is controllable. |

ApplyToFirstQubitCA | Applies operation op to the first qubit in the register. The modifier `CA` indicates that the operation is controllable and adjointable. |

ApplyToFirstThreeQubits | Applies an operation to the first three qubits in the register. |

ApplyToFirstThreeQubitsA | Applies an operation to the first three qubits in the register. The modifier `A` indicates that the operation is adjointable. |

ApplyToFirstThreeQubitsC | Applies an operation to the first three qubits in the register. The modifier `C` indicates that the operation is controllable. |

ApplyToFirstThreeQubitsCA | Applies an operation to the first three qubits in the register. The modifier `CA` indicates that the operation is controllable and adjointable. |

ApplyToFirstTwoQubits | Applies an operation to the first two qubits in the register. |

ApplyToFirstTwoQubitsA | Applies an operation to the first two qubits in the register. The modifier `A` indicates that the operation is adjointable. |

ApplyToFirstTwoQubitsC | Applies an operation to the first two qubits in the register. The modifier `C` indicates that the operation is controllable. |

ApplyToFirstTwoQubitsCA | Applies an operation to the first two qubits in the register. The modifier `CA` indicates that the operation is controllable and adjointable. |

ApplyToHead | Applies an operation to the first element of an array. |

ApplyToHeadA | Applies an operation to the first element of an array. |

ApplyToHeadC | Applies an operation to the first element of an array. |

ApplyToHeadCA | Applies an operation to the first element of an array. |

ApplyToMost | Applies an operation to all but the last element of an array. |

ApplyToMostA | Applies an operation to all but the last element of an array. |

ApplyToMostC | Applies an operation to all but the last element of an array. |

ApplyToMostCA | Applies an operation to all but the last element of an array. |

ApplyToPartition | Applies a pair of operations to a given partition of a register into two parts. |

ApplyToPartitionA | Applies a pair of operations to a given partition of a register into two parts. The modifier `A` indicates that the operation is adjointable. |

ApplyToPartitionC | Applies a pair of operations to a given partition of a register into two parts. The modifier `C` indicates that the operation is controllable. |

ApplyToPartitionCA | Applies a pair of operations to a given partition of a register into two parts. The modifier `CA` indicates that the operation is controllable and adjointable. |

ApplyToRest | Applies an operation to all but the first element of an array. |

ApplyToRestA | Applies an operation to all but the first element of an array. |

ApplyToRestC | Applies an operation to all but the first element of an array. |

ApplyToRestCA | Applies an operation to all but the first element of an array. |

ApplyToSubregister | Applies an operation to a subregister of a register, with qubits specified by an array of their indices. |

ApplyToSubregisterA | Applies an operation to a subregister of a register, with qubits specified by an array of their indices. The modifier `A` indicates that the operation is adjointable. |

ApplyToSubregisterC | Applies an operation to a subregister of a register, with qubits specified by an array of their indices. The modifier `C` indicates that the operation is controllable. |

ApplyToSubregisterCA | Applies an operation to a subregister of a register, with qubits specified by an array of their indices. The modifier `CA` indicates that the operation is controllable and adjointable. |

ApplyToTail | Applies an operation to the last element of an array. |

ApplyToTailA | Applies an operation to the last element of an array. |

ApplyToTailC | Applies an operation to the last element of an array. |

ApplyToTailCA | Applies an operation to the last element of an array. |

ApplyWith | Given two operations, applies one as conjugated with the other. |

ApplyWithA | Given two operations, applies one as conjugated with the other. |

ApplyWithC | Given two operations, applies one as conjugated with the other. |

ApplyWithCA | Given two operations, applies one as conjugated with the other. |

ApplyWithInputTransformation | Given an operation that accepts some input, a function that returns an output compatible with that operation, and an input to that function, applies the operation using the function to transform the input to a form expected by the operation. |

ApplyWithInputTransformationA | Given an operation that accepts some input, a function that returns an output compatible with that operation, and an input to that function, applies the operation using the function to transform the input to a form expected by the operation. |

ApplyWithInputTransformationC | Given an operation that accepts some input, a function that returns an output compatible with that operation, and an input to that function, applies the operation using the function to transform the input to a form expected by the operation. |

ApplyWithInputTransformationCA | |

ApproximateQFT | Apply the Approximate Quantum Fourier Transform (AQFT) to a quantum register. |

ApproximatelyApplyDiagonalUnitary | Applies an array of complex phases to numeric basis states of a register of qubits, truncating small rotation angles according to a given tolerance. |

ApproximatelyMultiplexPauli | Applies a Pauli rotation conditioned on an array of qubits, truncating small rotation angles according to a given tolerance. |

ApproximatelyMultiplexZ | Applies a Pauli Z rotation conditioned on an array of qubits, truncating small rotation angles according to a given tolerance. |

AssertHighestBit | > [!WARNING] |

AssertLessThanPhaseLE | > [!WARNING] |

AssertPhase | > [!WARNING] |

CNOTChain | > [!WARNING] |

CNOTChainTarget | > [!WARNING] |

CX | Applies the controlled-X (CX) gate to a pair of qubits. |

CY | Applies the controlled-Y (CY) gate to a pair of qubits. |

CZ | Applies the controlled-Z (CZ) gate to a pair of qubits. |

CascadeCCNOT | > [!WARNING] |

CascadeCNOT | > [!WARNING] |

Delay | Applies a given operation with a delay. |

DelayA | Applies a given operation with a delay. |

DelayC | Applies a given operation with a delay. |

DelayCA | Applies a given operation with a delay. |

HY | Applies the Y-basis analog to the Hadamard transformation that interchanges the Z and Y axes. |

InPlaceMajority | > [!WARNING] |

InPlaceXorBE | > [!WARNING] |

InPlaceXorLE | > [!WARNING] |

IntegerIncrementLE | > [!WARNING] |

IntegerIncrementPhaseLE | > [!WARNING] |

IterateThroughCartesianPower | Applies an operation for each index in the Cartesian power of an integer range. |

IterateThroughCartesianProduct | Applies an operation for each index in the Cartesian product of several ranges. |

ModularAddProductLE | > [!WARNING] |

ModularAddProductPhaseLE | > [!WARNING] |

ModularIncrementLE | > [!WARNING] |

ModularIncrementPhaseLE | > [!WARNING] |

ModularMultiplyByConstantLE | > [!WARNING] |

MultiplexOperations | Applies an array of operations controlled by an array of number states. |

MultiplexOperationsBruteForceFromGenerator | Applies multiply-controlled unitary operation $U$ that applies a unitary $V_j$ when controlled by n-qubit number state $\ket{j}$. |

MultiplexOperationsFromGenerator | Applies a multiply-controlled unitary operation $U$ that applies a unitary $V_j$ when controlled by n-qubit number state $\ket{j}$. |

MultiplexPauli | Applies a Pauli rotation conditioned on an array of qubits. |

MultiplexZ | Applies a Pauli Z rotation conditioned on an array of qubits. |

NoOp | Performs the identity operation (no-op) on an argument. |

PermuteQubits | Permutes qubits by using the SWAP operation. |

QFT | Performs the Quantum Fourier Transform on a quantum register containing an integer in the big-endian representation. |

QFTLE | Performs the Quantum Fourier Transform on a quantum register containing an integer in the little-endian representation. |

RAll0 | Rotates the all-zeros state by a given phase. |

RAll1 | Rotates the all-ones state by a given phase. |

Repeat | Repeats an operation a given number of times. |

RepeatA | Repeats an operation a given number of times. |

RepeatC | Repeats an operation a given number of times. |

RepeatCA | Repeats an operation a given number of times. |

SwapReverseRegister | Uses SWAP gates to Reversed the order of the qubits in a register. |

## Functions

Name | Summary |
---|---|

BigEndianToLittleEndian | > [!WARNING] |

Bound | Given an array of operations acting on a single input, produces a new operation that performs each given operation in sequence. |

BoundA | Given an array of operations acting on a single input, produces a new operation that performs each given operation in sequence. The modifier `A` indicates that all operations in the array are adjointable. |

BoundC | Given an array of operations acting on a single input, produces a new operation that performs each given operation in sequence. The modifier `C` indicates that all operations in the array are controllable. |

BoundCA | Given an array of operations acting on a single input, produces a new operation that performs each given operation in sequence. The modifier `CA` indicates that all operations in the array are adjointable and controllable. |

CControlled | Given an operation op, returns a new operation which applies the op if a classical control bit is true. If `false` , nothing happens. |

CControlledA | Given an operation op, returns a new operation which applies the op if a classical control bit is true. If `false` , nothing happens. The modifier `A` indicates that the operation is adjointable. |

CControlledC | Given an operation op, returns a new operation which applies the op if a classical control bit is true. If `false` , nothing happens. The modifier `C` indicates that the operation is controllable. |

CControlledCA | Given an operation op, returns a new operation which applies the op if a classical control bit is true. If `false` , nothing happens. The modifier `CA` indicates that the operation is controllable and adjointable. |

Compose | Returns the composition of two functions. |

ConjugatedBy | Given outer and inner operations, returns a new operation that conjugates the inner operation by the outer operation. |

ConjugatedByA | Given outer and inner operations, returns a new operation that conjugates the inner operation by the outer operation. |

ConjugatedByC | Given outer and inner operations, returns a new operation that conjugates the inner operation by the outer operation. |

ConjugatedByCA | |

ControlledOnBitString | Returns a unitary operation that applies an oracle on the target register if the control register state corresponds to a specified bit mask. |

ControlledOnInt | Returns a unitary operator that applies an oracle on the target register if the control register state corresponds to a specified nonnegative integer. |

CurriedOp | Returns a curried version of an operation on two inputs. |

CurriedOpA | Returns a curried version of an operation on two inputs. |

CurriedOpC | Returns a curried version of an operation on two inputs. |

CurriedOpCA | Returns a curried version of an operation on two inputs. |

DecomposeIntoTimeStepsCA | > [!WARNING] |

DecomposedIntoTimeStepsCA | Returns an operation implementing the Trotterâ€“Suzuki integrator for a given operation. |

Delayed | Returns an operation that applies given operation with given argument. |

DelayedA | Returns an operation that applies given operation with given argument. |

DelayedC | Returns an operation that applies given operation with given argument. |

DelayedCA | Returns an operation that applies given operation with given argument. |

EmbedPauli | Given a single-qubit Pauli operator and the index of a qubit, returns a multi-qubit Pauli operator with the given single-qubit operator at that index and `PauliI` at every other index. |

Fst | Given a pair, returns its first element. |

Ignore | Ignores the output of an operation or function. |

IsRangeEmpty | Returns true if and only if input range is empty. |

IsResultOne | Tests if a given Result value is equal to `One` . |

IsResultZero | Tests if a given Result value is equal to `Zero` . |

LittleEndianToBigEndian | > [!WARNING] |

MultiplexerBruteForceFromGenerator | Returns a multiply-controlled unitary operation $U$ that applies a unitary $V_j$ when controlled by n-qubit number state $\ket{j}$. |

MultiplexerFromGenerator | Returns a multiply-controlled unitary operation $U$ that applies a unitary $V_j$ when controlled by n-qubit number state $\ket{j}$. |

OperationPow | Raises an operation to a power. |

OperationPowA | Raises an operation to a power. The modifier `A` indicates that the operation is adjointable. |

OperationPowC | Raises an operation to a power. The modifier `C` indicates that the operation is controllable. |

OperationPowCA | Raises an operation to a power. The modifier `A` indicates that the operation is controllable and adjointable. |

RestrictedToSubregister | Restricts an operation to an array of indices of a register, i.e., a subregister. |

RestrictedToSubregisterA | Restricts an operation to an array of indices of a register, i.e., a subregister. The modifier `A` indicates that the operation is adjointable. |

RestrictedToSubregisterC | Restricts an operation to an array of indices of a register, i.e., a subregister. The modifier `C` indicates that the operation is controllable. |

RestrictedToSubregisterCA | Restricts an operation to an array of indices of a register, i.e., a subregister. The modifier `CA` indicates that the operation is controllable and adjointable. |

SinglyControlled | Given a controllable operation, returns a controlled version of that operation accepting exactly one control qubit. |

SinglyControlledA | Given a controllable operation, returns a controlled version of that operation accepting exactly one control qubit. |

Snd | Given a pair, returns its second element. |

TransformedOperation | Given a function and an operation, returns a new operation whose input is transformed by the given function. |

TransformedOperationA | Given a function and an operation, returns a new operation whose input is transformed by the given function. |

TransformedOperationC | Given a function and an operation, returns a new operation whose input is transformed by the given function. |

TransformedOperationCA | |

UncurriedOp | Given a function which returns operations, returns a new operation which takes both inputs as a tuple. |

UncurriedOpA | Given a function which returns operations, returns a new operation which takes both inputs as a tuple. The modifier `A` indicates that the operations are adjointable. |

UncurriedOpC | Given a function which returns operations, returns a new operation which takes both inputs as a tuple. The modifier `C` indicates that the operations are controllable. |

UncurriedOpCA | Given a function which returns operations, returns a new operation which takes both inputs as a tuple. The modifier `CA` indicates that the operations are controllable and adjointable. |

WeightOnePaulis | Returns an array of all weight-1 Pauli operators on a given number of qubits. |

XOR | > [!WARNING] |

## User-defined types

Name | Summary |
---|---|

CCNOTop | The signature type of CCNOT gate. |

## Feedback

Submit and view feedback for