comparison 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
comparison
equal deleted inserted replaced
159:23763c5fbda5 160:e3035d45d014
1 function varargout = Spark(obj)
2 % Calculates the minimum number of linearly dependent atoms in the matrix A
3 % WARNING: this function computes a combinatorial function, use only if the
4 % size of the problem is small (i.e. <20)
5 if nargout <= 1
6 A = obj.phi;
7 k = size(A,2);
8 if k>20
9 warning('This function computes a combinatorial function, use only if thesize of the problem is small (i.e. <20).');
10 choice = input('The calculation of spark will take a long time... do you wish to continue anyway (y/n)','s');
11 if strcmpi( choice,'n')
12 return
13 end
14 end
15 sigma = 2;
16 while true
17 P = nchoosek(1:k,sigma);
18 for i=1:size(P,1)
19 r = rank(A(:,P(i,:)));
20 if r<sigma
21 varargout{1} = sigma;
22 return
23 end
24 end
25 sigma = sigma + 1;
26 if sigma==k
27 varargout{1} = inf;
28 return
29 end
30 end
31 else
32 %% TODO: calculate lower and upper bounds on the spark
33 varargout{1} = 2;
34 varargout{2} = inf;
35 end