• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python misc.repr_lincomb函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sage.misc.misc.repr_lincomb函数的典型用法代码示例。如果您正苦于以下问题:Python repr_lincomb函数的具体用法?Python repr_lincomb怎么用?Python repr_lincomb使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: _repr_

        def _repr_(self):
            r"""
            Return a string representation of ``self``.

            Supports printing in exponential coordinates of the first and
            second kinds, depending on the default coordinate system.

            EXAMPLES::

                sage: L = LieAlgebra(QQ, 2, step=2)
                sage: G = L.lie_group('H')
                sage: g = G.point([1, 2, 3]); g
                exp(X_1 + 2*X_2 + 3*X_12)
                sage: G.set_default_chart(G.chart_exp2())
                sage: g
                exp(4*X_12)exp(2*X_2)exp(X_1)
            """
            G = self.parent()
            chart = G.default_chart()
            if chart != G._Exp1:
                if chart != G.chart_exp2():
                    chart = G._Exp1

            x = self.coordinates(chart=chart)
            B = G.lie_algebra().basis()
            nonzero_pairs = [(Xk, xk) for Xk, xk in zip(B, x) if xk]

            if chart == G._Exp1:
                s = repr_lincomb(nonzero_pairs)
            else:
                s = ")exp(".join(repr_lincomb([(Xk, xk)])
                                 for Xk, xk in reversed(nonzero_pairs))
                if not s:
                    s = "0"
            return "exp(%s)" % s
开发者ID:sagemath,项目名称:sage,代码行数:35,代码来源:nilpotent_lie_group.py


示例2: __repr__

    def __repr__(self):
        """
        EXAMPLES::
        
            sage: L = LazyPowerSeriesRing(QQ)
            sage: s = L(); s._name = 's'; s
            s
        
        ::
        
            sage: L()
            Uninitialized lazy power series
        
        ::
        
            sage: a = L([1,2,3])
            sage: a
            O(1)
            sage: a.compute_coefficients(2)
            sage: a
            1 + 2*x + 3*x^2 + O(x^3)
            sage: a.compute_coefficients(4)
            sage: a
            1 + 2*x + 3*x^2 + 3*x^3 + 3*x^4 + 3*x^5 + ...
        
        ::
        
            sage: a = L([1,2,3,0])
            sage: a.compute_coefficients(5)
            sage: a
            1 + 2*x + 3*x^2
        """
        if self._name is not None:
            return self._name

        if self.is_initialized:
            n = len(self._stream)
            x = self.parent()._name
            baserepr = repr_lincomb(self._get_repr_info(x))
            if self._stream.is_constant():
                if self._stream[n - 1] == 0:
                    l = baserepr
                else:
                    l = (
                        baserepr
                        + " + "
                        + repr_lincomb([(x + "^" + str(i), self._stream[n - 1]) for i in range(n, n + 3)])
                        + " + ..."
                    )
            else:
                l = baserepr + " + O(x^%s)" % n if n > 0 else "O(1)"
        else:
            l = "Uninitialized lazy power series"
        return l
开发者ID:pombredanne,项目名称:sage-1,代码行数:54,代码来源:series.py


示例3: _repr_

    def _repr_(self):
        """
        Return string representation of self.
        
        EXAMPLES::
        
            sage: A.<x,y,z>=FreeAlgebra(ZZ,3)
            sage: repr(-x+3*y*z)
            '-x + 3*y*z'

        Trac ticket #11068 enables the use of local variable names::

            sage: from sage.structure.parent_gens import localvars
            sage: with localvars(A, ['a','b','c']):
            ...    print -x+3*y*z
            ...
            -a + 3*b*c

        """
        v = self.__monomial_coefficients.items()
        v.sort()
        mons = [ m for (m, _) in v ]
        cffs = [ x for (_, x) in v ]
        P = self.parent()
        M = P.monoid()
        from sage.structure.parent_gens import localvars
        with localvars(M, P.variable_names(), normalize=False):
            x = repr_lincomb(mons, cffs).replace("*1 "," ")
        if x[len(x)-2:] == "*1":
            return x[:len(x)-2]
        else:
            return x
