def __init__(self, O, C, R): r""" INPUT: - `O` -- An action of a group `G` on a monoid as implemented in :class:`~fourier_expansion_framework.monoidpowerseries.monoidpowerseries_basismonoids.NNMonoid`. - `C` -- A monoid of charcters `G -> K` for a ring `K`. As implemented in :class:`~fourier_expansion_framework.monoidpowerseries.monoidpowerseries_basismonoids.CharacterMonoid_class`. - `R` -- A representation of `G` on some `K`-algebra or module `A`. As implemented in :class:`~fourier_expansion_framework.monoidpowerseries.monoidpowerseries_basismonoids.TrivialRepresentation`. TESTS:: sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_functor import MonoidPowerSeriesSymmetrisationRingFunctor sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_basicmonoids import NNMonoid, TrivialRepresentation, TrivialCharacterMonoid sage: F = MonoidPowerSeriesSymmetrisationRingFunctor(NNMonoid(), TrivialCharacterMonoid("1", ZZ), TrivialRepresentation("1", ZZ)) """ if O.group() != C.group(): raise ValueError( "The action on S and the characters must have the same group") if R.base_ring() != C.codomain(): # if C.codomain().has_coerce_map_from(R.base_ring()) : # pass # el if R.base_ring().has_coerce_map_from(C.codomain()): pass else: raise ValueError( "character codomain and representation base ring must be coercible" ) if not O.is_monoid_action(): raise ValueError( "monoid structure must be compatible with group action") self.__O = O self.__C = C self.__R = R ConstructionFunctor.__init__(self, Rings(), Rings())
def __init__(self, A, gens=None): """ A subring of the endomorphism ring. INPUT: - ``A`` - an abelian variety - ``gens`` - (default: None); optional; if given should be a tuple of the generators as matrices EXAMPLES:: sage: J0(23).endomorphism_ring() Endomorphism ring of Abelian variety J0(23) of dimension 2 sage: sage.modular.abvar.homspace.EndomorphismSubring(J0(25)) Endomorphism ring of Abelian variety J0(25) of dimension 0 sage: E = J0(11).endomorphism_ring() sage: type(E) <class 'sage.modular.abvar.homspace.EndomorphismSubring_with_category'> sage: E.category() Join of Category of hom sets in Category of sets and Category of rings sage: E.homset_category() Category of modular abelian varieties over Rational Field sage: TestSuite(E).run(skip=["_test_elements"]) TESTS: The following tests against a problem on 32 bit machines that occured while working on trac ticket #9944:: sage: sage.modular.abvar.homspace.EndomorphismSubring(J1(12345)) Endomorphism ring of Abelian variety J1(12345) of dimension 5405473 """ self._J = A.ambient_variety() self._A = A # Initialise self with the correct category. # TODO: a category should be able to specify the appropriate # category for its endomorphism sets # We need to initialise it as a ring first homset_cat = A.category() cat = Category.join([homset_cat.hom_category(), Rings()]) Ring.__init__(self, A.base_ring()) Homspace.__init__(self, A, A, cat=homset_cat) self._refine_category_(Rings()) if gens is None: self._gens = None else: self._gens = tuple([self._get_matrix(g) for g in gens]) self._is_full_ring = gens is None
def __init__(self, S): r""" INPUT: - `S` -- A monoid as in :class:`~from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_basicmonoids.NNMonoid` TESTS:: sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_functor import MonoidPowerSeriesRingFunctor sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_basicmonoids import NNMonoid sage: F = MonoidPowerSeriesRingFunctor(NNMonoid(False)) """ self.__S = S ConstructionFunctor.__init__(self, Rings(), Rings())
def __init__(self, base, name=None): """ Initialize ``self``. EXAMPLES:: sage: C = Algebras(GF(2)); C Category of algebras over Finite Field of size 2 sage: TestSuite(C).run() """ from sage.categories.rings import Rings if not (base in Rings() or isinstance(base, Category) and base.is_subcategory(Rings())): raise ValueError("base must be a ring or a subcategory of Rings()") Category_over_base.__init__(self, base, name)
def Algebras(self, base_ring): """ INPUT: - ``self`` -- a subcategory of ``Sets()`` - ``base_ring`` -- a ring Returns the category of objects constructed as algebras of objects of ``self`` over ``base_ring``. EXAMPLES:: sage: Monoids().Algebras(QQ) Category of monoid algebras over Rational Field sage: Groups().Algebras(QQ) Category of group algebras over Rational Field sage: M = Monoids().example(); M An example of a monoid: the free monoid generated by ('a', 'b', 'c', 'd') sage: A = M.algebra(QQ); A Free module generated by An example of a monoid: the free monoid generated by ('a', 'b', 'c', 'd') over Rational Field sage: A.category() Category of monoid algebras over Rational Field """ from sage.categories.rings import Rings assert base_ring in Rings() return AlgebrasCategory.category_of(self, base_ring)
def __call__(self, im_gens, check=True): """ Create a homomorphism. EXAMPLES:: sage: H = Hom(ZZ, QQ) sage: H([1]) Ring morphism: From: Integer Ring To: Rational Field Defn: 1 |--> 1 TESTS:: sage: H = Hom(ZZ, QQ) sage: H == loads(dumps(H)) True """ from sage.categories.map import Map from sage.categories.all import Rings if isinstance(im_gens, Map) and im_gens.category_for().is_subcategory( Rings()): return self._coerce_impl(im_gens) try: return morphism.RingHomomorphism_im_gens(self, im_gens, check=check) except (NotImplementedError, ValueError) as err: try: return self._coerce_impl(im_gens) except TypeError: raise TypeError("images do not define a valid homomorphism")
def __classcall_private__(cls, R, q=None): r""" Normalize input to ensure a unique representation. TESTS:: sage: R.<q> = LaurentPolynomialRing(QQ) sage: AW1 = algebras.AskeyWilson(QQ) sage: AW2 = algebras.AskeyWilson(R, q) sage: AW1 is AW2 True sage: AW = algebras.AskeyWilson(ZZ, 0) Traceback (most recent call last): ... ValueError: q cannot be 0 sage: AW = algebras.AskeyWilson(ZZ, 3) Traceback (most recent call last): ... ValueError: q=3 is not invertible in Integer Ring """ if q is None: R = LaurentPolynomialRing(R, 'q') q = R.gen() else: q = R(q) if q == 0: raise ValueError("q cannot be 0") if 1 / q not in R: raise ValueError("q={} is not invertible in {}".format(q, R)) if R not in Rings().Commutative(): raise ValueError("{} is not a commutative ring".format(R)) return super(AskeyWilsonAlgebra, cls).__classcall__(cls, R, q)
def __init__(self, degree, base_ring, category=None): """ Base class for matrix groups over generic base rings You should not use this class directly. Instead, use one of the more specialized derived classes. INPUT: - ``degree`` -- integer. The degree (matrix size) of the matrix group. - ``base_ring`` -- ring. The base ring of the matrices. TESTS:: sage: G = GL(2, QQ) sage: from sage.groups.matrix_gps.matrix_group import MatrixGroup_generic sage: isinstance(G, MatrixGroup_generic) True """ assert base_ring in Rings assert is_Integer(degree) self._deg = degree if self._deg <= 0: raise ValueError('the degree must be at least 1') cat = Groups() if category is None else category if base_ring in Rings().Finite(): cat = cat.Finite() super(MatrixGroup_generic, self).__init__(base=base_ring, category=cat)
def Modules(self, base_ring): """ Return the category of ``self``-modules over ``base_ring`` INPUT: - ``self`` -- a subcategory of ``Semigroups()`` - ``base_ring`` -- a ring EXAMPLES: The category of modules over ``\QQ`` endowed with a linear action of a monoid:: sage: Monoids().Modules(QQ) Category of semigroup modules over Rational Field The category of modules over ``\QQ`` endowed with a linear action of a finite group:: sage: Groups().Finite().Modules(QQ) Category of semigroup modules over Rational Field TESTS:: sage: TestSuite(Groups().Finite().Modules(QQ)).run() """ from sage.categories.rings import Rings assert base_ring in Rings() return ModulesCategory.category_of(self, base_ring)
def __init__(self, n=1, R=0): """ Initialize ``self``. EXAMPLES:: sage: H = groups.matrix.Heisenberg(n=2, R=5) sage: TestSuite(H).run() # long time sage: H = groups.matrix.Heisenberg(n=2, R=4) sage: TestSuite(H).run() # long time sage: H = groups.matrix.Heisenberg(n=3) sage: TestSuite(H).run(max_runs=30, skip="_test_elements") # long time sage: H = groups.matrix.Heisenberg(n=2, R=GF(4)) sage: TestSuite(H).run() # long time """ def elementary_matrix(i, j, val, MS): elm = copy(MS.one()) elm[i, j] = val elm.set_immutable() return elm self._n = n self._ring = R # We need the generators of the ring as a commutative additive group if self._ring is ZZ: ring_gens = [self._ring.one()] else: if self._ring.cardinality() == self._ring.characteristic(): ring_gens = [self._ring.one()] else: # This is overkill, but is the only way to ensure # we get all of the elements ring_gens = list(self._ring) dim = ZZ(n + 2) MS = MatrixSpace(self._ring, dim) gens_x = [ elementary_matrix(0, j, gen, MS) for j in range(1, dim - 1) for gen in ring_gens ] gens_y = [ elementary_matrix(i, dim - 1, gen, MS) for i in range(1, dim - 1) for gen in ring_gens ] gen_z = [elementary_matrix(0, dim - 1, gen, MS) for gen in ring_gens] gens = gens_x + gens_y + gen_z from sage.libs.gap.libgap import libgap gap_gens = [libgap(single_gen) for single_gen in gens] gap_group = libgap.Group(gap_gens) cat = Groups().FinitelyGenerated() if self._ring in Rings().Finite(): cat = cat.Finite() FinitelyGeneratedMatrixGroup_gap.__init__(self, ZZ(dim), self._ring, gap_group, category=cat)
def __init__(self, domain, on_generators, position=0, codomain=None, category=None): """ Given a map on the multiplicative basis of a free algebra, this method returns the algebra morphism that is the linear extension of its image on generators. INPUT: - ``domain`` -- an Askey-Wilson algebra - ``on_generators`` -- a list of length 6 corresponding to the images of the generators - ``codomain`` -- (optional) the codomain - ``position`` -- (default: 0) integer - ``category`` -- (optional) category OUTPUT: - module morphism EXAMPLES:: sage: AW = algebras.AskeyWilson(QQ) sage: sigma = AW.sigma() sage: TestSuite(sigma).run() """ if category is None: category = Algebras(Rings().Commutative()).WithBasis() self._on_generators = tuple(on_generators) ModuleMorphismByLinearity.__init__(self, domain=domain, codomain=codomain, position=position, category=category)
def super_categories(self): """ EXAMPLES:: sage: Domains().super_categories() [Category of rings] """ return [Rings()]
def super_categories(self): """ EXAMPLES:: sage: Algebras(ZZ).super_categories() [Category of rings, Category of modules over Integer Ring] """ R = self.base_ring() return [Rings(), Modules(R)]
def __init__(self, left_base, right_base, name=None): """ EXAMPLES:: sage: C = Bimodules(QQ, ZZ) sage: TestSuite(C).run() """ if not ( left_base in Rings() or (isinstance(left_base, Category) and left_base.is_subcategory(Rings())) ): raise ValueError("the left base must be a ring or a subcategory of Rings()") if not ( right_base in Rings() or (isinstance(right_base, Category) and right_base.is_subcategory(Rings())) ): raise ValueError("the right base must be a ring or a subcategory of Rings()") self._left_base_ring = left_base self._right_base_ring = right_base Category.__init__(self, name)