Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to use parallel program to select the longest element in a list?

I need to find the longest element in a list of elements of Weyl group. The way I do it is:

winner = W.one()
    for u1 in g1:
        for u2 in g2:
            t1=u1*w*u2
            if t1.length()>winner.length():
                winner=t1
    r=winner

I would like to make the above faster by using parallel computations. Is there some way in Sage or Python to do this? Thank you very much!

How to use parallel program to select the longest element in a list?

I need to find the longest element in a list of elements of Weyl group. The way I do it is:

 winner = W.one()
    for u1 in g1:
        for u2 in g2:
            t1=u1*w*u2
            if t1.length()>winner.length():
                winner=t1
    r=winner

I would like to make the above faster by using parallel computations. Is there some way in Sage or Python to do this? Thank you very much!

How to use parallel program to select the longest element in a list?

I need to find the longest element in a list of elements of Weyl group. The way I do it is:

    winner = W.one()
    for u1 in g1:
        for u2 in g2:
            t1=u1*w*u2
            if t1.length()>winner.length():
                winner=t1
    r=winner

Here g1 and g2 are two given subsets of the Weyl group I would like to make the above faster by using parallel computations. Is there some way in Sage or Python to do this? Thank you very much!

Edit: the full codes are:

def find_permutation2(L1, L2):
    perm = Word(L1).standard_permutation() / Word(L2).standard_permutation()
    assert [L2[i-1] for i in perm] == L1
    r=perm.reduced_word()
    return r

def LongestPermWInSBWInverseSA(W,A,B): 
    t1=StablizerOfTuple(A)
    t2=StablizerOfTuple(sorted(B))
    s=W.simple_reflections()
    #print(t1,t2)
    t3=[]
    for i in t1:
        t3.append(s[i])
    t4=[]
    for i in t2:
        t4.append(s[i])
    t5=find_permutation2(B,sorted(B))
    w=W.one()
    for i in t5:
        w=w*s[i]
    #print(t4,w,t3)
    r2=LongestPermInDoubleCosetWeylGroup(W,t4,w,t3)
    r=r2

    return r


def LongestPermInDoubleCosetWeylGroup(W,S1,w,S2): 
    g1=W.subgroup(S1)
    g2=W.subgroup(S2)
    winner = W.one()
    for u1 in g1:
        for u2 in g2:
            t1=u1*w*u2
            if t1.length()>winner.length():
                winner=t1
    r=winner

    return r

def SymmetricGroupActionOnListSi(i,L): #  w=s_i,  L=[a1,a2,...,an]
    r1=[]
    for j in L:
        r1.append(j)

    t1=r1[i-1]
    r1[i-1]=r1[i]
    r1[i]=t1 

    r=r1

    return r

def StablizerOfTuple(A): # A is a list, weakly increasing
    k = len(A)
    r=[]
    for i in [1..k-1]:
        t1=SymmetricGroupActionOnListSi(i,A)
        if t1==A:
            r.append(i)
    return r

A=[1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4]
B=[3, 3, 3, 5, 5, 5, 4, 4, 4, 6, 6, 6]
kk=len(A)
#print(kk)
typ='A' 
W=SymmetricGroup(kk)
w=LongestPermWInSBWInverseSA(W,A,B)
w