I just was wondering how the pow
function of the math.h
library works, does it implement the simplest sequencial algorithm or does it use another one else?
I just know the repeated squaring algorithm, which reports O(log n), maybe this is the implemented algorithm by the pow
function?
So I just made some tests using the sequential algorithm vs pow
and found out that the first version is almost 3 times faster than the second. Does calling functions really punish that much the performance of this test? Why?
Any other comments explaining what's happening, or how pow
is implemented are welcome.
EDIT: I was wrong, pow
is 3 times faster than the sequential algorithm.