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