The process of interpolation is equivalent to the conceptual notion of inserting Ir-1 zeros between each element of the input array. This increased rate signal array is convolved with the filter coefficients. Since the increased rate signal array has imbedded zeros, only every Ir'th filter coefficient is involved in producing a given output point. These coefficients can be considered to constitute a sub-filter. Sub-filters are used in a round-robin fashion to produce successive output points.
The process of subsampling is equivalent to keeping only every Nsub'th output point. The filter slides along Nsub elements at a time in the increased rate (interpolated) signal array for every point that is stored in the output array.
The input array is x[.]. The first lmem = (Ncof-1)/Ir samples of x[.] are past inputs. Let the increased rate array be xi[.]. Then, xi[l*Ir]=x[l], with other elements in xi[.] being zero. The relationship between indices of x[l] and xi[m] is m=l*Ir+mr, or l=floor(m/Ir), mr=m-l*Ir. The first output point is calculated with filter coefficient h[0] aligned with sample xi[Ir*lmem+mr], or equivalently, h[mr] aligned with sample x[lmem]. The last output point is calculated with h[0] aligned with the sample xi[Ir*lmem+mr+(Nout-1)*Nsub].
If Nout output values are to be calculated, the input array x[.] must have Nx elements, where Nx is determined from
lmem*Ir+mr+(Nout-1)*Nsub <= Ir*Nx-1From this relationship,
Nx = lmem + ceil((mr+1+(Nout-1)*Nsub)/Ir) = lmem + floor((mr+(Nout-1)*Nsub)/Ir) + 1Conversely if the input array has Nx elements, the number of output samples that can be calculated as
Nout = floor((Ir*(Nx-lmem)-1-mr)/Nsub) + 1 = ceil((Ir*(Nx-lmem)-mr)/Nsub).
y[0] = h[mr]*x[lmem] + h[mr+Ir]*x[lmem-1] + h[mr+2*Ir]*x[lmem-2] + ...The array x must have at least lmem+((Nout-1)*Nsub+mr)/Ir+1 elements.