thesoens/mu.py

37 lines
833 B
Python
Raw Permalink Normal View History

2022-01-29 13:04:08 +01:00
import numpy as np
def determu(q,dim,ulayer):
for i in range(dim):
for j in range(i+1,dim):
q=ulayer(dim,i,j)(q)
return q
def determr(q,dim,ulayer):
dex=[]
for i in range(dim):
for j in range(i+1,dim):
dex.append([i,j])
np.random.shuffle(dex)
for i,j in dex:
q=ulayer(dim,i,j)(q)
return q
def partu(q,pdim,dim,ulayer):
for i in range(pdim):
for j in range(i+1,dim):
q=ulayer(dim,i,j)(q)
return q
def partr(q,pdim,dim,ulayer):
#this is often just an approximation. But for sqrt runtime....
dex=[]
for i in range(pdim):
for j in range(i+1,dim):
dex.append([i,j])
np.random.shuffle(dex)
for i,j in dex:
q=ulayer(dim,i,j)(q)
return q
def cutdown(q,pdim):
return q[:,:pdim]