<gh_stars>0
# -*- coding: utf-8 -*-
"""Copy of Untitled19.ipynb

Automatically generated by Colaboratory.

Original file is located at
    https://colab.research.google.com/drive/1UsBzAPuuznzHflaQYUA3bs_blhuJIxeb
"""

import numpy as np
import math

L=[1,2,3,4,5,6,7]
L1=[]
L2=[]   
L3=[]
L4=[]

for ele in L:
  k=bin(ele)[2:]
  if len(k)!=3:
    k='0'*(3-len(k))+k
  L1.append(k)
print(L1)

for bin_num in L1:
  L2.append(np.array([int(bin_num[0]),int(bin_num[1]),int(bin_num[2])]))
print(L2)

for ket_no in L2:
  L3.append(ket_no.conjugate().transpose())

L5=[]
def f(req_no):
  global L5
  for x in L:
    if x==req_no:
      L5.append(1)
    else:
      L5.append(0)
  return L5

f(3)
L6=[]
k=0
for i in L3:
  L6.append(((-1)**L5[k])*i)
  k+=1

L6

i_bra_psi=(1/math.sqrt(2**len(L3)))*sum(L3)
i_bra_psi
i_ket_psi=i_bra_psi.conjugate().transpose()
i_ket_psi

f_bra_psi=i_bra_psi-np.array([[0,1,1]])
f_bra_psi

f_ket_psi=f_bra_psi.conjugate().transpose()
f_ket_psi

ur=(2*np.dot(f_ket_psi,f_bra_psi)-np.identity(n=3,dtype=int))
ur

np.dot(ur,i_ket_psi)




# -*- coding: utf-8 -*-
"""Copy of Untitled19.ipynb

Automatically generated by Colaboratory.

Original file is located at
    https://colab.research.google.com/drive/1UsBzAPuuznzHflaQYUA3bs_blhuJIxeb
"""

import numpy as np
import math

L=[1,2,3,4,5,6,7]
L1=[]
L2=[]   
L3=[]
L4=[]

for ele in L:
  k=bin(ele)[2:]
  if len(k)!=3:
    k='0'*(3-len(k))+k
  L1.append(k)
print(L1)

for bin_num in L1:
  L2.append(np.array([int(bin_num[0]),int(bin_num[1]),int(bin_num[2])]))
print(L2)

for ket_no in L2:
  L3.append(ket_no.conjugate().transpose())

L5=[]
def f(req_no):
  global L5
  for x in L:
    if x==req_no:
      L5.append(1)
    else:
      L5.append(0)
  return L5

f(3)
L6=[]
k=0
for i in L3:
  L6.append(((-1)**L5[k])*i)
  k+=1

L6

i_bra_psi=(1/math.sqrt(2**len(L3)))*sum(L3)
i_bra_psi
i_ket_psi=i_bra_psi.conjugate().transpose()
i_ket_psi

f_bra_psi=i_bra_psi-np.array([[0,1,1]])
f_bra_psi

f_ket_psi=f_bra_psi.conjugate().transpose()
f_ket_psi

ur=(2*np.dot(f_ket_psi,f_bra_psi)-np.identity(n=3,dtype=int))
ur

np.dot(ur,i_ket_psi)
# -*- coding: utf-8 -*- Copy of Untitled19.ipynb  Automatically generated by Colaboratory.  Original file is located at     https://colab.research.google.com/drive/1UsBzAPuuznzHflaQYUA3bs_blhuJIxeb