Exemplo n.º 1
0
    def __init__(self, R, n, names):
        """
        The free algebra on `n` generators over a base ring.

        INPUT:

        -  ``R`` - ring
        -  ``n`` - an integer
        -  ``names`` - generator names

        EXAMPLES::

            sage: F.<x,y,z> = FreeAlgebra(QQ, 3); F # indirect doctet
            Free Algebra on 3 generators (x, y, z) over Rational Field

        TEST:

        Note that the following is *not* the recommended way to create
        a free algebra.
        ::

            sage: from sage.algebras.free_algebra import FreeAlgebra_generic
            sage: FreeAlgebra_generic(ZZ,3,'abc')
            Free Algebra on 3 generators (a, b, c) over Integer Ring

        """
        if not isinstance(R, Ring):
            raise TypeError("Argument R must be a ring.")
        self.__monoid = FreeMonoid(n, names=names)
        self.__ngens = n
        #sage.structure.parent_gens.ParentWithGens.__init__(self, R, names)
        Algebra.__init__(self, R, names=names)
Exemplo n.º 2
0
    def __init__(self, R, n, names):
        """
        The free algebra on `n` generators over a base ring.

        INPUT:

        -  ``R`` - ring
        -  ``n`` - an integer
        -  ``names`` - generator names

        EXAMPLES::

            sage: F.<x,y,z> = FreeAlgebra(QQ, 3); F # indirect doctet
            Free Algebra on 3 generators (x, y, z) over Rational Field

        TEST:

        Note that the following is *not* the recommended way to create
        a free algebra.
        ::

            sage: from sage.algebras.free_algebra import FreeAlgebra_generic
            sage: FreeAlgebra_generic(ZZ,3,'abc')
            Free Algebra on 3 generators (a, b, c) over Integer Ring

        """
        if not isinstance(R, Ring):
            raise TypeError("Argument R must be a ring.")
        self.__ngens = n
        #sage.structure.parent_gens.ParentWithGens.__init__(self, R, names)
        self._basis_keys = FreeMonoid(n, names=names)
        Algebra.__init__(self, R, names, category=AlgebrasWithBasis(R))
    def __init__(self, coeff_ring=ZZ, group='Sp(4,Z)', weights='even', degree=2, default_prec=SMF_DEFAULT_PREC):
        r"""
        Initialize an algebra of Siegel modular forms of degree ``degree`` 
        with coefficients in ``coeff_ring``, on the group ``group``.  
        If ``weights`` is 'even', then only forms of even weights are 
        considered; if ``weights`` is 'all', then all forms are 
        considered.

        EXAMPLES::

            sage: A = SiegelModularFormsAlgebra(QQ)
            sage: B = SiegelModularFormsAlgebra(ZZ)
            sage: A._coerce_map_from_(B)
            True                                                                                                      
            sage: B._coerce_map_from_(A)
            False                                                                                                                                            
            sage: A._coerce_map_from_(ZZ)
            True   
        """
        self.__coeff_ring = coeff_ring
        self.__group = group
        self.__weights = weights
        self.__degree = degree
        self.__default_prec = default_prec
        R = coeff_ring
        from sage.algebras.all import GroupAlgebra
        if isinstance(R, GroupAlgebra):
            R = R.base_ring()
        from sage.rings.polynomial.polynomial_ring import is_PolynomialRing
        if is_PolynomialRing(R):
            self.__base_ring = R.base_ring()
        else:
            self.__base_ring = R
        from sage.categories.all import Algebras
        Algebra.__init__(self, base=self.__base_ring, category=Algebras(self.__base_ring))
Exemplo n.º 4
0
    def __init__(self, A, S) :
        r"""
        INPUT:
            - `A` -- A ring.
            - `S` -- A monoid as implemented in :class:~`fourier_expansion_framework.monoidpowerseries.monoidpowerseries_basicmonoids.NNMonoid`.

        TESTS::
            sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_basicmonoids import *
            sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_ring import MonoidPowerSeriesRing_generic
            sage: mps = MonoidPowerSeriesRing_generic(QQ, NNMonoid(False))
            sage: mps = MonoidPowerSeriesRing_generic(ZZ, NNMonoid(False))
            sage: mps.base_ring()
            Integer Ring
            sage: (1 / 2) * mps.0
            Monoid power series in Ring of monoid power series over NN
        """
        Algebra.__init__(self, A)        
        MonoidPowerSeriesAmbient_abstract.__init__(self, A, S)

        self.__monoid_gens = \
          [ self._element_class(self, dict([(s, A.one_element())]),
                                    self.monoid().filter_all() )
            for s in S.gens() ]
    
        from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_functor import MonoidPowerSeriesBaseRingInjection

        self._populate_coercion_lists_(
          coerce_list = [MonoidPowerSeriesBaseRingInjection(self.base_ring(), self)] + \
                        ([S] if isinstance(S, Parent) else []) )
    def _coerce_map_from_(self, other) :
        """
        TESTS::
            sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_basicmonoids import *
            sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_module 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: mps = MonoidPowerSeriesRing(QQ, NNMonoid(False))
            sage: ger = GradedExpansionRing_class(Sequence([MonoidPowerSeries(mps, {1: 1}, mps.monoid().filter(4))]), Sequence([MonoidPowerSeries(mps, {1: 1, 2: 3}, mps.monoid().filter(4))]), PolynomialRing(QQ, ['a', 'b']).ideal(0), DegreeGrading((1,2)))
            sage: ger._coerce_map_from_(ZZ)
        """
        if other is self.relations().ring() :
            from sage.structure.coerce_maps import CallableConvertMap
            
            return CallableConvertMap(other, self, self._element_constructor_)
        
        if isinstance(other, GradedExpansionSubmodule_abstract) :
            if other.graded_ambient() is self \
              or self.has_coerce_map_from(other.graded_ambient()) :
                from sage.structure.coerce_maps import CallableConvertMap
 
                return CallableConvertMap(other, self, other._graded_expansion_submodule_to_graded_ambient_)
 
        return Algebra._coerce_map_from_(self, other)
Exemplo n.º 6
0
    def _coerce_map_from_(self, other) :
        r"""
        TESTS::
            sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_basicmonoids import *
            sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_module 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: mps = MonoidPowerSeriesRing(QQ, NNMonoid(False))
            sage: ger = GradedExpansionRing_class(Sequence([MonoidPowerSeries(mps, {1: 1}, mps.monoid().filter(4))]), Sequence([MonoidPowerSeries(mps, {1: 1, 2: 3}, mps.monoid().filter(4))]), PolynomialRing(QQ, ['a', 'b']).ideal(0), DegreeGrading((1,2)))
            sage: ger._coerce_map_from_(ZZ)
        """
        if other is self.relations().ring() :
            from sage.structure.coerce_maps import CallableConvertMap
            
            return CallableConvertMap(other, self, self._element_constructor_)
        
        if isinstance(other, GradedExpansionSubmodule_abstract) :
            if other.graded_ambient() is self \
              or self.has_coerce_map_from(other.graded_ambient()) :
                from sage.structure.coerce_maps import CallableConvertMap
 
                return CallableConvertMap(other, self, other._graded_expansion_submodule_to_graded_ambient_)
 
        return Algebra._coerce_map_from_(self, other)
