diff solvers/SMALL_cgp.m @ 22:524cc3fff5ac

(none)
author idamnjanovic
date Tue, 27 Apr 2010 13:32:27 +0000
parents 01cad25206d6
children 92a9b18c3bd3
line wrap: on
line diff
--- a/solvers/SMALL_cgp.m	Tue Apr 27 13:31:44 2010 +0000
+++ b/solvers/SMALL_cgp.m	Tue Apr 27 13:32:27 2010 +0000
@@ -1,5 +1,15 @@
 function [A, resF]=SMALL_cgp(Dict,X, m,  maxNumCoef, errorGoal, varargin) 
-%=============================================
+%%% Conjugate Gradient Pursuit Multiple vectors sparse representation
+%
+%   Centre for Digital Music, Queen Mary, University of London.
+%   This file copyright 2009 Ivan Damnjanovic.
+%
+%   This program is free software; you can redistribute it and/or
+%   modify it under the terms of the GNU General Public License as
+%   published by the Free Software Foundation; either version 2 of the
+%   License, or (at your option) any later version.  See the file
+%   COPYING included with this distribution for more information.
+%   
 % Sparse coding of a group of signals based on a given 
 % dictionary and specified number of atoms to use. 
 % input arguments: Dict - the dictionary
@@ -13,11 +23,6 @@
 %
 % output arguments: A - sparse coefficient matrix.
 %
-% based on KSVD toolbox solver found on Miki Elad webpage (finding inverse
-% with pinv() is changed with conjugate gradient method)
-% Ivan Damnjanovic 2009
-%=============================================
-%%
 %%
 
 % This Dictionary check is based on Thomas Blumensath work in sparsify 0_4 greedy solvers 
@@ -43,7 +48,7 @@
     error('Dictionary is of unsupported type. Use explicit matrix, function_handle or object. Exiting.');
 end
 %%
-
+positivity=1;
 [n,P]=size(X);
 
 
@@ -67,8 +72,11 @@
         
         j = j+1;
         dir=Dt(residual);
-        
-        [tmp__, pos]=max(abs(dir));
+        if exist('positivity','var')&&(positivity==1)
+            [tmp__, pos]=max(dir);
+        else
+            [tmp__, pos]=max(abs(dir));
+        end
         indx(j)=pos;
         
         p(indx)=dir(indx);