annotate util/SMALL_solve.m @ 5:f44689e95ea4

(none)
author idamnjanovic
date Mon, 22 Mar 2010 10:43:01 +0000
parents 7750624e0c73
children 33850553b702
rev   line source
idamnjanovic@1 1 function SMALL = SMALL_solve(SMALL)
idamnjanovic@1 2 % Ivan Damnjanovic 2009
idamnjanovic@1 3 % Function gets as input SMALL structure that contains SPARCO problem to
idamnjanovic@1 4 % be solved, name of the toolbox and solver, and parameters file for particular solver
idamnjanovic@1 5 % Outputs are solution, reconstructed signal and time spent
idamnjanovic@1 6 %%
idamnjanovic@1 7
idamnjanovic@1 8 A = @(x) SMALL.Problem.A(x,1); % The operator
idamnjanovic@1 9 AT = @(y) SMALL.Problem.A(y,2); % and its transpose.
idamnjanovic@1 10 b = SMALL.Problem.b; % The right-hand-side vector.
idamnjanovic@1 11 m = SMALL.Problem.sizeA(1); % m is the no. of rows.
idamnjanovic@1 12 n = SMALL.Problem.sizeA(2); % n is the no. of columns.
idamnjanovic@1 13
idamnjanovic@1 14 fprintf('\nStarting solver %s... \n', SMALL.solver.name);
idamnjanovic@1 15 start=cputime;
idamnjanovic@1 16 %%
idamnjanovic@1 17 if strcmpi(SMALL.solver.toolbox,'sparselab')
idamnjanovic@1 18 y = eval([SMALL.solver.name,'(''SL_A'', b, n,',SMALL.solver.param,');']);
idamnjanovic@1 19 elseif strcmpi(SMALL.solver.toolbox,'sparsify')
idamnjanovic@1 20 y = eval([SMALL.solver.name,'(b, A, n, ''P_trans'', AT,',SMALL.solver.param,');']);
idamnjanovic@1 21 elseif (strcmpi(SMALL.solver.toolbox,'spgl1')||strcmpi(SMALL.solver.toolbox,'gpsr'))
idamnjanovic@1 22 y = eval([SMALL.solver.name,'(b, A,',SMALL.solver.param,');']);
idamnjanovic@1 23 else
idamnjanovic@1 24 y = eval([SMALL.solver.name,'(A, b, n,',SMALL.solver.param,',AT);']);
idamnjanovic@1 25 end
idamnjanovic@1 26 %%
idamnjanovic@1 27 SMALL.solver.time = cputime - start;
idamnjanovic@1 28 fprintf('Solver %s finished task in %2f seconds. \n', SMALL.solver.name, SMALL.solver.time);
idamnjanovic@1 29 SMALL.solver.solution = full(y);
idamnjanovic@1 30 SMALL.solver.reconstructed = SMALL.Problem.reconstruct(SMALL.solver.solution);
idamnjanovic@1 31 end
idamnjanovic@1 32