跳转到内容

CORDIC:修订间差异

维基百科,自由的百科全书
删除的内容 添加的内容
无编辑摘要
标签修改數值
第151行: 第151行:
<ref name="Schmid_1983">{{cite book |title=Decimal Computation |author-first=Hermann |author-last=Schmid<!-- General Electric Company, Binghamton, New York, USA --> |date=1983 |edition=1 (reprint) |publisher=Robert E. Krieger Publishing Company |location=Malabar, Florida, USA |pages=162, 165–176, 181–193 |isbn=0-89874-318-4 |url=https://books.google.com/books?id=uEYZAQAAIAAJ |access-date=2016-01-03}} (NB. At least some batches of this reprint edition were misprints with defective pages 115–146.<!-- they contain the contents of another book -->)</ref>
<ref name="Schmid_1983">{{cite book |title=Decimal Computation |author-first=Hermann |author-last=Schmid<!-- General Electric Company, Binghamton, New York, USA --> |date=1983 |edition=1 (reprint) |publisher=Robert E. Krieger Publishing Company |location=Malabar, Florida, USA |pages=162, 165–176, 181–193 |isbn=0-89874-318-4 |url=https://books.google.com/books?id=uEYZAQAAIAAJ |access-date=2016-01-03}} (NB. At least some batches of this reprint edition were misprints with defective pages 115–146.<!-- they contain the contents of another book -->)</ref>
<ref name="Daggett_1959">{{cite journal |author-last=Daggett |author-first=Dan H. |title=Decimal-Binary Conversions in CORDIC |journal=IRE Transactions on Electronic Computers |volume=8 |issue=3 |id=EC-8(3):335–339 |pages=335–339 |publisher=The Institute of Radio Engineers, Inc. (IRE) |date=September 1959 |doi=10.1109/TEC.1959.5222694 |issn=0367-9950 |url=https://www.researchgate.net/researcher/74881302_D_H_Daggett |access-date=2016-01-02}}</ref>
<ref name="Daggett_1959">{{cite journal |author-last=Daggett |author-first=Dan H. |title=Decimal-Binary Conversions in CORDIC |journal=IRE Transactions on Electronic Computers |volume=8 |issue=3 |id=EC-8(3):335–339 |pages=335–339 |publisher=The Institute of Radio Engineers, Inc. (IRE) |date=September 1959 |doi=10.1109/TEC.1959.5222694 |issn=0367-9950 |url=https://www.researchgate.net/researcher/74881302_D_H_Daggett |access-date=2016-01-02}}</ref>
<ref name="Muller_2006">{{cite book |author-first=Jean-Michel |author-last=Muller |title=Elementary Functions: Algorithms and Implementation |edition=2 |publisher=Birkhäuser |location=Boston |date=2006 |page=134 |isbn=978-0-8176-4372-0 |lccn=2005048094 |url=http://perso.ens-lyon.fr/jean-michel.muller/SecondEdition.html |access-date=2015-12-01}}</ref>
<ref name="Andraka_1998">{{cite journal |author-last=Andraka |author-first=Ray |title=A survey of CORDIC algorithms for FPGA based computers |date=1998 |journal=ACM |publisher=Andraka Consulting Group, Inc. |location=North Kingstown, RI, USA |id=0-89791-978-5/98/01 |url=http://www.andraka.com/files/crdcsrvy.pdf |access-date=2016-05-08}}</ref>
}}
}}



2024年1月29日 (一) 13:08的版本

CORDIC(全稱為coordinate rotation digital computer),也稱為Volder演算法,是一個可以計算三角函數,簡單且有效率的演算法,可以在任意進制下運算,一般會每次計算一位數字。因此CORDIC 是Digit-by-digit方法中的一個例子。

CORDIC演算法還有其他的名稱,像是圓形CORDIC (Jack E. Volder)[1][2]線性CORDIC雙曲線CORDIC(John Stephen Walther)[3][4]、及泛用雙曲線CORDIC(GH CORDIC, Yuanyong Luo et al.)[5][6]。用類似的方式也可以計算雙曲函數平方根乘法除法指數對數等。

CORDIC和一些名為「偽乘法」(pseudo-multiplication)、「偽除法」(pseudo-division)及factor combining的方法,常用在沒有乘法器的應用(像是簡單的微控制器以及FPGA),其中會用到的運算是加法減法位元移位查找表。這些算法可歸類在「移位和相加」(shift-and-add)演算法中。在計算機科學中,若CPU沒有硬體的乘法器,常會用CORDIC來實現浮点数运算

歷史

英國數學家亨利·布里格斯英语Henry Briggs (mathematician)早在1624年時就已發現此算法[7][8],後來Robert Flower也在1771年時發現[9],不過後來是因為低複雜度的有限狀態CPU,才針對CORDIC作較進一步的最佳化。

CORDIC是在1956年問世[10][11],是由康维尔空氣電子部門的Jack E. Volder英语Jack E. Volder發現,一開始是因為要取代B-58轟炸機英语B-58 Hustler導航電腦上面的類比式解角器(resolver),更換成更準確而實時的數位方案[11]。因此,有時也會將CORDIC稱為數位解角器(digital resolver)[12][13]

Volder的研究,是因為1946年版CRC化学和物理手册中的公式而得到靈感[11]

其中是使成立的值,且

他的研究最後產生了一個內部的技術報告,提到用CORDIC演算法來求解正弦餘弦函數,以及一個實現此功能的原型電腦[10][11]。報告中也提到用修改版的CORDIC演算法計算雙曲函數、座標旋轉對數指數的可能性[10][11]。用CORDIC來進行乘法和除法運算的想法也是在此時形成[11]。依照CORDIC演算法的原則,Volder的同事Dan H. Daggett發展了在二進位以及二進碼十進數(BCD)之間轉換的演算法[11][14]

應用

CORDIC用簡單的移位和相加運算來處理像是三角函數、雙曲函數、對數函數、實數及複數乘法、除法、方根計算、線性系統求解、特徵值估測、奇异值分解QR分解等。因此,CORDIC可以用在許多的應用中,像是信號處理影像處理通訊系統机器人学三维计算机图形[15][16]

硬體

若沒有硬體乘法器的話,CORDIC一般會比其他算法要快很多,若是用FPGAASIC的話,使用的邏輯閘也會少很多。

CORDIC是FPGA開發應用程式(像是Xilinx的Vivado)中的標準半导体IP核,而不是使用特殊函數的冪級數實現,其原因是CORDIC IP的通用性,CORDIC可以計算許多不同的函數,而為特定函數開發的乘法器只能計算特定的函數。

另一方面,若有硬體乘法器(例如DSP),查表法及冪級數會比CORDIC快很多。近年來,CORDIC演算法常用在生醫應用中,尤其是用FPGA實現的應用[來源請求]

使用泰勒级数的問題是此方法可以產生小的絕對誤差,但其中沒有良態的相對誤差[17]。其他多項式近似法,例如Minimax近似演算法英语Minimax approximation algorithm,可以同時控制這二種的誤差。

軟體

在CPU只有整數運算的古老系統中,會將CORDIC放在其IEEE 754函式庫的一部份。現代的通用CPU已有浮點運算暫存器,也有加法、減法、乘法、除法、三角函數、平方根、一般對數、自然對數等,幾乎沒有用到CORDIC的場合。只有一些有特殊安全性或是時間要求的應用程式才會用到CORDIC。

運作模式

旋轉模式

CORDIC可以用來計算許多不同的函數。以下說明如何在旋轉模式(rotation mode)下的CORDIC計算角度的正弦函數和餘弦函數,假設角度以弧度的定點格式表示。要找到一個角度的正弦函數和餘弦函數,可以在單位圓上找到對應角度的y座標和座標。利用CORDIC,會從以下的向量開始:

CORDIC演算法的圖解

在第一次的迭代時,向量逆時針轉45°,得到向量。接著繼續的迭代,每一次的角度漸漸變小,旋轉方向可能順時針,也可能逆時針,直到得到想要的角度為止。每一次的角度為,其中

若以更正式的方式表示,每一次的迭代就是一次旋轉,也就是將向量乘以旋转矩阵

旋转矩阵為

利用以下兩個三角恆等式:

旋转矩阵變成

旋转向量就會變成下式

其中的分量,若將角度限制在使的值,和tangent的乘法就以變成乘(或除)2的幂次,在數位電腦硬體中可以快速的用位元右移或左移來計算。因此上法會變成

其中

是用來判斷旋轉方向的。若角度為正,則為+1,否則則為−1。

所有的因子可以在迭代過程中忽略,最後再一次乘以因子即可:

此數可以事先計算好存在表格中,若迭代次數是固定的,只需計算一個常數且儲存即可,甚至此修正也可以事先進行,將常數先乘以,可以節省一次乘法。另外,可以注意到[18]

因此可以簡化演算法的複雜度。有些應用會避免修正,因此此演算法本身會帶一個增益[19]

在夠多次的迭代後,向量的角度會接近想要的角度。以一般的應用來說,40次的迭代(n = 40)已可以有小數10位的精度。

唯一未解決的問題是判斷每一次迭代要順時針旋轉或逆時針旋轉(選擇的值)。這可以記錄每一次旋轉的角度,從還需要旋轉的角度中減去此一角度,會得到下一個還需要旋轉的角度。若為正,需要順時針旋轉,否則,就需要順時針旋轉:

的值需要事先計算且記錄下來。不過若是小角度,根據小角度近似,在定點數下可得,因此可以節省儲存用的空間。

如以上所述,角度的正弦函數為其y坐標,餘弦函數為其x坐標。

相關條目

參考資料

  1. ^ Volder, Jack E. The CORDIC Computing Technique (PDF). Proceedings of the Western Joint Computer Conference (WJCC) (presentation) (San Francisco, California, USA: National Joint Computer Committee (NJCC)). 1959-03-03: 257–261 [2016-01-02]. 
  2. ^ Volder, Jack E. The CORDIC Trigonometric Computing Technique (PDF). IRE Transactions on Electronic Computers (The Institute of Radio Engineers, Inc. (IRE)). 1959-05-25, 8 (3): 330–334 (reprint: 226–230) (September 1959) [2016-01-01]. EC-8(3):330–334. (原始内容 (PDF)存档于2021-06-12). 
  3. ^ Walther, John Stephen. 写于Palo Alto, California, USA. A unified algorithm for elementary functions (PDF). Proceedings of the Spring Joint Computer Conference (Atlantic City, New Jersey, USA: Hewlett-Packard Company). May 1971, 38: 379–385 [2016-01-01]. (原始内容 (PDF)存档于2021-06-12) –通过American Federation of Information Processing Societies (AFIPS). 
  4. ^ Walther, John Stephen. The Story of Unified CORDIC. The Journal of VLSI Signal Processing (Hingham, MA, USA: Kluwer Academic Publishers). June 2000, 25 (2 (Special issue on CORDIC)): 107–112. ISSN 0922-5773. S2CID 26922158. doi:10.1023/A:1008162721424. 
  5. ^ Luo, Yuanyong; Wang, Yuxuan; Ha, Yajun; Wang, Zhongfeng; Chen, Siyuan; Pan, Hongbing. Generalized Hyperbolic CORDIC and Its Logarithmic and Exponential Computation With Arbitrary Fixed Base. IEEE Transactions on Very Large Scale Integration (VLSI) Systems. September 2019, 27 (9): 2156–2169. S2CID 196171166. doi:10.1109/TVLSI.2019.2919557. 
  6. ^ Luo, Yuanyong; Wang, Yuxuan; Ha, Yajun; Wang, Zhongfeng; Chen, Siyuan; Pan, Hongbing. Corrections to "Generalized Hyperbolic CORDIC and Its Logarithmic and Exponential Computation With Arbitrary Fixed Base". IEEE Transactions on Very Large Scale Integration (VLSI) Systems. September 2019, 27 (9): 2222. S2CID 201711001. doi:10.1109/TVLSI.2019.2932174. 
  7. ^ Briggs, Henry. Arithmetica Logarithmica. London. 1624.  (Translation: [1] 互联网档案馆存檔,存档日期4 March 2016.)
  8. ^ Laporte, Jacques. Henry Briggs and the HP 35. Paris, France. 2014 [2016-01-02]. (原始内容存档于2015-03-09).  [2] 互联网档案馆存檔,存档日期2020-08-10.
  9. ^ Flower, Robert. The Radix. A new way of making logarithms.. London: J. Beecroft. 1771 [2016-01-02]. 
  10. ^ 10.0 10.1 10.2 Volder, Jack E., Binary Computation Algorithms for Coordinate Rotation and Function Generation (internal report), Convair, Aeroelectronics group, 1956-06-15, IAR-1.148 
  11. ^ 11.0 11.1 11.2 11.3 11.4 11.5 11.6 Volder, Jack E. The Birth of CORDIC (PDF). Journal of VLSI Signal Processing (Hingham, MA, USA: Kluwer Academic Publishers). June 2000, 25 (2 (Special issue on CORDIC)): 101–105 [2016-01-02]. ISSN 0922-5773. S2CID 112881. doi:10.1023/A:1008110704586. (原始内容 (PDF)存档于2016-03-04). 
  12. ^ Perle, Michael D., CORDIC Technique Reduces Trigonometric Function Look-Up, Computer Design (Boston, MA, USA: Computer Design Publishing Corp.), June 1971: 72–78  (NB. Some sources erroneously refer to this as by P. Z. Perle or in Component Design.)
  13. ^ Schmid, Hermann. Decimal Computation 1 (reprint). Malabar, Florida, USA: Robert E. Krieger Publishing Company. 1983: 162, 165–176, 181–193 [2016-01-03]. ISBN 0-89874-318-4.  (NB. At least some batches of this reprint edition were misprints with defective pages 115–146.)
  14. ^ Daggett, Dan H. Decimal-Binary Conversions in CORDIC. IRE Transactions on Electronic Computers (The Institute of Radio Engineers, Inc. (IRE)). September 1959, 8 (3): 335–339 [2016-01-02]. ISSN 0367-9950. doi:10.1109/TEC.1959.5222694. EC-8(3):335–339. 
  15. ^ Meher, Pramod Kumar; Valls, Javier; Juang, Tso-Bing; Sridharan, K.; Maharatna, Koushik. 50 Years of CORDIC: Algorithms, Architectures and Applications (PDF). IEEE Transactions on Circuits and Systems I: Regular Papers. 2008-08-22, 56 (9): 1893–1907 (2009-09-09). S2CID 5465045. doi:10.1109/TCSI.2009.2025803. 
  16. ^ Meher, Pramod Kumar; Park, Sang Yoon. Low Complexity Generic VLSI Architecture Design Methodology for Nth Root and Nth Power Computations. IEEE Transactions on Very Large Scale Integration (VLSI) Systems. February 2013, 21 (2): 217–228. S2CID 7059383. doi:10.1109/TVLSI.2012.2187080. 
  17. ^ Error bounds of Taylor Expansion for Sine. Math Stack Exchange. [2021-01-01]. 
  18. ^ Muller, Jean-Michel. Elementary Functions: Algorithms and Implementation 2. Boston: Birkhäuser. 2006: 134 [2015-12-01]. ISBN 978-0-8176-4372-0. LCCN 2005048094. 
  19. ^ Andraka, Ray. A survey of CORDIC algorithms for FPGA based computers (PDF). ACM (North Kingstown, RI, USA: Andraka Consulting Group, Inc.). 1998 [2016-05-08]. 0-89791-978-5/98/01. 

外部連結