Hello, as I need to make extensive use of invfreq() with long filters (e.g. fitting FIR filters with 100 to 1000 coeffs to complex frequency responses), I would like to speed up invfreq.m by vectorising the inner loop.
Now, I think I was able to solve some of the task as shown in my_invfreq.m as attached. But there is a issues: how to "vectorise" the outer product to generate a 3-dim Rk "matrix"? Or is there any more appropriate approach in general? The current "vectorised" code takes about 2 times as long as the original on 3.0.3, MSVC, so without vectorising the rest of the loop, the current version is useless... Thanks for any hint, Rolf %!demo, extended for comparison of both versions: order = 12; % order of test filter fc = 1/2; % sampling rate / 4 n = 128; % frequency grid size [B,A] = butter(order,fc); [H,w] = freqz(B,A,n); tic;[Bo,Ao] = invfreq(H,w,order,order); toc tic;[Bh,Ah] = my_invfreq(H,w,order,order); toc [Ho,wo] = freqz(Bo,Ao,n); [Hh,wh] = freqz(Bh,Ah,n); plot(w,abs(H),w,abs(Hh),w,abs(Ho)) xlabel("Frequency (rad/sample)"); ylabel("Magnitude"); legend('Original','vectorised Measured','original Measured'); err_h = norm(H-Hh); err_o = norm(H-Ho); disp(sprintf('L2 norm of frequency response error, vectorised = %e',err_h)); disp(sprintf('L2 norm of frequency response error, original = %e',err_o));
my_invfreq.m
Description: Binary data
------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________ Octave-dev mailing list Octave-dev@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/octave-dev