ivan@155: function [Phiout,unhatnz] = dict_update_REG_cn(Phi,x,unhat,maxIT,eps,cvset) ivan@155: %% Regularized Dictionary Learning with the constraint on the column 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|| = 1, 1 = Convex ||d||<=1 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: K = zeros(size(Phi,1),size(Phi,2)); ivan@155: c = .1 + svds(unhat,1)^2; %.1 ivan@155: c3 = (1/c)*eye(size(B,2)); ivan@155: c1 = x*unhat'*c3; ivan@155: c2 = (c*eye(size(B,2))-unhat*unhat')*c3; ivan@155: ivan@155: %% ivan@155: ivan@155: for i=1:maxIT ivan@155: % if i>1 ivan@155: % B = K; ivan@155: % end ivan@155: ivan@155: K = c1 + B*c2; ivan@155: ivan@155: if cvset == 1, ivan@155: K = K*diag(min(sum(K.^2).^(-.5),1)); % with convex constraint set ivan@155: else ivan@155: % Mehrdad original - ivan@155: % K = K*diag(sum(K.^2).^(-.5)); % with fixed-norm constraint set ivan@155: K = normc(K); ivan@155: end ivan@155: ivan@155: if (sum(sum((B-K).^2)) < eps) ivan@155: break; ivan@155: end ivan@155: ivan@155: B = K; ivan@155: end ivan@155: %% depleted atoms cancellation %%% ivan@155: [Y,I] = sort(sum(K.^2),'descend'); ivan@155: RR = sum(Y>=.01); ivan@155: Phiout = K(:,I(1:RR)); ivan@155: unhatnz = unhat(I(1:RR),:); ivan@155: end