def random_even_arithgroup(index,nu2_max=None,nu3_max=None): r""" Return a random even arithmetic subgroup EXAMPLES:: sage: import sage.modular.arithgroup.tests as tests sage: G = tests.random_even_arithgroup(30); G # random Arithmetic subgroup of index 30 sage: G.is_even() True """ from sage.groups.perm_gps.permgroup import PermutationGroup test = False if nu2_max is None: nu2_max = index//5 elif nu2_max == 0: assert index%2 == 0 if nu3_max is None: nu3_max = index//7 elif nu3_max == 0: assert index%3 == 0 while not test: nu2 = prandom.randint(0,nu2_max) nu2 = index%2 + nu2*2 nu3 = prandom.randint(0,nu3_max) nu3 = index%3 + nu3*3 l = range(1,index+1) prandom.shuffle(l) S2 = [] for i in xrange(nu2): S2.append((l[i],)) for i in xrange(nu2,index,2): S2.append((l[i],l[i+1])) prandom.shuffle(l) S3 = [] for i in xrange(nu3): S3.append((l[i],)) for i in xrange(nu3,index,3): S3.append((l[i],l[i+1],l[i+2])) G = PermutationGroup([S2,S3]) test = G.is_transitive() return ArithmeticSubgroup_Permutation(S2=S2,S3=S3)
def random_even_arithgroup(index, nu2_max=None, nu3_max=None): r""" Return a random even arithmetic subgroup EXAMPLES:: sage: import sage.modular.arithgroup.tests as tests sage: G = tests.random_even_arithgroup(30); G # random Arithmetic subgroup of index 30 sage: G.is_even() True """ from sage.groups.perm_gps.permgroup import PermutationGroup test = False if nu2_max is None: nu2_max = index // 5 elif nu2_max == 0: assert index % 2 == 0 if nu3_max is None: nu3_max = index // 7 elif nu3_max == 0: assert index % 3 == 0 while not test: nu2 = prandom.randint(0, nu2_max) nu2 = index % 2 + nu2 * 2 nu3 = prandom.randint(0, nu3_max) nu3 = index % 3 + nu3 * 3 l = list(range(1, index + 1)) prandom.shuffle(l) S2 = [] for i in range(nu2): S2.append((l[i], )) for i in range(nu2, index, 2): S2.append((l[i], l[i + 1])) prandom.shuffle(l) S3 = [] for i in range(nu3): S3.append((l[i], )) for i in range(nu3, index, 3): S3.append((l[i], l[i + 1], l[i + 2])) G = PermutationGroup([S2, S3]) test = G.is_transitive() return ArithmeticSubgroup_Permutation(S2=S2, S3=S3)
def _get_random_ribbon_graph(self): r""" Return a random ribbon graph with right parameters. """ n = random.randint(self.min_num_seps, self.max_num_seps) S = SymmetricGroup(2 * n) e = S([(2 * i + 1, 2 * i + 2) for i in range(n)]) f = S.random_element() P = PermutationGroup([e, f]) while not P.is_transitive(): f = S.random_element() P = PermutationGroup([e, f]) return RibbonGraph(edges=[e(i + 1) - 1 for i in range(2 * n)], faces=[f(i + 1) - 1 for i in range(2 * n)])
def _get_random_ribbon_graph(self): r""" Return a random ribbon graph with right parameters. """ n = random.randint(self.min_num_seps,self.max_num_seps) S = SymmetricGroup(2*n) e = S([(2*i+1,2*i+2) for i in xrange(n)]) f = S.random_element() P = PermutationGroup([e,f]) while not P.is_transitive(): f = S.random_element() P = PermutationGroup([e,f]) return RibbonGraph( edges=[e(i+1)-1 for i in xrange(2*n)], faces=[f(i+1)-1 for i in xrange(2*n)])