平方根倒数速算法:修订间差异

求闻百科,共笔求闻
添加的内容 删除的内容
无编辑摘要
(机器人:清理不当的来源;移除无用的模板参数;替换{{reflist}}等模板参数;替换裸露的<references />)
第161行: 第161行:
|}
|}


对猜测平方根倒数速算法的最初构想来说,计算首次近似值所使用的常数'''<tt>0x5f3759df</tt>'''也是重要的线索。为确定程序员最初选此常数以近似求取平方根倒数的方法,Charles McEniry首先检验了在代码中选择任意常数R所求取出的首次近似值的精度。回想上一节关于整数和浮点数表示的比较:对于同样的32位二进制数码,若为浮点数表示时实际数值为<math>\textstyle x=(1+m_x)2^{e_x}</math>,而若为整数表示时实际数值则为<math>\textstyle I_x=E_xL+M_x</math>{{NoteTag|此处“浮点数”所指为标准化浮点数,也即有效数字部分必须满足<math>\textstyle 0 \le m_x <1)</math>,可参见{{cite journal|author = David Goldberg|title = What Every Computer Scientist Should Know About Floating-Point Arithmetic|url = https://archive.org/details/sim_acm-computing-surveys_1991-03_23_1/page/5|journal = [[ACM Computing Surveys]]|volume = 23|issue = 1|pages = 5–48|doi = 10.1145/103162.103163|date=March 1991}}}},其中<math>\textstyle L=2^{n-1-b}</math>。以下等式引入了一些由指数和有效数字导出的新元素:
对猜测平方根倒数速算法的最初构想来说,计算首次近似值所使用的常数'''<tt>0x5f3759df</tt>'''也是重要的线索。为确定程序员最初选此常数以近似求取平方根倒数的方法,Charles McEniry首先检验了在代码中选择任意常数R所求取出的首次近似值的精度。回想上一节关于整数和浮点数表示的比较:对于同样的32位二进制数码,若为浮点数表示时实际数值为<math>\textstyle x=(1+m_x)2^{e_x}</math>,而若为整数表示时实际数值则为<math>\textstyle I_x=E_xL+M_x</math>{{NoteTag|此处“浮点数”所指为标准化浮点数,也即有效数字部分必须满足<math>\textstyle 0 \le m_x <1)</math>,可参见{{cite journal|author = David Goldberg|title = What Every Computer Scientist Should Know About Floating-Point Arithmetic||journal = [[ACM Computing Surveys]]|volume = 23|issue = 1|pages = 5–48|doi = 10.1145/103162.103163|date=March 1991}}}},其中<math>\textstyle L=2^{n-1-b}</math>。以下等式引入了一些由指数和有效数字导出的新元素:
:<math>m_x=\frac{M_x}{L}</math>
:<math>m_x=\frac{M_x}{L}</math>
:<math>e_x=E_x-B</math>,其中<math>B=2^{b-1}-1</math>
:<math>e_x=E_x-B</math>,其中<math>B=2^{b-1}-1</math>
第227行: 第227行:
* {{Cite document| ref = harv| last = Eberly| first = David| title = Fast Inverse Square Root| publisher = Geometric Tools| year = 2002| url = http://www.geometrictools.com/Documentation/FastInverseSqrt.pdf| accessdate = 2009-03-22| | | }}
* {{Cite document| ref = harv| last = Eberly| first = David| title = Fast Inverse Square Root| publisher = Geometric Tools| year = 2002| url = http://www.geometrictools.com/Documentation/FastInverseSqrt.pdf| accessdate = 2009-03-22| | | }}
* {{cite web |ref={{harvid|Fog|2010}} |url=http://www.agner.org/optimize/calling_conventions.pdf |title=Calling conventions for different C++ compilers and operating systems: Chapter 3, Data Representation |date=2010-02-16 |accessdate=2010-08-30 |last=Fog |first=Agner |||}}
* {{cite web |ref={{harvid|Fog|2010}} |url=http://www.agner.org/optimize/calling_conventions.pdf |title=Calling conventions for different C++ compilers and operating systems: Chapter 3, Data Representation |date=2010-02-16 |accessdate=2010-08-30 |last=Fog |first=Agner |||}}
* {{cite book|ref=harv|last=Hennessey|first=John|coauthors=Patterson, David A.|title=Computer Organization and Design|publisher=Morgan Kaufmann Publishers|location=San Francisco, CA|year=1998|edition=2nd|isbn=978-1-55860-491-9|url=http://books.google.com/?id=7-ZQAAAAMAAJ}}
* {{cite book|ref=harv|last=Hennessey|first=John|coauthors=Patterson, David A.|title=Computer Organization and Design|publisher=Morgan Kaufmann Publishers|location=San Francisco, CA|year=1998|edition=2nd|isbn=978-1-55860-491-9|}}
* {{cite web|ref={{harvid|Lomont|2003}}|url=http://www.lomont.org/Math/Papers/2003/InvSqrt.pdf|title=Fast Inverse Square Root|last=Lomont|first=Chris|date=February 2003|accessdate=2009-02-13|||}}
* {{cite web|ref={{harvid|Lomont|2003}}|url=http://www.lomont.org/Math/Papers/2003/InvSqrt.pdf|title=Fast Inverse Square Root|last=Lomont|first=Chris|date=February 2003|accessdate=2009-02-13|||}}
* {{cite web|ref={{harvid|McEniry|2007}}|url=http://www.daxia.com/bibis/upload/406Fast_Inverse_Square_Root.pdf|title=The Mathematics Behind the Fast Inverse Square Root Function Code|last=McEniry|first=Charles|date=August 2007|accessdate=2009-02-13|||}}
* {{cite web|ref={{harvid|McEniry|2007}}|url=http://www.daxia.com/bibis/upload/406Fast_Inverse_Square_Root.pdf|title=The Mathematics Behind the Fast Inverse Square Root Function Code|last=McEniry|first=Charles|date=August 2007|accessdate=2009-02-13|||}}