Mercurial > hg > smallbox
comparison DL/two-step DL/dico_decorr.m @ 156:a4d0977d4595 danieleb
First branch commit, danieleb
author | danieleb |
---|---|
date | Tue, 30 Aug 2011 11:12:31 +0100 |
parents | 485747bf39e0 |
children |
comparison
equal
deleted
inserted
replaced
153:af307f247ac7 | 156:a4d0977d4595 |
---|---|
6 % amp: the amplitude coefficients, only used to decide which atom to | 6 % amp: the amplitude coefficients, only used to decide which atom to |
7 % project | 7 % project |
8 % | 8 % |
9 % Result: | 9 % Result: |
10 % dico: a dictionary close to the input one with coherence mu. | 10 % dico: a dictionary close to the input one with coherence mu. |
11 | |
12 eps = 1e-6; % define tolerance for normalisation term alpha | |
11 | 13 |
12 % compute atom weights | 14 % compute atom weights |
13 if nargin > 2 | 15 if nargin > 2 |
14 rank = sum(amp.*amp, 2); | 16 rank = sum(amp.*amp, 2); |
15 else | 17 else |
18 | 20 |
19 % several decorrelation iterations might be needed to reach global | 21 % several decorrelation iterations might be needed to reach global |
20 % coherence mu. niter can be adjusted to needs. | 22 % coherence mu. niter can be adjusted to needs. |
21 niter = 1; | 23 niter = 1; |
22 while niter < 5 && ... | 24 while niter < 5 && ... |
23 max(max(abs(dico'*dico -eye(length(dico))))) > mu + 10^-6 | 25 max(max(abs(dico'*dico -eye(length(dico))))) > mu + eps |
24 % find pairs of high correlation atoms | 26 % find pairs of high correlation atoms |
25 colors = dico_color(dico, mu); | 27 colors = dico_color(dico, mu); |
26 | 28 |
27 % iterate on all pairs | 29 % iterate on all pairs |
28 nbColors = max(colors); | 30 nbColors = max(colors); |
34 index = fliplr(index); | 36 index = fliplr(index); |
35 end | 37 end |
36 | 38 |
37 % update the atom | 39 % update the atom |
38 corr = dico(:,index(1))'*dico(:,index(2)); | 40 corr = dico(:,index(1))'*dico(:,index(2)); |
39 alpha = sqrt((1-mu*mu)/(1-corr*corr)); | 41 alpha = sqrt((1-mu*mu)/(1-corr^2+eps)); |
40 beta = corr*alpha-mu*sign(corr); | 42 beta = corr*alpha-mu*sign(corr); |
41 dico(:,index(2)) = alpha*dico(:,index(2))... | 43 dico(:,index(2)) = alpha*dico(:,index(2))... |
42 -beta*dico(:,index(1)); | 44 -beta*dico(:,index(1)); |
43 end | 45 end |
44 end | 46 end |