开发者ID:ppurka,项目名称:sagelib,代码行数:32,代码来源:free_algebra_element.py


示例4: _repr_

    def _repr_(self):
        """
        Return string representation of self.

        EXAMPLES::

            sage: A.<x,y,z>=FreeAlgebra(ZZ,3)
            sage: repr(-x+3*y*z)    # indirect doctest
            '-x + 3*y*z'

        Trac ticket :trac:`11068` enables the use of local variable names::

            sage: from sage.structure.parent_gens import localvars
            sage: with localvars(A, ['a','b','c']):
            ....:    print(-x+3*y*z)
            -a + 3*b*c

        """
        v = sorted(self._monomial_coefficients.items())
        P = self.parent()
        M = P.monoid()
        from sage.structure.parent_gens import localvars
        with localvars(M, P.variable_names(), normalize=False):
            x = repr_lincomb(v, strip_one=True)
        return x
开发者ID:robertwb,项目名称:sage,代码行数:25,代码来源:free_algebra_element.py


示例5: _latex_

    def _latex_(self):
        r"""
        Return a LaTeX representation of ``self``.

        OUTPUT:

        - string.

        TESTS::

            sage: R.<x, y> = ZZ[]
            sage: S = Spec(R)
            sage: from sage.schemes.generic.divisor import Divisor_generic
            sage: from sage.schemes.generic.divisor_group import DivisorGroup
            sage: Div = DivisorGroup(S)
            sage: D = Divisor_generic([(4, x), (-5, y), (1, x+2*y)], Div)
            sage: D._latex_()
            '\\mathrm{V}\\left(x + 2 y\\right)
            + 4\\mathrm{V}\\left(x\\right)
            + \\left(-5\\right)\\mathrm{V}\\left(y\\right)'
        """
        # The code is copied from _repr_ with latex adjustments
        terms = list(self)
        # We sort the terms by variety. The order is "reversed" to keep it
        # straight - as the test above demonstrates, it results in the first
        # generator being in front of the second one
        terms.sort(key=lambda x: x[1], reverse=True)
        return repr_lincomb([(r"\mathrm{V}\left(%s\right)" % latex(v), c) for c,v in terms],
                            is_latex=True)
开发者ID:chos9,项目名称:sage,代码行数:29,代码来源:divisor.py


示例6: _repr_

    def _repr_(self):
        r"""
        Return a string representation of ``self``.

        OUTPUT:

        - string.

        TESTS::

            sage: R.<x, y> = ZZ[]
            sage: S = Spec(R)
            sage: from sage.schemes.generic.divisor import Divisor_generic
            sage: from sage.schemes.generic.divisor_group import DivisorGroup
            sage: Div = DivisorGroup(S)
            sage: D = Divisor_generic([(4, x), (-5, y), (1, x+2*y)], Div)
            sage: D._repr_()
            'V(x + 2*y) + 4*V(x) - 5*V(y)'
        """
        # The default representation coming from formal sums does not look
        # very nice for divisors
        terms = list(self)
        # We sort the terms by variety. The order is "reversed" to keep it
        # straight - as the test above demonstrates, it results in the first
        # generator being in front of the second one
        terms.sort(key=lambda x: x[1], reverse=True)
        return repr_lincomb([("V(%s)" % v, c) for c,v in terms])
开发者ID:chos9,项目名称:sage,代码行数:27,代码来源:divisor.py


示例7: _repr_

    def _repr_(self):
        """
        Return the string representation of self.

        EXAMPLES::

            sage: ModularSymbols(Gamma0(11), 2).boundary_space()(Cusp(0))._repr_()
            '[0]'
            sage: (-6*ModularSymbols(Gamma0(11), 2).boundary_space()(Cusp(0)))._repr_()
            '-6*[0]'
        """
        return repr_lincomb([ ('[' + repr(self.parent()._known_gens[i]) + ']', c) for i,c in self.__x.items() ])
