NMSIS-DSP  Version 1.2.0
NMSIS DSP Software Library

Computes the trigonometric sine 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. More...

Functions

float32_t riscv_sin_f32 (float32_t x)
 Fast approximation to the trigonometric sine function for floating-point data. More...
 
q15_t riscv_sin_q15 (q15_t x)
 Fast approximation to the trigonometric sine function for Q15 data. More...
 
q31_t riscv_sin_q31 (q31_t x)
 Fast approximation to the trigonometric sine function for Q31 data. More...
 

Detailed Description

Computes the trigonometric sine 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 512 values together with linear interpolation. The steps used are:

  1. Calculation of the nearest integer table index
  2. Compute the fractional portion (fract) of the table index.
  3. The final result equals (1.0f-fract)*a + fract*b;

where

   b = Table[index];
   c = Table[index+1];

Function Documentation

◆ riscv_sin_f32()

float32_t riscv_sin_f32 ( float32_t  x)

Fast approximation to the trigonometric sine function for floating-point data.

Parameters
[in]xinput value in radians.
Returns
sin(x)

◆ riscv_sin_q15()

q15_t riscv_sin_q15 ( q15_t  x)

Fast approximation to the trigonometric sine function for Q15 data.

Parameters
[in]xScaled input value in radians
Returns
sin(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).

◆ riscv_sin_q31()

q31_t riscv_sin_q31 ( q31_t  x)

Fast approximation to the trigonometric sine function for Q31 data.

Parameters
[in]xScaled input value in radians
Returns
sin(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).