Commit 089e285
committed
Optimize ellipk and ellipe with binary tree branching
Replace O(n) linear if-elseif chain with O(log n) binary tree branching
for polynomial table selection. Key optimizations:
- Add _ellipk_core and _ellipe_core with binary tree structure
- Use integer index (idx = unsafe_trunc(Int, m*10)) for faster icmp vs fcmp
- Simplify wrapper functions to handle only negative m and special cases
- Add special handling for extremely negative m where x rounds to 1.0
Performance improvement:
- ellipk: 1.33x average speedup (10.5ns -> 7.9ns)
- ellipe: 1.46x average speedup (12.0ns -> 8.2ns)
- Largest gains for m in [0.65, 0.875]: 1.5x-1.85x speedup
All polynomial coefficients unchanged - only branching structure optimized.1 parent b846391 commit 089e285
1 file changed
+269
-257
lines changed
0 commit comments