-
Notifications
You must be signed in to change notification settings - Fork 1
/
k_rank_EE.m
132 lines (109 loc) · 3.98 KB
/
k_rank_EE.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
% k_rank_EE function calculates the rank-related information of matrix
% random A
% This function is useful for generating an is ill-conditioned and singular
% mixing matrix
%**************************************************************************
% Input variable:
% 1)A : mixing matrix (m*n)
%**************************************************************************
% Output variable (important ones)
% 1) min_krank: minimum k-rank
% 2) mineig: minimum eigenvalue of m*m-1 submatrices
%**************************************************************************
% Written by Bahador Makkiabadi and customized by Ehsan Eqlimi
% Copyright @ Ehsan Eqlimi and Bahador Makkiabadi
% Department of Medical Physics and Biomedical Enfineering,
% Tehran University of Medical Sciences (TUMS), Tehran, Iran
% Date: May 2016 - Jan 2017
%**************************************************************************
% Reference:
% [1] E. Eqlimi, B. Makkiabadi, N. Samadzadehaghdam, H. Khajehpour,
% F. Mohagheghian, and S. Sanei, “A novel underdetermined source
% recovery algorithm based on k-sparse component analysis,” Circuits,
% Systems, and Signal Processing, vol. 38, no. 3, pp. 1264–1286, 2019.
%Please cite the above papers in case of any usage or benchmarking.
%%
% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
% OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
% AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
% OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
% DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
% DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
% IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
% OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
function [min_krank,mineig,min_sel,minvec,all_eig,all_sel,all_vec,worst_case,krank_old,mineig_old,min_sel_old,minvec_old]=k_rank_EE(A,thr,maxlevel)
n=size(A,2);
m=size(A,1);
if(~exist('maxlevel'))
maxlevel=min(n,m);
end
%min_krank=maxlevel;
min_krank=min(m,n);
worst_case=[];
if(~exist('thr'))
thr=1e-3;
end
mineig=1e20;
minvec=[];
min_sel=[];
krank=1;
st=1;
for i=1:min(n,min(m,maxlevel))%min(n,m):-1:2
if(st)
ii=min(n,min(m,maxlevel));
% out=combntns(1:n,ii);
out=nchoosek(1:n,ii);
j=1;
svx=mnorm(svd(A(:,out(j,:)))) ;
all_eig(:,j,ii)=mineig;
all_vec(:,j,ii)=svx;
all_sel(:,j,ii)=out(j,:);
st=0;
end
%if(m<=n)
% out=combntns(1:n,i);
out=nchoosek(1:n,i);
%end
for j=1:size(out,1)
svx=mnorm(svd(A(:,out(j,:)))) ;
if(svx(end)<mineig)
mineig_old=mineig;
minvec_old=minvec;
min_sel_old=min_sel;
krank_old=krank;
mineig=svx(end);
minvec=svx;
min_sel=out(j,:);
krank=i;
end
all_sel(1:size(out,2),j,i)=out(j,:);
all_vec(1:length(svx),j,i)=svx;
all_eig(:,j,i)=svx(end);
if(svx(end)<=thr),
min_krank=min(i-1,min_krank);
zx=zeros(1,maxlevel);
zx(1:length(out(j,:)))=out(j,:);
worst_case=[worst_case;zx];
if(thr>0)
break;
end
end
end
if(mineig<=thr),
% worst_case=out;
if(thr>0)
break;
end
end
end
%krank,mineig,min_sel,minvec
if 0&(~isempty(worst_case))
mineig=mineig_old;
minvec=minvec_old;
min_sel=min_sel_old;
krank=i-1;%krank_old;
end
if (~isempty(worst_case))
%krank=i-1;
end