transfer<-function(a, N=1024) { ##a is a vector of filter coefficients ##N (power of two) is the number of frequencies in [-pi, pi] ##where the transfer function is calculated lambda<-seq(from=-pi, to=pi, length=N) temp<-fft(c(a, rep(0, N-length(a)))) ##reorder the values to match the frequencies temp<-c(temp[(N/2):N], temp[1:(N/2-1)]) real<-Re(temp) imag<-Im(temp) gain<-Mod(temp) phase<-Arg(temp) invisible(return(list("freq"=lambda, "real"=real,"imaginary"=imag, "gain"=gain, "phase"=phase))) }