Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Make a diagrammatic representation of a linear map in the ZX-calculus
ResourceFunction["MakeZXDiagram"][gen] makes a ZX-diagram using the list of generators gen. |
|
ResourceFunction["MakeZXDiagram"][assoc] makes a ZX-diagram using the association of generators assoc. |
Z [ name , in , out , phase ] | a Z-spider with name name, input arity in, output arity out and phase phase |
X [ name , in , out , phase ] | an X-spider with name name, input arity in, output arity out and phase phase |
H [ name ] | a Hadamard gate with name name |
B[name] | a black diamond with name name |
W [ name 1 , name 2 ] | a wire connecting generators name1 and name2 |
"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 |
Construct an elementary ZX-diagram corresponding to a simple unitary map:
In[1]:= |
![]() |
Out[1]= |
![]() |
Show the labeled graph:
In[2]:= |
![]() |
Out[2]= |
![]() |
Show its operator form:
In[3]:= |
![]() |
Out[3]= |
![]() |
Show its matrix form:
In[4]:= |
![]() |
Out[4]= |
![]() |
Construct a ZX-diagram from an association:
In[5]:= |
![]() |
Out[5]= |
![]() |
Show the unlabeled graph:
In[6]:= |
![]() |
Out[6]= |
![]() |
Show its operator form:
In[7]:= |
![]() |
Out[7]= |
![]() |
Show its matrix form:
In[8]:= |
![]() |
Out[8]= |
![]() |
Construct a more complicated ZX-diagram involving tensor products, Hadamard gates and diamonds:
In[9]:= |
![]() |
Out[9]= |
![]() |
Show the unlabeled graph:
In[10]:= |
![]() |
Out[10]= |
![]() |
Show its operator form:
In[11]:= |
![]() |
Out[11]= |
![]() |
Show its matrix form:
In[12]:= |
![]() |
Out[12]= |
![]() |
All of the standard generators of the ZX-calculus are supported (for both the computational and Hadamard-transformed bases), including states:
In[13]:= |
![]() |
Out[13]= |
![]() |
In[14]:= |
![]() |
Out[14]= |
![]() |
In[15]:= |
![]() |
Out[15]= |
![]() |
In[16]:= |
![]() |
Out[16]= |
![]() |
In[17]:= |
![]() |
Out[17]= |
![]() |
In[18]:= |
![]() |
Out[18]= |
![]() |
Unitary maps:
In[19]:= |
![]() |
Out[19]= |
![]() |
In[20]:= |
![]() |
Out[20]= |
![]() |
In[21]:= |
![]() |
Out[21]= |
![]() |
In[22]:= |
![]() |
Out[22]= |
![]() |
In[23]:= |
![]() |
Out[23]= |
![]() |
In[24]:= |
![]() |
Out[24]= |
![]() |
Linear isometries:
In[25]:= |
![]() |
Out[25]= |
![]() |
In[26]:= |
![]() |
Out[26]= |
![]() |
In[27]:= |
![]() |
Out[27]= |
![]() |
In[28]:= |
![]() |
Out[28]= |
![]() |
In[29]:= |
![]() |
Out[29]= |
![]() |
In[30]:= |
![]() |
Out[30]= |
![]() |
Partial linear isometries:
In[31]:= |
![]() |
Out[31]= |
![]() |
In[32]:= |
![]() |
Out[32]= |
![]() |
In[33]:= |
![]() |
Out[33]= |
![]() |
In[34]:= |
![]() |
Out[34]= |
![]() |
In[35]:= |
![]() |
Out[35]= |
![]() |
In[36]:= |
![]() |
Out[36]= |
![]() |
Projections (i.e. projective measurements):
In[37]:= |
![]() |
Out[37]= |
![]() |
In[38]:= |
![]() |
Out[38]= |
![]() |
In[39]:= |
![]() |
Out[39]= |
![]() |
In[40]:= |
![]() |
Out[40]= |
![]() |
In[41]:= |
![]() |
Out[41]= |
![]() |
In[42]:= |
![]() |
Out[42]= |
![]() |
Hadamard gates:
In[43]:= |
![]() |
Out[43]= |
![]() |
In[44]:= |
![]() |
Out[44]= |
![]() |
In[45]:= |
![]() |
Out[45]= |
![]() |
Black diamonds (i.e. scalar factors):
In[46]:= |
![]() |
Out[46]= |
![]() |
In[47]:= |
![]() |
Out[47]= |
![]() |
Properties supported by ZXDiagramObject include labeled graphs:
In[48]:= |
![]() |
Out[48]= |
![]() |
In[49]:= |
![]() |
Out[49]= |
![]() |
Unlabeled graphs:
In[50]:= |
![]() |
Out[50]= |
![]() |
Operator forms:
In[51]:= |
![]() |
Out[51]= |
![]() |
List forms:
In[52]:= |
![]() |
Out[52]= |
![]() |
Matrix forms:
In[53]:= |
![]() |
Out[53]= |
![]() |
Z-spider lists:
In[54]:= |
![]() |
Out[54]= |
![]() |
X-spider lists:
In[55]:= |
![]() |
Out[55]= |
![]() |
Hadamard gate lists:
In[56]:= |
![]() |
Out[56]= |
![]() |
Black diamond lists:
In[57]:= |
![]() |
Out[57]= |
![]() |
Wire lists:
In[58]:= |
![]() |
Out[58]= |
![]() |
This work is licensed under a Creative Commons Attribution 4.0 International License