示例#1
0
def orbittest(minD, maxD, eps=-1):
    for D in range(minD, maxD + 1):
        if is_fundamental_discriminant(eps * D) and is_odd(D):
            print(D)
            print(
                CMorbits(eps * D) -
                len(Newforms(kronecker_character(eps * D), 3, names='a')))
示例#2
0
def test_real_quadratic(minp=1, maxp=100, minwt=2, maxwt=1000):
    for p in prime_range(minp, maxp):
        if p % 4 == 1:
            print("p = ", p)
            gram = Matrix(ZZ, 2, 2, [2, 1, 1, (1 - p) / 2])
            M = VectorValuedModularForms(gram)
            if is_odd(minwt):
                minwt = minwt + 1
            for kk in range(minwt, round(maxwt / 2 - minwt)):
                k = minwt + 2 * kk
                if M.dimension_cusp_forms(k) - dimension_cusp_forms(
                        kronecker_character(p), k) / 2 != 0:
                    print("ERROR: {0},{1},{2}".format(
                        k, M.dimension_cusp_forms(k),
                        dimension_cusp_forms(kronecker_character(p), k / 2)))
                    return False
    return True
示例#3
0
 def _fc__unramfactor(self, content, det_4):
     chi = kronecker_character(-det_4)
     pfacs = prime_factors(det_4)
     fd = fundamental_discriminant(-det_4)
     l = [(p, valuation(content, p),
           (valuation(det_4, p) - valuation(fd, p)) / 2) for p in pfacs]
     return reduce(operator.mul,
                   [self._fc__unramfactor_at_p(p, ci, fi, chi)
                    for (p, ci, fi) in l])
示例#4
0
def compare_formulas_2a(D, k):
    d1 = dimension_new_cusp_forms(kronecker_character(D), k)
    if D < 0:
        D = -D
    d2 = RR(1 / pi * sqrt(D) * sum([
        log(d) * sigma(old_div(D, d), 0) for d in divisors(D) if Zmod(d)
        (old_div(D, d)).is_square() and is_fundamental_discriminant(-d)
    ]))
    return d1 - d2
示例#5
0
def compare_vv_scalar(V, k):
    dv = V.dimension_cusp_forms(k)
    N = V._level
    m = V._M.order()
    if k in ZZ:
        D = DirichletGroup(N)
        if is_even(k):
            chi = D(kronecker_character(m))
        else:
            chi = D(kronecker_character(-m))
        S = CuspForms(chi, k)
        N = Newforms(chi, k, names='a')
        ds = S.dimension()
        B = N
    else:
        D = magma.DirichletGroup(V._level)
        chi = magma.D(magma.KroneckerCharacter(2 * m))
        M = magma.HalfIntegralWeightForms(chi, k)
        S = M.CuspidalSubspace()
        ds = S.Dimension()
        B = S.Basis()
    return dv, ds, S, B
示例#6
0
 def __latex__(self):
     if self._is_dual:
         s=" \bar{v_{\theta}} "
     else:
         s=" v_{\theta} "
     if self._character<>None and not self._character.is_trivial():
         s+=" \cdot "
         if self._character == kronecker_character(self._conductor):
             s+=" \left( \frac\{\cdot\}\{ {0} \}\right)".format(self._conductor)
         elif self._character == kronecker_character_upside_down(self._conductor):
             s+=" \left( \frac\{ {0} \}\{ \cdot \}\right)".format(self._conductor)
         else:
             s+=" \chi_\{ {0}, {1} \}".format(self._conductor,self._char_nr)
     return s
 def __latex__(self):
     if self._is_dual:
         s=" \bar{v_{\theta}} "
     else:
         s=" v_{\theta} "
     if self._character<>None and not self._character.is_trivial():
         s+=" \cdot "
         if self._character == kronecker_character(self._conductor):
             s+=" \left( \frac\{\cdot\}\{ {0} \}\right)".format(self._conductor)
         elif self._character == kronecker_character_upside_down(self._conductor):
             s+=" \left( \frac\{ {0} \}\{ \cdot \}\right)".format(self._conductor)
         else:
             s+=" \chi_\{ {0}, {1} \}".format(self._conductor,self._char_nr)
     return s
