sqeleton module

class sqeleton.QuantumCircuit(num: int)

Bases: object

have gate and methods

H_gate = array([[ 0.70710678,  0.70710678],        [ 0.70710678, -0.70710678]])
I_gate = array([[1, 0],        [0, 1]])
P0 = array([[1, 0],        [0, 0]])
P1 = array([[0, 0],        [0, 1]])
T_gate = array([[1.        +0.j        , 0.        +0.j        ],        [0.        +0.j        , 0.70710678+0.70710678j]])
X_gate = array([[0, 1],        [1, 0]])
Y_gate = array([[ 0.+0.j, -0.-1.j],        [ 0.+1.j,  0.+0.j]])
Z_gate = array([[ 1,  0],        [ 0, -1]])
add_CNOT_gate(control: int, target: int) None

add CNOT gate in gateArray :param control: control qubit index :type control: int :param target: target qubit index :type target: int

Raises:

index error – target index is out of range

Examples

>>> circuit = QuantumCircuit(2)
>>> circuit.add_CNOT_gate(0, 1)
add_H_gate(num: int) None

add H gate in gateArray :param num: target qubit index :type num: int

Raises:

index error – target index is out of range

add_RX_gate(num: int, theta: float) None

add RX gate in gateArray :param num: target qubit index :type num: int :param theta: rotate angle :type theta: float

Raises:

index error – target index is out of range

Examples

>>> circuit = QuantumCircuit(2)
>>> circuit.add_RX_gate(0, np.pi)
add_RY_gate(num: int, theta: float) None

add RY gate in gateArray :param num: target qubit index :type num: int :param theta: rotate angle :type theta: float

Raises:

index error – target index is out of range

add_RZ_gate(num: int, theta: float) None

add RZ gate in gateArray :param num: target qubit index :type num: int :param theta: rotate angle :type theta: float

Raises:

index error – target index is out of range

add_T_gate(num: int) None

add T gate in gateArray :param num: target qubit index :type num: int

Raises:

index error – target index is out of range

add_X_gate(num: int) None

add X gate in gateArray :param num: target qubit index :type num: int

Raises:

index error – target index is out of range

Examples

>>> circuit = QuantumCircuit(2)
>>> circuit.add_X_gate(0)
add_Y_gate(num: int) None

add Y gate in gateArray :param num: target qubit index :type num: int

Raises:

index error – target index is out of range

add_Z_gate(num: int) None

add Z gate in gateArray :param num: target qubit index :type num: int

Raises:

index error – target index is out of range

get_depth() int

show circuit depth .. rubric:: Examples

>>> circuit = QuantumCircuit(2)
>>> circuit.add_X_gate(0)
>>> circuit.add_RX_gate(0, np.pi)
>>> circuit.add_CNOT_gate(0, 1)
>>> circuit.get_depth()
circuit depth : 3
get_info() None

show circuit information property: gateType (x,y,z,h,t,rx,ry,rx,cnot), qubit index (target, control), theta (if gate is ratate gate) .. rubric:: Examples

>>> circuit = QuantumCircuit(2)
>>> circuit.add_X_gate(0)
>>> circuit.add_RX_gate(0, np.pi)
>>> circuit.add_CNOT_gate(0, 1)
>>> circuit.get_info()
gateType: x , target: 0
gateType: rx , target: 0 , theta: 3.141592653589793
gateType: cnot , control: 0 , target: 1
update_quantum_state(state: QuantumState) None

interface of calling internal apply methods :param state: target state to apply circuit :type state: QuantumState

Examples

>>> state = QuantumState(2)
>>> circuit = QuantumCircuit(2)
>>> circuit.update_quantum_state(state)
class sqeleton.QuantumState(num: int)

Bases: object

manage state vector

get_probability_vector() None

show probability vector .. rubric:: Examples

>>> state = QuantumState(2)
>>> state.get_probability_vector()
|00>: [1.]
|01>: [0.]
|10>: [0.]
|11>: [0.]
get_state_vector() None

show state vector .. rubric:: Examples

>>> state = QuantumState(2)
    >>> state.get_state_vector()
|00>: [1.+0.j]
|01>: [0.+0.j]
|10>: [0.+0.j]
|11>: [0.+0.j]
sampling(count: int) None

sampling in the computational basis :param count: sampling number :type count: int

Examples

>>> state = QuantumState(2)
>>> state.sampling(1000)
|00>: 1000
|01>: 0
|10>: 0
|11>: 0