Пример #1
0
    def __init__(self,
                 A,
                 stream=None,
                 order=None,
                 aorder=None,
                 aorder_changed=True,
                 is_initialized=False,
                 name=None):
        """
        EXAMPLES::

            sage: L = LazyPowerSeriesRing(QQ)
            sage: f = L()
            sage: loads(dumps(f))
            Uninitialized lazy power series
        """
        AlgebraElement.__init__(self, A)
        self._stream = stream
        self.order = unk if order is None else order
        self.aorder = unk if aorder is None else aorder
        if self.aorder == inf:
            self.order = inf
        self.aorder_changed = aorder_changed
        self.is_initialized = is_initialized
        self._zero = A.base_ring().zero_element()
        self._name = name
Пример #2
0
    def __init__(self, parent, x, check):
        r""" Create an element of the parent group algebra. Not intended to be
        called by the user; see GroupAlgebra.__call__ for examples and
        doctests."""
        AlgebraElement.__init__(self, parent)

        if not hasattr(x, 'parent'):
            x = IntegerRing(
            )(x)  # occasionally coercion framework tries to pass a Python int

        if isinstance(x, FormalSum):
            if check:
                for c, d in x._data:
                    if d.parent() != self.parent().group():
                        raise TypeError("%s is not an element of group %s" %
                                        (d, self.parent().group()))
                self._fs = x
            else:
                self._fs = x

        elif self.base_ring().has_coerce_map_from(x.parent()):
            self._fs = self.parent()._formal_sum_module([
                (x, self.parent().group()(1))
            ])
        elif self.parent().group().has_coerce_map_from(x.parent()):
            self._fs = self.parent()._formal_sum_module([
                (1, self.parent().group()(x))
            ])
        else:
            raise TypeError(
                "Don't know how to create an element of %s from %s" %
                (self.parent(), x))
 def __init__(self, A, x):
     """
     Create the element x of the FreeAlgebra A.
     """
     if isinstance(x, FreeAlgebraElement):
         x = x.__monomial_coefficients
     AlgebraElement.__init__(self, A)
     R = A.base_ring()
     if isinstance(x, AlgebraElement): #and x.parent() == A.base_ring():
         self.__monomial_coefficients = { A.monoid()(1):R(x) } 
     elif isinstance(x, FreeMonoidElement):
         self.__monomial_coefficients = { x:R(1) }
     elif True:
         self.__monomial_coefficients = dict([ (A.monoid()(e1),R(e2)) for e1,e2 in x.items()])
     else:
         raise TypeError("Argument x (= %s) is of the wrong type."%x)
Пример #4
0
    def __init__(self, A, stream=None, order=None, aorder=None, aorder_changed=True, is_initialized=False, name=None):
        """
        EXAMPLES::

            sage: L = LazyPowerSeriesRing(QQ)
            sage: f = L()
            sage: loads(dumps(f))
            Uninitialized lazy power series
        """
        AlgebraElement.__init__(self, A)
        self._stream = stream
        self.order = unk if order is None else order
        self.aorder = unk if aorder is None else aorder
        if self.aorder == inf:
            self.order = inf
        self.aorder_changed = aorder_changed
        self.is_initialized = is_initialized
        self._zero = A.base_ring().zero_element()
        self._name = name
 def __init__(self, parent, precision, coefficient_function, components, bounding_precision ) :
     r"""
     INPUT:
         - ``parent``       -- An instance of :class:~`fourier_expansion_framework.monoidpowerseries.monoidpowerseries_ambient.MonoidPowerSeriesAmbient_abstract`.
         - ``precision``    -- A filter for the parent's action.
         - ``coefficient_function`` -- A function returning for each pair of characters and
                                       monoid element a Fourier coefficients.
         - ``components``   -- ``None`` or a list of characters. A list of components that do not
                               vanish. If ``None`` no component is assumed to be zero.
     
     TESTS::
         sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_lazyelement import *
         sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_ring import *
         sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_basicmonoids import *
         sage: emps = EquivariantMonoidPowerSeriesRing( NNMonoid(), TrivialCharacterMonoid("1", QQ), TrivialRepresentation("1", QQ) )
         sage: h = EquivariantMonoidPowerSeries_algebraelement_lazy(emps, emps.action().filter(3), lambda (ch, k) : 1, None, None)
     """
     AlgebraElement.__init__(self, parent)
     EquivariantMonoidPowerSeries_abstract_lazy.__init__(self, parent, precision,
              coefficient_function, components, bounding_precision)
 def __init__(self, parent, polynomial) :
     """
     INPUT:
         - ``parent``     -- An instance of :class:~`fourier_expansion_framework.gradedexpansions.gradedexpansion_ring.GradedExpansionRing_class`.
         - ``polynomial`` -- A polynomial in the polynomial ring underlying the parent.
     
     TESTS::
         sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_basicmonoids import *
         sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_ring import *
         sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_element import *
         sage: from psage.modform.fourier_expansion_framework.gradedexpansions.gradedexpansion_grading import DegreeGrading
         sage: from psage.modform.fourier_expansion_framework.gradedexpansions.gradedexpansion_ring import *
         sage: from psage.modform.fourier_expansion_framework.gradedexpansions.gradedexpansion_element import *
         sage: mps = MonoidPowerSeriesRing(QQ, NNMonoid(False))
         sage: P.<a,b> = QQ[]
         sage: ger = GradedExpansionRing_class(Sequence([MonoidPowerSeries(mps, {1: 1}, mps.monoid().filter(4))]), Sequence([MonoidPowerSeries(mps, {1: 1, 2: 3}, mps.monoid().filter(4))]), P.ideal(a - b), DegreeGrading((1,2)))
         sage: h = GradedExpansion_class(ger, a^2)
     """
     AlgebraElement.__init__(self, parent)
     GradedExpansion_abstract.__init__(self, parent, polynomial)        
