使用 C 或 C++ 重构功率曲线公式

问题描述

我正在尝试用 C 或 C++ 重构这个公式。即使我使用诸如 fastpow 近似之类的东西,POW 的使用在 cpu 方面也是非常昂贵的。

有没有办法不使用 pow 并且仍然得到拟合曲线来改变凸方向和凹方向的输入信号。只要我能得到类似的曲线,如果有一种更快的替代方案,但通常会给出从 0 开始到 10 结束的凸面或凹面形状,那就太好了。

如有任何帮助,将不胜感激。

enter image description here

//input signal 0 to 10
//curve -10 to 10

negCurve = clamp(curve,-10,0);
posCurve = clamp(curve,10);

negativef(x)=fasterpow((x*0.1),((-negCurve+1)*10);
positivef(x)=fasterpow((x*0.1),(((1)/(1+posCurve))*10);

这是近似值

static inline float 
fasterlog2 (float x)
{
  union { float f; uint32_t i; } vx = { x };
  float y = (float)(uint32_t)(vx.i);
  y *= 1.1920928955078125e-7f;
  return y - 126.94269504f;
}

static inline float
fastpow(float x,float p)
{
    return fastpow2(p * fastlog2(x));
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)