julia
191be7c1 - New `prod(::AbstractArray{BigInt})` implementation (#59456)

Commit
146 days ago
New `prod(::AbstractArray{BigInt})` implementation (#59456) Instead of taking of using a pre-allocated linear product tree (i.e. `foldl(mul!, arr)`), use a balanced binary product tree with pre-allocated linear leaves of length 16. This is far from optimal but already often an order of magnitude or two faster than the current implementation. It can be sub-optimal by up to a factor of `log2(n)`. This is reached in the case where there is one big element and the rest are small and nonzero in which case this implementation performs `log2(n)` large multiplications while the optimal only performs `1`. The current implementation is sub-optimal by a factor of `n/log2(n)` in cases where all the elements are similar sizes. Fixes #59052
Author
Parents
Loading