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


Python ZZ.prec方法代码示例

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


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

示例1: _element_constructor_

# 需要导入模块: from sage.rings.all import ZZ [as 别名]
# 或者: from sage.rings.all.ZZ import prec [as 别名]
    def _element_constructor_(self, x):
        r"""
        Return the element of the algebra ``self`` corresponding to ``x``.

        EXAMPLES::

            sage: S = SiegelModularFormsAlgebra(coeff_ring=QQ)
            sage: B = SiegelModularFormsAlgebra(coeff_ring=ZZ).1
            sage: S(B)
            Igusa_6
            sage: S(1/5)
            1/5
            sage: S(1/5).parent() is S
            True
            sage: S._element_constructor_(2.67)
            Traceback (most recent call last):
            ...
            TypeError: Unable to construct an element of Algebra of Siegel modular forms of degree 2 and even weights on Sp(4,Z) over Rational Field corresponding to 2.67000000000000
            sage: S.base_extend(RR)._element_constructor_(2.67)
            2.67000000000000
        """
        if isinstance(x, (int, long)):
            x = ZZ(x)
        if isinstance(x, float):
            from sage.rings.all import RR
            x = RR(x)
        if isinstance(x, complex):
            from sage.rings.all import CC
            x = CC(x)

        if isinstance(x.parent(), SiegelModularFormsAlgebra_class):
            d = dict((f, self.coeff_ring()(x[f])) for f in x.coeffs())
            return self.element_class(parent=self, weight=x.weight(), coeffs=d, prec=x.prec(), name=x.name())

        R = self.base_ring()
        if R.has_coerce_map_from(x.parent()):
            d = {(0, 0, 0): R(x)}
            from sage.rings.all import infinity
            return self.element_class(parent=self, weight=0, coeffs=d, prec=infinity, name=str(x))
        else:
            raise TypeError, "Unable to construct an element of %s corresponding to %s" %(self, x)
开发者ID:Alwnikrotikz,项目名称:purplesage,代码行数:43,代码来源:siegel_modular_forms_algebra.py

示例2: J_inv_ZZ

# 需要导入模块: from sage.rings.all import ZZ [as 别名]
# 或者: from sage.rings.all.ZZ import prec [as 别名]
    def J_inv_ZZ(self):
        r"""
        Return the rational Fourier expansion of ``J_inv``,
        where the parameter ``d`` is replaced by ``1``.

        This is the main function used to determine all Fourier expansions!

        .. NOTE:

        The Fourier expansion of ``J_inv`` for ``d!=1``
        is given by ``J_inv_ZZ(q/d)``.

        .. TODO:

          The functions that are used in this implementation are
          products of hypergeometric series with other, elementary,
          functions.  Implement them and clean up this representation.

        EXAMPLES::

            sage: from sage.modular.modform_hecketriangle.series_constructor import JFSeriesConstructor
            sage: JFSeriesConstructor(prec=3).J_inv_ZZ()
            q^-1 + 31/72 + 1823/27648*q + O(q^2)
            sage: JFSeriesConstructor(group=5, prec=3).J_inv_ZZ()
            q^-1 + 79/200 + 42877/640000*q + O(q^2)
            sage: JFSeriesConstructor(group=5, prec=3).J_inv_ZZ().parent()
            Laurent Series Ring in q over Rational Field

            sage: JFSeriesConstructor(group=infinity, prec=3).J_inv_ZZ()
            q^-1 + 3/8 + 69/1024*q + O(q^2)
        """

        F1       = lambda a,b:   self._qseries_ring(
                       [ ZZ(0) ]
                       + [
                           rising_factorial(a,k) * rising_factorial(b,k) / (ZZ(k).factorial())**2
                           * sum(ZZ(1)/(a+j) + ZZ(1)/(b+j) - ZZ(2)/ZZ(1+j)
                                  for j in range(ZZ(0),ZZ(k))
                             )
                           for k in range(ZZ(1), ZZ(self._prec+1))
                       ],
                       ZZ(self._prec+1)
                   )

        F        = lambda a,b,c: self._qseries_ring(
                       [
                         rising_factorial(a,k) * rising_factorial(b,k) / rising_factorial(c,k) / ZZ(k).factorial()
                         for k in range(ZZ(0), ZZ(self._prec+1))
                       ],
                       ZZ(self._prec+1)
                   )
        a        = self._group.alpha()
        b        = self._group.beta()
        Phi      = F1(a,b) / F(a,b,ZZ(1))
        q        = self._qseries_ring.gen()

        # the current implementation of power series reversion is slow
        # J_inv_ZZ = ZZ(1) / ((q*Phi.exp()).reversion())

        temp_f   = (q*Phi.exp()).polynomial()
        new_f    = temp_f.revert_series(temp_f.degree()+1)
        J_inv_ZZ = ZZ(1) / (new_f + O(q**(temp_f.degree()+1)))
        q        = self._series_ring.gen()
        J_inv_ZZ = sum([J_inv_ZZ.coefficients()[m] * q**J_inv_ZZ.exponents()[m] for m in range(len(J_inv_ZZ.coefficients()))]) + O(q**J_inv_ZZ.prec())

        return J_inv_ZZ
开发者ID:jjermann,项目名称:jacobi_forms,代码行数:68,代码来源:series_constructor.py


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