idamnjanovic@1: function SMALL = SMALL_solve(SMALL) idamnjanovic@1: % Ivan Damnjanovic 2009 idamnjanovic@1: % Function gets as input SMALL structure that contains SPARCO problem to idamnjanovic@1: % be solved, name of the toolbox and solver, and parameters file for particular solver idamnjanovic@1: % Outputs are solution, reconstructed signal and time spent idamnjanovic@1: %% idamnjanovic@1: idamnjanovic@1: A = @(x) SMALL.Problem.A(x,1); % The operator idamnjanovic@1: AT = @(y) SMALL.Problem.A(y,2); % and its transpose. idamnjanovic@1: b = SMALL.Problem.b; % The right-hand-side vector. idamnjanovic@1: m = SMALL.Problem.sizeA(1); % m is the no. of rows. idamnjanovic@1: n = SMALL.Problem.sizeA(2); % n is the no. of columns. idamnjanovic@1: idamnjanovic@1: fprintf('\nStarting solver %s... \n', SMALL.solver.name); idamnjanovic@1: start=cputime; idamnjanovic@1: %% idamnjanovic@1: if strcmpi(SMALL.solver.toolbox,'sparselab') idamnjanovic@1: y = eval([SMALL.solver.name,'(''SL_A'', b, n,',SMALL.solver.param,');']); idamnjanovic@1: elseif strcmpi(SMALL.solver.toolbox,'sparsify') idamnjanovic@1: y = eval([SMALL.solver.name,'(b, A, n, ''P_trans'', AT,',SMALL.solver.param,');']); idamnjanovic@1: elseif (strcmpi(SMALL.solver.toolbox,'spgl1')||strcmpi(SMALL.solver.toolbox,'gpsr')) idamnjanovic@1: y = eval([SMALL.solver.name,'(b, A,',SMALL.solver.param,');']); idamnjanovic@1: else idamnjanovic@1: y = eval([SMALL.solver.name,'(A, b, n,',SMALL.solver.param,',AT);']); idamnjanovic@1: end idamnjanovic@1: %% idamnjanovic@1: SMALL.solver.time = cputime - start; idamnjanovic@1: fprintf('Solver %s finished task in %2f seconds. \n', SMALL.solver.name, SMALL.solver.time); idamnjanovic@1: SMALL.solver.solution = full(y); idamnjanovic@1: SMALL.solver.reconstructed = SMALL.Problem.reconstruct(SMALL.solver.solution); idamnjanovic@1: end idamnjanovic@1: