0001 function x=nt_dss_repeat_cluster(x,nkeep,cluster_size)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 nt_greetings;
0013
0014
0015 if nargin<3; cluster_size=[]; end
0016 if nargin<2; nkeep=ceil(cluster_size/2); end
0017
0018 if ndims(x)~=3; error('!'); end
0019
0020 x0=x;
0021
0022 if isempty(cluster_size); cluster_size=round(size(x,1)/2); end
0023
0024 if size(x,2)<=cluster_size
0025 todss=nt_dss1(x);
0026 fromdss=pinv(todss);
0027 nkeep=min(nkeep,size(todss,2));
0028 x=nt_mmat(x,(todss(:,1:nkeep)*fromdss(1:nkeep,:)));
0029 else
0030 NCLUSTERS=2;
0031 [C,A]=vl_kmeans(nt_unfold(x),NCLUSTERS,'algorithm', 'elkan','initialization','plusplus','numrepetitions', 100);
0032 if numel(find(A==1)) && numel(find(A==2))
0033 xA=nt_dss_repeat_cluster(x(:,find(A==1),:),nkeep,cluster_size);
0034 xB=nt_dss_repeat_cluster(x(:,find(A==2),:),nkeep,cluster_size);
0035 x(:,find(A==1),:)=xA;
0036 x(:,find(A==2),:)=xB;
0037 end
0038 end
0039 x1=x;
0040
0041
0042 verbose=0;
0043 if nargout==0 || verbose;
0044 disp(['cluster size: ', num2str(size(x,2)), ', power ratio: ',num2str(nt_wpwr(x1)/nt_wpwr(x0))]);
0045 end
0046
0047