comparison solvers/SMALL_cgp.m @ 3:01cad25206d6

(none)
author idamnjanovic
date Fri, 05 Mar 2010 12:31:22 +0000
parents 7750624e0c73
children 524cc3fff5ac
comparison
equal deleted inserted replaced
2:257c289bf11d 3:01cad25206d6
1 function [A]=SMALL_cgp(Dict,X, m, maxNumCoef, errorGoal, varargin) 1 function [A, resF]=SMALL_cgp(Dict,X, m, maxNumCoef, errorGoal, varargin)
2 %============================================= 2 %=============================================
3 % Sparse coding of a group of signals based on a given 3 % Sparse coding of a group of signals based on a given
4 % dictionary and specified number of atoms to use. 4 % dictionary and specified number of atoms to use.
5 % input arguments: Dict - the dictionary 5 % input arguments: Dict - the dictionary
6 % X - the signals to represent 6 % X - the signals to represent
57 indx =[]; 57 indx =[];
58 j=0; 58 j=0;
59 59
60 60
61 currResNorm = residual'*residual/n; 61 currResNorm = residual'*residual/n;
62 errorGoal=errorGoal*currResNorm; 62 errGoal=errorGoal*currResNorm;
63 a = zeros(m,1); 63 a = zeros(m,1);
64 p = zeros(m,1); 64 p = zeros(m,1);
65 65
66 while j < maxNumCoef, 66 while j < maxNumCoef,
67 67
86 p(indx)=dir(indx)+beta*p(indx); 86 p(indx)=dir(indx)+beta*p(indx);
87 87
88 residual=residual-alfa*Dp; 88 residual=residual-alfa*Dp;
89 89
90 currResNorm = residual'*residual/n; 90 currResNorm = residual'*residual/n;
91 if currResNorm<errorGoal 91 if currResNorm<errGoal
92 fprintf('\nFound exact representation! \n'); 92 fprintf('\nFound exact representation! \n');
93 break; 93 break;
94 end 94 end
95 end; 95 end;
96 if (~isempty(indx)) 96 if (~isempty(indx))
97 resF(k)=currResNorm;
97 A(indx,k)=a(indx); 98 A(indx,k)=a(indx);
98 end 99 end
99 end; 100 end;
100 return; 101 return;
101 102