Пример #1
0
def permutation_vector(g):
    """
    The distance matrix obtained by permuting taxa according
    to the permutation g \in SymmetricGroup(n).
    """
    n = g.parent().degree()
    M = distance_matrix(n)
    M = permutation_action(g,permutation_action(g,M).transpose()).transpose()
    perm_vec = list(np.array(M)[triu_indices(n, 1)])
    return perm_vec
Пример #2
0
def interesting_permutations(S):
    m,n = (S.nrows(), S.ncols())
    Sr = SymmetricGroup(m)
    Sc = SymmetricGroup(n)
    try:
        ( (g,h) for g in Sr for h in Sc 
            if g != Sr.identity() and h != Sc.identity() and 
            S == permutation_action(h, permutation_action(g, S).transpose()).transpose() ).next()
    except StopIteration:
        return 0
    return 1
Пример #3
0
def orbit(S):
    m,n = (S.nrows(), S.ncols())
    Sr = SymmetricGroup(m)
    Sc = SymmetricGroup(n)
    ret = []
    mats = [ 
        permutation_action(h, permutation_action(g, S).transpose()).transpose()
        for g in Sr for h in Sc
        ]
    for M in mats:
        if M not in ret:
            ret.append(M)
    return ret
Пример #4
0
def ray_magic(C,n):
    ray_sets = [Set([ray_sign_vector(symmetric_matrix(n,r)) for r in cone]) for cone in C] 
    canonical = ray_sets[0]
    d = {}
    for g in SymmetricGroup(n):
        permute = Set([tuple(permutation_action(g, v)) for v in canonical])
        d[permute] = d.get(permute, []) + [g]
    return d
def cusp_sums_from_signature_to_standard_basis(cuspsums,signatures,level):
    """
    Converts a list of cuspsums where each entry is a list of multiplicities with respect
    to the input signature order. To a list of cuspsums where each entry is a list of multiplicities
    with respect to the standard order of the cusps.
    """
    P = Permutation([cusp_number_from_signature(s,level)+1 for s in signatures]).inverse()
    return [permutation_action(P,s) for s in cuspsums]
Пример #6
0
def test_permutation(g,R):
    Rp = permute_matrix(g,R)
    pat = map(ray_sign_pattern, [R,Rp])
    vec = np.array(permutation_action(g, ray_sign_vector(R)))
    if vec[0]==-1:
        vec *= -1
    pred = vector(list(vec))
    d = {-1:"-", 1:"+"}
    pred = "".join(map(d.get, pred))
    #print R,"\n\n",Rp
    #print "p0: %s\tp': %s\tp_pred: %s" % (pat[0], pat[1], pred)
    assert pred==pat[1]
Пример #7
0
def permute_matrix(g, M):
    mat = permutation_action(g, permutation_action(g, M).transpose()).transpose()
    mat.set_immutable()
    return mat
Пример #8
0
def row_orbit(M):
    mats = [permutation_action(g, M) for g in SymmetricGroup(M.nrows())]
    [m.set_immutable() for m in mats]
    return mats
Пример #9
0
def col_permutation_action(g, M):
    M = permutation_action(g, M.transpose()).transpose()
    M.set_immutable()
    return M