Skip to content

Commit e172da0

Browse files
authored
Merge pull request #6 from dshuman1/gsp_cheb_coeff_update
Option to compute Chebyshev coefficients with the Chebfun toolbox
2 parents 34b68df + 35f6250 commit e172da0

File tree

1 file changed

+29
-9
lines changed

1 file changed

+29
-9
lines changed

utils/gsp_cheby_coeff.m

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,14 @@
1818
% matrix. Every collumn correspond to a filter. The coefficients are
1919
% ordered such that c(j+1) is j'th Chebyshev coefficient
2020
%
21-
% *param* contain only one field param.verbose to controle the verbosity.
21+
% Additional parameters
22+
% ---------------------
23+
%
24+
% * *param.use_chebfun* : 1 to use the Chebfun package to compute
25+
% Chebyshev coefficients
26+
% * *param.splitting_on* : 1 to call chebfun with splitting on
27+
% * *param.verbose* : Verbosity level (0 no log - 1 display warnings)
28+
% (default 1).
2229
%
2330
% Example:::
2431
%
@@ -33,7 +40,7 @@
3340
% See also: gsp_cheby_op gsp_filter_analysis
3441
%
3542

36-
% Author: David K Hammond, Nathanael Perraudin
43+
% Author: David K Hammond, Nathanael Perraudin, David Shuman
3744
% Testing: test_filter
3845
% Date: 19 March 2014
3946

@@ -75,13 +82,26 @@
7582
else
7683
arange = G;
7784
end
78-
79-
a1=(arange(2)-arange(1))/2;
80-
a2=(arange(2)+arange(1))/2;
81-
c = zeros(m+1,1);
82-
for ii=1:m+1
83-
c(ii) = sum( filter( a1* cos( (pi*((1:N)-0.5))/N) + a2) .* ...
84-
cos( pi*(ii-1)*((1:N)-.5)/N) ) *2/N;
85+
86+
if ~isfield(param,'use_chebfun'), param.use_chebfun = 0; end;
87+
88+
if param.use_chebfun % Use Chebfun package, available at (http://www.chebfun.org/)
89+
if ~isfield(param,'splitting_on'), param.splitting_on = 0; end;
90+
if param.splitting_on
91+
h=chebfun(@(s) filter(s),arange,'splitting','on');
92+
else
93+
h=chebfun(@(s) filter(s),arange);
94+
end
95+
c=chebcoeffs(h,m+1);
96+
c(1)=c(1)*2;
97+
else
98+
a1=(arange(2)-arange(1))/2;
99+
a2=(arange(2)+arange(1))/2;
100+
c = zeros(m+1,1);
101+
for ii=1:m+1
102+
c(ii) = sum( filter( a1* cos( (pi*((1:N)-0.5))/N) + a2) .* ...
103+
cos( pi*(ii-1)*((1:N)-.5)/N) ) *2/N;
104+
end
85105
end
86106

87107
end

0 commit comments

Comments
 (0)