示例#1
0
        /// <summary>
        /// Evaluate impulse response
        /// </summary>
        /// <param name="length">Ignored for FIR filters (where IR is full copy of numerator)</param>
        /// <returns></returns>
        public double[] ImpulseResponse(int length = 512)
        {
            if (Denominator.Length == 1)
            {
                return(Numerator.FastCopy());
            }

            var b = Numerator;
            var a = Denominator;

            var response = new double[length];

            for (var n = 0; n < response.Length; n++)
            {
                if (n < b.Length)
                {
                    response[n] = b[n];
                }

                for (var m = 1; m < a.Length; m++)
                {
                    if (n >= m)
                    {
                        response[n] -= a[m] * response[n - m];
                    }
                }
            }

            return(response);
        }