DumpOperation operation


This documentation refers to the Classic QDK, which has been replaced by the Modern QDK.

Please see https://aka.ms/qdk.api for the API documentation for the Modern QDK.

Namespace: Microsoft.Quantum.Diagnostics

Package: Microsoft.Quantum.Standard

Given an operation, displays diagnostics about the operation that are made available by the current execution target.

operation DumpOperation (nQubits : Int, op : (Qubit[] => Unit is Adj)) : Unit is Adj + Ctl


nQubits : Int

The number of qubits on which the given operation acts.

op : Qubit[] => Unit is Adj

The operation that is to be diagnosed.

Output : Unit


When run on the quantum simulator target, the following snippet will output the matrix $$ \begin{aligned} \left(\begin{matrix} 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 \end{matrix}\right) \end{aligned}. $$

operation DumpCnot() : Unit {
    DumpOperation(2, ApplyToFirstTwoQubitsCA(CNOT, _));


Calling this operation has no observable effect from within Q#. The exact diagnostics that are displayed, if any, are dependent on the current execution target and editor environment. For example, when used on the full-state quantum simulator, a unitary matrix used to represent op is displayed.

Note that, when run on simulators that admit a global phase ambiguity (e.g.: the full-state simulator), returned representations may vary up to a global phase.

Similarly, the ordering of rows and columns matrix representations may vary with the conventions used by each simulator supporting this operation.