comparison util/classes/dictionaryMatrices/iterativeprojections.m @ 169:290cca7d3469 danieleb

Added dictionary decorrelation functions and test script for ICASSP paper.
author Daniele Barchiesi <daniele.barchiesi@eecs.qmul.ac.uk>
date Thu, 29 Sep 2011 09:46:52 +0100
parents
children 68fb71aa5339
comparison
equal deleted inserted replaced
168:ff866a412be5 169:290cca7d3469
1 function [A G res muMin] = grassmannian(n,m,nIter,dd1,dd2,initA,verb)
2 % grassmanian attempts to create an n by m matrix with minimal mutual
3 % coherence using an iterative projection method.
4 %
5 % [A G res] = grassmanian(n,m,nIter,dd1,dd2,initA)
6 %
7 % REFERENCE
8 % M. Elad, Sparse and Redundant Representations, Springer 2010.
9
10 %% Parameters and Defaults
11 error(nargchk(2,7,nargin));
12
13 if ~exist('verb','var') || isempty(verb), verb = false; end %verbose output
14 if ~exist('initA','var') || isempty(initA), initA = randn(n,m); end %initial matrix
15 if ~exist('dd2','var') || isempty(dd2), dd2 = 0.99; end %shrinking factor
16 if ~exist('dd1','var') || isempty(dd1), dd1 = 0.9; end %percentage of coherences to be shrinked
17 if ~exist('nIter','var') || isempty(nIter), nIter = 10; end %number of iterations
18
19 %% Main algo
20 A = normc(initA); %normalise columns
21 [Uinit Sigma] = svd(A);
22 G = A'*A; %gram matrix
23
24 muMin = sqrt((m-n)/(n*(m-1))); %Lower bound on mutual coherence (equiangular tight frame)
25 res = zeros(nIter,1);
26 if verb
27 fprintf(1,'Iter mu_min mu \n');
28 end
29
30 % optimise gram matrix
31 for iIter = 1:nIter
32 gg = sort(abs(G(:))); %sort inner products from less to most correlated
33 pos = find(abs(G(:))>=gg(round(dd1*(m^2-m))) & abs(G(:)-1)>1e-6); %find large elements of gram matrix
34 G(pos) = G(pos)*dd2; %shrink large elements of gram matrix
35 [U S V] = svd(G); %compute new SVD of gram matrix
36 S(n+1:end,1+n:end) = 0; %set small eigenvalues to zero (this ensures rank(G)<=d)
37 G = U*S*V'; %update gram matrix
38 G = diag(1./abs(sqrt(diag(G))))*G*diag(1./abs(sqrt(diag(G)))); %normalise gram matrix diagonal
39 if verb
40 Geye = G - eye(size(G));
41 fprintf(1,'%6i %12.8f %12.8f \n',iIter,muMin,max(abs(Geye(:))));
42 end
43 end
44
45 % [~, Sigma_gram V_gram] = svd(G); %calculate svd decomposition of gramian
46
47 % A = normc(A); %normalise dictionary
48
49 [V_gram Sigma_gram] = svd(G); %calculate svd decomposition of gramian
50 Sigma_new = sqrt(Sigma_gram(1:n,:)).*sign(Sigma); %calculate singular values of dictionary
51 A = Uinit*Sigma_new*V_gram'; %update dictionary
52
53 % param.step = 0.01;
54 % param.reg = 0.01;
55 % param.nIter = 20;
56 % A = rotatematrix(initA,A,'linesearchlie',param);
57
58 % %% Debug visualization function
59 % function plotcart2d(A)
60 % compass(A(1,:),A(2,:));