Exemplo n.º 7
0
    def __init__(self, O, C, R):
        r"""
        INPUT:
            - `O` -- A monoid with an action of a group; As implemented in
                     :class:~`fourier_expansion_framework.monoidpowerseries.NNMonoid`.
            - `C` -- A monoid of characters; As implemented in ::class:~`fourier_expansion_framework.monoidpowerseries.CharacterMonoid_class`.
            - `R` -- A representation on an algebra; As implemented
                     in :class:~`fourier_expansion_framework.monoidpowerseries.TrivialRepresentation`.

        EXAMPLES::
            sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_basicmonoids import *
            sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_ring import EquivariantMonoidPowerSeriesRing_generic
            sage: emps = EquivariantMonoidPowerSeriesRing_generic(NNMonoid(True), TrivialCharacterMonoid("1", QQ), TrivialRepresentation("1", QQ)) # indirect doctest
            sage: emps = EquivariantMonoidPowerSeriesRing_generic(NNMonoid(True), TrivialCharacterMonoid("1", ZZ), TrivialRepresentation("1", ZZ)) # indirect doctest
            sage: emps.base_ring()
            Integer Ring
            sage: (1 / 2) * emps.0
            Equivariant monoid power series in Ring of equivariant monoid power series over NN
        """

        Algebra.__init__(self, R.base_ring())
        EquivariantMonoidPowerSeriesAmbient_abstract.__init__(self, O, C, R)

        self.__monoid_gens = \
          [self._element_class(self,
            dict([( C.one_element(), dict([(s, self.coefficient_domain().one_element())]) )]),
            self.monoid().filter_all() )
           for s in self.action().gens()]
        self.__character_gens = \
          [self._element_class(self,
            dict([( c, dict([(self.monoid().zero_element(), self.coefficient_domain().one_element())]) )]),
            self.monoid().filter_all() )
           for c in C.gens()]
        self.__coefficient_gens = \
          [self._element_class(self,
            dict([( C.one_element(), dict([(self.monoid().zero_element(), g)]))]),
            self.monoid().filter_all() )
           for g in self.coefficient_domain().gens()]

        from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_functor import MonoidPowerSeriesBaseRingInjection

        self._populate_coercion_lists_(
            coerce_list=[
                MonoidPowerSeriesBaseRingInjection(R.codomain(), self)
            ],
            convert_list=([O.monoid()]
                          if isinstance(O.monoid(), Parent) else []))
Exemplo n.º 8
0
    def __init__(self, O, C, R) :
        r"""
        INPUT:
            - `O` -- A monoid with an action of a group; As implemented in
                     :class:~`fourier_expansion_framework.monoidpowerseries.NNMonoid`.
            - `C` -- A monoid of characters; As implemented in ::class:~`fourier_expansion_framework.monoidpowerseries.CharacterMonoid_class`.
            - `R` -- A representation on an algebra; As implemented
                     in :class:~`fourier_expansion_framework.monoidpowerseries.TrivialRepresentation`.

        EXAMPLES::
            sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_basicmonoids import *
            sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_ring import EquivariantMonoidPowerSeriesRing_generic
            sage: emps = EquivariantMonoidPowerSeriesRing_generic(NNMonoid(True), TrivialCharacterMonoid("1", QQ), TrivialRepresentation("1", QQ)) # indirect doctest
            sage: emps = EquivariantMonoidPowerSeriesRing_generic(NNMonoid(True), TrivialCharacterMonoid("1", ZZ), TrivialRepresentation("1", ZZ)) # indirect doctest
            sage: emps.base_ring()
            Integer Ring
            sage: (1 / 2) * emps.0
            Equivariant monoid power series in Ring of equivariant monoid power series over NN
        """
        
        Algebra.__init__(self, R.base_ring())
        EquivariantMonoidPowerSeriesAmbient_abstract.__init__(self, O, C, R)
    
        self.__monoid_gens = \
          [self._element_class(self,
            dict([( C.one_element(), dict([(s, self.coefficient_domain().one_element())]) )]),
            self.monoid().filter_all() )
           for s in self.action().gens()]
        self.__character_gens = \
          [self._element_class(self,
            dict([( c, dict([(self.monoid().zero_element(), self.coefficient_domain().one_element())]) )]),
            self.monoid().filter_all() )
           for c in C.gens()]
        self.__coefficient_gens = \
          [self._element_class(self,
            dict([( C.one_element(), dict([(self.monoid().zero_element(), g)]))]),
            self.monoid().filter_all() )
           for g in self.coefficient_domain().gens()]
        
        from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_functor import MonoidPowerSeriesBaseRingInjection

        self._populate_coercion_lists_(
          coerce_list = [MonoidPowerSeriesBaseRingInjection(R.codomain(), self)] ,
          convert_list = ([O.monoid()] if isinstance(O.monoid(), Parent) else []) )
