[62fbef]: wavelets / test_fwt_undec.m  Maximize  Restore  History

Download this file

93 lines (65 with data), 1.8 kB

 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
89
function test_failed = test_fwt_undec
ord = 10;
J= 6;
wavName = sprintf('db%d',ord);
[H, G] = wfilt_db(ord);
dwtM = 'per';
dwtmode(dwtM,'nodisp');
f = 1:2^J*20;
f = f(:);
% f = greasy;
% f = randn(2^J*180+47,1);
% f= zeros(2^J*180,1);
%f = [randn(2^J*200,1)];
tic;
[SWC] = swt(f,J,H{1}/sqrt(2),H{2}/sqrt(2));
t1= toc
tic;
c = comp_fwt_all(f,H,J,'undec',dwtM);
t2=toc
fprintf('Speedup: %f \n', t1/t2);
%fhat = ifwt(c,G,J,length(f),'undec');
% if(norm(f-fhat)>1^-10)
% figure(2); clf;
% stem([f,fhat]);
% end
[err,coefs] = checkCoefs(c,SWC,J);
printCoeffs(c,coefs);
if(err>10^(-10))
figure(1);clf;
printCoeffs(c,coefs);
error('Coefficients are not equal! Error is %g',err);
end
function [err, coefs] = checkCoefs(c,SWC,J)
coefs = cell(J+1,1);
coefs{1,1} = SWC(end,:);
for j=1:J
[coefs{end-j+1}] = SWC(j,:);
end
err = 0;
err = err + norm(c{J+1,1}(:) - coefs{J+1,1}(:));
for j=1:J
err = err + norm(c{j,1}(:) - coefs{j,1}(:));
end
function printError( x,y)
[J,N1] = size(x);
for j=1:J
subplot(J,1,j);
err = x{j}(:) - y{j}(:);
stem(err);
lh = line([0 length(x{j})],[eps eps]);
set(lh,'Color',[1 0 0]);
lh =line([0 length(x{j})],[-eps -eps]);
set(lh,'Color',[1 0 0]);
end
function printCoeffs( x,y)
[J,N1] = size(x);
for j=1:J
subplot(J,1,j);
% err = x{j}(:) - y{j}(:);
stem([x{j}(:),y{j}(:)]);
lh = line([0 length(x{j})],[eps eps]);
set(lh,'Color',[1 0 0]);
lh =line([0 length(x{j})],[-eps -eps]);
set(lh,'Color',[1 0 0]);
end

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks