Пример #1
0
    def __call__(self, x):
        """
        Coerce an element into this quotient space V/W if there is a way to make
        sense of it.

        An element coerces in if it can be coerced into V, or if not at least if
        if it can be made sense of as a list of length the dimension of self.

        EXAMPLES:
        We create a 2-dimensional quotient of a 3-dimension ambient vector space.
            sage: M = QQ^3 / [[1,2,3]]

        A list of length 3 coerces into QQ^3, so it coerces into M.
            sage: M([1,2,4])
            (-1/3, -2/3)
            sage: M([1,2,3])
            (0, 0)

        A list of length 2 at least coerces into M, where here it just gives
        the corresponding linear combination of the basis for M.
            sage: M([1,2])
            (1, 2)
            sage: M.0 + 2*M.1
            (1, 2)
        """
        try:
            if x.parent() is self:
                return x
        except AttributeError:
            pass
        try:
            return FreeModule_ambient_field.__call__(self, x)
        except TypeError:
            pass
        return self._coerce_impl(self.__domain(x))
    def __call__(self, x):
        """
        Coerce an element into this quotient space V/W if there is a way to make
        sense of it.

        An element coerces in if it can be coerced into V, or if not at least if
        if it can be made sense of as a list of length the dimension of self.

        EXAMPLES:
        We create a 2-dimensional quotient of a 3-dimension ambient vector space.
            sage: M = QQ^3 / [[1,2,3]]

        A list of length 3 coerces into QQ^3, so it coerces into M.
            sage: M([1,2,4])
            (-1/3, -2/3)
            sage: M([1,2,3])
            (0, 0)

        A list of length 2 at least coerces into M, where here it just gives
        the corresponding linear combination of the basis for M.
            sage: M([1,2])
            (1, 2)
            sage: M.0 + 2*M.1
            (1, 2)
        """
        try:
            if x.parent() is self:
                return x
        except AttributeError:
            pass
        try:
            return FreeModule_ambient_field.__call__(self, x)
        except TypeError:
            pass
        return self._coerce_impl(self.__domain(x))