【发布时间】:2016-01-18 11:52:16
【问题描述】:
我正在研究生成“S 曲线”的伽马函数。 我需要在实时环境中运行它,所以我需要尽可能加快它的速度。
代码如下:
float Gamma = 2.0f; //Input Variable
float GammaMult = pow(0.5f, 1.0f-Gamma);
if(Input<1.0f && Input>0.0f)
{
if(Input<0.5f)
{
Output = pow(Input,Gamma)*GammaMult;
}
else
{
Output = 1.0f-pow(1.0f-Input,Gamma)*GammaMult;
}
}
else
{
Output = Input;
}
有什么办法可以优化这段代码吗?
【问题讨论】:
-
浮点伽玛 = 2.0f; //输入变量当然应该是动态的吧?
-
它是动态的,只是为了示例目的而设置。
标签: c++ gamma-function