Ticket #14891: toric_point_count.patch

File toric_point_count.patch, 2.4 KB (added by Adriana Salerno, 9 years ago)
  • sage/schemes/toric/variety.py

    # HG changeset patch
    # User Adriana Salerno <asalerno@bates.edu>
    # Date 1373851028 25200
    # Node ID b8d89ef361716195e98bbdcb7ff907ccc4e688bd
    # Parent  0f8fd922eaed351e39f913f1317d319dcceb4c01
    Added point counting function
    
    diff --git a/sage/schemes/toric/variety.py b/sage/schemes/toric/variety.py
    a b  
    27472747        from sage.geometry.fan import discard_faces
    27482748        return ToricVariety(Fan(discard_faces(cones), check=False))
    27492749
     2750    def toricPointCount(self,q):
     2751        r"""
     2752        This function computes the number of points in the ambient toric variety over F_q using the formula in Fulton [F], section 4.5, as long as the variety is smooth.
     2753
     2754        INPUT:
     2755
     2756        - ``q`` -- a positive prime integer or prime power.
     2757
     2758        OUTPUT:
     2759
     2760        - The number of points on the toric variety over Fq.
     2761
     2762
     2763        REFERENCES:
     2764
     2765        .. [F] Fulton, W., "Introduction to Toric Varieties", Princeton University Press, 1993.
     2766
     2767
     2768        EXAMPLES:
     2769
     2770        This example illustrates the point count for a few primes and powers of primes.
     2771
     2772            ::
     2773
     2774            sage: o = lattice_polytope.octahedron(3)
     2775            sage: cube = o.polar()
     2776            sage: V=ToricVariety(NormalFan(cube))
     2777            sage: V.toricPointCount(2)
     2778            27
     2779            sage: V.toricPointCount(8)
     2780            729
     2781            sage: V.toricPointCount(101)
     2782            1061208
     2783
     2784        This is an example of what happens for a non-smooth variety.
     2785
     2786            ::
     2787
     2788            sage: o = lattice_polytope.octahedron(3)
     2789            sage: V=ToricVariety(NormalFan(o))
     2790            sage: V.toricPointCount(31)
     2791            Traceback (most recent call last):
     2792            ...
     2793            TypeError: The variety is not smooth
     2794
     2795        AUTHORS:
     2796
     2797        - Beth Malmskog (2013-07-14): 0.1
     2798        - Adriana Salerno (2013-07-14): 0.1
     2799        - Yiwei She (2013-07-14): 0.1
     2800        - Christelle Vincent (2013-07-14): 0.1
     2801        - Ursula Whitcher (2013-07-14): 0.1
     2802
     2803        """
     2804        if self.is_smooth():
     2805            fan = self.fan()
     2806            cones=fan.cones()
     2807            n = self.dimension()
     2808            d = []
     2809            for i in range(n+1):
     2810                d.append(len(cones[i]))
     2811            card = 0
     2812            for k in range(n+1):
     2813                card = card + d[n-k]*(q-1)**k
     2814            return card
     2815        else:
     2816            raise TypeError, "The variety is not smooth"
    27502817
    27512818
    27522819