示例#8
0
def compare_formulas_1(D, k):
    DG = DirichletGroup(abs(D))
    chi = DG(kronecker_character(D))
    d1 = dimension_new_cusp_forms(chi, k)
    #if D>0:
    #    lvals=sage.lfunctions.all.lcalc.twist_values(1,2,D)
    #else:
    #    lvals=sage.lfunctions.all.lcalc.twist_values(1,D,0)
    #s1=RR(sum([sqrt(abs(lv[0]))*lv[1]*2**len(prime_factors(D/lv[0])) for lv in lvals if lv[0].divides(D) and Zmod(lv[0])(abs(D/lv[0])).is_square()]))
    #d2=RR(1/pi*s1)
    d2 = 0
    for d in divisors(D):
        if is_fundamental_discriminant(-d):
            K = QuadraticField(-d)
            DD = old_div(ZZ(D), ZZ(d))
            ep = euler_phi((chi * DG(kronecker_character(-d))).conductor())
            #ep=euler_phi(squarefree_part(abs(D*d)))
            print("ep=", ep, D, d)
            ids = [a for a in K.ideals_of_bdd_norm(-DD)[-DD]]
            eulers1 = []
            for a in ids:
                e = a.euler_phi()
                if e != 1 and ep == 1:
                    if K(-1).mod(a) != K(1).mod(a):
                        e = old_div(e, (2 * ep))
                else:
                    e = old_div(e, ep)
                eulers1.append(e)
            print(eulers1, ep)
            s = sum(eulers1)
            if ep == 1 and not (d.divides(DD) or abs(DD) == 1):
                continue
            print(d, s)
            if len(eulers1) > 0:
                d2 += s * K.class_number()
    return d1 - d2
示例#9
0
def quadratic_twist_zeros(D, n, algorithm='clib'):
    """
    Return imaginary parts of the first n zeros of all the Dirichlet
    character corresponding to the quadratic field of discriminant D.

    INPUT:
        - D -- fundamental discriminant
        - n -- number of zeros to find
        - algorithm -- 'clib' (use C library) or 'subprocess' (open another process)
    """
    if algorithm == 'clib':
        L = Lfunction_from_character(kronecker_character(D), type="int")
        return L.find_zeros_via_N(n)
    elif algorithm == 'subprocess':
        assert is_fundamental_discriminant(D)
        cmd = "lcalc -z {0} --twist-quadratic --start {1} --finish {2}".format(
            n, D, D)
        out = os.popen(cmd).read().split()
        return [float(out[i]) for i in range(len(out)) if i % 2 != 0]
    else:
        raise ValueError("unknown algorithm '{0}'".format(algorithm))
示例#10
0
    def __init__(self,group,dchar=(0,0),dual=False,is_trivial=False,dimension=1,**kwargs):
        r"""
        if dual is set to true we use the complex conjugate of the representation (we assume the representation is unitary)


        The pair dchar = (conductor,char_nr) gives the character.
        If char_nr = -1  = > kronecker_character
        If char_nr = -2  = > kronecker_character_upside_down
        """
        #print "kwargs0=",kwargs
        self._group = group
        self._dim = dimension
        self._ambient_rank=kwargs.get('ambient_rank',None)
        self._kwargs = kwargs
        self._verbose = kwargs.get("verbose",0)
        if self._verbose>0:
             print "Init multiplier system!"
        (conductor,char_nr)=dchar
        self._conductor=conductor
        self._char_nr=char_nr
        self._character = None
        self._level = group.generalised_level()
        if kwargs.has_key('character'):
            if str(type(kwargs['character'])).find('DirichletCharacter')>=0:
                self._character = kwargs['character']
                self._conductor=self._character.conductor()
                self._char_nr=list((self._character).parent()).index(self._character)
        elif group.is_congruence():
            if conductor<=0:
                    self._conductor=group.level(); self._char_nr=0
            if char_nr>=0:
                self._char_nr=char_nr
            
            if self._char_nr==0:
                self._character = trivial_character(self._conductor)
            elif self._char_nr==-1:                
                if self._conductor % 4 == 3:
                    self._character = kronecker_character(-self._conductor)
                elif self._conductor % 4 == 1:
                    self._character = kronecker_character(self._conductor)                    
                assert self._character.conductor()==self._conductor
            elif self._char_nr<=-2:
                self._character = kronecker_character_upside_down(self._conductor)    
            else:
                D = list(DirichletGroup(self._conductor))
                if self._char_nr <0 or self._char_nr>len(D):
                    self._char_nr=0
                self._character = D[self._char_nr]
        else:
            self._conductor = 1
            self._character = trivial_character(1)
        #if not hasattr(self._character,'is_trivial'):
        #    if isinstance(self._character,(int,Integer)) and group.is_congruence():
        #        j = self._character
        #        self._character = DirichletGroup(group.level())[j]
        ## Extract the class name for the reduce algorithm
        self._class_name=str(type(self))[1:-2].split(".")[-1]
        if not isinstance(dimension,(int,Integer)):
            raise ValueError,"Dimension must be integer!"
        self._is_dual = dual
        self._is_trivial=is_trivial and self._character.is_trivial()
        if is_trivial and self._character.order()<=2:
            self._is_real=True
        else:
            self._is_real=False
        self._character_values = [] ## Store for easy access
