Mercurial > hg > smallbox
comparison util/SMALL_solve.m @ 156:a4d0977d4595 danieleb
First branch commit, danieleb
author | danieleb |
---|---|
date | Tue, 30 Aug 2011 11:12:31 +0100 |
parents | 31d2864dfdd4 |
children | 23763c5fbda5 |
comparison
equal
deleted
inserted
replaced
153:af307f247ac7 | 156:a4d0977d4595 |
---|---|
13 % This program is free software; you can redistribute it and/or | 13 % This program is free software; you can redistribute it and/or |
14 % modify it under the terms of the GNU General Public License as | 14 % modify it under the terms of the GNU General Public License as |
15 % published by the Free Software Foundation; either version 2 of the | 15 % published by the Free Software Foundation; either version 2 of the |
16 % License, or (at your option) any later version. See the file | 16 % License, or (at your option) any later version. See the file |
17 % COPYING included with this distribution for more information. | 17 % COPYING included with this distribution for more information. |
18 % | 18 % |
19 %% | 19 %% |
20 | 20 |
21 if isa(Problem.A,'float') | 21 if isa(Problem.A,'float') |
22 A = Problem.A; | 22 A = Problem.A; |
23 SparseLab_A=Problem.A; | 23 SparseLab_A=Problem.A; |
43 fprintf('\nStarting solver %s... \n', solver.name); | 43 fprintf('\nStarting solver %s... \n', solver.name); |
44 end | 44 end |
45 | 45 |
46 start=cputime; | 46 start=cputime; |
47 tStart=tic; | 47 tStart=tic; |
48 if strcmpi(solver.toolbox,'sparselab') | 48 switch solver.toolbox |
49 y = eval([solver.name,'(SparseLab_A, b, n,',solver.param,');']); | 49 case 'sparselab' |
50 elseif strcmpi(solver.toolbox,'sparsify') | 50 y = eval([solver.name,'(SparseLab_A, b, n,',solver.param,');']); |
51 y = eval([solver.name,'(b, A, n, ''P_trans'', AT,',solver.param,');']); | 51 case 'sparsify' |
52 elseif (strcmpi(solver.toolbox,'spgl1')||strcmpi(solver.toolbox,'gpsr')) | 52 y = eval([solver.name,'(b, A, n, ''P_trans'', AT,',solver.param,');']); |
53 y = eval([solver.name,'(b, A,',solver.param,');']); | 53 case 'spgl1' |
54 elseif (strcmpi(solver.toolbox,'SPAMS')) | 54 y = eval([solver.name,'(b, A,',solver.param,');']); |
55 y = eval([solver.name,'(b, A, solver.param);']); | 55 case 'gpsr' |
56 elseif (strcmpi(solver.toolbox,'SMALL')) | 56 y = eval([solver.name,'(b, A,',solver.param,');']); |
57 if isa(Problem.A,'float') | 57 case 'SPAMS' |
58 y = eval([solver.name,'(A, b, n,',solver.param,');']); | 58 y = eval([solver.name,'(b, A, solver.param);']); |
59 else | 59 case 'SMALL' |
60 y = eval([solver.name,'(A, b, n,',solver.param,',AT);']); | 60 if isa(Problem.A,'float') |
61 end | 61 y = eval([solver.name,'(A, b, n,',solver.param,');']); |
62 elseif (strcmpi(solver.toolbox, 'ompbox')) | 62 else |
63 G=A'*A; | 63 y = eval([solver.name,'(A, b, n,',solver.param,',AT);']); |
64 epsilon=solver.param.epsilon; | 64 end |
65 maxatoms=solver.param.maxatoms; | 65 case 'ompbox' |
66 y = eval([solver.name,'(A, b, G,epsilon,''maxatoms'',maxatoms,''checkdict'',''off'');']); | 66 G = A'*A; |
67 elseif (strcmpi(solver.toolbox, 'ompsbox')) | 67 maxatoms=solver.param.maxatoms; |
68 basedict = Problem.basedict; | 68 switch solver.name |
69 if issparse(Problem.A) | 69 case 'omp' |
70 A = Problem.A; | 70 y = omp(A,b,G,maxatoms,'checkdict','off'); |
71 else | 71 case 'omp2' |
72 A = sparse(Problem.A); | 72 epsilon=solver.param.epsilon; |
73 end | 73 y = omp2(A,b,G,epsilon,'maxatoms',maxatoms,'checkdict','off'); |
74 G = dicttsep(basedict,A,dictsep(basedict,A,speye(size(A,2)))); | 74 end |
75 epsilon=solver.param.epsilon; | 75 case 'ompsbox' |
76 maxatoms=solver.param.maxatoms; | 76 basedict = Problem.basedict; |
77 y = eval([solver.name,'(basedict, A, b, G,epsilon,''maxatoms'',maxatoms,''checkdict'',''off'');']); | 77 if issparse(Problem.A) |
78 Problem.sparse=1; | 78 A = Problem.A; |
79 % To introduce new sparse representation algorithm put the files in | 79 else |
80 % your Matlab path. Next, unique name <TolboxID> for your toolbox and | 80 A = sparse(Problem.A); |
81 % prefferd API <Preffered_API> needs to be defined. | 81 end |
82 % | 82 G = dicttsep(basedict,A,dictsep(basedict,A,speye(size(A,2)))); |
83 % elseif strcmpi(solver.toolbox,'<ToolboxID>') | 83 epsilon=solver.param.epsilon; |
84 % | 84 maxatoms=solver.param.maxatoms; |
85 % % - Evaluate the function (solver.name - defined in the main) with | 85 y = eval([solver.name,'(basedict, A, b, G,epsilon,''maxatoms'',maxatoms,''checkdict'',''off'');']); |
86 % % parameters given above | 86 Problem.sparse=1; |
87 % | 87 % To introduce new sparse representation algorithm put the files in |
88 % y = eval([solver.name,'(<Preffered_API>);']); | 88 % your Matlab path. Next, unique name <TolboxID> for your toolbox and |
89 | 89 % prefferd API <Preffered_API> needs to be defined. |
90 else | 90 % |
91 printf('\nToolbox has not been registered. Please change SMALL_solver file.\n'); | 91 % elseif strcmpi(solver.toolbox,'<ToolboxID>') |
92 return | 92 % |
93 % % - Evaluate the function (solver.name - defined in the main) with | |
94 % % parameters given above | |
95 % | |
96 % y = eval([solver.name,'(<Preffered_API>);']); | |
97 otherwise | |
98 printf('\nToolbox has not been registered. Please change SMALL_solver file.\n'); | |
99 return | |
93 end | 100 end |
94 | 101 |
95 %% | 102 %% |
96 % Sparse representation time | 103 % Sparse representation time |
97 tElapsed=toc(tStart); | 104 tElapsed=toc(tStart); |