function [fval,x_new,iter] = pro_gra_l1l2( A, b, nmA, lambda, tol, maxiter)

fprintf('\n Start proximal gradient algorithm\n')

% set matrix handles
Ahandle = @(x) A*x;
AThandle = @(x) A'*x;

% initialization
[~, n] = size(A);
L = nmA;

x_old = zeros(n, 1);
x_new = x_old;

% num_restart = 0;
iter = 0;

while iter < maxiter
    
    tmp0 = norm(x_new);
    if tmp0 < 1e-8
        tmp = zeros(n,1);
    else
        tmp = lambda*x_new/tmp0;
    end
    
    % proximal gradient
    y_tmp = x_new - (1/L)*(AThandle(Ahandle(x_new) - b) - tmp);
    x_old = x_new;
    x_new = soft_thresh(y_tmp,lambda/L);
    
    % check for termination
    if (norm(x_new - x_old)/max(1,norm(x_new)) < tol || iter == maxiter - 1)
        iter = iter + 1;
        z = Ahandle(x_new) - b;
        fval = 1/2*norm(z)^(2) + lambda*(norm(x_new,1) - norm(x_new));
%         fprintf(' Termination: it_num = %d, restart_num = %d\n', iter, num_restart);
        break
    end
    
    
    iter = iter + 1;
    
end
