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]


