In [4]:
import numpy as np
import quasm_module as qm
import qutip
from qutip import qip
In [7]:
qip.cnot(3,2,1)[0]
Out[7]:
In [3]:
qm.single_qubit_gate('h',0,2)
Out[3]:
In [2]:
bla=qm.load_qasm_file('test4.qasm')
In [3]:
instructions=qm.get_filtered_qasm(bla)
In [12]:
instructions
Out[12]:
In [15]:
qm.read_instruction_line(qm.delete_instruction(instructions,3))
Out[15]:
In [6]:
qm.delete_instruction(instructions)
Out[6]:
In [3]:
filename='test1.qasm'
quasm_file=[]
f=open(filename,'r')
for line in f:
quasm_file.append(line)
print(line)
In [20]:
quasm_instrunctions=[]
alphabet='abcdefghijklmnopqrstuvwxyz'
m=0
for tt, line in enumerate(quasm_file):
if not line[0] in alphabet:
m+=1
pass
else:
quasm_instrunctions.append('')
for char in line:
if not char=='#' or char=='\n':
quasm_instrunctions[tt-m]+=char
else:
break
print(quasm_instrunctions)
In [13]:
num_qubits=0
for line in quasm_instrunctions:
if 'qubit' in line:
num_qubits+=1
print('Number of qubits is '+str(num_qubits))
In [11]:
def number_of_qubits(quasm_instrunctions):
num_qubits=0
for line in quasm_instrunctions:
if 'qubit' in line:
num_qubits+=1
return num_qubits
Out[11]:
In [2]:
qm.operator_dict_default()
Out[2]:
In [6]:
1/np.sqrt(2)*np.array([[1,1],[1,-1]])
Out[6]:
In [11]:
my_dict={}
my_dict['h']=1/np.sqrt(2)*np.array([[1,1],[1,-1]])
In [12]:
my_dict.update({'i':np.array([[1,0],[0,1]])})
In [ ]:
In [4]:
qm.single_qubit_gate(h,1,2)
In [45]:
np.tensordot([[0,1],[0,1]],[[0,1],[0,1]])
Out[45]:
In [52]:
A=np.array([[1,0],[0,1]])
print(A)
B=np.array([[1,0],[1,1]])
print(B)
print(np.kron(A,B))
In [47]:
np.outer([[1,0],[0,1]],[[0,1],[0,1]])
Out[47]:
In [ ]: