def __call__(self, x):
        """
        Return the image of ``x``

        INPUT:

        - ``x`` -- a vector or lattice polytope.

        EXAMPLES::

            sage: from sage.geometry.polyhedron.ppl_lattice_polytope \
            ....:     import LatticePolytope_PPL, C_Polyhedron
            sage: from sage.geometry.polyhedron.lattice_euclidean_group_element \
            ....:     import LatticeEuclideanGroupElement
            sage: M = LatticeEuclideanGroupElement([[1,2],[2,3],[-1,2]], [1,2,3])
            sage: M(vector(ZZ, [11,13]))
            (38, 63, 18)
            sage: M(LatticePolytope_PPL((0,0),(1,0),(0,1)))
            A 2-dimensional lattice polytope in ZZ^3 with 3 vertices
        """
        from sage.geometry.polyhedron.ppl_lattice_polytope import (
            LatticePolytope_PPL, LatticePolytope_PPL_class)
        if isinstance(x, LatticePolytope_PPL_class):
            if x.is_empty():
                from sage.libs.ppl import C_Polyhedron
                return LatticePolytope_PPL(C_Polyhedron(self._b.degree(),
                                                        'empty'))
            return LatticePolytope_PPL(*[self(v) for v in x.vertices()])
            pass
        v = self._A*x+self._b
        v.set_immutable()

        return v
Пример #2
0
def Newton_polygon_embedded(polynomial, variables):
    r"""
    Embed the Newton polytope of the polynomial in one of the three
    maximal reflexive polygons.

    This function is a helper for :func:`WeierstrassForm`

    INPUT:

    Same as :func:`WeierstrassForm` with only a single polynomial passed.

    OUTPUT:

    A tuple `(\Delta, P, (x,y))` where

    * `\Delta` is the Newton polytope of ``polynomial``.

    * `P(x,y)` equals the input ``polynomial`` but with redefined variables
      such that its Newton polytope is `\Delta`.

    EXAMPLES::

        sage: from sage.schemes.toric.weierstrass import Newton_polygon_embedded
        sage: R.<x,y,z> = QQ[]
        sage: cubic = x^3 + y^3 + z^3
        sage: Newton_polygon_embedded(cubic, [x,y,z])
        (A 2-dimensional lattice polytope in ZZ^3 with 3 vertices,
         x^3 + y^3 + 1,
         (x, y))

        sage: R.<a, x,y,z> = QQ[]
        sage: cubic = x^3 + a*y^3 + a^2*z^3
        sage: Newton_polygon_embedded(cubic, variables=[x,y,z])
        (A 2-dimensional lattice polytope in ZZ^3 with 3 vertices,
         a^2*x^3 + y^3 + a,
         (x, y))

        sage: R.<s,t,x,y> = QQ[]
        sage: biquadric = (s+t)^2 * (x+y)^2
        sage: Newton_polygon_embedded(biquadric, [s,t,x,y])
        (A 2-dimensional lattice polytope in ZZ^4 with 4 vertices,
         s^2*t^2 + 2*s^2*t + 2*s*t^2 + s^2 + 4*s*t + t^2 + 2*s + 2*t + 1,
         (s, t))
    """
    p_dict = Newton_polytope_vars_coeffs(polynomial, variables)
    newton_polytope = LatticePolytope_PPL(list(p_dict))
    assert newton_polytope.affine_dimension() <= 2
    embedding = newton_polytope.embed_in_reflexive_polytope('points')
    x, y = variables[0:2]
    embedded_polynomial = polynomial.parent().zero()
    for e, c in p_dict.items():
        e_embed = embedding[e]
        embedded_polynomial += c * x**(e_embed[0]) * y**(e_embed[1])
    return newton_polytope, embedded_polynomial, (x, y)
Пример #3
0
def Newton_polygon_embedded(polynomial, variables):
    r"""
    Embed the Newton polytope of the polynomial in one of the three
    maximal reflexive polygons.

    This function is a helper for :func:`WeierstrassForm`

    INPUT:

    Same as :func:`WeierstrassForm` with only a single polynomial passed.

    OUTPUT:

    A tuple `(\Delta, P, (x,y))` where

    * `\Delta` is the Newton polytope of ``polynomial``.

    * `P(x,y)` equals the input ``polynomial`` but with redefined variables
      such that its Newton polytope is `\Delta`.

    EXAMPLES::

        sage: from sage.schemes.toric.weierstrass import Newton_polygon_embedded
        sage: R.<x,y,z> = QQ[]
        sage: cubic = x^3 + y^3 + z^3
        sage: Newton_polygon_embedded(cubic, [x,y,z])
        (A 2-dimensional lattice polytope in ZZ^3 with 3 vertices,
         x^3 + y^3 + 1,
         (x, y))

        sage: R.<a, x,y,z> = QQ[]
        sage: cubic = x^3 + a*y^3 + a^2*z^3
        sage: Newton_polygon_embedded(cubic, variables=[x,y,z])
        (A 2-dimensional lattice polytope in ZZ^3 with 3 vertices,
         a^2*x^3 + y^3 + a,
         (x, y))

        sage: R.<s,t,x,y> = QQ[]
        sage: biquadric = (s+t)^2 * (x+y)^2
        sage: Newton_polygon_embedded(biquadric, [s,t,x,y])
        (A 2-dimensional lattice polytope in ZZ^4 with 4 vertices,
         s^2*t^2 + 2*s^2*t + 2*s*t^2 + s^2 + 4*s*t + t^2 + 2*s + 2*t + 1,
         (s, t))
    """
    p_dict = Newton_polytope_vars_coeffs(polynomial, variables)
    newton_polytope = LatticePolytope_PPL(p_dict.keys())
    assert newton_polytope.affine_dimension() <= 2
    embedding = newton_polytope.embed_in_reflexive_polytope('points')
    x, y = variables[0:2]
    embedded_polynomial = polynomial.parent().zero()
    for e, c in p_dict.iteritems():
        e_embed = embedding[e]
        embedded_polynomial += c * x**(e_embed[0]) * y**(e_embed[1])
    return newton_polytope, embedded_polynomial, (x, y)
Пример #4
0
def polar_P2_112_polytope():
    """
    The polar of the `P^2[1,1,2]` polytope

    EXAMPLES::

        sage: from sage.geometry.polyhedron.ppl_lattice_polygon import polar_P2_112_polytope
        sage: polar_P2_112_polytope()
        A 2-dimensional lattice polytope in ZZ^2 with 3 vertices
        sage: _.vertices()
        ((0, 0), (0, 2), (4, 0))
    """
    return LatticePolytope_PPL((0, 0), (4, 0), (0, 2))
Пример #5
0
def polar_P1xP1_polytope():
    r"""
    The polar of the `P^1 \times P^1` polytope

    EXAMPLES::

        sage: from sage.geometry.polyhedron.ppl_lattice_polygon import polar_P1xP1_polytope
        sage: polar_P1xP1_polytope()
        A 2-dimensional lattice polytope in ZZ^2 with 4 vertices
        sage: _.vertices()
        ((0, 0), (0, 2), (2, 0), (2, 2))
    """
    return LatticePolytope_PPL((0, 0), (2, 0), (0, 2), (2, 2))
Пример #6
0
    def _iterate_PPL(self, start, stop, step):
        """
        Iterate over the reflexive polytopes.

        INPUT:

        - ``start``, ``stop``, ``step`` -- integers specifying the
          range to iterate over.

        OUTPUT:

        A generator for PPL-based lattice polyhedra.

        EXAMPLES::

            sage: from sage.geometry.polyhedron.palp_database import PALPreader
            sage: polygons = PALPreader(2)
            sage: iter = polygons._iterate_PPL(0,4,2)
            sage: next(iter)
            A 2-dimensional lattice polytope in ZZ^2 with 3 vertices
        """
        for vertices in self._iterate_list(start, stop, step):
            yield LatticePolytope_PPL(*vertices)