问题
Does any Python library offer a function that implements the "fast inverse square root" algorithm described in following link? http://en.wikipedia.org/wiki/Fast_inverse_square_root Perhaps numpy/SciPy?
回答1:
You can already do the inverse square root just do x**-1/2
so you don't need to make a complicated function to do it and its probably faster to do it this way anyway and its much easier
and like interjay said if you're really worried about the speed of something like that you probably should use a faster more exact language to get a faster way
the only library that maybe has it that i found is mpmath
Good Luck!!
回答2:
You can do this in Python, but not in a very direct way (ie. lots of function calls), so doing x**-.5
will likely be much faster.
So it might be an interesting exercise, but not practical at all.
来源:https://stackoverflow.com/questions/16702339/inverse-square-root-in-python