Пример #7
0
 def __init__(self, parent, precision, coefficient_function, components,
              bounding_precision):
     r"""
     INPUT:
         - ``parent``       -- An instance of :class:~`fourier_expansion_framework.monoidpowerseries.monoidpowerseries_ambient.MonoidPowerSeriesAmbient_abstract`.
         - ``precision``    -- A filter for the parent's action.
         - ``coefficient_function`` -- A function returning for each pair of characters and
                                       monoid element a Fourier coefficients.
         - ``components``   -- ``None`` or a list of characters. A list of components that do not
                               vanish. If ``None`` no component is assumed to be zero.
     
     TESTS::
         sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_lazyelement import *
         sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_ring import *
         sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_basicmonoids import *
         sage: emps = EquivariantMonoidPowerSeriesRing( NNMonoid(), TrivialCharacterMonoid("1", QQ), TrivialRepresentation("1", QQ) )
         sage: h = EquivariantMonoidPowerSeries_algebraelement_lazy(emps, emps.action().filter(3), lambda (ch, k) : 1, None, None)
     """
     AlgebraElement.__init__(self, parent)
     EquivariantMonoidPowerSeries_abstract_lazy.__init__(
         self, parent, precision, coefficient_function, components,
         bounding_precision)
Пример #8
0
    def __init__(self, A, x):
        """
        Create the element ``x`` of the FreeAlgebra ``A``.

        TESTS::

            sage: F.<x,y,z> = FreeAlgebra(QQ, 3)
            sage: elt = x^3 * y - z^2*x
            sage: TestSuite(elt).run()
        """
        if isinstance(x, FreeAlgebraElement):
            x = x.__monomial_coefficients
        AlgebraElement.__init__(self, A)
        R = A.base_ring()
        if isinstance(x, AlgebraElement): #and x.parent() == A.base_ring():
            self.__monomial_coefficients = { A.monoid()(1):R(x) }
        elif isinstance(x, FreeMonoidElement):
            self.__monomial_coefficients = { x:R(1) }
        elif True:
            self.__monomial_coefficients = dict([ (A.monoid()(e1),R(e2)) for e1,e2 in x.items()])
        else:
            raise TypeError("Argument x (= %s) is of the wrong type."%x)
Пример #9
0
    def __init__(self, A, x):
        """
        Create the element ``x`` of the FreeAlgebra ``A``.

        TESTS::

            sage: F.<x,y,z> = FreeAlgebra(QQ, 3)
            sage: elt = x^3 * y - z^2*x
            sage: TestSuite(elt).run()
        """
        if isinstance(x, FreeAlgebraElement):
            x = x.__monomial_coefficients
        AlgebraElement.__init__(self, A)
        R = A.base_ring()
        if isinstance(x, AlgebraElement):  #and x.parent() == A.base_ring():
            self.__monomial_coefficients = {A.monoid()(1): R(x)}
        elif isinstance(x, FreeMonoidElement):
            self.__monomial_coefficients = {x: R(1)}
        elif True:
            self.__monomial_coefficients = dict([(A.monoid()(e1), R(e2))
                                                 for e1, e2 in x.items()])
        else:
            raise TypeError("Argument x (= %s) is of the wrong type." % x)
