1function test_failed = test_libltfat_firwin(varargin) 2test_failed = 0; 3 4fprintf(' =============== %s ================ \n',upper(mfilename)); 5 6definput.flags.complexity={'double','single'}; 7[flags]=ltfatarghelper({},definput,varargin); 8dataPtr = [flags.complexity, 'Ptr']; 9 10[~,~,enuminfo]=libltfatprotofile; 11Cenumnorms = enuminfo.LTFAT_FIRWIN; 12 13d = arg_firwin; 14wins = d.flags.wintype; 15wins(strcmp('truncgauss',wins)) = []; 16 17wins = [wins 'truncgauss01']; 18 19names =fieldnames(Cenumnorms); 20 21libwins = {}; 22for nameId = 1:numel(wins) 23libwins{end+1} = Cenumnorms.(names{strcmpi(['ltfat_', wins{nameId}],names)}); 24end 25 26Larr = [1,9,10,11,110,111]; 27 28for do_complex = 0:1 29 complexstring = ''; 30 if do_complex, complexstring = 'complex'; end 31 funname = makelibraryname('firwin',flags.complexity,do_complex); 32 for L = Larr 33 for nId = 1:numel(wins) 34 win = wins{nId}; 35 lwin = libwins{nId}; 36 37 if do_complex 38 z = cast((1:L)' + i*(1:L)',flags.complexity); 39 zi = complex2interleaved(z); 40 ziPtr = libpointer(dataPtr,zi); 41 else 42 z = cast((1:L)',flags.complexity); 43 zi = z; 44 ziPtr = libpointer(dataPtr,zi); 45 end 46 47 status = calllib('libltfat',funname,lwin,L,ziPtr); 48 49 startswith = 'truncgauss'; 50 if regexpi(win,['^',startswith]) 51 percent = 1; 52 if numel(win) > numel(startswith) 53 percent = str2double(win(numel(startswith)+1:end)); 54 end 55 56 trueres = long2fir(pgauss(10*L,'width',L,'atheight',percent/100,'inf'),L); 57 if rem(L,2) == 0 58 trueres(end/2+1) = 0; % 59 end 60 else 61 trueres = firwin(win,L); 62 end 63 64 if do_complex 65 res = norm(trueres - interleaved2complex(ziPtr.Value)); 66 else 67 res = norm(trueres - ziPtr.Value); 68 end 69 70 [test_failed,fail]=ltfatdiditfail(res+status,test_failed); 71 fprintf(['FIRWIN L:%3i, %s %s %s %s %s\n'],L,win,flags.complexity,complexstring,ltfatstatusstring(status),fail); 72 end 73 end 74end 75 76 77 78%-*- texinfo -*- 79%@deftypefn {Function} test_libltfat_firwin 80%@verbatim 81%@end verbatim 82%@strong{Url}: @url{http://ltfat.github.io/doc/libltfat/modules/libltfat/testing/mUnit/test_libltfat_firwin.html} 83%@end deftypefn 84 85% Copyright (C) 2005-2016 Peter L. Soendergaard <peter@sonderport.dk>. 86% This file is part of LTFAT version 2.3.1 87% 88% This program is free software: you can redistribute it and/or modify 89% it under the terms of the GNU General Public License as published by 90% the Free Software Foundation, either version 3 of the License, or 91% (at your option) any later version. 92% 93% This program is distributed in the hope that it will be useful, 94% but WITHOUT ANY WARRANTY; without even the implied warranty of 95% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 96% GNU General Public License for more details. 97% 98% You should have received a copy of the GNU General Public License 99% along with this program. If not, see <http://www.gnu.org/licenses/>. 100 101