Skip to content
This repository has been archived by the owner on Sep 1, 2023. It is now read-only.

Document the lattice point enumeration #73

Merged
merged 1 commit into from
Jan 15, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/nupic/experimental/GridUniqueness.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,16 @@ struct LatticeBox {
* Enumerate the points of a lattice near or within a specified rectangle. This
* is equivalent to checking whether any circles centered on the points of a
* lattice overlap the rectangle.
*
* This enumeration works by first guessing at an initial lattice point (i, j),
* then performing a series of nested sweeps. It sweeps downward, decrementing j
* until decrementing j causes the distance of the lattice point from the
* rectangle to increase. Then it sweeps upward using the same rules. It sweeps
* leftward, decrementing i and repeating these downward and upward sweeps at
* each i until it passes the lowest i possible for this rectangle. It repeats
* the process sweeping right. As it sweeps left and right it attempts to choose
* a good starting j value by considering results from the previous downward and
* upward sweeps.
*/
class LatticePointEnumerator
{
Expand Down Expand Up @@ -170,7 +180,7 @@ class LatticePointEnumerator
{
bool foundContainedPoint = false;

while (!foundContainedPoint && i_ <= iMax_)
while (!foundContainedPoint && (!sweepingLeft_ || i_ <= iMax_))
{
const pair<double, double> p = transform2D(latticeBasis_, {i_, j_});

Expand Down