Revision 92e52d722527714dbc5e219c81323c495f736335 authored by Michael Friedlander on 19 September 2014, 16:58:42 UTC, committed by Michael Friedlander on 19 September 2014, 16:58:42 UTC
1 parent f01ddaa
Raw File
NormL12_project.m
function x = NormL12_project(g,x,weights,tau)
% Projection with number of groups equal to g

% Convert to matrix
m = round(length(x) / g); n = g;
x = reshape(x,m,n);

% Compute two-norms of rows
if isreal(x)
   xa  = sqrt(sum(x.^2,2));
else
   xa  = sqrt(sum(abs(x).^2,2));
end

% Project one one-norm ball
idx = xa < eps;
xc  = oneProjector(xa,weights,tau);

% Scale original
xc  = xc ./ xa; xc(idx) = 0;
x   = spdiags(xc,0,m,m)*x;

% Vectorize result
x = x(:);
back to top