diff solvers/SMALL_cgp.m @ 3:01cad25206d6

(none)
author idamnjanovic
date Fri, 05 Mar 2010 12:31:22 +0000
parents 7750624e0c73
children 524cc3fff5ac
line wrap: on
line diff
--- a/solvers/SMALL_cgp.m	Fri Mar 05 12:23:57 2010 +0000
+++ b/solvers/SMALL_cgp.m	Fri Mar 05 12:31:22 2010 +0000
@@ -1,4 +1,4 @@
-function [A]=SMALL_cgp(Dict,X, m,  maxNumCoef, errorGoal, varargin) 
+function [A, resF]=SMALL_cgp(Dict,X, m,  maxNumCoef, errorGoal, varargin) 
 %=============================================
 % Sparse coding of a group of signals based on a given 
 % dictionary and specified number of atoms to use. 
@@ -59,7 +59,7 @@
    
 	
     currResNorm = residual'*residual/n;
-    errorGoal=errorGoal*currResNorm;
+    errGoal=errorGoal*currResNorm;
     a = zeros(m,1);
     p = zeros(m,1);
     
@@ -88,12 +88,13 @@
         residual=residual-alfa*Dp;
     
 		currResNorm = residual'*residual/n;
-        if currResNorm<errorGoal
+        if currResNorm<errGoal
             fprintf('\nFound exact representation! \n');
             break;
         end
    end;
    if (~isempty(indx))
+       resF(k)=currResNorm;
        A(indx,k)=a(indx);
    end
 end;