Comment Re:Vectorized factorials! (Score 1) 225
I never meant to suggest that it is optimal. But it certainly is "optimized!" Vectorizing this function is simply ridiculous.
That said, I just ran a benchmark, comparing it to the more straightforward code output by G++ 4.4. The vectorized version produced by 4.8 is slightly faster, by about 12%. The recursive approach is still quite a bit slower than a lookup table or switch-case. Interestingly, the lookup table and switch-case versions got slightly slower in 4.8 compared to 4.4.