annotate util/SMALL_solve.m @ 247:ecce33192fcc tip

Added tag ver_2.1 for changeset cef4500b936f
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Wed, 31 Oct 2012 12:24:44 +0000
parents 198d4d9cee74
children
rev   line source
idamnjanovic@8 1 function solver = SMALL_solve(Problem, solver)
ivan@161 2 %% SMALL sparse solver caller function
idamnjanovic@24 3 %
ivan@85 4 % Function gets as input SMALL structure that contains SPARCO problem to
ivan@85 5 % be solved, name of the toolbox and solver, and parameters file for
ivan@85 6 % particular solver.
ivan@85 7 %
ivan@85 8 % Outputs are solution, reconstructed signal and time spent
ivan@85 9
idamnjanovic@24 10 % Centre for Digital Music, Queen Mary, University of London.
idamnjanovic@24 11 % This file copyright 2009 Ivan Damnjanovic.
idamnjanovic@24 12 %
idamnjanovic@24 13 % This program is free software; you can redistribute it and/or
idamnjanovic@24 14 % modify it under the terms of the GNU General Public License as
idamnjanovic@24 15 % published by the Free Software Foundation; either version 2 of the
idamnjanovic@24 16 % License, or (at your option) any later version. See the file
idamnjanovic@24 17 % COPYING included with this distribution for more information.
luis@199 18 %
idamnjanovic@8 19 %%
idamnjanovic@8 20
luis@216 21 SMALLboxInit
luis@203 22
idamnjanovic@8 23 if isa(Problem.A,'float')
idamnjanovic@8 24 A = Problem.A;
idamnjanovic@8 25 SparseLab_A=Problem.A;
idamnjanovic@8 26 m = size(Problem.A,1); % m is the no. of rows.
idamnjanovic@8 27 n = size(Problem.A,2); % n is the no. of columns.
idamnjanovic@8 28 else
idamnjanovic@8 29 A = @(x) Problem.A(x,1); % The operator
idamnjanovic@8 30 AT = @(y) Problem.A(y,2); % and its transpose.
idamnjanovic@8 31 SparseLab_A =@(mode, m, n, x, I, dim) SL_A(Problem.A, mode, m, n, x, I, dim);
idamnjanovic@8 32 m = Problem.sizeA(1); % m is the no. of rows.
idamnjanovic@8 33 n = Problem.sizeA(2); % n is the no. of columns.
idamnjanovic@8 34
idamnjanovic@1 35 end
idamnjanovic@37 36 % if signal that needs to be represented is different then training set for
idamnjanovic@37 37 % dictionary learning it should be stored in Problem.b1 matix
idamnjanovic@37 38 if isfield(Problem, 'b1')
idamnjanovic@37 39 b = Problem.b1;
idamnjanovic@37 40 else
idamnjanovic@37 41 b = Problem.b; % The right-hand-side vector.
idamnjanovic@37 42 end
idamnjanovic@8 43 %%
ivan@140 44 if (solver.profile)
ivan@140 45 fprintf('\nStarting solver %s... \n', solver.name);
ivan@140 46 end
ivan@140 47
idamnjanovic@8 48 start=cputime;
idamnjanovic@37 49 tStart=tic;
luis@199 50
luis@228 51 %% solvers configuration
luis@228 52 % test if there is a locally modified version of the config
luis@228 53 % otherwise reads the "default" config file
luis@228 54 if exist(fullfile(SMALL_path, 'config/SMALL_solve_config_local.m'), 'file') == 2
luis@228 55 run(fullfile(SMALL_path, 'config/SMALL_solve_config_local.m'));
luis@228 56 else
luis@228 57 run(fullfile(SMALL_path, 'config/SMALL_solve_config.m'));
luis@228 58 end
idamnjanovic@8 59
idamnjanovic@8 60 %%
idamnjanovic@8 61 % Sparse representation time
idamnjanovic@37 62 tElapsed=toc(tStart);
idamnjanovic@8 63 solver.time = cputime - start;
ivan@140 64 if (solver.profile)
ivan@140 65 fprintf('Solver %s finished task in %2f seconds (cpu time). \n', solver.name, solver.time);
ivan@140 66 fprintf('Solver %s finished task in %2f seconds (tic-toc time). \n', solver.name, tElapsed);
ivan@140 67 end
idamnjanovic@37 68 solver.time=tElapsed;
idamnjanovic@8 69 % geting around out of memory problem when converting big matrix from
idamnjanovic@8 70 % sparse to full...
idamnjanovic@8 71
idamnjanovic@18 72 if isfield(Problem, 'sparse')&&(Problem.sparse==1)
idamnjanovic@8 73 solver.solution = y;
idamnjanovic@8 74 else
idamnjanovic@8 75 solver.solution = full(y);
idamnjanovic@8 76 end
idamnjanovic@37 77 if isfield(Problem,'reconstruct')
ivan@140 78 % Reconstruct the signal from the solution
ivan@140 79 solver.reconstructed = Problem.reconstruct(solver.solution);
idamnjanovic@8 80 end
idamnjanovic@37 81 end