Mercurial > hg > smallbox
comparison util/SMALL_solve.m @ 164:4205744092e6 release_1.9
Merge from branch "ivand_dev"
author | Ivan Damnjanovic lnx <ivan.damnjanovic@eecs.qmul.ac.uk> |
---|---|
date | Wed, 07 Sep 2011 14:17:30 +0100 |
parents | f42aa8bcb82f |
children | 4ea4badb2266 751fa3bddd30 |
comparison
equal
deleted
inserted
replaced
151:af5abc34a5e1 | 164:4205744092e6 |
---|---|
1 function solver = SMALL_solve(Problem, solver) | 1 function solver = SMALL_solve(Problem, solver) |
2 %% SMALL sparse solver | 2 %% SMALL sparse solver caller function |
3 % | 3 % |
4 % Function gets as input SMALL structure that contains SPARCO problem to | 4 % Function gets as input SMALL structure that contains SPARCO problem to |
5 % be solved, name of the toolbox and solver, and parameters file for | 5 % be solved, name of the toolbox and solver, and parameters file for |
6 % particular solver. | 6 % particular solver. |
7 % | 7 % |
46 start=cputime; | 46 start=cputime; |
47 tStart=tic; | 47 tStart=tic; |
48 if strcmpi(solver.toolbox,'sparselab') | 48 if strcmpi(solver.toolbox,'sparselab') |
49 y = eval([solver.name,'(SparseLab_A, b, n,',solver.param,');']); | 49 y = eval([solver.name,'(SparseLab_A, b, n,',solver.param,');']); |
50 elseif strcmpi(solver.toolbox,'sparsify') | 50 elseif strcmpi(solver.toolbox,'sparsify') |
51 y = eval([solver.name,'(b, A, n, ''P_trans'', AT,',solver.param,');']); | 51 if isa(Problem.A,'float') |
52 y = eval([solver.name,'(b, A, n,',solver.param,');']); | |
53 else | |
54 y = eval([solver.name,'(b, A, n, ''P_trans'', AT,',solver.param,');']); | |
55 end | |
52 elseif (strcmpi(solver.toolbox,'spgl1')||strcmpi(solver.toolbox,'gpsr')) | 56 elseif (strcmpi(solver.toolbox,'spgl1')||strcmpi(solver.toolbox,'gpsr')) |
53 y = eval([solver.name,'(b, A,',solver.param,');']); | 57 y = eval([solver.name,'(b, A,',solver.param,');']); |
54 elseif (strcmpi(solver.toolbox,'SPAMS')) | 58 elseif (strcmpi(solver.toolbox,'SPAMS')) |
55 y = eval([solver.name,'(b, A, solver.param);']); | 59 y = eval([solver.name,'(b, A, solver.param);']); |
56 elseif (strcmpi(solver.toolbox,'SMALL')) | 60 elseif (strcmpi(solver.toolbox,'SMALL')) |
64 epsilon=solver.param.epsilon; | 68 epsilon=solver.param.epsilon; |
65 maxatoms=solver.param.maxatoms; | 69 maxatoms=solver.param.maxatoms; |
66 y = eval([solver.name,'(A, b, G,epsilon,''maxatoms'',maxatoms,''checkdict'',''off'');']); | 70 y = eval([solver.name,'(A, b, G,epsilon,''maxatoms'',maxatoms,''checkdict'',''off'');']); |
67 elseif (strcmpi(solver.toolbox, 'ompsbox')) | 71 elseif (strcmpi(solver.toolbox, 'ompsbox')) |
68 basedict = Problem.basedict; | 72 basedict = Problem.basedict; |
69 if issparse(Problem.A) | 73 if issparse(Problem.A) |
70 A = Problem.A; | 74 A = Problem.A; |
71 else | 75 else |
72 A = sparse(Problem.A); | 76 A = sparse(Problem.A); |
73 end | 77 end |
74 G = dicttsep(basedict,A,dictsep(basedict,A,speye(size(A,2)))); | 78 G = dicttsep(basedict,A,dictsep(basedict,A,speye(size(A,2)))); |
75 epsilon=solver.param.epsilon; | 79 epsilon=solver.param.epsilon; |
76 maxatoms=solver.param.maxatoms; | 80 maxatoms=solver.param.maxatoms; |
77 y = eval([solver.name,'(basedict, A, b, G,epsilon,''maxatoms'',maxatoms,''checkdict'',''off'');']); | 81 y = eval([solver.name,'(basedict, A, b, G,epsilon,''maxatoms'',maxatoms,''checkdict'',''off'');']); |
78 Problem.sparse=1; | 82 Problem.sparse=1; |
79 % To introduce new sparse representation algorithm put the files in | 83 elseif (strcmpi(solver.toolbox, 'ALPS')) |
80 % your Matlab path. Next, unique name <TolboxID> for your toolbox and | 84 if ~isa(Problem.A,'float') |
81 % prefferd API <Preffered_API> needs to be defined. | 85 % ALPS does not accept implicit dictionary definition |
82 % | 86 A = opToMatrix(Problem.A, 1); |
83 % elseif strcmpi(solver.toolbox,'<ToolboxID>') | 87 end |
84 % | 88 [y, numiter, time, y_path] = wrapper_ALPS_toolbox(b, A, solver.param); |
85 % % - Evaluate the function (solver.name - defined in the main) with | 89 elseif (strcmpi(solver.toolbox, 'MMbox')) |
86 % % parameters given above | 90 if ~isa(Problem.A,'float') |
87 % | 91 % MMbox does not accept implicit dictionary definition |
88 % y = eval([solver.name,'(<Preffered_API>);']); | 92 A = opToMatrix(Problem.A, 1); |
89 | 93 end |
94 | |
95 [y, cost] = wrapper_mm_solver(b, A, solver.param); | |
96 | |
97 | |
98 | |
99 % To introduce new sparse representation algorithm put the files in | |
100 % your Matlab path. Next, unique name <TolboxID> for your toolbox and | |
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 | |
90 else | 110 else |
91 printf('\nToolbox has not been registered. Please change SMALL_solver file.\n'); | 111 printf('\nToolbox has not been registered. Please change SMALL_solver file.\n'); |
92 return | 112 return |
93 end | 113 end |
94 | 114 |