renom_q.gate

renom_q.gate.measure

renom_q.gate.measure. measure ( self , *args )

Measure the quantum state of the qubits.

args:
* args (renom_q.QuantumRegister and renom_q.ClassicalRegister, tuple and tuple or None):
If arg type is tuple and tuple (ex: q[0], c[0]), measured a quantum register No.0 into a classical register No.0. If arg type is a renom_q.QuantumRegister and a renom_q.ClassicalRegister, measured all quantum registers in renom_q.QuantumRegister into all classical registers in renom_q.ClassicalRegister. If arg is None, measured all of multiple quantum registers into all classical registers in renom_q.ClassicalRegister. Only when definited single classical register, coding like example1 is possible.
Example 1:
>>> import renom_q
>>> q = renom_q.QuantumRegister(2)
>>> c = renom_q.ClassicalRegister(2)
>>> qc = renom_q.QuantumCircuit(q, c)
>>> qc.h(q[0])
>>> qc.measure()
Example 2:
>>> import renom_q
>>> q = renom_q.QuantumRegister(2)
>>> c = renom_q.ClassicalRegister(2)
>>> qc = renom_q.QuantumCircuit(q, c)
>>> qc.h(q[0])
>>> qc.measure(q, c)
Example 3:
>>> import renom_q
>>> q = renom_q.QuantumRegister(2)
>>> c = renom_q.ClassicalRegister(2)
>>> qc = renom_q.QuantumCircuit(q, c)
>>> qc.h(q[0])
>>> for i in range(2):
...     qc.measure(q[i], c[i])

renom_q.gate.barrier

renom_q.gate.barrier. barrier ( self , *args )

Add a barrier block in circuit diagram.

args:
* args (renom_q.QuantumRegister, tuple or None):
If arg type is a tuple (ex: q[0]), a quantum register No.0 is added a barrier block. If arg type is a renom_q.QuantumRegister, all quantum registers in renom_q.QuantumRegister are added a barrier block. If arg type is None, all of multiple quantum registers are added a barrier block.
Example:
>>> import renom_q
>>> q = renom_q.QuantumRegister(2)
>>> c = renom_q.ClassicalRegister(2)
>>> qc = renom_q.QuantumCircuit(q, c)
>>> qc.barrier()

renom_q.gate.gate_base1

renom_q.gate.gate_base1. gate_base1 ( self , gate_matrix , num , gatemark )

renom_q.gate.reset

renom_q.gate.reset. reset ( self )

Apply reset gate to quantum register.

Thie gate is available only when resetting all quantum register.

Example:
>>> import renom_q
>>> q = renom_q.QuantumRegister(1)
>>> c = renom_q.ClassicalRegister(1)
>>> qc = renom_q.QuantumCircuit(q, c)
>>> qc.reset()

renom_q.gate.id

renom_q.gate.id. id ( self , q_num )

Apply id gate to quantum register.

Args:
q_num (tuple):
A tuple of a quantum register and its index (ex:q[0]).
Example:
>>> import renom_q
>>> q = renom_q.QuantumRegister(1)
>>> c = renom_q.ClassicalRegister(1)
>>> qc = renom_q.QuantumCircuit(q, c)
>>> qc.id(q[0])

renom_q.gate.x

renom_q.gate.x. x ( self , q_num )

Apply x gate to quantum register.

Args:
q_num (tuple):
A tuple of a quantum register and its index (ex:q[0]).
Example:
>>> import renom_q
>>> q = renom_q.QuantumRegister(1)
>>> c = renom_q.ClassicalRegister(1)
>>> qc = renom_q.QuantumCircuit(q, c)
>>> qc.x(q[0])

renom_q.gate.y

renom_q.gate.y. y ( self , q_num )

Apply y gate to quantum register.

Args:
q_num (tuple):
A tuple of a quantum register and its index (ex:q[0]).
Example:
>>> import renom_q
>>> q = renom_q.QuantumRegister(1)
>>> c = renom_q.ClassicalRegister(1)
>>> qc = renom_q.QuantumCircuit(q, c)
>>> qc.y(q[0])

renom_q.gate.z

renom_q.gate.z. z ( self , q_num )

Apply z gate to quantum register.

Args:
q_num (tuple):
A tuple of a quantum register and its index (ex:q[0]).
Example:
>>> import renom_q
>>> q = renom_q.QuantumRegister(1)
>>> c = renom_q.ClassicalRegister(1)
>>> qc = renom_q.QuantumCircuit(q, c)
>>> qc.z(q[0])

