rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
count_column_frequency.m
1 function [unique_vectors, count] = count_column_frequency(vectors)
2 %function [unique_vectors, count] = count_columns_frequency(vectors)
3 %
4 % function removing duplicates from the matrix "vectors" (which
5 % contains columnwise vectors) and determining the frequency of the
6 % vectors. i.e. unique_vectors(:,i) appeared count(i) times in the
7 % original list.
8 %
9 % The implementation is "expensive" by a double loop. Could be optimized.
10 
11 % Bernard Haasdonk 26.7.2006
12 
13 % expensive: double loop!!
14 
15 nvec = size(vectors,2);
16 
17 unique_vectors = [];
18 count = [];
19 
20 treated = zeros(1,nvec);
21 for i = 1:nvec;
22  if ~treated(i)
23  unique_vectors = [unique_vectors, vectors(:,i)];
24  % l-infty difference of all other vectors to current one
25 % keyboard;
26  ii = repmat(vectors(:,i),1,nvec-i+1);
27  di = max(abs(vectors(:,i:end)-ii));
28  j = find(di==0);
29  treated(j+i-1) = 1;
30  count = [count, length(j)];
31  end;
32 end;
33 
34 % TO BE ADJUSTED TO NEW SYNTAX
35 %| \docupdate