Exemplo n.º 9
0
    def __init__(self,
                 coeff_ring=ZZ,
                 group='Sp(4,Z)',
                 weights='even',
                 degree=2,
                 default_prec=SMF_DEFAULT_PREC):
        r"""
        Initialize an algebra of Siegel modular forms of degree ``degree`` 
        with coefficients in ``coeff_ring``, on the group ``group``.  
        If ``weights`` is 'even', then only forms of even weights are 
        considered; if ``weights`` is 'all', then all forms are 
        considered.

        EXAMPLES::

            sage: A = SiegelModularFormsAlgebra(QQ)
            sage: B = SiegelModularFormsAlgebra(ZZ)
            sage: A._coerce_map_from_(B)
            True                                                                                                      
            sage: B._coerce_map_from_(A)
            False                                                                                                                                            
            sage: A._coerce_map_from_(ZZ)
            True   
        """
        self.__coeff_ring = coeff_ring
        self.__group = group
        self.__weights = weights
        self.__degree = degree
        self.__default_prec = default_prec
        R = coeff_ring
        from sage.algebras.all import GroupAlgebra
        if isinstance(R, GroupAlgebra):
            R = R.base_ring()
        from sage.rings.polynomial.polynomial_ring import is_PolynomialRing
        if is_PolynomialRing(R):
            self.__base_ring = R.base_ring()
        else:
            self.__base_ring = R
        from sage.categories.all import Algebras
        Algebra.__init__(self,
                         base=self.__base_ring,
                         category=Algebras(self.__base_ring))
Exemplo n.º 10
0
    def __init__(self, R, n, names):
        """
        The free algebra on `n` generators over a base ring.

        INPUT:
        
        -  ``R`` - ring
        -  ``n`` - an integer
        -  ``names`` - generator names
    
        EXAMPLES::
    
            sage: F.<x,y,z> = FreeAlgebra(QQ, 3); F # indirect doctet
            Free Algebra on 3 generators (x, y, z) over Rational Field
        """
        if not isinstance(R, Ring):
            raise TypeError("Argument R must be a ring.")
        self.__monoid = FreeMonoid(n, names=names)
        self.__ngens = n
        #sage.structure.parent_gens.ParentWithGens.__init__(self, R, names)
        Algebra.__init__(self, R, names=names)
Exemplo n.º 11
0
    def __init__(self, R, n, names):
        """
        The free algebra on `n` generators over a base ring.

        INPUT:
        
        -  ``R`` - ring
        -  ``n`` - an integer
        -  ``names`` - generator names
    
        EXAMPLES::
    
            sage: F.<x,y,z> = FreeAlgebra(QQ, 3); F # indirect doctet
            Free Algebra on 3 generators (x, y, z) over Rational Field
        """
        if not isinstance(R, Ring):
            raise TypeError, "Argument R must be a ring."
        self.__monoid = FreeMonoid(n, names=names)
        self.__ngens = n
        #sage.structure.parent_gens.ParentWithGens.__init__(self, R, names)
        Algebra.__init__(self, R,names=names)
