Beispiel #1
0
 def endomorphismSpace2(self):
     pool.start_pool()
     endspace = parallel_weaksim(self.stconsts)
     x = endspace.get()
     endo = ParallelIntersection(x, packed=True).get()
     pool.stop_pool()
     return endo
Beispiel #2
0
def compute_basis2(As, Bs):
    pool.start_pool()
    Lspaces = parallel_weaksim(Bs)
    Vspaces = parallel_weaksim(As, Bs)
    Lbasis = ParallelIntersection(Lspaces.get(), packed=True, nch=pool.PROCESSES/2)
    Vbasis = ParallelIntersection(Vspaces.get(), packed=True, nch=pool.PROCESSES/2)
    pool.stop_pool()
    return (Lbasis.get(), Vbasis.get())
Beispiel #3
0
def similarity(As, Bs, name=None):

    dim = As[0].row
    field = As[0].coeff_ring
    for A in As: assert A.row == A.column == dim
    for B in Bs: assert B.row == B.column == dim
    assert len(As) == len(Bs)
    print "Simultaneous similarity over %d %dx%d matrices" % (len(As), dim, dim)
    if name is not None:
        try:
            Vbasis = numpy_load_matrices(
                        default_file_name(name + "_basis", field), field)
            L = algebra.Algebra.fromFile(field, name)
            #L.semisimple = True
            V = algebra.Module.fromFile(field, L, name)
        except IOError:
            L = None
            V = None
    if name is None or L is None or V is None:
        (Lbasis, Vbasis) = compute_basis3(As, Bs)
        pool.stop_pool()
        # If V = {}, then there is no solution.
        if not Vbasis:
            print "No X found such that X*A_i = B_i*X"
            return None
        
        assert all([X * B == B * X for B in Bs for X in Lbasis])
        assert all([X * A == B * X for (A, B) in zip(As, Bs) for X in Vbasis])
        
        print "Constructing %d-dimensional algebra L" % len(Lbasis)
        L = algebra.Algebra.fromBasis(field, Lbasis)
        #L.semisimple = True
        print "Constructing %d-dimensional module V" % len(Vbasis)
        V = algebra.Module.fromBasis(field, Lbasis, Vbasis, L)
        
        if name is not None:
            # Save this work for later.
            L.save(name)
            V.save(name)
            numpy_save_matrices(Vbasis, default_file_name(name + "_basis", field))
    #print_matrices(V.stconsts)
    print "Finding a generator in V"
    v = V.findGenerator()
    
    if v is not None:
        Z = vector_to_matrix(v, Vbasis)
        # Check if Z is invertible, i.e. if v is a unit. If v is not a unit
        # then there are no units in V.
        try:
            Zprime = Z.inverse()
        except matrix.NoInverse:
            return None
        assert all(Z * A * Zprime == B for (A,B) in zip(As, Bs))
        return Z
    return None