def codeinit(self): self.exnum = self.galorbnums[0] self.exchi = ConreyCharacter(self.modulus, self.exnum) values_gens = db.char_dir_values.lookup( "{}.{}".format(self.modulus, self.exnum), projection='values_gens' ) vals = [int(v) for g, v in values_gens] sage_zeta_order = self.exchi.sage_zeta_order(self.order) self._genvalues_for_code = get_sage_genvalues(self.modulus, self.order, vals, sage_zeta_order) return { 'sage': [ 'from sage.modular.dirichlet import DirichletCharacter', 'H = DirichletGroup({}, base_ring=CyclotomicField({}))'.format( self.modulus, sage_zeta_order), 'M = H._module', 'chi = DirichletCharacter(H, M([{}]))'.format( ','.join(str(val) for val in self._genvalues_for_code) ), 'chi.galois_orbit()' ], 'pari': [ '[g,chi] = znchar(Mod(%i,%i))' % (self.exnum, self.modulus), 'order = charorder(g,chi)', '[ charpow(g,chi, k % order) | k <-[1..order-1], gcd(k,order)==1 ]' ] }
def _set_generators_and_genvalues(self, values_data): """ The char_dir_values db collection contains `values_gens`, which contains the generators for the unit group U(modulus) and the values of the character on those generators. """ valuepairs = values_data['values_gens'] if self.modulus == 1: self.generators = r"\(1\)" self.genvalues = r"\(1\)" else: gens = [int(g) for g, v in valuepairs] vals = [int(v) for g, v in valuepairs] self._genvalues_for_code = get_sage_genvalues(self.modulus, self.order, vals, self.chi.sage_zeta_order(self.order)) self.generators = self.textuple([str(g) for g in gens]) self.genvalues = self.textuple([self._tex_value(v) for v in vals])