comparison util/SMALL_solve.m @ 37:d80c103d9876

(none)
author idamnjanovic
date Mon, 14 Mar 2011 15:33:05 +0000
parents fc395272d53e
children fd1c32cda22c
comparison
equal deleted inserted replaced
36:e6191f5bb21b 37:d80c103d9876
28 SparseLab_A =@(mode, m, n, x, I, dim) SL_A(Problem.A, mode, m, n, x, I, dim); 28 SparseLab_A =@(mode, m, n, x, I, dim) SL_A(Problem.A, mode, m, n, x, I, dim);
29 m = Problem.sizeA(1); % m is the no. of rows. 29 m = Problem.sizeA(1); % m is the no. of rows.
30 n = Problem.sizeA(2); % n is the no. of columns. 30 n = Problem.sizeA(2); % n is the no. of columns.
31 31
32 end 32 end
33 b = Problem.b; % The right-hand-side vector. 33 % if signal that needs to be represented is different then training set for
34 % dictionary learning it should be stored in Problem.b1 matix
35 if isfield(Problem, 'b1')
36 b = Problem.b1;
37 else
38 b = Problem.b; % The right-hand-side vector.
39 end
34 %% 40 %%
35 fprintf('\nStarting solver %s... \n', solver.name); 41 fprintf('\nStarting solver %s... \n', solver.name);
36 start=cputime; 42 start=cputime;
37 43 tStart=tic;
38 if strcmpi(solver.toolbox,'sparselab') 44 if strcmpi(solver.toolbox,'sparselab')
39 y = eval([solver.name,'(SparseLab_A, b, n,',solver.param,');']); 45 y = eval([solver.name,'(SparseLab_A, b, n,',solver.param,');']);
40 elseif strcmpi(solver.toolbox,'sparsify') 46 elseif strcmpi(solver.toolbox,'sparsify')
41 y = eval([solver.name,'(b, A, n, ''P_trans'', AT,',solver.param,');']); 47 y = eval([solver.name,'(b, A, n, ''P_trans'', AT,',solver.param,');']);
42 elseif (strcmpi(solver.toolbox,'spgl1')||strcmpi(solver.toolbox,'gpsr')) 48 elseif (strcmpi(solver.toolbox,'spgl1')||strcmpi(solver.toolbox,'gpsr'))
47 if isa(Problem.A,'float') 53 if isa(Problem.A,'float')
48 y = eval([solver.name,'(A, b, n,',solver.param,');']); 54 y = eval([solver.name,'(A, b, n,',solver.param,');']);
49 else 55 else
50 y = eval([solver.name,'(A, b, n,',solver.param,',AT);']); 56 y = eval([solver.name,'(A, b, n,',solver.param,',AT);']);
51 end 57 end
52 58 elseif (strcmpi(solver.toolbox, 'ompbox'))
59 G=A'*A;
60 epsilon=solver.param.epsilon;
61 maxatoms=solver.param.maxatoms;
62 y = eval([solver.name,'(A, b, G,epsilon,''maxatoms'',maxatoms,''checkdict'',''off'');']);
63 elseif (strcmpi(solver.toolbox, 'ompsbox'))
64 basedict = Problem.basedict;
65 if issparse(Problem.A)
66 A = Problem.A;
67 else
68 A = sparse(Problem.A);
69 end
70 G = dicttsep(basedict,A,dictsep(basedict,A,speye(size(A,2))));
71 epsilon=solver.param.epsilon;
72 maxatoms=solver.param.maxatoms;
73 y = eval([solver.name,'(basedict, A, b, G,epsilon,''maxatoms'',maxatoms,''checkdict'',''off'');']);
74 Problem.sparse=1;
53 % To introduce new sparse representation algorithm put the files in 75 % To introduce new sparse representation algorithm put the files in
54 % your Matlab path. Next, unique name <TolboxID> for your toolbox and 76 % your Matlab path. Next, unique name <TolboxID> for your toolbox and
55 % prefferd API <Preffered_API> needs to be defined. 77 % prefferd API <Preffered_API> needs to be defined.
56 % 78 %
57 % elseif strcmpi(solver.toolbox,'<ToolboxID>') 79 % elseif strcmpi(solver.toolbox,'<ToolboxID>')
66 return 88 return
67 end 89 end
68 90
69 %% 91 %%
70 % Sparse representation time 92 % Sparse representation time
71 93 tElapsed=toc(tStart);
72 solver.time = cputime - start; 94 solver.time = cputime - start;
73 fprintf('Solver %s finished task in %2f seconds. \n', solver.name, solver.time); 95 fprintf('Solver %s finished task in %2f seconds. \n', solver.name, solver.time);
74 96 fprintf('Solver %s finished task in %2f seconds. \n', solver.name, tElapsed);
97 solver.time=tElapsed;
75 % geting around out of memory problem when converting big matrix from 98 % geting around out of memory problem when converting big matrix from
76 % sparse to full... 99 % sparse to full...
77 100
78 if isfield(Problem, 'sparse')&&(Problem.sparse==1) 101 if isfield(Problem, 'sparse')&&(Problem.sparse==1)
79 solver.solution = y; 102 solver.solution = y;
80 else 103 else
81 solver.solution = full(y); 104 solver.solution = full(y);
82 end 105 end
83 106 if isfield(Problem,'reconstruct')
84 % Reconstruct the signal from the solution 107 % Reconstruct the signal from the solution
85 solver.reconstructed = Problem.reconstruct(solver.solution); 108 solver.reconstructed = Problem.reconstruct(solver.solution);
86 end 109 end
110 end