ivan@155: function [Phiout,unhatnz] = dict_update_REG_fn(Phi,x,unhat,maxIT,eps,cvset) ivan@155: %% Regularized Dictionary Learning with the constraint on the matrix frobenius norms %%%%% ivan@155: % Phi = Normalized Initial Dictionary ivan@155: % x = Signal(x). This can be a vector or a matrix ivan@155: % unhat = Initial guess for the coefficients ivan@155: % to = 1/(step size) . It is larger than spectral norm of coefficient matrix x ivan@155: % eps = Stopping criterion for iterative softthresholding and MM dictionary update ivan@155: % cvset = Dictionary constraint. 0 = Non convex ||D|| = N, 1 = Convex ||D||<=N ivan@155: % Phiout = Updated Dictionary ivan@155: % unhatnz Updated Coefficients (the same as input in this version) ivan@155: ivan@155: %% ivan@155: B = Phi; ivan@155: phim = norm(Phi, 'fro'); ivan@155: K = zeros(size(Phi,1),size(Phi,2)); ivan@155: c = .1 + svds(unhat,1)^2; ivan@155: ivan@155: %% ivan@155: i = 1; ivan@155: while (sum(sum((B-K).^2)) > eps)&&(i<=maxIT) ivan@155: if i>1 ivan@155: B = K; ivan@155: end ivan@155: K = 1/c *(x*unhat' + B*(c*eye(size(B,2))-unhat*unhat')); ivan@155: Kfn = sum(sum(K.^2)); ivan@155: if cvset == 1, ivan@155: K = min(1,phim/Kfn)*K; % with convex constraint set ivan@155: else ivan@155: K = (phim/Kfn)*K; % with fixed-norm constraint set ivan@155: end ivan@155: i = i+1; ivan@155: end ivan@155: ivan@155: %% depleted atoms cancellation %%% ivan@155: [Y,I] = sort(sum(K.^2),'descend'); ivan@155: RR = sum(Y>=0.0001); ivan@155: Phiout = K(:,I(1:RR)); ivan@155: unhatnz = unhat(I(1:RR),:); ivan@155: end