27、固定点数学与高性能数字滤波器技术解析

固定点数学与高性能数字滤波器技术解析

1. 固定点数学基础

固定点数学在许多应用场景中具有重要作用,特别是在对性能要求较高的嵌入式系统中。下面先介绍使用固定点数学计算正弦函数的方法。

首先是一个简单的固定点正弦函数实现:

template<typename fixed_point_type>
fixed_point_type sin(const fixed_point_type& x)
{
    // Scale x to chi (+-pi/2 to +-1).
    fixed_point_type chi(x * 0.6366198F);
    // Calculate chi^2 for the polynomial expansion.
    fixed_point_type chi2 = chi * chi;
    // Do the order-5 polynomial expansion.
    return ((
        0.0722739F
        * chi2 - 0.6425639F)
        * chi2 + 1.5704128F)
        * chi;
}

我们使用 Q15.16 固定点表示来计算 sin(1 / 2) 的近似值:

// 0.47937
fixed_point_15pt16 y = sin(fixed_point_15pt16(1) / 2);

计算结果 y 为 0.4

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值