inverse square root in Python [closed]

别说谁变了你拦得住时间么 提交于 2019-12-02 00:29:31

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!