renom_q.gate.h

renom_q.gate.h. h ( self , q_num )

Apply h gate to quantum register.

Args:
q_num (tuple):
A tuple of a quantum register and its index (ex:q[0]).
Example:
>>> import renom_q
>>> q = renom_q.QuantumRegister(1)
>>> c = renom_q.ClassicalRegister(1)
>>> qc = renom_q.QuantumCircuit(q, c)
>>> qc.h(q[0])

renom_q.gate.s

renom_q.gate.s. s ( self , q_num )

Apply s gate to quantum register.

Args:
q_num (tuple):
A tuple of a quantum register and its index (ex:q[0]).
Example:
>>> import renom_q
>>> q = renom_q.QuantumRegister(1)
>>> c = renom_q.ClassicalRegister(1)
>>> qc = renom_q.QuantumCircuit(q, c)
>>> qc.s(q[0])

renom_q.gate.sdg

renom_q.gate.sdg. sdg ( self , q_num )

Apply sdg gate to quantum register.

Args:
q_num (tuple):
A tuple of a quantum register and its index (ex:q[0]).
Example:
>>> import renom_q
>>> q = renom_q.QuantumRegister(1)
>>> c = renom_q.ClassicalRegister(1)
>>> qc = renom_q.QuantumCircuit(q, c)
>>> qc.sdg(q[0])

renom_q.gate.t

renom_q.gate.t. t ( self , q_num )

Apply t gate to quantum register.

Args:
q_num (tuple):
A tuple of a quantum register and its index (ex:q[0]).
Example:
>>> import renom_q
>>> q = renom_q.QuantumRegister(1)
>>> c = renom_q.ClassicalRegister(1)
>>> qc = renom_q.QuantumCircuit(q, c)
>>> qc.t(q[0])

renom_q.gate.tdg

renom_q.gate.tdg. tdg ( self , q_num )

Apply tdg gate to quantum register.

Args:
q_num (tuple):
A tuple of a quantum register and its index (ex:q[0]).
Example:
>>> import renom_q
>>> q = renom_q.QuantumRegister(1)
>>> c = renom_q.ClassicalRegister(1)
>>> qc = renom_q.QuantumCircuit(q, c)
>>> qc.tsg(q[0])

renom_q.gate.rx

renom_q.gate.rx. rx ( self , theta , q_num )

Apply rx gate to quantum register.

Args:
theta (float):
Rotation angle of quantum statevector.
q_num (tuple):
A tuple of a quantum register and its index (ex:q[0]).
Example:
>>> import renom_q
>>> q = renom_q.QuantumRegister(1)
>>> c = renom_q.ClassicalRegister(1)
>>> qc = renom_q.QuantumCircuit(q, c)
>>> qc.rx(math.pi, q[0])

renom_q.gate.ry

renom_q.gate.ry. ry ( self , theta , q_num )

Apply ry gate to quantum register.

Args:
theta (float):
Rotation angle of quantum statevector.
q_num (tuple):
A tuple of a quantum register and its index (ex:q[0]).
Example:
>>> import renom_q
>>> q = renom_q.QuantumRegister(1)
>>> c = renom_q.ClassicalRegister(1)
>>> qc = renom_q.QuantumCircuit(q, c)
>>> qc.ry(math.pi, q[0])

renom_q.gate.rz

renom_q.gate.rz. rz ( self , theta , q_num )

Apply rz gate to quantum register.

Args:
theta (float):
Rotation angle of quantum statevector.
q_num (tuple):
A tuple of a quantum register and its index (ex:q[0]).
Example:
>>> import renom_q
>>> q = renom_q.QuantumRegister(1)
>>> c = renom_q.ClassicalRegister(1)
>>> qc = renom_q.QuantumCircuit(q, c)
>>> qc.rz(math.pi, q[0])

renom_q.gate.u1

renom_q.gate.u1. u1 ( self , lam , q_num )

Apply u1 gate to quantum register.

Args:
lam (float):
The paramater of unitary gate U1.
q_num (tuple):
A tuple of a quantum register and its index (ex:q[0]).
Example:
>>> import renom_q
>>> q = renom_q.QuantumRegister(1)
>>> c = renom_q.ClassicalRegister(1)
>>> qc = renom_q.QuantumCircuit(q, c)
>>> qc.u1(math.pi, q[0])

renom_q.gate.u2

