與IIR濾波器係數有關的快速問題。這是我在網上找到的一個直接II型II型二進制IIR處理器的非常典型的實現。IIR濾波器的優化
// b0, b1, b2, a1, a2 are filter coefficients
// m1, m2 are the memory locations
// dn is the de-denormal coeff (=1.0e-20f)
void processBiquad(const float* in, float* out, unsigned length)
{
for(unsigned i = 0; i < length; ++i)
{
register float w = in[i] - a1*m1 - a2*m2 + dn;
out[i] = b1*m1 + b2*m2 + b0*w;
m2 = m1; m1 = w;
}
dn = -dn;
}
據我所知,「登記冊」在某種程度上是不必要的,因爲現代編譯器對於這種事物有多聰明。我的問題是,將濾波器係數存儲在單個變量中而不是使用數組和取消引用值有什麼潛在的性能好處?這個問題的答案是否取決於目標平臺?
即
out[i] = b[1]*m[1] + b[2]*m[2] + b[0]*w;
與
out[i] = b1*m1 + b2*m2 + b0*w;