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


Python misc.repr_lincomb函数代码示例

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


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


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