% for a lasso problem, usually the latter one will stop earlier than expected
m = 120; n = 512; k = 20; % m rows, n cols, k nonzeros.
p = randperm(n); x0 = zeros(n,1); x0(p(1:k)) = sign(randn(k,1));
A = randn(m,n); [Q,R] = qr(A',0); A = Q';
b = Ax0 + 0.005 \ randn(m,1);
opts.optTol = 1e-4;
opts.iterations = 20;
tau = norm(x0,1);
[x,r,g,info] = spgl1(A, b,tau,[], [], opts); % Find BP sol'n.
% for a lasso problem, usually the latter one will stop earlier than expected
m = 120; n = 512; k = 20; % m rows, n cols, k nonzeros. p = randperm(n); x0 = zeros(n,1); x0(p(1:k)) = sign(randn(k,1)); A = randn(m,n); [Q,R] = qr(A',0); A = Q'; b = Ax0 + 0.005 \ randn(m,1); opts.optTol = 1e-4; opts.iterations = 20; tau = norm(x0,1); [x,r,g,info] = spgl1(A, b,tau,[], [], opts); % Find BP sol'n.
opts.optTol = info.rNorm; [x,r,g,info] = spgl1(A, b, tau, [], [], opts); % Find BP sol'n.