> I was wondering if sage implements any algorithm for counting the number of > points with integer coordinates inside polyhedra with rational coordinates. > even such an algorithm for polygons would be useful for me.
Have a look at the integral_points method of Polyhedron objects, which might do what you're looking for: sage: P = Polyhedron([[1/2, 1/2], [1/2, 7/2], [7/2, 1/2], [7/2, 7/2]]) sage: P A 2-dimensional polyhedron in QQ^2 defined as the convex hull of 4 vertices. sage: P.integral_points() [(1, 1), (1, 2), (1, 3), (2, 1), (2, 2), (2, 3), (3, 1), (3, 2), (3, 3)] sage: len(P.integral_points()) 9 Note that this constructs the integral points rather than counts them, so if there are lots of points in the enveloping lattice polytope it won't be that fast, but maybe it'll work for your purposes. Doug -- Department of Earth Sciences University of Hong Kong -- To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
