1function test_failed = test_libltfat_middlepad(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; 11Cenumsymmetry = enuminfo.ltfat_symmetry_t; 12 13Larr = [9,11,110, 9, 8, 8, 11, 11, 10, 11,9,12,221,10, 10, 11, 15, 16, 1000]; 14Loutarr = [9,12,221,10, 10, 11, 15, 16, 1000, 1, 9,11,110, 9, 8, 8, 11, 11, 10]; 15 16for symflag = {'wp','hp'} 17symflag = symflag{1}; 18 19switch symflag 20 case 'wp' 21 csymflag = Cenumsymmetry.LTFAT_WHOLEPOINT; 22 case 'hp' 23 csymflag = Cenumsymmetry.LTFAT_HALFPOINT; 24end 25 26 27for do_complex = 0:1 28 complexstring = ''; 29 if do_complex, complexstring = 'complex'; end 30 funname = makelibraryname('middlepad',flags.complexity,do_complex); 31 32 for Lidx = 1:numel(Larr) 33 L = Larr(Lidx); 34 Lout = Loutarr(Lidx); 35 36 if do_complex 37 z = cast((1:L)'+1i*(L:-1:1)',flags.complexity); 38 zi = complex2interleaved(z); 39 zout = randn(2*Lout,1,flags.complexity); 40 41 ziPtr = libpointer(dataPtr,zi); 42 zoutPtr = libpointer(dataPtr,zout); 43 else 44 z = cast((1:L)',flags.complexity); 45 zi = z; 46 zout = randn(Lout,1,flags.complexity); 47 48 ziPtr = libpointer(dataPtr,zi); 49 zoutPtr = libpointer(dataPtr,zout); 50 end 51 52 trueres = middlepad(z,Lout,symflag); 53 54 55 status = calllib('libltfat',funname,ziPtr,L,csymflag,Lout,zoutPtr); 56 57 if do_complex 58 res = norm(trueres - interleaved2complex(zoutPtr.Value)); 59 else 60 res = norm(trueres - zoutPtr.Value); 61 end 62 63 [test_failed,fail]=ltfatdiditfail(res+status,test_failed,0); 64 fprintf(['MIDDLEPAD OP L:%3i, Lout:%3i, %s %s %s %s\n'],L,Lout,flags.complexity,complexstring,ltfatstatusstring(status),fail); 65 66 zoutPtr.Value(:) = randn(size(zoutPtr.Value),flags.complexity); 67 zoutPtr.Value(1:numel(ziPtr.Value)) = ziPtr.Value; 68 status = calllib('libltfat',funname,zoutPtr,L,csymflag,Lout,zoutPtr); 69 70 if do_complex 71 res = norm(trueres - postpad(interleaved2complex(zoutPtr.Value),Lout)); 72 else 73 res = norm(trueres - zoutPtr.Value(1:Lout)); 74 end 75 76 [test_failed,fail]=ltfatdiditfail(res+status,test_failed,0); 77 fprintf(['MIDDLEPAD IP L:%3i, Lout:%3i, %s %s %s %s\n'],L,Lout,flags.complexity,complexstring,ltfatstatusstring(status),fail); 78 end 79end 80end 81 82 83%-*- texinfo -*- 84%@deftypefn {Function} test_libltfat_middlepad 85%@verbatim 86%@end verbatim 87%@strong{Url}: @url{http://ltfat.github.io/doc/libltfat/modules/libltfat/testing/mUnit/test_libltfat_middlepad.html} 88%@end deftypefn 89 90% Copyright (C) 2005-2016 Peter L. Soendergaard <peter@sonderport.dk>. 91% This file is part of LTFAT version 2.3.1 92% 93% This program is free software: you can redistribute it and/or modify 94% it under the terms of the GNU General Public License as published by 95% the Free Software Foundation, either version 3 of the License, or 96% (at your option) any later version. 97% 98% This program is distributed in the hope that it will be useful, 99% but WITHOUT ANY WARRANTY; without even the implied warranty of 100% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 101% GNU General Public License for more details. 102% 103% You should have received a copy of the GNU General Public License 104% along with this program. If not, see <http://www.gnu.org/licenses/>. 105 106