renom_q.gate.u2. u2 ( self , phi , lam , q_num )

Apply u2 gate to quantum register.

Args:
phi (float):
The paramater of unitary gate U2.
lam (float):
The paramater of unitary gate U2.
q_num (tuple):
A tuple of a quantum register and its index (ex:q[0]).
Example:
>>> import renom_q
>>> q = renom_q.QuantumRegister(1)
>>> c = renom_q.ClassicalRegister(1)
>>> qc = renom_q.QuantumCircuit(q, c)
>>> qc.u2(0, math.pi, q[0])

renom_q.gate.u3

renom_q.gate.u3. u3 ( self , theta , phi , lam , q_num )

Apply u3 gate to quantum register.

Args:
theta (float):
The paramater of unitary gate U3.
phi (float):
The paramater of unitary gate U3.
lam (float):
The paramater of unitary gate U3.
q_num (tuple):
A tuple of a quantum register and its index (ex:q[0]).
Example:
>>> import renom_q
>>> q = renom_q.QuantumRegister(1)
>>> c = renom_q.ClassicalRegister(1)
>>> qc = renom_q.QuantumCircuit(q, c)
>>> qc.u3(math.pi, 0, math.pi, q[0])

renom_q.gate.gate_base2

renom_q.gate.gate_base2. gate_base2 ( self , gate_matrix , ctl , tgt , gatemark )

renom_q.gate.cx

renom_q.gate.cx. cx ( self , q_num1 , q_num2 )

Apply cx gate to quantum register.

Args:
q_num1 (tuple):
A tuple of a quantum register and its index (ex:q[0]). It’s the control qubit.
q_num2 (tuple):
A tuple of a quantum register and its index (ex:q[0]). It’s the target qubit.
Example:
>>> import renom_q
>>> q = renom_q.QuantumRegister(2)
>>> c = renom_q.ClassicalRegister(2)
>>> qc = renom_q.QuantumCircuit(q, c)
>>> qc.cx(q[0], q[1])

renom_q.gate.cy

renom_q.gate.cy. cy ( self , q_num1 , q_num2 )

Apply cy gate to quantum register.

Args:
q_num1 (tuple):
A tuple of a quantum register and its index (ex:q[0]). It’s the control qubit.
q_num2 (tuple):
A tuple of a quantum register and its index (ex:q[0]). It’s the target qubit.
Example:
>>> import renom_q
>>> q = renom_q.QuantumRegister(2)
>>> c = renom_q.ClassicalRegister(2)
>>> qc = renom_q.QuantumCircuit(q, c)
>>> qc.cy(q[0], q[1])

renom_q.gate.cz

renom_q.gate.cz. cz ( self , q_num1 , q_num2 )

Apply cz gate to quantum register.

Args:
q_num1 (tuple):
A tuple of a quantum register and its index (ex:q[0]). It’s the control qubit.
q_num2 (tuple):
A tuple of a quantum register and its index (ex:q[0]). It’s the target qubit.
Example:
>>> import renom_q
>>> q = renom_q.QuantumRegister(2)
>>> c = renom_q.ClassicalRegister(2)
>>> qc = renom_q.QuantumCircuit(q, c)
>>> qc.cz(q[0], q[1])

renom_q.gate.ch

renom_q.gate.ch. ch ( self , q_num1 , q_num2 )

Apply ch gate to quantum register.

Args:
q_num1 (tuple):
A tuple of a quantum register and its index (ex:q[0]). It’s the control qubit.
q_num2 (tuple):
A tuple of a quantum register and its index (ex:q[0]). It’s the target qubit.
Example:
>>> import renom_q
>>> q = renom_q.QuantumRegister(2)
>>> c = renom_q.ClassicalRegister(2)
>>> qc = renom_q.QuantumCircuit(q, c)
>>> qc.ch(q[0], q[1])

renom_q.gate.cs

renom_q.gate.cs. cs ( self , q_num1 , q_num2 )

Apply cs gate to quantum register.

Args:
q_num1 (tuple):
A tuple of a quantum register and its index (ex:q[0]). It’s the control qubit.
q_num2 (tuple):
A tuple of a quantum register and its index (ex:q[0]). It’s the target qubit.
Example:
>>> import renom_q
>>> q = renom_q.QuantumRegister(2)
>>> c = renom_q.ClassicalRegister(2)
>>> qc = renom_q.QuantumCircuit(q, c)
>>> qc.cs(q[0], q[1])