Exemplo n.º 12
0
    def __init__(self, A, mons, mats, names):
        """
        Returns a quotient algebra defined via the action of a free algebra
        A on a (finitely generated) free module. The input for the quotient
        algebra is a list of monomials (in the underlying monoid for A)
        which form a free basis for the module of A, and a list of
        matrices, which give the action of the free generators of A on this
        monomial basis.
        
        EXAMPLES:
        
        Quaternion algebra defined in terms of three generators::
        
            sage: n = 3
            sage: A = FreeAlgebra(QQ,n,'i')
            sage: F = A.monoid()
            sage: i, j, k = F.gens()
            sage: mons = [ F(1), i, j, k ]
            sage: M = MatrixSpace(QQ,4)
            sage: mats = [M([0,1,0,0, -1,0,0,0, 0,0,0,-1, 0,0,1,0]),  M([0,0,1,0, 0,0,0,1, -1,0,0,0, 0,-1,0,0]),  M([0,0,0,1, 0,0,-1,0, 0,1,0,0, -1,0,0,0]) ]
            sage: H3.<i,j,k> = FreeAlgebraQuotient(A,mons,mats)
            sage: x = 1 + i + j + k
            sage: x
            1 + i + j + k
            sage: x**128
            -170141183460469231731687303715884105728 + 170141183460469231731687303715884105728*i + 170141183460469231731687303715884105728*j + 170141183460469231731687303715884105728*k
        
        Same algebra defined in terms of two generators, with some penalty
        on already slow arithmetic.
        
        ::
        
            sage: n = 2
            sage: A = FreeAlgebra(QQ,n,'x')
            sage: F = A.monoid()
            sage: i, j = F.gens()
            sage: mons = [ F(1), i, j, i*j ]
            sage: r = len(mons)
            sage: M = MatrixSpace(QQ,r)
            sage: mats = [M([0,1,0,0, -1,0,0,0, 0,0,0,-1, 0,0,1,0]), M([0,0,1,0, 0,0,0,1, -1,0,0,0, 0,-1,0,0]) ]
            sage: H2.<i,j> = A.quotient(mons,mats)
            sage: k = i*j
            sage: x = 1 + i + j + k
            sage: x
            1 + i + j + i*j
            sage: x**128
            -170141183460469231731687303715884105728 + 170141183460469231731687303715884105728*i + 170141183460469231731687303715884105728*j + 170141183460469231731687303715884105728*i*j

        TEST::

            sage: TestSuite(H2).run()

        """
        if not is_FreeAlgebra(A):
            raise TypeError, "Argument A must be an algebra."
        R = A.base_ring()
        #        if not R.is_field():  # TODO: why?
        #            raise TypeError, "Base ring of argument A must be a field."
        n = A.ngens()
        assert n == len(mats)
        self.__free_algebra = A
        self.__ngens = n
        self.__dim = len(mons)
        self.__module = FreeModule(R, self.__dim)
        self.__matrix_action = mats
        self.__monomial_basis = mons  # elements of free monoid
        Algebra.__init__(self, R, names, normalize=True)
