-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsgwt_cheby_square.m
66 lines (62 loc) · 1.89 KB
/
sgwt_cheby_square.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
% sgwt_cheby_square : Chebyshev coefficients for square of polynomial
%
% function d=sgwt_cheby_square(c)
%
% Inputs :
% c - Chebyshev coefficients for p(x) = sum c(1+k) T_k(x) ; 0<=K<=M
%
% Outputs :
% d - Chebyshev coefficients for p(x)^2 = sum d(1+k) T_k(x) ;
% 0<=k<=2*M
% This file is part of the SGWT toolbox (Spectral Graph Wavelet Transform toolbox)
% Copyright (C) 2010, David K. Hammond.
%
% The SGWT toolbox is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% The SGWT toolbox is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with the SGWT toolbox. If not, see <http://www.gnu.org/licenses/>.
function d=sgwt_cheby_square(c)
M=numel(c)-1;
cp=c;
cp(1)=.5*c(1);
% adjust cp so that
% p(x) = sum cp(1+k) T_k(x)
% for all k>=0 (rather than with special case for k=0)
%
% Then formula for dp in terms of cp is simpler.
% Ref: my notes, july 20, 2009
dp=zeros(1,2*M+1);
% keep in mind : due to indexing from 1
% c(1+k) is k'th Chebyshev coefficient
for m=0:(2*M)
if (m==0)
dp(1+m)=dp(1+m)+.5*cp(1)^2;
for i=0:M
dp(1+m)=dp(1+m)+.5*cp(1+i)^2;
end
elseif (m<=M)
for i=0:m
dp(1+m)=dp(1+m)+.5*cp(1+i)*cp(1+m-i);
end
for i=0:(M-m)
dp(1+m)=dp(1+m)+.5*cp(1+i)*cp(1+i+m);
end
for i=m:M
dp(1+m)=dp(1+m)+.5*cp(1+i)*cp(1+i-m);
end
else % M<m<=2*M
for i=(m-M):M
dp(1+m)=dp(1+m)+.5*cp(1+i)*cp(1+m-i);
end
end
end
d=dp;
d(1)=2*dp(1);