Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mbed-os by
Cosine
[Fast Math Functions]
Computes the trigonometric cosine function using a combination of table lookup and linear interpolation. More...
Functions | |
float32_t | arm_cos_f32 (float32_t x) |
Fast approximation to the trigonometric cosine function for floating-point data. | |
q15_t | arm_cos_q15 (q15_t x) |
Fast approximation to the trigonometric cosine function for Q15 data. | |
q31_t | arm_cos_q31 (q31_t x) |
Fast approximation to the trigonometric cosine function for Q31 data. |
Detailed Description
Computes the trigonometric cosine function using a combination of table lookup and linear 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.
The implementation is based on table lookup using 256 values together with linear interpolation. The steps used are:
- Calculation of the nearest integer table index
- Compute the fractional portion (fract) of the table index.
- The final result equals
(1.0f-fract)*a + fract*b;
where
b=Table[index+0]; c=Table[index+1];
Function Documentation
float32_t arm_cos_f32 | ( | float32_t | x ) |
Fast approximation to the trigonometric cosine function for floating-point data.
- Parameters:
-
[in] x input value in radians.
- Returns:
- cos(x).
Definition at line 82 of file arm_cos_f32.c.
q15_t arm_cos_q15 | ( | q15_t | x ) |
Fast approximation to the trigonometric cosine function for Q15 data.
- Parameters:
-
[in] x Scaled input value in radians.
- Returns:
- cos(x).
The Q15 input value is in the range [0 +0.9999] and is mapped to a radian value in the range [0 2*pi).
Definition at line 62 of file arm_cos_q15.c.
q31_t arm_cos_q31 | ( | q31_t | x ) |
Fast approximation to the trigonometric cosine function for Q31 data.
- Parameters:
-
[in] x Scaled input value in radians.
- Returns:
- cos(x).
The Q31 input value is in the range [0 +0.9999] and is mapped to a radian value in the range [0 2*pi).
Definition at line 62 of file arm_cos_q31.c.
Generated on Tue Jul 12 2022 13:16:31 by