Exemplo n.º 13
0
    def __init__ ( self, base_ring_generators, generators,
                   relations, grading, all_relations = True, reduce_before_evaluating = True) :
        """
        The degree one part of the monomials that correspond to generators over the
        base expansion ring will serve as the coordinates of the elements.
        
        INPUT:
            - ``base_ring_generators``      -- A list of (equivariant) monoid power series with
                                               coefficient domain the base ring of the coefficient
                                               domain of the generators or ``None``.
            - ``generators``                -- A list of (equivariant) monoid power series; The generators
                                               of the ambient over the ring generated by the base ring
                                               generators.
            - ``relations``                 -- An ideal in a polynomial ring with ``len(base_ring_generators) + len(generators)``
                                               variables.
            - ``grading``                   -- A grading deriving from :class:~`fourier_expansion_framework.gradedexpansions.gradedexpansion_grading`;
                                               A grading for the polynomial ring of the relations.
            - ``all_relations``             -- A boolean (default: ``True``); If ``True`` the relations given
                                               for the polynomial ring are all relations that the Fourier
                                               expansion have.
            - ``reduce_before_evaluating``  -- A boolean (default: ``True``); If ``True`` any monomial
                                               will be Groebner reduced before the Fourier expansion
                                               is calculated.

        NOTE:
            The grading must respect the relations of the generators.
        
        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: mps = MonoidPowerSeriesRing(QQ, NNMonoid(False))
            sage: ger = GradedExpansionRing_class(Sequence([MonoidPowerSeries(mps, {1: 1}, mps.monoid().filter(4))]), Sequence([MonoidPowerSeries(mps, {1: 1, 2: 3}, mps.monoid().filter(4))]), PolynomialRing(QQ, ['a', 'b']).ideal(0), DegreeGrading((1,2)))
            sage: ger.base_ring()
            Graded expansion ring with generators a
       """
        if not hasattr(self, '_element_class') :
            self._element_class = GradedExpansion_class
        
        if hasattr(self, "_extended_base_ring") :
            Algebra.__init__(self, self._extended_base_ring)
        elif base_ring_generators is None or len(base_ring_generators) == 0 :
            Algebra.__init__(self, relations.base_ring())
        else :
            gb = filter( lambda p: all( all(a == 0 for a in list(e)[len(base_ring_generators):])
                                        for e in p.exponents() ),
                         relations.groebner_basis() )
            P = PolynomialRing( relations.base_ring(),
                                list(relations.ring().variable_names())[:len(base_ring_generators)] )
            base_relations = P.ideal(gb)
            R = GradedExpansionRing_class(None, base_ring_generators, base_relations,
                    grading.subgrading(xrange(len(base_ring_generators))), all_relations, reduce_before_evaluating)
            Algebra.__init__(self, R)

        GradedExpansionAmbient_abstract.__init__(self, base_ring_generators, generators, relations, grading, all_relations, reduce_before_evaluating)
        
        self._populate_coercion_lists_(
          coerce_list = [GradedExpansionBaseringInjection(self.base_ring(), self)],
          convert_list = [self.relations().ring()],
          convert_method_name = "_graded_expansion_submodule_to_graded_ambient_" )
Exemplo n.º 14
0
    def __init__(self, A, mons, mats, names):
        """
        Returns a quotient algebra defined via the action of a free algebra
        A on a (finitely generated) free module. The input for the quotient
        algebra is a list of monomials (in the underlying monoid for A)
        which form a free basis for the module of A, and a list of
        matrices, which give the action of the free generators of A on this
        monomial basis.
        
        EXAMPLES:
        
        Quaternion algebra defined in terms of three generators::
        
            sage: n = 3
            sage: A = FreeAlgebra(QQ,n,'i')
            sage: F = A.monoid()
            sage: i, j, k = F.gens()
            sage: mons = [ F(1), i, j, k ]
            sage: M = MatrixSpace(QQ,4)
            sage: mats = [M([0,1,0,0, -1,0,0,0, 0,0,0,-1, 0,0,1,0]),  M([0,0,1,0, 0,0,0,1, -1,0,0,0, 0,-1,0,0]),  M([0,0,0,1, 0,0,-1,0, 0,1,0,0, -1,0,0,0]) ]
            sage: H3.<i,j,k> = FreeAlgebraQuotient(A,mons,mats)
            sage: x = 1 + i + j + k
            sage: x
            1 + i + j + k
            sage: x**128
            -170141183460469231731687303715884105728 + 170141183460469231731687303715884105728*i + 170141183460469231731687303715884105728*j + 170141183460469231731687303715884105728*k
        
        Same algebra defined in terms of two generators, with some penalty
        on already slow arithmetic.
        
        ::
        
            sage: n = 2
            sage: A = FreeAlgebra(QQ,n,'x')
            sage: F = A.monoid()
            sage: i, j = F.gens()
            sage: mons = [ F(1), i, j, i*j ]
            sage: r = len(mons)
            sage: M = MatrixSpace(QQ,r)
            sage: mats = [M([0,1,0,0, -1,0,0,0, 0,0,0,-1, 0,0,1,0]), M([0,0,1,0, 0,0,0,1, -1,0,0,0, 0,-1,0,0]) ]
            sage: H2.<i,j> = A.quotient(mons,mats)
            sage: k = i*j
            sage: x = 1 + i + j + k
            sage: x
            1 + i + j + i*j
            sage: x**128
            -170141183460469231731687303715884105728 + 170141183460469231731687303715884105728*i + 170141183460469231731687303715884105728*j + 170141183460469231731687303715884105728*i*j

        TEST::

            sage: TestSuite(H2).run()

        """
        if not is_FreeAlgebra(A):
            raise TypeError("Argument A must be an algebra.")
        R = A.base_ring()
