Skip to content

Comments

feat: O(n) order_cherries using parental indices#94

Merged
Neclow merged 1 commit intosbhattlab:mainfrom
Neclow:faster_order_cherries
Aug 6, 2025
Merged

feat: O(n) order_cherries using parental indices#94
Neclow merged 1 commit intosbhattlab:mainfrom
Neclow:faster_order_cherries

Conversation

@Neclow
Copy link
Collaborator

@Neclow Neclow commented Aug 6, 2025

No need to use sort_by_key for row_idxs which is O(n log n), we can simply use the parental indices, which should be continuous (e.g., n, .., 2(n-1)) to reorder the rows in the ancestry matrix.

Also reduces the size of Fenwick trees to n_leaves - 1 instead of n_leaves (last element not needed).

Provided ~25% speed-ups on my machine (for n = 100000, from_newick went from ~9 ms to ~7 ms)

@Neclow
Copy link
Collaborator Author

Neclow commented Aug 6, 2025

GitHub: from ~12.5ms (#93) to 9.5ms!

@Neclow Neclow merged commit ca225c5 into sbhattlab:main Aug 6, 2025
7 checks passed
@Neclow Neclow deleted the faster_order_cherries branch August 6, 2025 14:44
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