Skip to content

Flat-array distance precomputation + bitset CSR pipeline#17

Open
adthoms wants to merge 1 commit into
MIT-SPARK:masterfrom
adthoms:worktree-agent-a929f846
Open

Flat-array distance precomputation + bitset CSR pipeline#17
adthoms wants to merge 1 commit into
MIT-SPARK:masterfrom
adthoms:worktree-agent-a929f846

Conversation

@adthoms
Copy link
Copy Markdown

@adthoms adthoms commented Apr 15, 2026

Summary

  • Add bulk pairwise distance precomputation using flat float arrays (include/robin/distance.hpp) and compact bitset edge storage with popcount-based CSR construction (include/robin/bitset.hpp)
  • Factor out pair_from_linear_index utility from inline code in core.hpp into math.hpp for reuse across the codebase
  • Wire optimized precomputed pipeline into Make3dRegInvGraph and Make3dNormalRegInvGraph with automatic fallback to existing path when memory budget exceeds 512MB

Test plan

  • pair_from_linear_index unit tests: validates all pairs unique and ordered for N=5,10,50,100
  • Precomputed graph equivalence test: builds graph via both existing atomic CSR and new precomputed path, compares per-vertex neighbor sets
  • Integration tests for Make3dRegInvGraph precomputed pipeline: no-outlier and with-outlier scenarios (N=20)
  • Existing test suite passes unchanged (precomputed path is transparent to callers)

🤖 Generated with Claude Code

Precompute all N*(N-1)/2 pairwise Euclidean distances as flat float
arrays, then scan once to build a bitset of compatible edges, and
convert to CSR graph. This eliminates per-pair Eigen temporaries and
operator[] calls, enabling SIMD-friendly memory access patterns.

New files:
- include/robin/distance.hpp: bulk pairwise Euclidean + cosine precomputation
- include/robin/bitset.hpp: compact bitset with popcount + CSR construction

Modified:
- include/robin/math.hpp: factored out pair_from_linear_index utility
- include/robin/robin.hpp: declared precomputed pipeline free functions
- src/robin.cpp: implemented precomputed pipelines, wired into Make3dRegInvGraph
  and Make3dNormalRegInvGraph with automatic fallback for large inputs
- tests/: added tests for pair_from_linear_index, precomputed graph equivalence,
  and integration tests for the optimized 3D registration pipeline

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant