Mercurial > hg > smallbox
comparison util/SMALL_solve.m @ 159:23763c5fbda5 danieleb
Merge
author | Daniele Barchiesi <daniele.barchiesi@eecs.qmul.ac.uk> |
---|---|
date | Wed, 31 Aug 2011 10:43:32 +0100 |
parents | a4d0977d4595 b14209313ba4 |
children | 4ea4badb2266 |
comparison
equal
deleted
inserted
replaced
158:855aa3288394 | 159:23763c5fbda5 |
---|---|
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 switch solver.toolbox | 48 if strcmpi(solver.toolbox,'sparselab') |
49 case 'sparselab' | 49 y = eval([solver.name,'(SparseLab_A, b, n,',solver.param,');']); |
50 y = eval([solver.name,'(SparseLab_A, b, n,',solver.param,');']); | 50 elseif strcmpi(solver.toolbox,'sparsify') |
51 case 'sparsify' | 51 if isa(Problem.A,'float') |
52 y = eval([solver.name,'(b, A, n,',solver.param,');']); | |
53 else | |
52 y = eval([solver.name,'(b, A, n, ''P_trans'', AT,',solver.param,');']); | 54 y = eval([solver.name,'(b, A, n, ''P_trans'', AT,',solver.param,');']); |
53 case 'spgl1' | 55 end |
54 y = eval([solver.name,'(b, A,',solver.param,');']); | 56 elseif (strcmpi(solver.toolbox,'spgl1')||strcmpi(solver.toolbox,'gpsr')) |
55 case 'gpsr' | 57 y = eval([solver.name,'(b, A,',solver.param,');']); |
56 y = eval([solver.name,'(b, A,',solver.param,');']); | 58 elseif (strcmpi(solver.toolbox,'SPAMS')) |
57 case 'SPAMS' | 59 y = eval([solver.name,'(b, A, solver.param);']); |
58 y = eval([solver.name,'(b, A, solver.param);']); | 60 elseif (strcmpi(solver.toolbox,'SMALL')) |
59 case 'SMALL' | 61 if isa(Problem.A,'float') |
60 if isa(Problem.A,'float') | 62 y = eval([solver.name,'(A, b, n,',solver.param,');']); |
61 y = eval([solver.name,'(A, b, n,',solver.param,');']); | 63 else |
62 else | 64 y = eval([solver.name,'(A, b, n,',solver.param,',AT);']); |
63 y = eval([solver.name,'(A, b, n,',solver.param,',AT);']); | 65 end |
64 end | 66 elseif (strcmpi(solver.toolbox, 'ompbox')) |
65 case 'ompbox' | 67 G=A'*A; |
66 G = A'*A; | 68 epsilon=solver.param.epsilon; |
67 maxatoms=solver.param.maxatoms; | 69 maxatoms=solver.param.maxatoms; |
68 switch solver.name | 70 y = eval([solver.name,'(A, b, G,epsilon,''maxatoms'',maxatoms,''checkdict'',''off'');']); |
69 case 'omp' | 71 elseif (strcmpi(solver.toolbox, 'ompsbox')) |
70 y = omp(A,b,G,maxatoms,'checkdict','off'); | 72 basedict = Problem.basedict; |
71 case 'omp2' | 73 if issparse(Problem.A) |
72 epsilon=solver.param.epsilon; | 74 A = Problem.A; |
73 y = omp2(A,b,G,epsilon,'maxatoms',maxatoms,'checkdict','off'); | 75 else |
74 end | 76 A = sparse(Problem.A); |
75 case 'ompsbox' | 77 end |
76 basedict = Problem.basedict; | 78 G = dicttsep(basedict,A,dictsep(basedict,A,speye(size(A,2)))); |
77 if issparse(Problem.A) | 79 epsilon=solver.param.epsilon; |
78 A = Problem.A; | 80 maxatoms=solver.param.maxatoms; |
79 else | 81 y = eval([solver.name,'(basedict, A, b, G,epsilon,''maxatoms'',maxatoms,''checkdict'',''off'');']); |
80 A = sparse(Problem.A); | 82 Problem.sparse=1; |
81 end | 83 elseif (strcmpi(solver.toolbox, 'ALPS')) |
82 G = dicttsep(basedict,A,dictsep(basedict,A,speye(size(A,2)))); | 84 if ~isa(Problem.A,'float') |
83 epsilon=solver.param.epsilon; | 85 % ALPS does not accept implicit dictionary definition |
84 maxatoms=solver.param.maxatoms; | 86 A = opToMatrix(Problem.A, 1); |
85 y = eval([solver.name,'(basedict, A, b, G,epsilon,''maxatoms'',maxatoms,''checkdict'',''off'');']); | 87 end |
86 Problem.sparse=1; | 88 [y, numiter, time, y_path] = wrapper_ALPS_toolbox(b, A, solver.param); |
87 % To introduce new sparse representation algorithm put the files in | 89 elseif (strcmpi(solver.toolbox, 'MMbox')) |
88 % your Matlab path. Next, unique name <TolboxID> for your toolbox and | 90 if ~isa(Problem.A,'float') |
89 % prefferd API <Preffered_API> needs to be defined. | 91 % ALPS does not accept implicit dictionary definition |
90 % | 92 A = opToMatrix(Problem.A, 1); |
91 % elseif strcmpi(solver.toolbox,'<ToolboxID>') | 93 end |
92 % | 94 |
93 % % - Evaluate the function (solver.name - defined in the main) with | 95 [y, cost] = wrapper_mm_solver(b, A, solver.param); |
94 % % parameters given above | 96 |
95 % | 97 |
96 % y = eval([solver.name,'(<Preffered_API>);']); | 98 |
97 otherwise | 99 % To introduce new sparse representation algorithm put the files in |
98 printf('\nToolbox has not been registered. Please change SMALL_solver file.\n'); | 100 % your Matlab path. Next, unique name <TolboxID> for your toolbox and |
99 return | 101 % prefferd API <Preffered_API> needs to be defined. |
102 % | |
103 % elseif strcmpi(solver.toolbox,'<ToolboxID>') | |
104 % | |
105 % % - Evaluate the function (solver.name - defined in the main) with | |
106 % % parameters given above | |
107 % | |
108 % y = eval([solver.name,'(<Preffered_API>);']); | |
109 | |
110 else | |
111 printf('\nToolbox has not been registered. Please change SMALL_solver file.\n'); | |
112 return | |
100 end | 113 end |
101 | 114 |
102 %% | 115 %% |
103 % Sparse representation time | 116 % Sparse representation time |
104 tElapsed=toc(tStart); | 117 tElapsed=toc(tStart); |