Пример #1
0
        def pushout_univariate_factors(self, other, var, Sfactors, Ofactors):
            try:
                return merge_overlapping(Sfactors, Ofactors, lambda f: (underlying_class(f), f._var_.var_repr))
            except ValueError:
                pass

            cm = sage.structure.element.get_coercion_model()
            try:
                Z = cm.common_parent(*Sfactors + Ofactors)
                return (Z,), (Z,)
            except TypeError:
                pass

            def subfactors(F):
                for f in F:
                    if isinstance(f, GenericProduct):
                        for g in subfactors(f.cartesian_factors()):
                            yield g
                    else:
                        yield f

            try:
                return merge_overlapping(
                    tuple(subfactors(Sfactors)),
                    tuple(subfactors(Ofactors)),
                    lambda f: (underlying_class(f), f._var_.var_repr),
                )
            except ValueError:
                pass

            from sage.structure.coerce_exceptions import CoercionException

            raise CoercionException(
                "Cannot construct the pushout of %s and %s: The factors "
                "with variables %s are not overlapping, "
                "no common parent was found, and "
                "splitting the factors was unsuccessful." % (self, other, var)
            )
Пример #2
0
        def pushout_univariate_factors(self, other, var, Sfactors, Ofactors):
            try:
                return merge_overlapping(
                    Sfactors, Ofactors, lambda f:
                    (underlying_class(f), f._var_.var_repr))
            except ValueError:
                pass

            cm = sage.structure.element.get_coercion_model()
            try:
                Z = cm.common_parent(*Sfactors + Ofactors)
                return (Z, ), (Z, )
            except TypeError:
                pass

            def subfactors(F):
                for f in F:
                    if isinstance(f, GenericProduct):
                        for g in subfactors(f.cartesian_factors()):
                            yield g
                    else:
                        yield f

            try:
                return merge_overlapping(
                    tuple(subfactors(Sfactors)), tuple(subfactors(Ofactors)),
                    lambda f: (underlying_class(f), f._var_.var_repr))
            except ValueError:
                pass

            from sage.structure.coerce_exceptions import CoercionException
            raise CoercionException(
                'Cannot construct the pushout of %s and %s: The factors '
                'with variables %s are not overlapping, '
                'no common parent was found, and '
                'splitting the factors was unsuccessful.' % (self, other, var))
Пример #3
0
    def _create_element_in_extension_(self, element):
        r"""
        Create an element in an extension of this Cartesian product of
        growth groups which is chosen according to the input ``element``.

        INPUT:

        - ``element`` -- a tuple.

        OUTPUT:

        An element.

        EXAMPLES::

            sage: from sage.rings.asymptotic.growth_group import GrowthGroup
            sage: G = GrowthGroup('z^ZZ * log(z)^ZZ')
            sage: z = G('z')[0]
            sage: lz = G('log(z)')[1]
            sage: G._create_element_in_extension_((z^3, lz)).parent()
            Growth Group z^ZZ * log(z)^ZZ
            sage: G._create_element_in_extension_((z^(1/2), lz)).parent()
            Growth Group z^QQ * log(z)^ZZ

        ::

            sage: G._create_element_in_extension_((3, 3, 3))
            Traceback (most recent call last):
            ...
            ValueError: Cannot create (3, 3, 3) as a Cartesian product like
            Growth Group z^ZZ * log(z)^ZZ.
        """
        factors = self.cartesian_factors()
        if len(element) != len(factors):
            raise ValueError(
                'Cannot create %s as a Cartesian product like %s.' %
                (element, self))

        if all(n.parent() is f for n, f in zip(element, factors)):
            parent = self
        else:
            from misc import underlying_class
            parent = underlying_class(self)(tuple(n.parent() for n in element),
                                            category=self.category())
        return parent(element)
Пример #4
0
    def _create_element_in_extension_(self, element):
        r"""
        Create an element in an extension of this Cartesian product of
        growth groups which is chosen according to the input ``element``.

        INPUT:

        - ``element`` -- a tuple.

        OUTPUT:

        An element.

        EXAMPLES::

            sage: from sage.rings.asymptotic.growth_group import GrowthGroup
            sage: G = GrowthGroup('z^ZZ * log(z)^ZZ')
            sage: z = G('z')[0]
            sage: lz = G('log(z)')[1]
            sage: G._create_element_in_extension_((z^3, lz)).parent()
            Growth Group z^ZZ * log(z)^ZZ
            sage: G._create_element_in_extension_((z^(1/2), lz)).parent()
            Growth Group z^QQ * log(z)^ZZ

        ::

            sage: G._create_element_in_extension_((3, 3, 3))
            Traceback (most recent call last):
            ...
            ValueError: Cannot create (3, 3, 3) as a Cartesian product like
            Growth Group z^ZZ * log(z)^ZZ.
        """
        factors = self.cartesian_factors()
        if len(element) != len(factors):
            raise ValueError('Cannot create %s as a Cartesian product like %s.' %
                             (element, self))

        if all(n.parent() is f for n, f in zip(element, factors)):
            parent = self
        else:
            from misc import underlying_class
            parent = underlying_class(self)(tuple(n.parent() for n in element),
                                            category=self.category())
        return parent(element)