1function test_failed = test_libltfat_slidgtrealmp(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;
11LTFAT_FIRWIN = enuminfo.LTFAT_FIRWIN;
12
13Larr =     [ 4*2048];
14Warr =      [ 1];
15
16bufLenInit = 100;
17bufLenMax = 1000;
18
19for initId = 0:1
20
21for ii = 1:numel(Larr)
22    L = Larr(ii);
23    W = Warr(ii);
24    parbuf = libpointer();
25    slimpstate = libpointer();
26
27    funname = makelibraryname('dgtrealmp_parbuf_init',flags.complexity,0);
28    calllib('libltfat',funname, parbuf);
29
30    funname = makelibraryname('dgtrealmp_parbuf_add_firwin',flags.complexity,0);
31    calllib('libltfat',funname, parbuf, LTFAT_FIRWIN.LTFAT_BLACKMAN, 2048,  512, 2048);
32    calllib('libltfat',funname, parbuf, LTFAT_FIRWIN.LTFAT_BLACKMAN, 512,  128, 512);
33
34    funname = makelibraryname('dgtrealmp_setparbuf_maxit',flags.complexity,0);
35    calllib('libltfat',funname, parbuf, L);
36
37    funname = makelibraryname('dgtrealmp_setparbuf_iterstep',flags.complexity,0);
38    calllib('libltfat',funname, parbuf, L);
39
40    funname = makelibraryname('dgtrealmp_setparbuf_snrdb',flags.complexity,0);
41    calllib('libltfat',funname, parbuf, 40);
42
43    funname = makelibraryname('slidgtrealmp_init',flags.complexity,0);
44    calllib('libltfat',funname, parbuf, L, W, bufLenMax, slimpstate);
45
46    funname = makelibraryname('slidgtrealmp_getprocdelay',flags.complexity,0);
47    procdelay = calllib('libltfat',funname,slimpstate);
48    initstr = 'INIT WIN';
49
50    [bufIn,fs] = gspi;
51    bufIn = cast(bufIn,flags.complexity);
52    bufIn = bsxfun(@times, repmat(bufIn,1,W), [1, rand(1,W-1,flags.complexity) + 1]);
53
54    bufOut = 1000*ones(size(bufIn),flags.complexity);
55    L = size(bufIn,1);
56    status = 0;
57    startIdx = 1;
58    bufLen = bufLenInit;
59    while startIdx <= L
60        stopIdx = min([startIdx + bufLen - 1,L]);
61        slice = startIdx : stopIdx;
62        buf = bufIn(slice,:);
63        bufInPtr = libpointer(dataPtr,buf);
64        bufOutPtr = libpointer(dataPtr,randn(size(buf),flags.complexity));
65
66        % Matlab automatically converts Ptr to PtrPtr
67        funname = makelibraryname('slidgtrealmp_execute',flags.complexity,0);
68        status = calllib('libltfat',funname,slimpstate,bufInPtr,numel(slice),W,bufOutPtr);
69        if status
70            break;
71        end
72
73        bufOut(slice,:) = bufOutPtr.Value;
74        startIdx = stopIdx + 1;
75        bufLen = randi(bufLenMax);
76    end
77
78    inshift = circshift(bufIn,(procdelay));
79    inshift(1:(procdelay),:) = 0;
80    plotthat = [bufOut - inshift];
81    plotthat(end-(procdelay):end,:) = 0;
82
83    [test_failed,fail]=ltfatdiditfail(20*log10(norm(inshift)/norm(plotthat)) < 35 + any(bufOut(:)>10),test_failed);
84    fprintf(['DGTREAL_PROCESSOR OP %s gl:%3i, W:%3i, %s %s %s\n'],initstr,L,W,flags.complexity,ltfatstatusstring(status),fail);
85
86
87
88end
89end
90
91
92
93
94
95
96
97%-*- texinfo -*-
98%@deftypefn {Function} test_libltfat_slidgtrealmp
99%@verbatim
100%@end verbatim
101%@strong{Url}: @url{http://ltfat.github.io/doc/libltfat/modules/libltfat/testing/mUnit/test_libltfat_slidgtrealmp.html}
102%@end deftypefn
103
104% Copyright (C) 2005-2016 Peter L. Soendergaard <peter@sonderport.dk>.
105% This file is part of LTFAT version 2.3.1
106%
107% This program is free software: you can redistribute it and/or modify
108% it under the terms of the GNU General Public License as published by
109% the Free Software Foundation, either version 3 of the License, or
110% (at your option) any later version.
111%
112% This program is distributed in the hope that it will be useful,
113% but WITHOUT ANY WARRANTY; without even the implied warranty of
114% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
115% GNU General Public License for more details.
116%
117% You should have received a copy of the GNU General Public License
118% along with this program.  If not, see <http://www.gnu.org/licenses/>.
119
120