示例#1
0
    def __call__(self, x, check=True):
        r"""
        Convert x into an element of this Hecke algebra. Here x is either:
        
        - an element of a Hecke algebra equal to this one
        
        - an element of the corresponding anemic Hecke algebra, if x is a full
          Hecke algebra

        - an element of the corresponding full Hecke algebra of the
          form `T_i` where i is coprime to ``self.level()``, if self
          is an anemic Hecke algebra

        - something that can be converted into an element of the
          underlying matrix space.
        
        In the last case, the parameter ``check'' controls whether or
        not to check that this element really does lie in the
        appropriate algebra. At present, setting ``check=True'' raises
        a NotImplementedError unless x is a scalar (or a diagonal
        matrix).

        EXAMPLES::

            sage: T = ModularSymbols(11).hecke_algebra()
            sage: T.gen(2) in T
            True
            sage: 5 in T
            True
            sage: T.gen(2).matrix() in T
            Traceback (most recent call last):
            ...
            NotImplementedError: Membership testing for '...' not implemented
            sage: T(T.gen(2).matrix(), check=False)
            Hecke operator on Modular Symbols space of dimension 3 for Gamma_0(11) of weight 2 with sign 0 over Rational Field defined by:
            [ 3  0 -1]
            [ 0 -2  0]
            [ 0  0 -2]
            sage: A = ModularSymbols(11).anemic_hecke_algebra()
            sage: A(T.gen(3))
            Hecke operator T_3 on Modular Symbols space of dimension 3 for Gamma_0(11) of weight 2 with sign 0 over Rational Field
            sage: A(T.gen(11))
            Traceback (most recent call last):
            ...
            TypeError: Don't know how to construct an element of Anemic Hecke algebra acting on Modular Symbols space of dimension 3 for Gamma_0(11) of weight 2 with sign 0 over Rational Field from Hecke operator T_11 on Modular Symbols space of dimension 3 for Gamma_0(11) of weight 2 with sign 0 over Rational Field

        TESTS:

        We test that coercion is OK between the Hecke algebras associated to two submodules which are equal but have different bases::

            sage: M = CuspForms(Gamma0(57))                                                
            sage: f1,f2,f3 = M.newforms()                                                  
            sage: N1 = M.submodule(M.free_module().submodule_with_basis([f1.element().element(), f2.element().element()]))
            sage: N2 = M.submodule(M.free_module().submodule_with_basis([f1.element().element(), (f1.element() + f2.element()).element()]))
            sage: N1.hecke_operator(5).matrix_form()
            Hecke operator on Modular Forms subspace of dimension 2 of ... defined by:
            [-3  0]                                                                          
            [ 0  1]                                                                          
            sage: N2.hecke_operator(5).matrix_form()
            Hecke operator on Modular Forms subspace of dimension 2 of ... defined by: 
            [-3  0]                                                                          
            [-4  1]
            sage: N1.hecke_algebra()(N2.hecke_operator(5)).matrix_form()
            Hecke operator on Modular Forms subspace of dimension 2 of ... defined by:
            [-3  0]
            [ 0  1]
            sage: N1.hecke_algebra()(N2.hecke_operator(5).matrix_form())
            Hecke operator on Modular Forms subspace of dimension 2 of ... defined by:
            [-3  0]
            [ 0  1]
        """
        try:
            if not isinstance(x, Element):
                x = self.base_ring()(x)
            if x.parent() is self:
                return x
            elif hecke_operator.is_HeckeOperator(x):
                if x.parent() == self \
                        or (self.is_anemic() == False and x.parent() == self.anemic_subalgebra()) \
                        or (self.is_anemic() == True and x.parent().anemic_subalgebra() == self and arith.gcd(x.index(), self.level()) == 1):
                    return hecke_operator.HeckeOperator(self, x.index())
                else:
                    raise TypeError
            elif hecke_operator.is_HeckeAlgebraElement(x):
                if x.parent() == self or (self.is_anemic() == False
                                          and x.parent()
                                          == self.anemic_subalgebra()):
                    if x.parent().module().basis_matrix() == self.module(
                    ).basis_matrix():
                        return hecke_operator.HeckeAlgebraElement_matrix(
                            self, x.matrix())
                    else:
                        A = matrix([self.module().coordinate_vector(x.parent().module().gen(i)) \
                            for i in xrange(x.parent().module().rank())])
                        return hecke_operator.HeckeAlgebraElement_matrix(
                            self, ~A * x.matrix() * A)
                elif x.parent() == self.anemic_subalgebra():
                    pass

                else:
                    raise TypeError
            else:
                A = self.matrix_space()(x)
                if check:
                    if not A.is_scalar():
                        raise NotImplementedError, "Membership testing for '%s' not implemented" % self
                return hecke_operator.HeckeAlgebraElement_matrix(self, A)

        except TypeError:
            raise TypeError, "Don't know how to construct an element of %s from %s" % (
                self, x)
