Mercurial > hg > smallbox
comparison util/classes/dictionaryMatrices/grassmannian.m @ 166:1495bdfa13e9 danieleb
Updated grassmanian function (restored old computation of the dictionary) and added functions to the audio class
author | Daniele Barchiesi <daniele.barchiesi@eecs.qmul.ac.uk> |
---|---|
date | Mon, 19 Sep 2011 14:53:23 +0100 |
parents | 88578ec2f94a |
children | 290cca7d3469 |
comparison
equal
deleted
inserted
replaced
162:88578ec2f94a | 166:1495bdfa13e9 |
---|---|
2 % grassmanian attempts to create an n by m matrix with minimal mutual | 2 % grassmanian attempts to create an n by m matrix with minimal mutual |
3 % coherence using an iterative projection method. | 3 % coherence using an iterative projection method. |
4 % | 4 % |
5 % [A G res] = grassmanian(n,m,nIter,dd1,dd2,initA) | 5 % [A G res] = grassmanian(n,m,nIter,dd1,dd2,initA) |
6 % | 6 % |
7 % | 7 % REFERENCE |
8 % M. Elad, Sparse and Redundant Representations, Springer 2010. | |
9 | |
8 %% Parameters and Defaults | 10 %% Parameters and Defaults |
9 error(nargchk(2,7,nargin)); | 11 error(nargchk(2,7,nargin)); |
10 | 12 |
11 if ~exist('verb','var') || isempty(verb), verb = false; end %verbose output | 13 if ~exist('verb','var') || isempty(verb), verb = false; end %verbose output |
12 if ~exist('initA','var') || isempty(initA), initA = randn(n,m); end %initial matrix | 14 if ~exist('initA','var') || isempty(initA), initA = randn(n,m); end %initial matrix |
13 if ~exist('dd2','var') || isempty(dd2), dd2 = 0.95; end %shrinking factor | 15 if ~exist('dd2','var') || isempty(dd2), dd2 = 0.99; end %shrinking factor |
14 if ~exist('dd1','var') || isempty(dd1), dd1 = 0.9; end %percentage of coherences to be shrinked | 16 if ~exist('dd1','var') || isempty(dd1), dd1 = 0.9; end %percentage of coherences to be shrinked |
15 if ~exist('nIter','var') || isempty(nIter), nIter = 10; end %number of iterations | 17 if ~exist('nIter','var') || isempty(nIter), nIter = 10; end %number of iterations |
16 | 18 |
17 %% Main algo | 19 %% Main algo |
18 A = normc(initA); %normalise columns | 20 A = normc(initA); %normalise columns |
21 [Uinit Sigma] = svd(A); | |
19 G = A'*A; %gram matrix | 22 G = A'*A; %gram matrix |
20 | 23 |
21 muMin = sqrt((m-n)/(n*(m-1))); %Lower bound on mutual coherence (equiangular tight frame) | 24 muMin = sqrt((m-n)/(n*(m-1))); %Lower bound on mutual coherence (equiangular tight frame) |
22 res = zeros(nIter,1); | 25 res = zeros(nIter,1); |
23 if verb | 26 if verb |
38 fprintf(1,'%6i %12.8f %12.8f \n',iIter,muMin,max(abs(Geye(:)))); | 41 fprintf(1,'%6i %12.8f %12.8f \n',iIter,muMin,max(abs(Geye(:)))); |
39 end | 42 end |
40 end | 43 end |
41 | 44 |
42 % [~, Sigma_gram V_gram] = svd(G); %calculate svd decomposition of gramian | 45 % [~, Sigma_gram V_gram] = svd(G); %calculate svd decomposition of gramian |
43 % Sigma_new = sqrt(Sigma_gram(1:n,:)).*sign(Sigma); %calculate singular values of dictionary | 46 |
44 % A = Uinit*Sigma_new*V_gram'; %update dictionary | |
45 % A = normc(A); %normalise dictionary | 47 % A = normc(A); %normalise dictionary |
46 | 48 |
47 [U S] = svd(G); %calculate svd decomposition of gramian | 49 [V_gram Sigma_gram] = svd(G); %calculate svd decomposition of gramian |
48 A = sqrt(S(1:n,1:n))*U(:,1:n)'; %calculate valid frame, s.t. A'*A=G | 50 Sigma_new = sqrt(Sigma_gram(1:n,:)).*sign(Sigma); %calculate singular values of dictionary |
51 A = Uinit*Sigma_new*V_gram'; %update dictionary | |
49 | 52 |
50 % %% Debug visualization function | 53 % %% Debug visualization function |
51 % function plotcart2d(A) | 54 % function plotcart2d(A) |
52 % compass(A(1,:),A(2,:)); | 55 % compass(A(1,:),A(2,:)); |