1function test_failed = test_nonu2ufilterbank 2%-*- texinfo -*- 3%@deftypefn {Function} test_nonu2ufilterbank 4%@verbatim 5% This tests equality of coefficients of a non uniform and 6% an identical uniform filterbanks 7%@end verbatim 8%@strong{Url}: @url{http://ltfat.github.io/doc/testing/test_nonu2ufilterbank.html} 9%@end deftypefn 10 11% Copyright (C) 2005-2016 Peter L. Soendergaard <peter@sonderport.dk>. 12% This file is part of LTFAT version 2.3.1 13% 14% This program is free software: you can redistribute it and/or modify 15% it under the terms of the GNU General Public License as published by 16% the Free Software Foundation, either version 3 of the License, or 17% (at your option) any later version. 18% 19% This program is distributed in the hope that it will be useful, 20% but WITHOUT ANY WARRANTY; without even the implied warranty of 21% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22% GNU General Public License for more details. 23% 24% You should have received a copy of the GNU General Public License 25% along with this program. If not, see <http://www.gnu.org/licenses/>. 26test_failed=0; 27 28disp('-------------TEST_NONU2UFILTERBANK-------------'); 29 30for ftypeCell = {'time','freq'} 31 ftype = ftypeCell{1}; 32 disp(sprintf('--------------- %s ------------',ftype)); 33for M=[1,6]; 34 35for aCell = {(1:M)',(M:-1:1)',ones(M,1), M*ones(M,1)} 36a = aCell{1}; 37N=10; 38 39L=filterbanklength(1,a)*N; 40for W = 1:3 41 42g=cell(1,M); 43if strcmp(ftype,'time') 44for ii=1:M 45 g{ii}=tester_crand(L/2,1); 46end; 47elseif strcmp(ftype,'freq') 48 for ii=1:M 49 g{ii}=struct('H',tester_crand(L,1),'foff',0,'L',L); 50end; 51end 52 53f = tester_crand(L,W); 54 55% Target coefficients 56c_non = filterbank(f,g,a); 57 58% Do a uniform filterbank 59[gu,au,pk] = nonu2ufilterbank(g,a); 60 61% Identical cell-array 62c_u = filterbank(f,gu,au); 63 64% Identical matrix 65c_uu = ufilterbank(f,gu,au); 66 67res=0; 68for m=1:M 69 res=res+norm(c_u{m}-squeeze(c_uu(:,m,:))); 70end; 71[test_failed,fail]=ltfatdiditfail(res,test_failed); 72fprintf('COEFEQ L:%3i,W:%3i,M:%3i, %0.5g %s\n',L,W,M,res,fail); 73 74% Convert back to nonuniform format 75c = u2nonucfmt(c_u,pk); 76 77res = norm(cell2mat(c_non) - cell2mat(c)); 78[test_failed,fail]=ltfatdiditfail(res,test_failed); 79fprintf('FORMAT CELL L:%3i,W:%3i,M:%3i, %0.5g %s\n',L,W,M,res,fail); 80 81% Convert back to nonuniform format 82c = u2nonucfmt(c_uu,pk); 83 84res = norm(cell2mat(c_non) - cell2mat(c)); 85[test_failed,fail]=ltfatdiditfail(res,test_failed); 86fprintf('FORMAT MAT L:%3i,W:%3i,M:%3i, %0.5g %s\n',L,W,M,res,fail); 87 88 89% Convert 90c_uuu = nonu2ucfmt(c_non,pk); 91 92res = norm(cell2mat(c_uuu) - cell2mat(c_u)); 93[test_failed,fail]=ltfatdiditfail(res,test_failed); 94fprintf('FORMATBACK L:%3i,W:%3i,M:%3i, %0.5g %s\n',L,W,M,res,fail); 95 96 97end 98end 99end 100end 101 102