Пример #10
0
    def __init__(self, parent, x, check):
        r""" Create an element of the parent group algebra. Not intended to be
        called by the user; see GroupAlgebra.__call__ for examples and
        doctests."""
        AlgebraElement.__init__(self, parent)

        if not hasattr(x, 'parent'):
            x = IntegerRing()(x) # occasionally coercion framework tries to pass a Python int

        if isinstance(x, FormalSum):
            if check:
                for c,d in x._data:
                    if d.parent() != self.parent().group():
                        raise TypeError("%s is not an element of group %s" % (d, self.parent().group()))
                self._fs = x
            else:
                self._fs = x

        elif self.base_ring().has_coerce_map_from(x.parent()):
            self._fs = self.parent()._formal_sum_module([ (x, self.parent().group()(1)) ])
        elif self.parent().group().has_coerce_map_from(x.parent()):
            self._fs = self.parent()._formal_sum_module([ (1, self.parent().group()(x)) ])
        else:
            raise TypeError("Don't know how to create an element of %s from %s" % (self.parent(), x))
    def __init__(self, A, x):
        """
        Create the element x of the FreeAlgebraQuotient A.

        EXAMPLES::

            sage: H, (i,j,k) = sage.algebras.free_algebra_quotient.hamilton_quatalg(ZZ)
            sage: sage.algebras.free_algebra_quotient.FreeAlgebraQuotientElement(H, i)
            i
            sage: a = sage.algebras.free_algebra_quotient.FreeAlgebraQuotientElement(H, 1); a
            1
            sage: a in H
            True

        TESTS::

            sage: TestSuite(i).run()
        """
        AlgebraElement.__init__(self, A)
        Q = self.parent()

        if isinstance(x, FreeAlgebraQuotientElement) and x.parent() == Q:
            self.__vector = Q.module()(x.vector())
            return
        if isinstance(x, (int, long, Integer)):
            self.__vector = Q.module().gen(0) * x
            return
        elif isinstance(x, FreeModuleElement) and x.parent() is Q.module():
            self.__vector = x
            return
        elif isinstance(x, FreeModuleElement) and x.parent() == A.module():
            self.__vector = x
            return
        R = A.base_ring()
        M = A.module()
        F = A.monoid()
        B = A.monomial_basis()

        if isinstance(x, (int, long, Integer)):
            self.__vector = x*M.gen(0)
        elif isinstance(x, RingElement) and not isinstance(x, AlgebraElement) and x in R:
            self.__vector = x * M.gen(0)
        elif isinstance(x, FreeMonoidElement) and x.parent() is F:
            if x in B:
                self.__vector = M.gen(B.index(x))
            else:
                raise AttributeError("Argument x (= %s) is not in monomial basis"%x)
        elif isinstance(x, list) and len(x) == A.dimension():
            try:
                self.__vector = M(x)
            except TypeError:
                raise TypeError("Argument x (= %s) is of the wrong type."%x)
        elif isinstance(x, FreeAlgebraElement) and x.parent() is A.free_algebra():
            # Need to do more work here to include monomials not
            # represented in the monomial basis.
            self.__vector = M(0)
            for m, c in x._FreeAlgebraElement__monomial_coefficients.iteritems():
                self.__vector += c*M.gen(B.index(m))
        elif isinstance(x, dict):
            self.__vector = M(0)
            for m, c in x.iteritems():
                self.__vector += c*M.gen(B.index(m))
        elif isinstance(x, AlgebraElement) and x.parent().ambient_algebra() is A:
            self.__vector = x.ambient_algebra_element().vector()
        else:
            raise TypeError("Argument x (= %s) is of the wrong type."%x)
    def __init__(self, A, x):
        """
        Create the element x of the FreeAlgebraQuotient A.

        EXAMPLES::

            sage: H, (i,j,k) = sage.algebras.free_algebra_quotient.hamilton_quatalg(ZZ)
            sage: sage.algebras.free_algebra_quotient.FreeAlgebraQuotientElement(H, i)
            i
            sage: a = sage.algebras.free_algebra_quotient.FreeAlgebraQuotientElement(H, 1); a
            1
            sage: a in H
            True

        TESTS::

            sage: TestSuite(i).run()
        """
        AlgebraElement.__init__(self, A)
        Q = self.parent()

        if isinstance(x, FreeAlgebraQuotientElement) and x.parent() == Q:
            self.__vector = Q.module()(x.vector())
            return
        if isinstance(x, (int, long, Integer)):
            self.__vector = Q.module().gen(0) * x
            return
        elif isinstance(x, FreeModuleElement) and x.parent() is Q.module():
            self.__vector = x
            return
        elif isinstance(x, FreeModuleElement) and x.parent() == A.module():
            self.__vector = x
            return
        R = A.base_ring()
        M = A.module()
        F = A.monoid()
        B = A.monomial_basis()

        if isinstance(x, (int, long, Integer)):
            self.__vector = x * M.gen(0)
        elif isinstance(
                x,
                RingElement) and not isinstance(x, AlgebraElement) and x in R:
            self.__vector = x * M.gen(0)
        elif isinstance(x, FreeMonoidElement) and x.parent() is F:
            if x in B:
                self.__vector = M.gen(B.index(x))
            else:
                raise AttributeError, \
                      "Argument x (= %s) is not in monomial basis"%x
        elif isinstance(x, list) and len(x) == A.dimension():
            try:
                self.__vector = M(x)
            except TypeError:
                raise TypeError, "Argument x (= %s) is of the wrong type." % x
        elif isinstance(x,
                        FreeAlgebraElement) and x.parent() is A.free_algebra():
            # Need to do more work here to include monomials not
            # represented in the monomial basis.
            self.__vector = M(0)
            for m, c in x._FreeAlgebraElement__monomial_coefficients.iteritems(
            ):
                self.__vector += c * M.gen(B.index(m))
        elif isinstance(x, dict):
            self.__vector = M(0)
            for m, c in x.iteritems():
                self.__vector += c * M.gen(B.index(m))
        elif isinstance(x,
                        AlgebraElement) and x.parent().ambient_algebra() is A:
            self.__vector = x.ambient_algebra_element().vector()
        else:
            raise TypeError, "Argument x (= %s) is of the wrong type." % x