Python中的平方根倒数 [英] inverse square root in Python
问题描述
是否有任何 Python 库提供实现以下链接中描述的快速平方根倒数"算法的函数?http://en.wikipedia.org/wiki/Fast_inverse_square_root也许 numpy/SciPy?
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?
推荐答案
你已经可以做平方根了,只要做 x**-1/2
所以你不需要做一个这样做的功能很复杂,无论如何这样做可能会更快,而且更容易
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
就像 interjay 所说的那样,如果您真的担心此类事情的速度,您可能应该使用更快更准确的语言来获得更快的方法
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
我发现的唯一可能拥有它的库是 mpmath
the only library that maybe has it that i found is mpmath
祝你好运!!
这篇关于Python中的平方根倒数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!