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


Python QQ.sqrt方法代码示例

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


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

示例1: get_satake_parameters

# 需要导入模块: from sage.all import QQ [as 别名]
# 或者: from sage.all.QQ import sqrt [as 别名]
def get_satake_parameters(k, N=1, chi=0, fi=0, prec=10, bits=53, angles=False):
    r""" Compute the Satake parameters and return an html-table.

    INPUT:
    - ''k'' -- positive integer : the weight
    - ''N'' -- positive integer (default 1) : level
    - ''chi'' -- non-neg. integer (default 0) use character nr. chi    - ''fi'' -- non-neg. integer (default 0) We want to use the element nr. fi f=Newforms(N,k)[fi]
    -''prec'' -- compute parameters for p <=prec
    -''bits'' -- do real embedings intoi field of bits precision
    -''angles''-- return the angles t_p instead of the alpha_p
                  here alpha_p=p^((k-1)/2)exp(i*t_p)

    """
    (t, f) = _get_newform(k, N, chi, fi)
    if(not t):
        return f
    K = f.base_ring()
    RF = RealField(bits)
    CF = ComplexField(bits)
    if(K != QQ):
        M = len(K.complex_embeddings())
        ems = dict()
        for j in range(M):
            ems[j] = list()
    ps = prime_range(prec)
    alphas = list()
    for p in ps:
        ap = f.coefficients(ZZ(prec))[p]
        if(K == QQ):
            f1 = QQ(4 * p ** (k - 1) - ap ** 2)
            alpha_p = (QQ(ap) + I * f1.sqrt()) / QQ(2)
            # beta_p=(QQ(ap)-I*f1.sqrt())/QQ(2)
            # satake[p]=(alpha_p,beta_p)
            ab = RF(p ** ((k - 1) / 2))
            norm_alpha = alpha_p / ab
            t_p = CF(norm_alpha).argument()
            if(angles):
                alphas.append(t_p)
            else:
                alphas.append(alpha_p)

        else:
            for j in range(M):
                app = ap.complex_embeddings(bits)[j]
                f1 = (4 * p ** (k - 1) - app ** 2)
                alpha_p = (app + I * f1.sqrt()) / RealField(bits)(2)
                ab = RF(p ** ((k - 1) / 2))
                norm_alpha = alpha_p / ab
                t_p = CF(norm_alpha).argument()
                if(angles):
                    ems[j].append(t_p)
                else:
                    ems[j].append(alpha_p)

    tbl = dict()
    tbl['headersh'] = ps
    if(K == QQ):
        tbl['headersv'] = [""]
        tbl['data'] = [alphas]
        tbl['corner_label'] = "$p$"
    else:
        tbl['data'] = list()
        tbl['headersv'] = list()
        tbl['corner_label'] = "Embedding \ $p$"
        for j in ems.keys():
            tbl['headersv'].append(j)
            tbl['data'].append(ems[j])
    # logger.debug(tbl)
    s = html_table(tbl)
    return s
开发者ID:arbooker,项目名称:lmfdb,代码行数:72,代码来源:emf_core.py

示例2: compute_satake_parameters_numeric

# 需要导入模块: from sage.all import QQ [as 别名]
# 或者: from sage.all.QQ import sqrt [as 别名]
    def compute_satake_parameters_numeric(self, prec=10, bits=53,insert_in_db=True):
        r""" Compute the Satake parameters and return an html-table.

        We only do satake parameters for primes p primitive to the level.
        By defintion the S. parameters are given as the roots of
         X^2 - c(p)X + chi(p)*p^(k-1) if (p,N)=1

        INPUT:
        -''prec'' -- compute parameters for p <=prec
        -''bits'' -- do real embedings intoi field of bits precision

        """
        if self.character().order()>2:
            ## We only implement this for trival or quadratic characters.
            ## Otherwise there is difficulty to figure out what the embeddings mean... 
            return 
        K = self.coefficient_field()
        degree = self.degree()
        RF = RealField(bits)
        CF = ComplexField(bits)
        ps = prime_range(prec)

        self._satake['ps'] = []
        alphas = dict()
        thetas = dict()
        aps = list()
        tps = list()
        k = self.weight()

        for j in range(degree):
            alphas[j] = dict()
            thetas[j] = dict()
        for j in xrange(len(ps)):
            p = ps[j]
            try:
                ap = self.coefficient(p) 
            except IndexError:
                break
            # Remove bad primes
            if p.divides(self.level()):
                continue
            self._satake['ps'].append(p)
            chip = self.character().value(p)
            wmf_logger.debug("p={0}".format(p))
            wmf_logger.debug("chip={0} of type={1}".format(chip,type(chip)))
            if hasattr(chip,'complex_embeddings'):
                wmf_logger.debug("embeddings(chip)={0}".format(chip.complex_embeddings()))
            wmf_logger.debug("ap={0}".format(ap))
            wmf_logger.debug("K={0}".format(K))                        
            
            # ap=self._f.coefficients(ZZ(prec))[p]
            if K.absolute_degree()==1:
                f1 = QQ(4 * chip * p ** (k - 1) - ap ** 2)
                alpha_p = (QQ(ap) + I * f1.sqrt()) / QQ(2)
                ab = RF(p ** ((k - 1) / 2))
                norm_alpha = alpha_p / ab
                t_p = CF(norm_alpha).argument()
                thetas[0][p] = t_p
                alphas[0][p] = (alpha_p / ab).n(bits)
            else:
                for jj in range(degree):
                    app = ap.complex_embeddings(bits)[jj]
                    wmf_logger.debug("chip={0}".format(chip))
                    wmf_logger.debug("app={0}".format(app))
                    wmf_logger.debug("jj={0}".format(jj))            
                    if not hasattr(chip,'complex_embeddings'):
                        f1 = (4 * CF(chip) * p ** (k - 1) - app ** 2)
                    else:
                        f1 = (4 * chip.complex_embeddings(bits)[jj] * p ** (k - 1) - app ** 2)
                    alpha_p = (app + I * abs(f1).sqrt())
                    # ab=RF(/RF(2)))
                    # alpha_p=alpha_p/RealField(bits)(2)
                    wmf_logger.debug("f1={0}".format(f1))
                    
                    alpha_p = alpha_p / RF(2)
                    wmf_logger.debug("alpha_p={0}".format(alpha_p))                    
                    t_p = CF(alpha_p).argument()
                    # tps.append(t_p)
                    # aps.append(alpha_p)
                    alphas[jj][p] = alpha_p
                    thetas[jj][p] = t_p
        self._satake['alphas'] = alphas
        self._satake['thetas'] = thetas
        self._satake['alphas_latex'] = dict()
        self._satake['thetas_latex'] = dict()
        for j in self._satake['alphas'].keys():
            self._satake['alphas_latex'][j] = dict()
            for p in self._satake['alphas'][j].keys():
                s = latex(self._satake['alphas'][j][p])
                self._satake['alphas_latex'][j][p] = s
        for j in self._satake['thetas'].keys():
            self._satake['thetas_latex'][j] = dict()
            for p in self._satake['thetas'][j].keys():
                s = latex(self._satake['thetas'][j][p])
                self._satake['thetas_latex'][j][p] = s

        wmf_logger.debug("satake=".format(self._satake))
        return self._satake
开发者ID:sehlen,项目名称:modforms-db,代码行数:100,代码来源:web_modforms_computing.py


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