#        if not R.is_field():  # TODO: why?
#            raise TypeError, "Base ring of argument A must be a field."
        n = A.ngens()
        assert n == len(mats)
        self.__free_algebra = A
        self.__ngens = n
        self.__dim = len(mons)
        self.__module = FreeModule(R,self.__dim)
        self.__matrix_action = mats
        self.__monomial_basis = mons # elements of free monoid
        Algebra.__init__(self, R, names, normalize=True)
Exemplo n.º 15
0
    def __init__ ( self, base_ring_generators, generators,
                   relations, grading, all_relations = True, reduce_before_evaluating = True) :
        r"""
        The degree one part of the monomials that correspond to generators over the
        base expansion ring will serve as the coordinates of the elements.
        
        INPUT:
            - ``base_ring_generators``      -- A list of (equivariant) monoid power series with
                                               coefficient domain the base ring of the coefficient
                                               domain of the generators or ``None``.
            - ``generators``                -- A list of (equivariant) monoid power series; The generators
                                               of the ambient over the ring generated by the base ring
                                               generators.
            - ``relations``                 -- An ideal in a polynomial ring with ``len(base_ring_generators) + len(generators)``
                                               variables.
            - ``grading``                   -- A grading deriving from :class:~`fourier_expansion_framework.gradedexpansions.gradedexpansion_grading`;
                                               A grading for the polynomial ring of the relations.
            - ``all_relations``             -- A boolean (default: ``True``); If ``True`` the relations given
                                               for the polynomial ring are all relations that the Fourier
                                               expansion have.
            - ``reduce_before_evaluating``  -- A boolean (default: ``True``); If ``True`` any monomial
                                               will be Groebner reduced before the Fourier expansion
                                               is calculated.

        NOTE:
            The grading must respect the relations of the generators.
        
        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: mps = MonoidPowerSeriesRing(QQ, NNMonoid(False))
            sage: ger = GradedExpansionRing_class(Sequence([MonoidPowerSeries(mps, {1: 1}, mps.monoid().filter(4))]), Sequence([MonoidPowerSeries(mps, {1: 1, 2: 3}, mps.monoid().filter(4))]), PolynomialRing(QQ, ['a', 'b']).ideal(0), DegreeGrading((1,2)))
            sage: ger.base_ring()
            Graded expansion ring with generators a
       """
        if not hasattr(self, '_element_class') :
            self._element_class = GradedExpansion_class
        
        if hasattr(self, "_extended_base_ring") :
            Algebra.__init__(self, self._extended_base_ring)
        elif base_ring_generators is None or len(base_ring_generators) == 0 :
            Algebra.__init__(self, relations.base_ring())
        else :
            gb = [p for p in relations.groebner_basis() if all( all(a == 0 for a in list(e)[len(base_ring_generators):])
                                        for e in p.exponents() )]
            P = PolynomialRing( relations.base_ring(),
                                list(relations.ring().variable_names())[:len(base_ring_generators)] )
            base_relations = P.ideal(gb)
            R = GradedExpansionRing_class(None, base_ring_generators, base_relations,
                    grading.subgrading(range(len(base_ring_generators))), all_relations, reduce_before_evaluating)
            Algebra.__init__(self, R)

        GradedExpansionAmbient_abstract.__init__(self, base_ring_generators, generators, relations, grading, all_relations, reduce_before_evaluating)

        self._populate_coercion_lists_(
          coerce_list = [GradedExpansionBaseringInjection(self.base_ring(), self)],
# This is deactivated since it leads to errors in the coercion system for Sage 4.8
# TODO: Find out why
#          convert_list = [self.relations().ring()],
          convert_list = [],
          convert_method_name = "_graded_expansion_submodule_to_graded_ambient_" )