示例#2
0
文件: algebra.py 项目: Babyll/sage
    def __call__(self, x, check=True):
        r"""
        Convert x into an element of this Hecke algebra. Here x is either:

        - an element of a Hecke algebra equal to this one

        - an element of the corresponding anemic Hecke algebra, if x is a full
          Hecke algebra

        - an element of the corresponding full Hecke algebra of the
          form `T_i` where i is coprime to ``self.level()``, if self
          is an anemic Hecke algebra

        - something that can be converted into an element of the
          underlying matrix space.

        In the last case, the parameter ``check'' controls whether or
        not to check that this element really does lie in the
        appropriate algebra. At present, setting ``check=True'' raises
        a NotImplementedError unless x is a scalar (or a diagonal
        matrix).

        EXAMPLES::

            sage: T = ModularSymbols(11).hecke_algebra()
            sage: T.gen(2) in T
            True
            sage: 5 in T
            True
            sage: T.gen(2).matrix() in T
            Traceback (most recent call last):
            ...
            NotImplementedError: Membership testing for '...' not implemented
            sage: T(T.gen(2).matrix(), check=False)
            Hecke operator on Modular Symbols space of dimension 3 for Gamma_0(11) of weight 2 with sign 0 over Rational Field defined by:
            [ 3  0 -1]
            [ 0 -2  0]
            [ 0  0 -2]
            sage: A = ModularSymbols(11).anemic_hecke_algebra()
            sage: A(T.gen(3))
            Hecke operator T_3 on Modular Symbols space of dimension 3 for Gamma_0(11) of weight 2 with sign 0 over Rational Field
            sage: A(T.gen(11))
            Traceback (most recent call last):
            ...
            TypeError: Don't know how to construct an element of Anemic Hecke algebra acting on Modular Symbols space of dimension 3 for Gamma_0(11) of weight 2 with sign 0 over Rational Field from Hecke operator T_11 on Modular Symbols space of dimension 3 for Gamma_0(11) of weight 2 with sign 0 over Rational Field

        TESTS:

        We test that coercion is OK between the Hecke algebras associated to two submodules which are equal but have different bases::

            sage: M = CuspForms(Gamma0(57))
            sage: f1,f2,f3 = M.newforms()
            sage: N1 = M.submodule(M.free_module().submodule_with_basis([f1.element().element(), f2.element().element()]))
            sage: N2 = M.submodule(M.free_module().submodule_with_basis([f1.element().element(), (f1.element() + f2.element()).element()]))
            sage: N1.hecke_operator(5).matrix_form()
            Hecke operator on Modular Forms subspace of dimension 2 of ... defined by:
            [-3  0]
            [ 0  1]
            sage: N2.hecke_operator(5).matrix_form()
            Hecke operator on Modular Forms subspace of dimension 2 of ... defined by:
            [-3  0]
            [-4  1]
            sage: N1.hecke_algebra()(N2.hecke_operator(5)).matrix_form()
            Hecke operator on Modular Forms subspace of dimension 2 of ... defined by:
            [-3  0]
            [ 0  1]
            sage: N1.hecke_algebra()(N2.hecke_operator(5).matrix_form())
            Hecke operator on Modular Forms subspace of dimension 2 of ... defined by:
            [-3  0]
            [ 0  1]
        """
        try:
            if not isinstance(x, Element):
                x = self.base_ring()(x)
            if x.parent() is self:
                return x
            elif hecke_operator.is_HeckeOperator(x):
                if x.parent() == self \
                        or (self.is_anemic() == False and x.parent() == self.anemic_subalgebra()) \
                        or (self.is_anemic() == True and x.parent().anemic_subalgebra() == self and arith.gcd(x.index(), self.level()) == 1):
                    return hecke_operator.HeckeOperator(self, x.index())
                else:
                    raise TypeError
            elif hecke_operator.is_HeckeAlgebraElement(x):
                if x.parent() == self or (self.is_anemic() == False and x.parent() == self.anemic_subalgebra()):
                    if x.parent().module().basis_matrix() == self.module().basis_matrix():
                        return hecke_operator.HeckeAlgebraElement_matrix(self, x.matrix())
                    else:
                        A = matrix([self.module().coordinate_vector(x.parent().module().gen(i)) \
                            for i in xrange(x.parent().module().rank())])
                        return hecke_operator.HeckeAlgebraElement_matrix(self, ~A * x.matrix() * A)
                elif x.parent() == self.anemic_subalgebra():
                    pass

                else:
                    raise TypeError
            else:
                A = self.matrix_space()(x)
                if check:
                    if not A.is_scalar():
                        raise NotImplementedError("Membership testing for '%s' not implemented" % self)
                return hecke_operator.HeckeAlgebraElement_matrix(self, A)

        except TypeError:
            raise TypeError("Don't know how to construct an element of %s from %s" % (self, x))