Prev Next quadratic_ok.m

l1_quadratic: Example and Test

Source Code
 
function [ok] = quadratic_ok()
ok = true;
% ------------------------------------------------------------------------
% You can change these parameters
n = 3;  % number of variables in l1 minimization problem
% ------------------------------------------------------------------------
% Define the problem
rand('seed', 123);
A        = rand(n, n);
A        = A' * A;
b        = rand(n, 1);
lambda   = .1 * rand(1, 1);
%
% compute solution
max_itr  = 20;
delta    = 1e-4;
[x, info] = l1_quadratic(max_itr, A, b, lambda, delta);
%
% check solution
Ax_b = A * x + b;
for i = 1 : n
     if x(i) > delta
          ok = ok & delta >= abs(Ax_b(i) + lambda);
     elseif x(i) < -delta
          ok = ok & delta >= abs(Ax_b(i) - lambda);
     else
          ok = ok & lambda + delta >= abs(Ax_b(i));
     end
end
%
return
end

Input File: test/quadratic_ok.m