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