开发者ID:saraedum,项目名称:sage-renamed,代码行数:12,代码来源:boundary.py


示例8: __repr__

    def __repr__(self):
        """
        EXAMPLES::

            sage: s = sage.combinat.combinatorial_algebra.TestAlgebra(QQ)
            sage: a = 2 + s([3,2,1])
            sage: print(a.__repr__())
            2*s[] + s[3, 2, 1]
        """
        v = sorted(self._monomial_coefficients.items())
        prefix = self.parent().prefix()
        retur = repr_lincomb( [(prefix + repr(m), c) for m,c in v ], strip_one = True)
开发者ID:mcognetta,项目名称:sage,代码行数:12,代码来源:combinatorial_algebra.py


示例9: _latex_

    def _latex_(self):
        """
        EXAMPLES::

            sage: H, (i,j,k) = sage.algebras.free_algebra_quotient.hamilton_quatalg(QQ)
            sage: ((2/3)*i - j)._latex_()
            '\\frac{2}{3}i - j'
        """
        Q = self.parent()
        M = Q.monoid()
        with localvars(M, Q.variable_names()):
            cffs = tuple(self.__vector)
            mons = Q.monomial_basis()
            return repr_lincomb(zip(mons, cffs), is_latex=True, strip_one=True)
开发者ID:BlairArchibald,项目名称:sage,代码行数:14,代码来源:free_algebra_quotient_element.py


示例10: _repr_

    def _repr_(self):
        """
        EXAMPLES::

            sage: H, (i,j,k) = sage.algebras.free_algebra_quotient.hamilton_quatalg(ZZ)
            sage: i._repr_()
            'i'
        """
        Q = self.parent()
        M = Q.monoid()
        with localvars(M, Q.variable_names()):
            cffs = list(self.__vector)
            mons = Q.monomial_basis()
            return repr_lincomb(zip(mons, cffs), strip_one=True)
开发者ID:BlairArchibald,项目名称:sage,代码行数:14,代码来源:free_algebra_quotient_element.py


示例11: _latex_

    def _latex_(self):
        r"""
        Return latex representation of self.

        EXAMPLES::

            sage: A.<x,y,z>=FreeAlgebra(ZZ,3)
            sage: latex(-x+3*y^20*z)   # indirect doctest
            -x + 3y^{20}z
            sage: alpha,beta,gamma=FreeAlgebra(ZZ,3,'alpha,beta,gamma').gens()
            sage: latex(alpha-beta)
            \alpha - \beta
        """
        v = sorted(self._monomial_coefficients.items())
        return repr_lincomb(v, strip_one=True, is_latex=True)
开发者ID:robertwb,项目名称:sage,代码行数:15,代码来源:free_algebra_element.py


示例12: _latex_

 def _latex_(self):
     r"""
     Return latex representation of self.
     
     EXAMPLES::
     
         sage: A.<x,y,z>=FreeAlgebra(ZZ,3)
         sage: latex(-x+3*y^20*z)
         \left(-1\right)x + 3y^{20}z
         sage: alpha,beta,gamma=FreeAlgebra(ZZ,3,'alpha,beta,gamma').gens()
         sage: latex(alpha-beta)
         \alpha + \left(-1\right)\beta
     """
     v = self.__monomial_coefficients.items()
     v.sort()
     return repr_lincomb(v, strip_one=True, is_latex=True)
开发者ID:jwbober,项目名称:sagelib,代码行数:16,代码来源:free_algebra_element.py


