CMSIS-DSP  Verison 3.0
CMSIS DSP Software Library
Sine

Functions

float32_t arm_sin_f32 (float32_t x)
 Fast approximation to the trigonometric sine function for floating-point data.
q15_t arm_sin_q15 (q15_t x)
 Fast approximation to the trigonometric sine function for Q15 data.
q31_t arm_sin_q31 (q31_t x)
 Fast approximation to the trigonometric sine function for Q31 data.

Description

Computes the trigonometric sine 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 1) mapping to [0 2*pi).

The implementation is based on table lookup using 256 values together with cubic interpolation. The steps used are:

  1. Calculation of the nearest integer table index
  2. Fetch the four table values a, b, c, and d
  3. Compute the fractional portion (fract) of the table index.
  4. Calculation of wa, wb, wc, wd
  5. The final result equals a*wa + b*wb + c*wc + d*wd

where

   
    a=Table[index-1];   
    b=Table[index+0];   
    c=Table[index+1];   
    d=Table[index+2];   
 

and

   
    wa=-(1/6)*fract.^3 + (1/2)*fract.^2 - (1/3)*fract;   
    wb=(1/2)*fract.^3 - fract.^2 - (1/2)*fract + 1;   
    wc=-(1/2)*fract.^3+(1/2)*fract.^2+fract;   
    wd=(1/6)*fract.^3 - (1/6)*fract;   
 

Function Documentation

float32_t arm_sin_f32 ( float32_t  x)
Parameters:
[in]xinput value in radians.
Returns:
sin(x).
Examples:
arm_linear_interp_example_f32.c, and arm_sin_cos_example_f32.c.
q15_t arm_sin_q15 ( q15_t  x)
Parameters:
[in]xScaled input value in radians.
Returns:
sin(x).

The Q15 input value is in the range [0 +1) and is mapped to a radian value in the range [0 2*pi).

q31_t arm_sin_q31 ( q31_t  x)
Parameters:
[in]xScaled input value in radians.
Returns:
sin(x).

The Q31 input value is in the range [0 +1) and is mapped to a radian value in the range [0 2*pi).