Ejemplo n.º 1
0
 def create_key(self,
                group,
                weight=None,
                sign=0,
                p=None,
                prec_cap=None,
                base=None,
                coefficients=None):
     #print group, weight, sign, p, prec_cap, base, coefficients
     if sign not in (-1, 0, 1):
         raise ValueError("sign must be -1, 0, 1")
     if isinstance(group, (int, Integer)):
         character = None
     elif isinstance(group, DirichletCharacter):
         character = group
     if coefficients is None:
         #OverconvergentDistributions can handle prec_cap and base being None
         coefficients = OverconvergentDistributions(weight, p, prec_cap,
                                                    base, character)
     if isinstance(group, (int, Integer)):
         p = coefficients.prime()
         if group % p != 0:
             group *= p
         group = Gamma0(group)
     elif isinstance(group, DirichletCharacter):
         p = coefficients.prime()
         group = group.modulus()
         if group % p != 0:
             group *= p
         group = Gamma0(group)
     return (group, coefficients, sign)
Ejemplo n.º 2
0
 def specialize(self, k, return_map=False):
     from sage.modular.pollack_stevens.coeffmod_OMS_space import OverconvergentDistributions
     D = OverconvergentDistributions(k, base=self.base_ring().base_ring(), prec_cap=self._prec_cap[0], character=self._character, adjuster=self._adjuster, act_on_left=self.action().is_left(), dettwist=self._dettwist)
     if not return_map:
         return D
     else:
         return D, None
Ejemplo n.º 3
0
def test_correctness_and_precision_of_solve_diff_eqn(number=20, verbosity=1):
    """
    ``number`` is how many different random distributions to check. 
    
    Currently, avoids the prime 2.
    """
    from sage.misc.prandom import randint
    from sage.rings.arith import random_prime
    from sage.rings.padics.factory import ZpCA
    from sage.modular.pollack_stevens.coeffmod_OMS_space import OverconvergentDistributions
    from sage.structure.sage_object import dumps
    errors = []
    munus = []
    for i in range(number):
        Mspace = randint(1, 20)    #Moments of space
        M = randint(max(0, Mspace - 5), Mspace)
        p = random_prime(13, lbound=3)
        k = randint(0, 6)
        Rprec = Mspace + randint(0, 5)
        R = ZpCA(p, Rprec)
        D = OverconvergentDistributions(k, base=R, prec_cap=Mspace)
        S0 = D.action().actor()
        Delta_mat = S0([1,1,0,1])
        mu = D.random_element(M)
        mu_save = dumps(mu)#[deepcopy(mu.ordp), deepcopy(mu._moments)]
        if verbosity > 0:
            print "\nTest #{0} data (Mspace, M, p, k, Rprec) =".format(i+1), (Mspace, M, p, k, Rprec)
            print "mu =", mu
        
        nu = mu * Delta_mat - mu
        nu_save = [deepcopy(nu.ordp), deepcopy(nu._moments)]
        mu2 = nu.solve_diff_eqn()
        nu_abs_prec = nu.precision_absolute()
        expected = nu_abs_prec - nu_abs_prec.exact_log(p) - 1
        if M != 1:
            try:
                agree = (mu - mu2).is_zero(expected)
            except PrecisionError:
                print (Mspace, M, p, k, Rprec), mu_save._repr_(), nu_save
                assert False
        else:
            agree = mu2.is_zero(expected)
        if verbosity > 1:
            print "    Just so you know:"
            print "     mured =", mu.reduce_precision_absolute(expected)
            print "       mu2 =", mu2
            print "        nu = ", nu
        if not agree:
            errors.append((i+1, 1))
            munus.append((mu_save, nu_save, mu2, (Mspace, M, p, k, Rprec)))
        if verbosity > 0:
            print "    Test finding mu from mu|Delta accurate: %s"%(agree)
            print "        nu_abs_prec  soln_abs_prec_expected  actual  agree"
        mu2_abs_prec = mu2.precision_absolute()
        agree = (expected == mu2_abs_prec)
        if verbosity > 0:
            print "        %s             %s                       %s      %s"%(nu_abs_prec, expected, mu2_abs_prec, agree)
        if not agree:
            errors.append((i+1, 2))
            munus.append((mu_save, nu_save, mu2, (Mspace, M, p, k, Rprec)))
        
        if mu.precision_relative() > 0:
            mu._moments[0] = R(0, mu.precision_relative())
        mu_save = [deepcopy(mu.ordp), deepcopy(mu._moments)]
        if verbosity > 0:
            print "    mu modified =", mu
        nu = mu.solve_diff_eqn()
        mu_abs_prec = mu.precision_absolute()
        expected = mu_abs_prec - mu_abs_prec.exact_log(p) - 1
        nud = nu * Delta_mat - nu
        nu_save = [deepcopy(nu.ordp), deepcopy(nu._moments)]
        agree = (nud - mu).is_zero(expected)
        if verbosity > 1:
            print "    Just so you know:"
            print "        mu =", mu
            print "     mured =", mu.reduce_precision_absolute(expected)
            print "       nud =", nud
        if not agree:
            errors.append((i+1, 3))
            munus.append((mu_save, nu_save, (Mspace, M, p, k, Rprec)))
        if verbosity > 0:
            print "    Test finding nu with nu|Delta == mu: %s"%(agree)
            print "        mu_abs_prec  soln_abs_prec_expected  actual  agree"
        nu_abs_prec = nu.precision_absolute()
        agree = (expected == nu_abs_prec)
        if verbosity > 0:
            print "        %s             %s                       %s      %s"%(mu_abs_prec, expected, nu_abs_prec, agree)
        if not agree:
            errors.append((i+1, 4))
            munus.append((mu_save, nu_save, (Mspace, M, p, k, Rprec)))
    if len(errors) == 0:
        if verbosity > 0:
            print "\nTest passed with no errors."
        return
    if verbosity > 0:
        print "\nTest failed with errors: %s\n"%(errors)
    return errors, munus