示例13: _latex_

    def _latex_(self):
        """
        EXAMPLES::

            sage: H, (i,j,k) = sage.algebras.free_algebra_quotient.hamilton_quatalg(QQ)
            sage: ((2/3)*i - j)._latex_()
            '\\frac{2}{3}i + \\left(-1\\right)j'        
        """
        Q = self.parent()
        M = Q.monoid()
        with localvars(M, Q.variable_names()):
            cffs = list(self.__vector)
            mons = Q.monomial_basis()
            x = repr_lincomb(mons, cffs, True).replace("*1 "," ")
            if x[len(x)-2:] == "*1":
                return x[:len(x)-2]
            else:
                return x
开发者ID:ppurka,项目名称:sagelib,代码行数:18,代码来源:free_algebra_quotient_element.py


示例14: _repr_

    def _repr_(self):
        """
        EXAMPLES::

            sage: H, (i,j,k) = sage.algebras.free_algebra_quotient.hamilton_quatalg(ZZ)
            sage: i._repr_()
            'i'
        """
        Q = self.parent()
        M = Q.monoid()
        with localvars(M, Q.variable_names()):
            cffs = list(self.__vector)
            mons = Q.monomial_basis()
            x = repr_lincomb(mons, cffs).replace("*1 "," ")
            if x[len(x)-2:] == "*1":
                return x[:len(x)-2]
            else:
                return x
开发者ID:ppurka,项目名称:sagelib,代码行数:18,代码来源:free_algebra_quotient_element.py


示例15: __repr__

 def __repr__(self):
     """
     EXAMPLES::
         sage: R.<u,v,w,z> = = FormalMultivariatePowerSeriesRing(QQ)
         sage: L = R([[],[(1,[1,0,0,0]),(3,[0,0,1,0])],[(1,[1,1,0,0]),(-5,[0,0,0,2])],[],[(1,[0,3,0,2])],[]])
         sage: L.coefficients(5)
         sage: L
         u + 3*w + u*v + (-5)*z^2 + v^3*z^2
     """
     if self._name is not None:
         return self._name
     
     if self.is_initialized:
         n = len(self._stream)
         x = self.parent()._names
         l = repr_lincomb(self._get_repr_info())
     else:
         l = 'Uninitialized formal multivariate power series'
     return l
开发者ID:MatthieuDien,项目名称:PSTL-SAGE-Gfun,代码行数:19,代码来源:multivariate_series.py


示例16: _latex_

 def _latex_(self):
     r"""
     Return latex representation of self.
     
     EXAMPLES::
     
         sage: A.<x,y,z>=FreeAlgebra(ZZ,3)
         sage: latex(-x+3*y^20*z)
         \left(-1\right)x + 3y^{20}z
         sage: alpha,beta,gamma=FreeAlgebra(ZZ,3,'alpha,beta,gamma').gens()
         sage: latex(alpha-beta)
         \alpha + \left(-1\right)\beta
     """
     v = self.__monomial_coefficients.items()
     v.sort()
     mons = [ m for (m, _) in v ]
     cffs = [ x for (_, x) in v ]
     x = repr_lincomb(mons, cffs,is_latex=True)
     return x
开发者ID:ppurka,项目名称:sagelib,代码行数:19,代码来源:free_algebra_element.py


示例17: __repr__

 def __repr__(self):
     """
     EXAMPLES::
     
         sage: s = sage.combinat.combinatorial_algebra.TestAlgebra(QQ)
         sage: a = 2 + s([3,2,1])
         sage: print a.__repr__()
         2*s[] + s[3, 2, 1]
     """
     v = self._monomial_coefficients.items()
     v.sort()
     prefix = self.parent().prefix()
     mons = [ prefix + repr(m) for (m, _) in v ]
     cffs = [ x for (_, x) in v ]
     x = repr_lincomb(mons, cffs).replace("*1 "," ")
     if x[len(x)-2:] == "*1":
         return x[:len(x)-2]
     else:
         return x
开发者ID:ppurka,项目名称:sagelib,代码行数:19,代码来源:combinatorial_algebra.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python misc.sage_makedirs函数代码示例发布时间:2022-05-27
下一篇:
Python misc.prod函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap