% function nonconvex_prox_l11111
% 
% while 1
% eta = rand(1)*100;
% b = randn(1)*100;
% v = randn(1)*100;
% lambda = rand(1)*100;
% 
% HandleObj = @(x)eta*0.5*norm(x-b)^2 + lambda * sum(abs(abs(x)-v));
% x1 = nonconvex_prox_genl1_matlab(eta,b,lambda,v);
% x2 = nonconvex_prox_gen_l11(eta,b,lambda,v);
% 
% tttt = HandleObj(x1) - HandleObj(x2)
% 
% if(tttt < -1e-8)
%     tttt
%     ddf
% end
% 
% end
% function [x] = nonconvex_prox_genl1_matlab(eta,b,lambda,v)
% % min_x eta*0.5*||x-b||_2^2 + lambda * || abs(x) - v ||_1;
% n = length(b);
% for i=1:n
% 
% HandleObj = @(t)eta*0.5*(t-b(i))^2 + lambda * abs(abs(t)-v(i));
% x(i) = fminbnd(HandleObj,-100,100);
% end
% x = x(:);


function [x] = nonconvex_prox_gen_l1_l1(eta,b,lambda,v)
% min_x eta*0.5*||x-b||_2^2 + lambda * || abs(x) - v ||_1;
HandleObj = @(x)eta.*0.5.*(x-b).^2 + lambda * abs(abs(x)-v);
n = length(v);
x1 = abs(v);
x2 = - x1;
x3 = zeros(n,1);
%      eta(x-b) + lambda = 0  
% =>   x  = b - lambda /  eta
x4 = b - lambda /  eta;
%      eta(x-b) - lambda = 0  
% =>   x  = b + lambda /  eta
x5 = b + lambda / eta;

x = ComputeBestRoot5(HandleObj,x1,x2,x3,x4,x5);



