当前位置: 首页>>代码示例>>Python>>正文


Python ZZ.valuation方法代码示例

本文整理汇总了Python中sage.all.ZZ.valuation方法的典型用法代码示例。如果您正苦于以下问题:Python ZZ.valuation方法的具体用法?Python ZZ.valuation怎么用?Python ZZ.valuation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sage.all.ZZ的用法示例。


在下文中一共展示了ZZ.valuation方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: factor_out_p

# 需要导入模块: from sage.all import ZZ [as 别名]
# 或者: from sage.all.ZZ import valuation [as 别名]
def factor_out_p(val, p):
    val = ZZ(val)
    if val == 0 or val == -1:
        return str(val)
    if val==1:
        return '+1'
    s = 1
    if val<0:
        s = -1
        val = -val
    ord = val.valuation(p)
    val = val/p**ord
    out = ''
    if s == -1:
        out += '-'
    else:
        out += '+'
    if ord==1:
        out +=  str(p)
    elif ord>1:
        out +=  '%d^{%d}' % (p, ord)
    if val>1:
        if ord ==1:
            out += r'\cdot '
        out += str(val)
    return out
开发者ID:sanni85,项目名称:lmfdb,代码行数:28,代码来源:main.py

示例2: twoadic

# 需要导入模块: from sage.all import ZZ [as 别名]
# 或者: from sage.all.ZZ import valuation [as 别名]
def twoadic(line):
    r""" Parses one line from a 2adic file.  Returns the label and a dict
    containing fields with keys '2adic_index', '2adic_log_level',
    '2adic_gens' and '2adic_label'.

    Input line fields:

    conductor iso number ainvs index level gens label

    Sample input lines:

    110005 a 2 [1,-1,1,-185793,29503856] 12 4 [[3,0,0,1],[3,2,2,3],[3,0,0,3]] X24
    27 a 1 [0,0,1,0,-7] inf inf [] CM
    """
    data = split(line)
    assert len(data)==8
    label = data[0] + data[1] + data[2]
    model = data[7]
    if model == 'CM':
        return label, {
            '2adic_index': int(0),
            '2adic_log_level': None,
            '2adic_gens': None,
            '2adic_label': None,
        }

    index = int(data[4])
    level = ZZ(data[5])
    log_level = int(level.valuation(2))
    assert 2**log_level==level
    if data[6]=='[]':
        gens=[]
    else:
        gens = data[6][1:-1].replace('],[','];[').split(';')
        gens = [[int(c) for c in g[1:-1].split(',')] for g in gens]

    return label, {
            '2adic_index': index,
            '2adic_log_level': log_level,
            '2adic_gens': gens,
            '2adic_label': model,
    }
开发者ID:AurelPage,项目名称:lmfdb,代码行数:44,代码来源:import_ec_data.py

示例3: GaloisRepresentation

# 需要导入模块: from sage.all import ZZ [as 别名]
# 或者: from sage.all.ZZ import valuation [as 别名]
class GaloisRepresentation( Lfunction):

    def __init__(self, thingy):
        """
        Class representing a L-function coming from a Galois representation.
        Typically, dirichlet characters, artin reps, elliptic curves,...
        can give rise to such a class.

        It can be used for tensor two such together (mul below) and a
        L-function class can be extracted from it.
        """

        # this is an important global variable.
        # it is the maximum of the imag parts of values s at
        # which we will compute L(s,.)
        self.max_imaginary_part = "40"

        if isinstance(thingy, sage.schemes.elliptic_curves.ell_rational_field.EllipticCurve_rational_field):
            self.init_elliptic_curve(thingy)

        elif isinstance(thingy, lmfdb.WebCharacter.WebDirichletCharacter):
            self.init_dir_char(thingy)

        elif isinstance(thingy, lmfdb.artin_representations.math_classes.ArtinRepresentation):
            self.init_artin_rep(thingy)

        elif (isinstance(thingy, list) and
              len(thingy) == 2 and
              isinstance(thingy[0],lmfdb.classical_modular_forms.web_newform.WebNewform) and
              isinstance(thingy[1],sage.rings.integer.Integer) ):
            self.init_elliptic_modular_form(thingy[0],thingy[1])

        elif (isinstance(thingy, list) and
              len(thingy) == 2 and
              isinstance(thingy[0], GaloisRepresentation) and
              isinstance(thingy[1], GaloisRepresentation) ):
            self.init_tensor_product(thingy[0], thingy[1])

        else:
            raise ValueError("GaloisRepresentations are currently not implemented for that type (%s) of objects"%type(thingy))

        # set a few common variables
        self.level = self.conductor
        self.degree = self.dim
        self.poles = []
        self.residues = []
        self.algebraic = True
        self.weight = self.motivic_weight + 1

## Various ways to construct such a class

    def init_elliptic_curve(self, E):
        """
        Returns the Galois rep of an elliptic curve over Q
        """

        self.original_object = [E]
        self.object_type = "ellipticcurve"
        self.dim = 2
        self.motivic_weight = 1
        self.conductor = E.conductor()
        self.bad_semistable_primes = [ fa[0] for fa in self.conductor.factor() if fa[1]==1 ]
        self.bad_pot_good = [p for p in self.conductor.prime_factors() if E.j_invariant().valuation(p) > 0 ]
        self.sign = E.root_number()
        self.mu_fe = []
        self.nu_fe = [ZZ(1)/ZZ(2)]
        self.gammaV = [0, 1]
        self.langlands = True
        self.selfdual = True
        self.primitive = True
        self.set_dokchitser_Lfunction()
        self.set_number_of_coefficients()
        self.coefficient_type = 2
        self.coefficient_period = 0
        self.besancon_bound = 50000
        self.ld.gp().quit()

        def eu(p):
            """
            Local Euler factor passed as a function
            whose input is a prime and
            whose output is a polynomial
            such that evaluated at p^-s,
            we get the inverse of the local factor
            of the L-function
            """
            R = PolynomialRing(QQ, "T")
            T = R.gens()[0]
            N = self.conductor
            if N % p != 0 : # good reduction
                return 1 - E.ap(p) * T + p * T**2
            elif N % (p**2) != 0: # multiplicative reduction
                return 1 - E.ap(p) * T
            else:
                return R(1)

        self.local_euler_factor = eu

    def init_dir_char(self, chi):
        """
#.........这里部分代码省略.........
开发者ID:koffie,项目名称:lmfdb,代码行数:103,代码来源:galois_reps.py


注:本文中的sage.all.ZZ.valuation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。