forked from ltfat/ltfat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wildual.m
88 lines (73 loc) · 2.4 KB
/
wildual.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
function [gamma]=wildual(g,M,L)
%WILDUAL Wilson dual window
% Usage: gamma=wildual(g,M);
% gamma=wildual(g,M,L);
%
% Input parameters:
% g : Gabor window.
% M : Number of modulations.
% L : Length of window. (optional)
% Output parameters:
% gamma : Canonical dual window.
%
% `wildual(g,M)` returns the dual window of the Wilson or WMDCT basis with
% window *g*, parameter *M* and length equal to the length of the window *g*.
%
% The window *g* may be a vector of numerical values, a text string or a
% cell array. See the help of |wilwin| for more details.
%
% If the length of *g* is equal to $2\cdot M$ then the input window is
% assumed to be an FIR window. In this case, the dual window also has
% length of $2\cdot M$. Otherwise the smallest possible transform length is
% chosen as the window length.
%
% `wildual(g,M,L)` does the same, but now *L* is used as the length of the
% Wilson basis.
%
% The input window *g* must be real and whole-point even. If *g* is not
% whole-point even, then reconstruction using the dual window will not be
% perfect. For a random window *g*, the window closest to *g* that satisfies
% these restrictions can be found by ::
%
% g_wpe = real(peven(g));
%
% All windows in the toolbox satisfies these restrictions unless
% clearly stated otherwise.
%
% See also: dwilt, wilwin, wmdct, wilorth, isevenfunction
% AUTHOR : Peter L. Søndergaard.
% TESTING: TEST_DWILT
% REFERENCE: OK
error(nargchk(2,3,nargin));
if nargin==2
L=[];
end;
%% ------ step 2: Verify a, M and L
if isempty(L)
if isnumeric(g)
% Use the window length
Ls=length(g);
else
% Use the smallest possible length
Ls=1;
end;
% ----- step 2b : Verify M and get L from the window length ----------
L=dwiltlength(Ls,M);
else
% ----- step 2a : Verify M and get L
Luser=dwiltlength(L,M);
if Luser~=L
error(['%s: Incorrect transform length L=%i specified. Next valid length ' ...
'is L=%i. See the help of DWILTLENGTH for the requirements.'],...
upper(mfilename),L,Luser);
end;
end;
%% ----- step 3 : Determine the window
[g,info]=wilwin(g,M,L,upper(mfilename));
if L<info.gl
error('%s: Window is too long.',upper(mfilename));
end;
%% ----- call gabdual ----------------
a=M;
g=fir2long(g,L);
gamma=2*comp_gabdual_long(g,a,2*M);