CQ出版社インターフェース誌の2017年8月号で解説している,固定小数点演算で sin 関数の値を求める二つの関数を比較するためのプログラムの全体.

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Sin

Functions

q15_t arm_sin_q15 (q15_t x)
 Fast approximation to the trigonometric sine function for Q15 data.

Variables

static const q15_t sinTableQ15 [259]

Function Documentation

q15_t arm_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 +1) and is mapped to a radian value in the range [0 2*pi).

Definition at line 103 of file arm_sin_q15.c.


Variable Documentation

const q15_t sinTableQ15[259] [static]
Example code for Generation of Q15 Sin Table:
tableSize = 256;  
 for(n = -1; n < (tableSize + 1); n++)  
 {  
	sinTable[n+1]=sin(2*pi*n/tableSize);  
 } 
where pi value is 3.14159265358979
Convert Floating point to Q15(Fixed point): (sinTable[i] * pow(2, 15))
rounding to nearest integer is done sinTable[i] += (sinTable[i] > 0 ? 0.5 :-0.5);

Definition at line 58 of file arm_sin_q15.c.