55 extension : .md
66 format_name : markdown
77 format_version : ' 1.3'
8- jupytext_version : 1.13.8
8+ jupytext_version : 1.16.4
99 kernelspec :
1010 display_name : Python 3 (ipykernel)
1111 language : python
@@ -63,7 +63,7 @@ cphase(pi / 2)
6363``` python
6464q = QubitCircuit(2 , reverse_states = False )
6565q.add_gate(" CSIGN" , controls = [0 ], targets = [1 ])
66- q.png
66+ q.draw()
6767```
6868
6969### Rotation about X-axis
@@ -74,8 +74,8 @@ rx(pi / 2)
7474
7575``` python
7676q = QubitCircuit(1 , reverse_states = False )
77- q.add_gate(" RX" , targets = [0 ], arg_value = pi / 2 , arg_label = r " \f rac{ \p i} {2} " )
78- q.png
77+ q.add_gate(" RX" , targets = [0 ], arg_value = pi / 2 , style = { " showarg " : True } )
78+ q.draw()
7979```
8080
8181### Rotation about Y-axis
@@ -86,8 +86,8 @@ ry(pi / 2)
8686
8787``` python
8888q = QubitCircuit(1 , reverse_states = False )
89- q.add_gate(" RY" , targets = [0 ], arg_value = pi / 2 , arg_label = r " \f rac{ \p i} {2} " )
90- q.png
89+ q.add_gate(" RY" , targets = [0 ], arg_value = pi / 2 , style = { " showarg " : True } )
90+ q.draw()
9191```
9292
9393### Rotation about Z-axis
@@ -98,8 +98,8 @@ rz(pi / 2)
9898
9999``` python
100100q = QubitCircuit(1 , reverse_states = False )
101- q.add_gate(" RZ" , targets = [0 ], arg_value = pi / 2 , arg_label = r " \f rac{ \p i} {2} " )
102- q.png
101+ q.add_gate(" RZ" , targets = [0 ], arg_value = pi / 2 , style = { " showarg " : True } )
102+ q.draw()
103103```
104104
105105### CNOT
@@ -111,7 +111,7 @@ cnot()
111111``` python
112112q = QubitCircuit(2 , reverse_states = False )
113113q.add_gate(" CNOT" , controls = [0 ], targets = [1 ])
114- q.png
114+ q.draw()
115115```
116116
117117### CSIGN
@@ -123,7 +123,7 @@ csign()
123123``` python
124124q = QubitCircuit(2 , reverse_states = False )
125125q.add_gate(" CSIGN" , controls = [0 ], targets = [1 ])
126- q.png
126+ q.draw()
127127```
128128
129129### Berkeley
@@ -135,7 +135,7 @@ berkeley()
135135``` python
136136q = QubitCircuit(2 , reverse_states = False )
137137q.add_gate(" BERKELEY" , targets = [0 , 1 ])
138- q.png
138+ q.draw()
139139```
140140
141141### SWAPalpha
@@ -162,7 +162,7 @@ toffoli()
162162swap()
163163q = QubitCircuit(2 , reverse_states = False )
164164q.add_gate(" SWAP" , targets = [0 , 1 ])
165- q.png
165+ q.draw()
166166```
167167
168168### ISWAP
@@ -171,7 +171,7 @@ q.png
171171iswap()
172172q = QubitCircuit(2 , reverse_states = False )
173173q.add_gate(" ISWAP" , targets = [0 , 1 ])
174- q.png
174+ q.draw()
175175```
176176
177177### SQRTiSWAP
@@ -234,7 +234,7 @@ cnot(N=3)
234234``` python
235235q = QubitCircuit(3 , reverse_states = False )
236236q.add_gate(" CNOT" , controls = [1 ], targets = [2 ])
237- q.png
237+ q.draw()
238238```
239239
240240Furthermore, the control and target qubits (when applicable) can also be similarly specified using keyword arguments ` control ` and ` target ` (or in some cases ` controls ` or ` targets ` ):
@@ -246,7 +246,7 @@ cnot(N=3, control=2, target=0)
246246``` python
247247q = QubitCircuit(3 , reverse_states = False )
248248q.add_gate(" CNOT" , controls = [0 ], targets = [2 ])
249- q.png
249+ q.draw()
250250```
251251
252252## Setup of a Qubit Circuit
@@ -261,7 +261,7 @@ In the following example, we take a SWAP gate. It is known that a swap gate is e
261261N = 2
262262qc0 = QubitCircuit(N)
263263qc0.add_gate(" ISWAP" , [0 , 1 ], None )
264- qc0.png
264+ qc0.draw()
265265```
266266
267267``` python
@@ -275,7 +275,7 @@ qc1 = QubitCircuit(N)
275275qc1.add_gate(" CNOT" , 0 , 1 )
276276qc1.add_gate(" CNOT" , 1 , 0 )
277277qc1.add_gate(" CNOT" , 0 , 1 )
278- qc1.png
278+ qc1.draw()
279279```
280280
281281``` python
@@ -288,7 +288,7 @@ In place of manually converting the SWAP gate to CNOTs, it can be automatically
288288
289289``` python
290290qc2 = qc0.resolve_gates(" CNOT" )
291- qc2.png
291+ qc2.draw()
292292```
293293
294294``` python
@@ -301,7 +301,7 @@ From QuTiP 4.4, we can also add gate at arbitrary position in a circuit.
301301
302302``` python
303303qc1.add_gate(" CSIGN" , index = [1 ], targets = [0 ], controls = [1 ])
304- qc1.png
304+ qc1.draw()
305305```
306306
307307## Example of basis transformation
@@ -313,7 +313,7 @@ qc3.add_gate("RX", 0, None, pi / 2, r"\pi/2")
313313qc3.add_gate(" RY" , 1 , None , pi / 2 , r " \p i/2" )
314314qc3.add_gate(" RZ" , 2 , None , pi / 2 , r " \p i/2" )
315315qc3.add_gate(" ISWAP" , [1 , 2 ])
316- qc3.png
316+ qc3.draw()
317317```
318318
319319``` python
325325
326326``` python
327327qc4 = qc3.resolve_gates(" CNOT" )
328- qc4.png
328+ qc4.draw()
329329```
330330
331331``` python
335335
336336``` python
337337qc5 = qc3.resolve_gates(" ISWAP" )
338- qc5.png
338+ qc5.draw()
339339```
340340
341341``` python
347347
348348``` python
349349qc6 = qc3.resolve_gates([" ISWAP" , " RX" , " RY" ])
350- qc6.png
350+ qc6.draw()
351351```
352352
353353``` python
357357
358358``` python
359359qc7 = qc3.resolve_gates([" CNOT" , " RZ" , " RX" ])
360- qc7.png
360+ qc7.draw()
361361```
362362
363363``` python
@@ -373,7 +373,7 @@ Interactions between non-adjacent qubits can be resolved by QubitCircuit to a se
373373``` python
374374qc8 = QubitCircuit(3 )
375375qc8.add_gate(" CNOT" , 2 , 0 )
376- qc8.png
376+ qc8.draw()
377377```
378378
379379``` python
393393
394394``` python
395395qc10 = qc9.resolve_gates(" CNOT" )
396- qc10.png
396+ qc10.draw()
397397```
398398
399399``` python
@@ -418,7 +418,7 @@ From QuTiP 4.4 on, user defined gates can be defined by a python function that t
418418``` python
419419def user_gate1 (arg_value ):
420420 # controlled rotation X
421- mat = np.zeros((4 , 4 ), dtype = np. complex)
421+ mat = np.zeros((4 , 4 ), dtype = complex )
422422 mat[0 , 0 ] = mat[1 , 1 ] = 1.0
423423 mat[2 :4 , 2 :4 ] = rx(arg_value)
424424 return Qobj(mat, dims = [[2 , 2 ], [2 , 2 ]])
0 commit comments