renom_q.gate.cu1

renom_q.gate.cu1. cu1 ( self , lam , q_num1 , q_num2 )

Apply cu1 gate to quantum register.

Args:
lam (float):
The paramater of unitary gate cU1.
q_num1 (tuple):
A tuple of a quantum register and its index (ex:q[0]). It’s the control qubit.
q_num2 (tuple):
A tuple of a quantum register and its index (ex:q[0]). It’s the target qubit.
Example:
>>> import renom_q
>>> q = renom_q.QuantumRegister(2)
>>> c = renom_q.ClassicalRegister(2)
>>> qc = renom_q.QuantumCircuit(q, c)
>>> qc.cu1(math.pi, q[0], q[1])

renom_q.gate.cu3

renom_q.gate.cu3. cu3 ( self , theta , phi , lam , q_num1 , q_num2 )

Apply cu3 gate to quantum register.

Args:
theta (float):
The paramater of unitary gate cU3.
phi (float):
The paramater of unitary gate cU3.
lam (float):
The paramater of unitary gate cU3.
q_num1 (tuple):
A tuple of a quantum register and its index (ex:q[0]). It’s the control qubit.
q_num2 (tuple):
A tuple of a quantum register and its index (ex:q[0]). It’s the target qubit.
Example:
>>> import renom_q
>>> q = renom_q.QuantumRegister(2)
>>> c = renom_q.ClassicalRegister(2)
>>> qc = renom_q.QuantumCircuit(q, c)
>>> qc.cu3(math.pi, 0, math.pi, q[0], q[1])

renom_q.gate.crz

renom_q.gate.crz. crz ( self , lam , q_num1 , q_num2 )

Apply crz gate to quantum register.

Args:
lam (float):
Rotation angle of quantum statevector.
q_num1 (tuple):
A tuple of a quantum register and its index (ex:q[0]). It’s the control qubit.
q_num2 (tuple):
A tuple of a quantum register and its index (ex:q[0]). It’s the target qubit.
Example:
>>> import renom_q
>>> q = renom_q.QuantumRegister(2)
>>> c = renom_q.ClassicalRegister(2)
>>> qc = renom_q.QuantumCircuit(q, c)
>>> qc.crz(math.pi, q[0], q[1])

renom_q.gate.swap

renom_q.gate.swap. swap ( self , q_num1 , q_num2 )

Apply swap gate to quantum register.

Args:
q_num1 (tuple):
A tuple of a quantum register and its index (ex:q[0]). It’s the exchanging qubit.
q_num2 (tuple):
A tuple of a quantum register and its index (ex:q[0]). It’s the exchanging qubit.
Example:
>>> import renom_q
>>> q = renom_q.QuantumRegister(2)
>>> c = renom_q.ClassicalRegister(2)
>>> qc = renom_q.QuantumCircuit(q, c)
>>> qc.swap(q[0], q[1])

renom_q.gate.ccx

renom_q.gate.ccx. ccx ( self , q_ctl1 , q_ctl2 , q_tgt )

Apply ccx gate to quantum register.

Args:
q_ctl1 (tuple):
A tuple of a quantum register and its index (ex:q[0]). It’s one of the control qubit.
q_ctl2 (tuple):
A tuple of a quantum register and its index (ex:q[0]). It’s one of the control qubit.
q_tgt (tuple):
A tuple of a quantum register and its index (ex:q[0]). It’s the target qubit.
Example:
>>> import renom_q
>>> q = renom_q.QuantumRegister(3)
>>> c = renom_q.ClassicalRegister(3)
>>> qc = renom_q.QuantumCircuit(q, c)
>>> qc.ccx(q[0], q[1], q[2])

renom_q.gate.cswap

renom_q.gate.cswap. cswap ( self , q_ctl , q_num1 , q_num2 )

Apply cswap gate to quantum register.

Args:
q_ctl (tuple):
A tuple of a quantum register and its index (ex:q[0]). It’s the control qubit.
q_num1 (tuple):
A tuple of a quantum register and its index (ex:q[0]). It’s the exchanging qubit.
q_num2 (tuple):
A tuple of a quantum register and its index (ex:q[0]). It’s the exchanging qubit.
Example:
>>> import renom_q
>>> q = renom_q.QuantumRegister(3)
>>> c = renom_q.ClassicalRegister(3)
>>> qc = renom_q.QuantumCircuit(q, c)
>>> qc.cswap(q[0], q[1], q[2])