Counting All Lattice Rectangles in the Square Grid in Near-Linear Time
Dmitry Babichev, and Sergey Babichev

TL;DR
This paper develops efficient algorithms for counting all lattice rectangles within a square grid, including non-axis-parallel ones, achieving near-linear time complexity for the problem.
Contribution
The authors introduce several exact algorithms with improved complexities, including a near-linear time algorithm for counting all lattice rectangles in a grid.
Findings
Multiple algorithms with complexities from O(n^2) to O(n log^2 n) for counting lattice rectangles.
An all-values algorithm computing counts for all sizes in O(N^{3/2}) operations.
A two-term asymptotic expansion for the count function validating the algorithms.
Abstract
We study the exact counting problem for all lattice rectangles contained in the square , including non-axis-parallel ones. Starting from the standard parametrization by a primitive direction and two side lengths, we derive several exact algorithms: the classical sweep, decompositions of complexity and , a ten-moment weighted-floor-sum reduction of complexity , and a divisor-layer algorithm with the complexity . We also give an all-values algorithm that computes in arithmetic operations. The main idea behind the near-linear one-value algorithms is to reduce the geometric summation to constant-size families of weighted floor sums closed under Euclidean-style affine and reciprocal transformations. Besides the exact algorithmic results, we derive a two-term…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
