function [X , S , r] = LO(A,b,band,sparsity,supprec,search,ep)
%% local optimization
%% input: A:        sensing matrix
%%        b:        measurement
%%        band:     radius of searching band in Local Optimization
%%        sparsity: # elements in supprec
%%        supprec:  input support to be locally optimized
%%        ep:       noise level Ax + e = b where ||e||_2 \le ep. By
%%                  default, ep = 1e-12.
%%        search:   search == 1: locally optimize the object one by one
%%                  according to the order of the input support(supprec); 
%%                  search == 2: locally optimize the object
%%                  in a random order. By default, search == 1.
%% output: X:       output vector
%%         S:       output support which has been locally optimized
%%         r:       A*X-b

if(nargin<7)
    ep = 1e-12;
end

if search == 1
    [X , S , r] = LS(A,b,band,sparsity,supprec);
elseif search == 2
    [X , S , r] = MultiLS(A,b,band,sparsity,supprec,1,ep);
else
    display('invalid input of search: search = 1 is applied')
    [X , S , r] = LS(A,b,band,sparsity,supprec);
end
