Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Convert a discrete quantum operator into a ZX-diagram
ResourceFunction["QuantumDiscreteOperatorToZXDiagram"][QuantumDiscreteOperator[…]] converts the specified QuantumDiscreteOperator into an equivalent ZXDiagramObject. |
| "LabeledGraph" | graph form of the ZX-diagram with phases labeled |
| "UnlabeledGraph" | graph form of the ZX-diagram without phases labeled |
| "OperatorForm" | ZX-diagram represented as a tensor product of generators |
| "ListForm" | ZX-diagram represented as a list of generators |
| "MatrixForm" | ZX-diagram represented as an explicit linear map on qubits |
| "ZSpiders" | list of Z-spiders in the ZX-diagram |
| "XSpiders" | list of X-spiders in the ZX-diagram |
| "HadamardGates" | list of Hadamard gates in the ZX-diagram |
| "Diamonds" | list of black diamonds in the ZX-diagram |
| "Wires" | list of wires in the ZX-diagram |
| "ZSpiderCount" | number of Z-spiders in the ZX-diagram |
| "XSpiderCount" | number of X-spiders in the ZX-diagram |
| "HadamardGateCount" | number of Hadamard gates in the ZX-diagram |
| "DiamondCount" | number of black diamonds in the ZX-diagram |
| "WireCount" | number of wires in the ZX-diagram |
Convert an arity-1 discrete quantum operator (a Pauli-Z gate) into a single-spider ZX-diagram:
| In[1]:= |
|
| Out[1]= |
|
| In[2]:= |
|
| Out[2]= |
|
| In[3]:= |
|
| Out[3]= |
|
Convert a different arity-1 discrete quantum operator (a Hadamard gate) into a three-spider ZX-diagram:
| In[4]:= |
|
| Out[4]= |
|
| In[5]:= |
|
| Out[5]= |
|
| In[6]:= |
|
| Out[6]= |
|
| In[7]:= |
|
| Out[7]= |
|
Convert an arity-2 discrete quantum operator (a CNOT gate) into a two-spider ZX-diagram:
| In[8]:= |
|
| Out[8]= |
|
| In[9]:= |
|
| Out[9]= |
|
| In[10]:= |
|
| Out[10]= |
|
| In[11]:= |
|
| Out[11]= |
|
Show the layered graph form of the ZX-diagram with the inputs at the top:
| In[12]:= |
|
| Out[12]= |
|
Convert a CNOT gate with an additional control qubit (i.e. an arity-3 Toffoli gate) into a three-spider ZX-diagram:
| In[13]:= |
|
| Out[13]= |
|
| In[14]:= |
|
| Out[14]= |
|
| In[15]:= |
|
| Out[15]= |
|
| In[16]:= |
|
| Out[16]= |
|
Show the layered graph form of the ZX-diagram with the inputs at the top:
| In[17]:= |
|
| Out[17]= |
|
Convert a more complicated arity-3 quantum Fourier transform operator into a 15-spider ZX-diagram:
| In[18]:= |
|
| Out[18]= |
|
| In[19]:= |
|
| Out[19]= |
|
| In[20]:= |
|
| Out[20]= |
|
| In[21]:= |
|
| Out[21]= |
|
Show the layered graph form of the ZX-diagram with the inputs at the top:
| In[22]:= |
|
| Out[22]= |
|
Convert an arity-4 inverse quantum Fourier transform operator into a 24-spider ZX-diagram:
| In[23]:= |
|
| Out[23]= |
|
| In[24]:= |
|
| Out[24]= |
|
| In[25]:= |
|
| Out[25]= |
|
Show the layered graph form of the ZX-diagram with the inputs at the top:
| In[26]:= |
|
| Out[26]= |
|
Convert an inverse quantum Fourier transform operator with two additional control qubits into a 26-spider ZX-diagram:
| In[27]:= |
|
| Out[27]= |
|
| In[28]:= |
|
| Out[28]= |
|
| In[29]:= |
|
| Out[29]= |
|
Show the layered graph form of the ZX-diagram with the inputs at the top:
| In[30]:= |
|
| Out[30]= |
|
If the specified QuantumDiscreteOperator object cannot be expressed as a ZX-diagram, QuantumDiscreteOperatorToZXDiagram will return Indeterminate:
| In[31]:= |
|
| Out[31]= |
|
| In[32]:= |
|
| Out[32]= |
|
Convert an S-gate (a π/2 phase change gate) to a ZX-diagram:
| In[33]:= |
|
| Out[33]= |
|
Convert a T-gate (a π/8 phase change gate) to a ZX-diagram:
| In[34]:= |
|
| Out[34]= |
|
Convert a CNOT gate (a controlled NOT gate) to a ZX-diagram:
| In[35]:= |
|
| Out[35]= |
|
Convert a CPHASE gate (a controlled π phase change gate) to a ZX-diagram:
| In[36]:= |
|
| Out[36]= |
|
Convert a CX gate (a controlled Pauli-X gate—equivalent to a CNOT) to a ZX-diagram:
| In[37]:= |
|
| Out[37]= |
|
Convert a CY gate (a controlled Pauli-Y gate) to a ZX-diagram:
| In[38]:= |
|
| Out[38]= |
|
Convert a CZ gate (a controlled Pauli-Z gate) to a ZX-diagram:
| In[39]:= |
|
| Out[39]= |
|
Convert a controlled-U gate (with U being a 2-by-2 Hadamard matrix) to a ZX-diagram with one control qubit:
| In[40]:= |
|
| Out[40]= |
|
Convert a controlled-U gate (with U being a 2-by-2 Hadamard matrix) to a ZX-diagram with three control qubits instead:
| In[41]:= |
|
| Out[41]= |
|
Convert a single-qubit QFT gate (quantum Fourier transform) to a ZX-diagram:
| In[42]:= |
|
| Out[42]= |
|
Convert a two-qubit QFT gate (quantum Fourier transform) to a ZX-diagram:
| In[43]:= |
|
| Out[43]= |
|
Convert a three-qubit QFT gate (quantum Fourier transform) to a ZX-diagram:
| In[44]:= |
|
| Out[44]= |
|
Convert a four-qubit QFT gate (quantum Fourier transform) to a ZX-diagram:
| In[45]:= |
|
| Out[45]= |
|
Convert a single-qubit IQFT gate (inverse quantum Fourier transform) to a ZX-diagram:
| In[46]:= |
|
| Out[46]= |
|
Convert a two-qubit IQFT gate (inverse quantum Fourier transform) to a ZX-diagram:
| In[47]:= |
|
| Out[47]= |
|
Convert a three-qubit IQFT gate (inverse quantum Fourier transform) to a ZX-diagram:
| In[48]:= |
|
| Out[48]= |
|
Convert a four-qubit IQFT gate (inverse quantum Fourier transform) to a ZX-diagram:
| In[49]:= |
|
| Out[49]= |
|
Convert a SUM gate (a half-adder for qubits—similar to a CNOT gate) to a ZX-diagram:
| In[50]:= |
|
| Out[50]= |
|
Convert a Pauli-X gate (a π rotation around the x axis of the Bloch sphere) to a ZX-diagram:
| In[51]:= |
|
| Out[51]= |
|
Convert a Pauli-Y gate (a π rotation around the y axis of the Bloch sphere) to a ZX-diagram:
| In[52]:= |
|
| Out[52]= |
|
Convert a Pauli-Z gate (a π rotation around the z axis of the Bloch sphere) to a ZX-diagram:
| In[53]:= |
|
| Out[53]= |
|
Convert the square root of a NOT gate (half a Pauli-X rotation) to a ZX-diagram:
| In[54]:= |
|
| Out[54]= |
|
Convert a Toffoli gate (a π/2 Deutsch gate) to a ZX-diagram:
| In[55]:= |
|
| Out[55]= |
|
This work is licensed under a Creative Commons Attribution 4.0 International License