group__cos.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
  5. <meta http-equiv="X-UA-Compatible" content="IE=9"/>
  6. <title>CMSIS-DSP: Cosine</title>
  7. <link href="tabs.css" rel="stylesheet" type="text/css"/>
  8. <link href="cmsis.css" rel="stylesheet" type="text/css" />
  9. <script type="text/javascript" src="jquery.js"></script>
  10. <script type="text/javascript" src="dynsections.js"></script>
  11. <link href="navtree.css" rel="stylesheet" type="text/css"/>
  12. <script type="text/javascript" src="resize.js"></script>
  13. <script type="text/javascript" src="navtree.js"></script>
  14. <script type="text/javascript">
  15. $(document).ready(initResizable);
  16. </script>
  17. <link href="search/search.css" rel="stylesheet" type="text/css"/>
  18. <script type="text/javascript" src="search/search.js"></script>
  19. <script type="text/javascript">
  20. $(document).ready(function() { searchBox.OnSelectItem(0); });
  21. </script>
  22. <link href="stylsheetf" rel="stylesheet" type="text/css" />
  23. </head>
  24. <body>
  25. <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
  26. <div id="titlearea">
  27. <table cellspacing="0" cellpadding="0">
  28. <tbody>
  29. <tr style="height: 46px;">
  30. <td id="projectlogo"><img alt="Logo" src="CMSIS_Logo_Final.png"/></td>
  31. <td style="padding-left: 0.5em;">
  32. <div id="projectname">CMSIS-DSP
  33. &#160;<span id="projectnumber">Version 1.4.4</span>
  34. </div>
  35. <div id="projectbrief">CMSIS DSP Software Library</div>
  36. </td>
  37. </tr>
  38. </tbody>
  39. </table>
  40. </div>
  41. <!-- end header part -->
  42. <div id="CMSISnav" class="tabs1">
  43. <ul class="tablist">
  44. <li><a href="../../General/html/index.html"><span>CMSIS</span></a></li>
  45. <li><a href="../../Core/html/index.html"><span>CORE</span></a></li>
  46. <li><a href="../../Driver/html/index.html"><span>Driver</span></a></li>
  47. <li class="current"><a href="../../DSP/html/index.html"><span>DSP</span></a></li>
  48. <li><a href="../../RTOS/html/index.html"><span>RTOS API</span></a></li>
  49. <li><a href="../../Pack/html/index.html"><span>Pack</span></a></li>
  50. <li><a href="../../SVD/html/index.html"><span>SVD</span></a></li>
  51. </ul>
  52. </div>
  53. <!-- Generated by Doxygen 1.8.2 -->
  54. <script type="text/javascript">
  55. var searchBox = new SearchBox("searchBox", "search",false,'Search');
  56. </script>
  57. <div id="navrow1" class="tabs">
  58. <ul class="tablist">
  59. <li><a href="index.html"><span>Main&#160;Page</span></a></li>
  60. <li><a href="pages.html"><span>Usage&#160;and&#160;Description</span></a></li>
  61. <li><a href="modules.html"><span>Reference</span></a></li>
  62. <li>
  63. <div id="MSearchBox" class="MSearchBoxInactive">
  64. <span class="left">
  65. <img id="MSearchSelect" src="search/mag_sel.png"
  66. onmouseover="return searchBox.OnSearchSelectShow()"
  67. onmouseout="return searchBox.OnSearchSelectHide()"
  68. alt=""/>
  69. <input type="text" id="MSearchField" value="Search" accesskey="S"
  70. onfocus="searchBox.OnSearchFieldFocus(true)"
  71. onblur="searchBox.OnSearchFieldFocus(false)"
  72. onkeyup="searchBox.OnSearchFieldChange(event)"/>
  73. </span><span class="right">
  74. <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
  75. </span>
  76. </div>
  77. </li>
  78. </ul>
  79. </div>
  80. </div><!-- top -->
  81. <div id="side-nav" class="ui-resizable side-nav-resizable">
  82. <div id="nav-tree">
  83. <div id="nav-tree-contents">
  84. <div id="nav-sync" class="sync"></div>
  85. </div>
  86. </div>
  87. <div id="splitbar" style="-moz-user-select:none;"
  88. class="ui-resizable-handle">
  89. </div>
  90. </div>
  91. <script type="text/javascript">
  92. $(document).ready(function(){initNavTree('group__cos.html','');});
  93. </script>
  94. <div id="doc-content">
  95. <!-- window showing the filter options -->
  96. <div id="MSearchSelectWindow"
  97. onmouseover="return searchBox.OnSearchSelectShow()"
  98. onmouseout="return searchBox.OnSearchSelectHide()"
  99. onkeydown="return searchBox.OnSearchSelectKey(event)">
  100. <a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Data Structures</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Macros</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&#160;</span>Groups</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(10)"><span class="SelectionMark">&#160;</span>Pages</a></div>
  101. <!-- iframe showing the search results (closed by default) -->
  102. <div id="MSearchResultsWindow">
  103. <iframe src="javascript:void(0)" frameborder="0"
  104. name="MSearchResults" id="MSearchResults">
  105. </iframe>
  106. </div>
  107. <div class="header">
  108. <div class="summary">
  109. <a href="#func-members">Functions</a> </div>
  110. <div class="headertitle">
  111. <div class="title">Cosine</div> </div>
  112. <div class="ingroups"><a class="el" href="group__group_fast_math.html">Fast Math Functions</a></div></div><!--header-->
  113. <div class="contents">
  114. <table class="memberdecls">
  115. <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
  116. Functions</h2></td></tr>
  117. <tr class="memitem:gace15287f9c64b9b4084d1c797d4c49d8"><td class="memItemLeft" align="right" valign="top"><a class="el" href="arm__math_8h.html#a4611b605e45ab401f02cab15c5e38715">float32_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__cos.html#gace15287f9c64b9b4084d1c797d4c49d8">arm_cos_f32</a> (<a class="el" href="arm__math_8h.html#a4611b605e45ab401f02cab15c5e38715">float32_t</a> x)</td></tr>
  118. <tr class="memdesc:gace15287f9c64b9b4084d1c797d4c49d8"><td class="mdescLeft">&#160;</td><td class="mdescRight">Fast approximation to the trigonometric cosine function for floating-point data. <a href="#gace15287f9c64b9b4084d1c797d4c49d8"></a><br/></td></tr>
  119. <tr class="separator:gace15287f9c64b9b4084d1c797d4c49d8"><td class="memSeparator" colspan="2">&#160;</td></tr>
  120. <tr class="memitem:gadfd60c24def501638c0d5db20f4c869b"><td class="memItemLeft" align="right" valign="top"><a class="el" href="arm__math_8h.html#ab5a8fb21a5b3b983d5f54f31614052ea">q15_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__cos.html#gadfd60c24def501638c0d5db20f4c869b">arm_cos_q15</a> (<a class="el" href="arm__math_8h.html#ab5a8fb21a5b3b983d5f54f31614052ea">q15_t</a> x)</td></tr>
  121. <tr class="memdesc:gadfd60c24def501638c0d5db20f4c869b"><td class="mdescLeft">&#160;</td><td class="mdescRight">Fast approximation to the trigonometric cosine function for Q15 data. <a href="#gadfd60c24def501638c0d5db20f4c869b"></a><br/></td></tr>
  122. <tr class="separator:gadfd60c24def501638c0d5db20f4c869b"><td class="memSeparator" colspan="2">&#160;</td></tr>
  123. <tr class="memitem:gad80f121949ef885a77d83ab36e002567"><td class="memItemLeft" align="right" valign="top"><a class="el" href="arm__math_8h.html#adc89a3547f5324b7b3b95adec3806bc0">q31_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__cos.html#gad80f121949ef885a77d83ab36e002567">arm_cos_q31</a> (<a class="el" href="arm__math_8h.html#adc89a3547f5324b7b3b95adec3806bc0">q31_t</a> x)</td></tr>
  124. <tr class="memdesc:gad80f121949ef885a77d83ab36e002567"><td class="mdescLeft">&#160;</td><td class="mdescRight">Fast approximation to the trigonometric cosine function for Q31 data. <a href="#gad80f121949ef885a77d83ab36e002567"></a><br/></td></tr>
  125. <tr class="separator:gad80f121949ef885a77d83ab36e002567"><td class="memSeparator" colspan="2">&#160;</td></tr>
  126. </table>
  127. <a name="details" id="details"></a><h2 class="groupheader">Description</h2>
  128. <p>Computes the trigonometric cosine function using a combination of table lookup and cubic interpolation. There are separate functions for Q15, Q31, and floating-point data types. The input to the floating-point version is in radians while the fixed-point Q15 and Q31 have a scaled input with the range [0 +0.9999] mapping to [0 2*pi). The fixed-point range is chosen so that a value of 2*pi wraps around to 0.</p>
  129. <p>The implementation is based on table lookup using 256 values together with cubic interpolation. The steps used are:</p>
  130. <ol type="1">
  131. <li>Calculation of the nearest integer table index</li>
  132. <li>Fetch the four table values a, b, c, and d</li>
  133. <li>Compute the fractional portion (fract) of the table index.</li>
  134. <li>Calculation of wa, wb, wc, wd</li>
  135. <li>The final result equals <code>a*wa + b*wb + c*wc + d*wd</code></li>
  136. </ol>
  137. <p>where </p>
  138. <pre>
  139. a=Table[index-1];
  140. b=Table[index+0];
  141. c=Table[index+1];
  142. d=Table[index+2];
  143. </pre><p> and </p>
  144. <pre>
  145. wa=-(1/6)*fract.^3 + (1/2)*fract.^2 - (1/3)*fract;
  146. wb=(1/2)*fract.^3 - fract.^2 - (1/2)*fract + 1;
  147. wc=-(1/2)*fract.^3+(1/2)*fract.^2+fract;
  148. wd=(1/6)*fract.^3 - (1/6)*fract;
  149. </pre> <h2 class="groupheader">Function Documentation</h2>
  150. <a class="anchor" id="gace15287f9c64b9b4084d1c797d4c49d8"></a>
  151. <div class="memitem">
  152. <div class="memproto">
  153. <table class="memname">
  154. <tr>
  155. <td class="memname"><a class="el" href="arm__math_8h.html#a4611b605e45ab401f02cab15c5e38715">float32_t</a> arm_cos_f32 </td>
  156. <td>(</td>
  157. <td class="paramtype"><a class="el" href="arm__math_8h.html#a4611b605e45ab401f02cab15c5e38715">float32_t</a>&#160;</td>
  158. <td class="paramname"><em>x</em></td><td>)</td>
  159. <td></td>
  160. </tr>
  161. </table>
  162. </div><div class="memdoc">
  163. <dl class="params"><dt>Parameters</dt><dd>
  164. <table class="params">
  165. <tr><td class="paramdir">[in]</td><td class="paramname">x</td><td>input value in radians. </td></tr>
  166. </table>
  167. </dd>
  168. </dl>
  169. <dl class="section return"><dt>Returns</dt><dd>cos(x). </dd></dl>
  170. <dl><dt><b>Examples: </b></dt><dd><a class="el" href="arm_sin_cos_example_f32_8c-example.html#a11">arm_sin_cos_example_f32.c</a>.</dd>
  171. </dl>
  172. <p>References <a class="el" href="arm__math_8h.html#afcb9147c96853bea484cfc2dde07463d">FAST_MATH_TABLE_SIZE</a>, and <a class="el" href="arm__common__tables_8c.html#a1dec82d596780f1a66ef4f76f137c1d9">sinTable_f32</a>.</p>
  173. <p>Referenced by <a class="el" href="arm__sin__cos__example__f32_8c.html#a52d2cba30e6946c95578be946ac12a65">main()</a>.</p>
  174. </div>
  175. </div>
  176. <a class="anchor" id="gadfd60c24def501638c0d5db20f4c869b"></a>
  177. <div class="memitem">
  178. <div class="memproto">
  179. <table class="memname">
  180. <tr>
  181. <td class="memname"><a class="el" href="arm__math_8h.html#ab5a8fb21a5b3b983d5f54f31614052ea">q15_t</a> arm_cos_q15 </td>
  182. <td>(</td>
  183. <td class="paramtype"><a class="el" href="arm__math_8h.html#ab5a8fb21a5b3b983d5f54f31614052ea">q15_t</a>&#160;</td>
  184. <td class="paramname"><em>x</em></td><td>)</td>
  185. <td></td>
  186. </tr>
  187. </table>
  188. </div><div class="memdoc">
  189. <dl class="params"><dt>Parameters</dt><dd>
  190. <table class="params">
  191. <tr><td class="paramdir">[in]</td><td class="paramname">x</td><td>Scaled input value in radians. </td></tr>
  192. </table>
  193. </dd>
  194. </dl>
  195. <dl class="section return"><dt>Returns</dt><dd>cos(x).</dd></dl>
  196. <p>The Q15 input value is in the range [0 +0.9999] and is mapped to a radian value in the range [0 2*pi). </p>
  197. <p>References <a class="el" href="arm__math_8h.html#a34716b73c631e65e8dd855e08384ecb2">FAST_MATH_Q15_SHIFT</a>, and <a class="el" href="arm__common__tables_8c.html#a9cbcfe313f61add745ebfeddb4fecd55">sinTable_q15</a>.</p>
  198. </div>
  199. </div>
  200. <a class="anchor" id="gad80f121949ef885a77d83ab36e002567"></a>
  201. <div class="memitem">
  202. <div class="memproto">
  203. <table class="memname">
  204. <tr>
  205. <td class="memname"><a class="el" href="arm__math_8h.html#adc89a3547f5324b7b3b95adec3806bc0">q31_t</a> arm_cos_q31 </td>
  206. <td>(</td>
  207. <td class="paramtype"><a class="el" href="arm__math_8h.html#adc89a3547f5324b7b3b95adec3806bc0">q31_t</a>&#160;</td>
  208. <td class="paramname"><em>x</em></td><td>)</td>
  209. <td></td>
  210. </tr>
  211. </table>
  212. </div><div class="memdoc">
  213. <dl class="params"><dt>Parameters</dt><dd>
  214. <table class="params">
  215. <tr><td class="paramdir">[in]</td><td class="paramname">x</td><td>Scaled input value in radians. </td></tr>
  216. </table>
  217. </dd>
  218. </dl>
  219. <dl class="section return"><dt>Returns</dt><dd>cos(x).</dd></dl>
  220. <p>The Q31 input value is in the range [0 +0.9999] and is mapped to a radian value in the range [0 2*pi). </p>
  221. <p>References <a class="el" href="arm__math_8h.html#a4268f77b1811a0c7fc2532a0bf6108b0">FAST_MATH_Q31_SHIFT</a>, and <a class="el" href="arm__common__tables_8c.html#a8bfccee9e1c0042cf4a765f4b19d097d">sinTable_q31</a>.</p>
  222. </div>
  223. </div>
  224. </div><!-- contents -->
  225. </div><!-- doc-content -->
  226. <!-- start footer part -->
  227. <div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  228. <ul>
  229. <li class="footer">Generated on Tue Sep 23 2014 18:52:43 for CMSIS-DSP by ARM Ltd. All rights reserved.
  230. <!--
  231. <a href="http://www.doxygen.org/index.html">
  232. <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.2
  233. -->
  234. </li>
  235. </ul>
  236. </div>
  237. </body>
  238. </html>