示例#11
0
    def __init__(self,
                 group,
                 dchar=(1, 1),
                 dual=False,
                 is_trivial=False,
                 dimension=1,
                 **kwargs):
        r"""
        if dual is set to true we use the complex conjugate of the representation (we assume the representation is unitary)


        
        The pair dchar = (conductor,number) gives the character in conrey numbering
        If char_nr = -1  = > kronecker_character
        If char_nr = -2  = > kronecker_character_upside_down
        """
        self._group = group
        if not hasattr(self, '_weight'):
            self._weight = None
        self._dim = dimension
        self._ambient_rank = kwargs.get('ambient_rank', None)
        self._kwargs = kwargs
        self._verbose = kwargs.get("verbose", 0)
        if self._verbose > 0:
            print("Init multiplier system!")
        (conductor, char_nr) = dchar
        self._conductor = conductor
        self._char_nr = char_nr
        self._character = None
        self._level = group.generalised_level()
        if 'character' in kwargs:
            if str(type(kwargs['character'])).find('Dirichlet') >= 0:
                self._character = kwargs['character']
                self._conductor = self._character.conductor()
                try:
                    self._char_nr = self._character.number()
                except:
                    for x in DirichletGroup_conrey(self._conductor):
                        if x.sage_character() == self._character:
                            self._char_nr = x.number()
        elif group.is_congruence():
            if conductor <= 0:
                self._conductor = group.level()
                self._char_nr = 1
            if char_nr >= 0:
                self._char_nr = char_nr

            if self._char_nr == 0 or self._char_nr == 1:
                self._character = trivial_character(self._conductor)
            elif self._char_nr == -1:
                if self._conductor % 4 == 3:
                    self._character = kronecker_character(-self._conductor)
                elif self._conductor % 4 == 1:
                    self._character = kronecker_character(self._conductor)
                assert self._character.conductor() == self._conductor
            elif self._char_nr <= -2:
                self._character = kronecker_character_upside_down(
                    self._conductor)
            else:
                self._character = DirichletCharacter_conrey(
                    DirichletGroup_conrey(self._conductor),
                    self._char_nr).sage_character()
        else:
            self._conductor = 1
            self._character = trivial_character(1)
        #if not hasattr(self._character,'is_trivial'):
        #    if isinstance(self._character,(int,Integer)) and group.is_congruence():
        #        j = self._character
        #        self._character = DirichletGroup(group.level())[j]
        ## Extract the class name for the reduce algorithm
        self._class_name = str(type(self))[1:-2].split(".")[-1]
        if not isinstance(dimension, (int, Integer)):
            raise ValueError("Dimension must be integer!")
        self._is_dual = dual
        self._is_trivial = is_trivial and self._character.is_trivial()
        if is_trivial and self._character.order() <= 2:
            self._is_real = True
        else:
            self._is_real = False
        self._character_values = []  ## Store for easy access
示例#12
0
def compare_formulas_3(D, k):
    d1 = dimension_cusp_forms(kronecker_character(D), k)
    d2 = RR(
        sqrt(abs(D)) * log(abs(D)) / pi + sqrt(abs(D)) * log(abs(D)) * 9 /
        (sqrt(3) * pi))
    return d1 - d2