AM中波放送用SDR.CICフィルタのみを使用.CQ出版社「トランジスタ技術」誌,2021年5月号に掲載

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers FastSin.hpp Source File

FastSin.hpp

00001 //--------------------------------------------------------------
00002 //  高速低精度 sin 計算
00003 //      sin(πx/2), -2< = x <= 2 を計算する
00004 //      誤差の絶対値の最大値:6.7706E-5
00005 //
00006 //      係数はミニマックス近似で求めたもの.ただし,誤差は絶対誤差で評価した
00007 //
00008 //  2020/08/11, Copyright (c) 2020 MIKAMI, Naoki
00009 //--------------------------------------------------------------
00010 
00011 #include "mbed.h"
00012 
00013 #ifndef FAST_SINE_LOW_PRECISION_HPP
00014 #define FAST_SINE_LOW_PRECISION_HPP
00015 
00016 namespace Mikami
00017 {
00018     float FastSin(float x)
00019     {
00020         static const float A1 =  1.57032033f;
00021         static const float A3 = -0.64211427f;
00022         static const float A5 =  0.07186159f;
00023         
00024         x = (x >  1.0f) ?  2.0f - x : x;
00025         x = (x < -1.0f) ? -2.0f - x : x;
00026 
00027         float x2 = x*x;
00028         float sinx = ((A5*x2 + A3)*x2 + A1)*x;
00029         
00030         return sinx;
00031     }
00032 }
00033 #endif  // FAST_SINE_LOW_PRECISION_HPP