def __call__(self, x):
        """
        Coerce x into a boundary symbol space.

        If x is a modular symbol (with the same group, weight, character,
        sign, and base field), this returns the image of that modular
        symbol under the boundary map.

        EXAMPLES::

            sage: M = ModularSymbols(Gamma0(15), 2) ; B = M.boundary_space()
            sage: B(M.0)
            [Infinity] - [0]
            sage: B(Cusp(1))
            [0]
            sage: B(Cusp(oo))
            [Infinity]
            sage: B(7)
            Traceback (most recent call last):
            ...
            TypeError: Coercion of 7 (of type <type 'sage.rings.integer.Integer'>) into Space of Boundary Modular Symbols for Congruence Subgroup Gamma0(15) of weight 2 and over Rational Field not (yet) defined.
        """
        if isinstance(x, int) and x == 0:
            return BoundarySpaceElement(self, {})

        elif isinstance(x, cusps.Cusp):
            return self._coerce_cusp(x)

        elif manin_symbols.is_ManinSymbol(x):
            return self._coerce_in_manin_symbol(x)

        elif element.is_ModularSymbolsElement(x):
            M = x.parent()
            if not isinstance(M, ambient.ModularSymbolsAmbient):
                raise TypeError(
                    "x (=%s) must be an element of a space of modular symbols of type ModularSymbolsAmbient"
                    % x)
            if M.level() != self.level():
                raise TypeError("x (=%s) must have level %s but has level %s" %
                                (x, self.level(), M.level()))
            S = x.manin_symbol_rep()
            if len(S) == 0:
                return self(0)
            return sum([c * self._coerce_in_manin_symbol(v) for c, v in S])

        elif is_FreeModuleElement(x):
            y = dict([(i, x[i]) for i in xrange(len(x))])
            return BoundarySpaceElement(self, y)

        raise TypeError(
            "Coercion of %s (of type %s) into %s not (yet) defined." %
            (x, type(x), self))
Example #2
0
    def __call__(self, x):
        """
        Coerce x into a boundary symbol space.
        
        If x is a modular symbol (with the same group, weight, character,
        sign, and base field), this returns the image of that modular
        symbol under the boundary map.
        
        EXAMPLES::
        
            sage: M = ModularSymbols(Gamma0(15), 2) ; B = M.boundary_space()
            sage: B(M.0)
            [Infinity] - [0]
            sage: B(Cusp(1))
            [0]
            sage: B(Cusp(oo))
            [Infinity]
            sage: B(7)
            Traceback (most recent call last):
            ...
            TypeError: Coercion of 7 (of type <type 'sage.rings.integer.Integer'>) into Space of Boundary Modular Symbols for Congruence Subgroup Gamma0(15) of weight 2 and over Rational Field not (yet) defined.
        """
        if isinstance(x, int) and x == 0:
            return BoundarySpaceElement(self, {})

        elif isinstance(x, cusps.Cusp):
            return self._coerce_cusp(x)

        elif manin_symbols.is_ManinSymbol(x):
            return self._coerce_in_manin_symbol(x)
        
        elif element.is_ModularSymbolsElement(x):
            M = x.parent()
            if not isinstance(M, ambient.ModularSymbolsAmbient):
                raise TypeError, "x (=%s) must be an element of a space of modular symbols of type ModularSymbolsAmbient"%x
            if M.level() != self.level():
                raise TypeError, "x (=%s) must have level %s but has level %s"%(
                    x, self.level(), M.level())
            S = x.manin_symbol_rep()
            if len(S) == 0:
                return self(0)
            return sum([c*self._coerce_in_manin_symbol(v) for c, v in S])

        elif is_FreeModuleElement(x):
            y = dict([(i,x[i]) for i in xrange(len(x))])
            return BoundarySpaceElement(self, y)

        raise TypeError, "Coercion of %s (of type %s) into %s not (yet) defined."%(x, type(x), self)