示例#1
0
    def inject_shorthands(self, shorthands = _shorthands):
        """
        Imports standard shorthands into the global namespace

        INPUT:

         - shorthands - a list (or iterable) of strings (default: ['e', 'h', 'm', 'p', 's'])

        EXAMPLES::

            sage: S = SymmetricFunctions(ZZ)
            sage: S.inject_shorthands()
            doctest:...: RuntimeWarning: redefining global value `e`
            doctest:...: RuntimeWarning: redefining global value `m`
            sage: s[1] + e[2] * p[1,1] + 2*h[3] + m[2,1]
            s[1] - 2*s[1, 1, 1] + s[1, 1, 1, 1] + s[2, 1] + 2*s[2, 1, 1] + s[2, 2] + 2*s[3] + s[3, 1]
            sage: e
            Symmetric Function Algebra over Integer Ring, Elementary symmetric functions as basis
            sage: p
            Symmetric Function Algebra over Integer Ring, Power symmetric functions as basis
            sage: s
            Symmetric Function Algebra over Integer Ring, Schur symmetric functions as basis

            sage: e == S.e(), h == S.h(), m == S.m(), p == S.p(), s == S.s()
            (True, True, True, True, True)

        One can also just import a subset of the shorthands::

            sage: S = SymmetricFunctions(QQ)
            sage: S.inject_shorthands(['p', 's'])
            doctest:...: RuntimeWarning: redefining global value `p`
            doctest:...: RuntimeWarning: redefining global value `s`
            sage: p
            Symmetric Function Algebra over Rational Field, Power symmetric functions as basis
            sage: s
            Symmetric Function Algebra over Rational Field, Schur symmetric functions as basis

        Note that ``e`` is left unchanged::

            sage: e
            Symmetric Function Algebra over Integer Ring, Elementary symmetric functions as basis
        """
        from sage.misc.misc import inject_variable
        for shorthand in shorthands:
            assert shorthand in self._shorthands
            inject_variable(shorthand, getattr(self, shorthand)())
示例#2
0
    def inject_shorthands(self, shorthands=_shorthands):
        """
        Imports standard shorthands into the global namespace

        INPUT:

        - ``shorthands`` -- a list (or iterable) of strings (default: ['e', 'h', 'm', 'p', 's'])

        EXAMPLES::

            sage: S = SymmetricFunctions(ZZ)
            sage: S.inject_shorthands()
            sage: s[1] + e[2] * p[1,1] + 2*h[3] + m[2,1]
            s[1] - 2*s[1, 1, 1] + s[1, 1, 1, 1] + s[2, 1] + 2*s[2, 1, 1] + s[2, 2] + 2*s[3] + s[3, 1]
            sage: e
            Symmetric Functions over Integer Ring in the elementary basis
            sage: p
            Symmetric Functions over Integer Ring in the powersum basis
            sage: s
            Symmetric Functions over Integer Ring in the Schur basis

            sage: e == S.e(), h == S.h(), m == S.m(), p == S.p(), s == S.s()
            (True, True, True, True, True)

        One can also just import a subset of the shorthands::

            sage: S = SymmetricFunctions(QQ)
            sage: S.inject_shorthands(['p', 's'])
            sage: p
            Symmetric Functions over Rational Field in the powersum basis
            sage: s
            Symmetric Functions over Rational Field in the Schur basis

        Note that ``e`` is left unchanged::

            sage: e
            Symmetric Functions over Integer Ring in the elementary basis
        """
        from sage.misc.misc import inject_variable
        for shorthand in shorthands:
            assert shorthand in self._shorthands
            inject_variable(shorthand, getattr(self, shorthand)())
示例#3
0
文件: sf.py 项目: sageb0t/testsage
    def inject_shorthands(self, shorthands = _shorthands):
        """
        Imports standard shorthands into the global namespace

        INPUT:

        - ``shorthands`` -- a list (or iterable) of strings (default: ['e', 'h', 'm', 'p', 's'])

        EXAMPLES::

            sage: S = SymmetricFunctions(ZZ)
            sage: S.inject_shorthands()
            sage: s[1] + e[2] * p[1,1] + 2*h[3] + m[2,1]
            s[1] - 2*s[1, 1, 1] + s[1, 1, 1, 1] + s[2, 1] + 2*s[2, 1, 1] + s[2, 2] + 2*s[3] + s[3, 1]
            sage: e
            Symmetric Functions over Integer Ring in the elementary basis
            sage: p
            Symmetric Functions over Integer Ring in the powersum basis
            sage: s
            Symmetric Functions over Integer Ring in the Schur basis

            sage: e == S.e(), h == S.h(), m == S.m(), p == S.p(), s == S.s()
            (True, True, True, True, True)

        One can also just import a subset of the shorthands::

            sage: S = SymmetricFunctions(QQ)
            sage: S.inject_shorthands(['p', 's'])
            sage: p
            Symmetric Functions over Rational Field in the powersum basis
            sage: s
            Symmetric Functions over Rational Field in the Schur basis

        Note that ``e`` is left unchanged::

            sage: e
            Symmetric Functions over Integer Ring in the elementary basis
        """
        from sage.misc.misc import inject_variable
        for shorthand in shorthands:
            assert shorthand in self._shorthands
            inject_variable(shorthand, getattr(self, shorthand)())
示例#4
0
    def fusion_labels(self, labels=None, inject_variables=False):
        r"""
        Set the labels of the basis.

        INPUT:

        - ``labels`` -- (default: ``None``) a list of strings or string
        - ``inject_variables`` -- (default: ``False``) if ``True``, then
          inject the variable names into the global namespace; note that
          this could override objects already defined

        If ``labels`` is a list, the length of the list must equal the
        number of basis elements. These become the names of
        the basis elements.

        If ``labels`` is a string, this is treated as a prefix and a
        list of names is generated.

        If ``labels`` is ``None``, then this resets the labels to the default.

        EXAMPLES::

            sage: A13 = FusionRing("A1", 3)
            sage: A13.fusion_labels("x")
            sage: fb = list(A13.basis()); fb
            [x0, x1, x2, x3]
            sage: Matrix([[x*y for y in A13.basis()] for x in A13.basis()])
            [     x0      x1      x2      x3]
            [     x1 x0 + x2 x1 + x3      x2]
            [     x2 x1 + x3 x0 + x2      x1]
            [     x3      x2      x1      x0]

        We give an example where the variables are injected into the
        global namepsace::

            sage: A13.fusion_labels("y", inject_variables=True)
            sage: y0
            y0
            sage: y0.parent() is A13
            True

        We reset the labels to the default::

            sage: A13.fusion_labels()
            sage: fb
            [A13(0), A13(1), A13(2), A13(3)]
            sage: y0
            A13(0)
        """
        if labels is None:
            # Remove the fusion labels
            self._fusion_labels = None
            return

        B = self.basis()
        if isinstance(labels, str):
            labels = [labels + str(k) for k in range(len(B))]
        elif len(labels) != len(B):
            raise ValueError('invalid data')

        d = {}
        ac = self.simple_coroots()
        for j, b in enumerate(self.get_order()):
            t = tuple([b.inner_product(x) for x in ac])
            d[t] = labels[j]
            if inject_variables:
                inject_variable(labels[j], B[b])
        self._fusion_labels = d