Mercurial > hg > smallbox
annotate util/classes/util/regularisedictionary.m @ 160:e3035d45d014 danieleb
Added support classes
author | Daniele Barchiesi <daniele.barchiesi@eecs.qmul.ac.uk> |
---|---|
date | Wed, 31 Aug 2011 10:53:10 +0100 |
parents | |
children |
rev | line source |
---|---|
daniele@160 | 1 function Dreg = regularisedictionary(D) |
daniele@160 | 2 % REGULARISEDICTIONARY regularise dictionary for sparse representation |
daniele@160 | 3 % |
daniele@160 | 4 % Example |
daniele@160 | 5 % Dreg = regularisedictionary(D) |
daniele@160 | 6 % |
daniele@160 | 7 % Input |
daniele@160 | 8 % - D: initial dictionary matrix. |
daniele@160 | 9 % |
daniele@160 | 10 % Output |
daniele@160 | 11 % - Dreg: regularised dictionary |
daniele@160 | 12 % |
daniele@160 | 13 % References: |
daniele@160 | 14 % |
daniele@160 | 15 % See also |
daniele@160 | 16 |
daniele@160 | 17 % Author(s): Daniele Barchiesi |
daniele@160 | 18 % Copyright 2011-2011 |
daniele@160 | 19 |
daniele@160 | 20 [n m] = size(D); %dimension and number of atoms |
daniele@160 | 21 [U S V] = svd(D); %SVD decomposition of the dictionary |
daniele@160 | 22 G = V*(S'*S)*V'; %gram matrix (equivalent to D'*D) |
daniele@160 | 23 I = eye(m); %identity matrix |
daniele@160 | 24 lambda = 1; %regularisation coefficient |
daniele@160 | 25 |
daniele@160 | 26 % Optimise the gram matrix |
daniele@160 | 27 cvx_begin %start cvx optimisation problem |
daniele@160 | 28 variable Greg(m,m) symmetric; %declare optimisation variable to be an mxm symmetric matrix |
daniele@160 | 29 expression residual(m,m) %declare residual as an intermediate calculation step |
daniele@160 | 30 residual = G-Greg; %define residual |
daniele@160 | 31 minimise (max(max(abs(Greg-I)))); %define objective function |
daniele@160 | 32 subject to %declare constraints |
daniele@160 | 33 Greg == semidefinite(m); %positive semidefinite cone membership |
daniele@160 | 34 diag(Greg) == ones(m,1); %unit diagonal |
daniele@160 | 35 norm(residual,'fro') <= lambda; % |
daniele@160 | 36 cvx_end |
daniele@160 | 37 |
daniele@160 | 38 [~, Sgram Vgram] = svd(Greg); %SVD decomposition of gramian |
daniele@160 | 39 Snew = sqrt(Sgram(1:n,:)).*sign(S); %calculate singular values of the regularised dictionary |
daniele@160 | 40 Dreg = U*Snew*Vgram'; %calculate regularised dictionary |
daniele@160 | 41 Dreg = normc(Dreg); %normalise columns of regularised dictionary |