annotate util/classes/@dictionary/spark.m @ 160:e3035d45d014 danieleb

Added support classes
author Daniele Barchiesi <daniele.barchiesi@eecs.qmul.ac.uk>
date Wed, 31 Aug 2011 10:53:10 +0100
parents
children
rev   line source
daniele@160 1 function varargout = Spark(obj)
daniele@160 2 % Calculates the minimum number of linearly dependent atoms in the matrix A
daniele@160 3 % WARNING: this function computes a combinatorial function, use only if the
daniele@160 4 % size of the problem is small (i.e. <20)
daniele@160 5 if nargout <= 1
daniele@160 6 A = obj.phi;
daniele@160 7 k = size(A,2);
daniele@160 8 if k>20
daniele@160 9 warning('This function computes a combinatorial function, use only if thesize of the problem is small (i.e. <20).');
daniele@160 10 choice = input('The calculation of spark will take a long time... do you wish to continue anyway (y/n)','s');
daniele@160 11 if strcmpi( choice,'n')
daniele@160 12 return
daniele@160 13 end
daniele@160 14 end
daniele@160 15 sigma = 2;
daniele@160 16 while true
daniele@160 17 P = nchoosek(1:k,sigma);
daniele@160 18 for i=1:size(P,1)
daniele@160 19 r = rank(A(:,P(i,:)));
daniele@160 20 if r<sigma
daniele@160 21 varargout{1} = sigma;
daniele@160 22 return
daniele@160 23 end
daniele@160 24 end
daniele@160 25 sigma = sigma + 1;
daniele@160 26 if sigma==k
daniele@160 27 varargout{1} = inf;
daniele@160 28 return
daniele@160 29 end
daniele@160 30 end
daniele@160 31 else
daniele@160 32 %% TODO: calculate lower and upper bounds on the spark
daniele@160 33 varargout{1} = 2;
daniele@160 34 varargout{2} = inf;
daniele@160 35 end