0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030 function [xp_h, gamma_xh, iter,cpu] = DynamicX_BPDN_function(A, AtAgx, iAtAgx, y, yt, xp, gamma_x, pk, tau, maxiter)
0031 t0 = cputime;
0032 N = length(xp);
0033 xp_h = xp;
0034 gamma_xh = gamma_x;
0035 pk_old = pk;
0036
0037 iter = 0;
0038 done = 0;
0039
0040
0041
0042
0043
0044
0045 warning('off','MATLAB:divideByZero');
0046
0047 e0 = 0;
0048 itheta = [];
0049 d = A'*(y-yt);
0050
0051 while iter < maxiter
0052 iter = iter +1 ;
0053
0054 delx = -iAtAgx*d(gamma_xh);
0055 delx_vec = zeros(N,1);
0056 delx_vec(gamma_xh) = delx;
0057
0058 pk = pk_old;
0059
0060
0061 Ag_delx = A(:,gamma_xh)*delx;
0062 AtAg_delx = A'*Ag_delx;
0063 dk = AtAg_delx+d;
0064
0065
0066 temp_gamma = zeros(N,1);
0067 temp_gamma(gamma_xh) = gamma_xh;
0068 gamma_xc = find([1:N]' ~= temp_gamma);
0069
0070
0071 b_constr1 = (tau-pk(gamma_xc))./dk(gamma_xc);
0072 b_constr2 = (tau+pk(gamma_xc))./-dk(gamma_xc);
0073 b_constr3 = (-xp_h(gamma_xh)./delx_vec(gamma_xh));
0074 itheta_1 = find(b_constr1>2*eps);
0075 itheta_2 = find(b_constr2>2*eps);
0076 itheta_3 = find(b_constr3>2*eps);
0077 theta1 = min(b_constr1(itheta_1));
0078 theta2 = min(b_constr2(itheta_2));
0079 theta3 = min(b_constr3(itheta_3));
0080 if theta1>theta2
0081 theta = theta2;
0082 itheta = gamma_xc(find(b_constr2==theta2));
0083 flag = 1;
0084 else
0085 theta = theta1;
0086 itheta = gamma_xc(find(b_constr1==theta1));
0087 flag = 1;
0088 end
0089 if theta3 < theta
0090 theta = theta3;
0091 itheta = gamma_xh(find(b_constr3==theta3));
0092 flag = 0;
0093 end
0094
0095 epsilon = (theta+e0);
0096 if epsilon < 0
0097 epsilon= inf;
0098 end
0099
0100 if epsilon >=1
0101 theta_end = (1-e0);
0102 xp_h = xp_h + theta_end*delx_vec;
0103 cpu = cputime-t0;
0104 break;
0105 end
0106
0107 gamma_xh_old = gamma_xh;
0108 xp_old = xp_h;
0109 xp_h = xp_h+theta*delx_vec;
0110
0111 if flag == 1
0112 AtgxAnx = A(:,gamma_xh)'*A(:,itheta);
0113 AtAgx_mod = [AtAgx AtgxAnx; AtgxAnx' A(:,itheta)'*A(:,itheta)];
0114
0115 iAtAgx = update_inverse(AtAgx_mod, iAtAgx,1);
0116 AtAgx = AtAgx_mod;
0117
0118 AtAgx_mod = [];
0119 gamma_xh = [gamma_xh; itheta];
0120 xp_h(itheta) = 0;
0121 else
0122 g_old = gamma_xh;
0123 outx_index = find(gamma_xh==itheta);
0124 len_gamma = length(gamma_xh);
0125 gamma_xh(outx_index) = gamma_xh(len_gamma);
0126 gamma_xh = gamma_xh(1:len_gamma-1);
0127
0128 rowi = outx_index;
0129 colj = outx_index;
0130
0131 AtAgx_ij = AtAgx;
0132 temp_row = AtAgx_ij(rowi,:);
0133 AtAgx_ij(rowi,:) = AtAgx_ij(len_gamma,:);
0134 AtAgx_ij(len_gamma,:) = temp_row;
0135 temp_col = AtAgx_ij(:,colj);
0136 AtAgx_ij(:,colj) = AtAgx_ij(:,len_gamma);
0137 AtAgx_ij(:,len_gamma) = temp_col;
0138
0139 iAtAgx_ij = iAtAgx;
0140 temp_row = iAtAgx_ij(colj,:);
0141 iAtAgx_ij(colj,:) = iAtAgx_ij(len_gamma,:);
0142 iAtAgx_ij(len_gamma,:) = temp_row;
0143 temp_col = iAtAgx_ij(:,rowi);
0144 iAtAgx_ij(:,rowi) = iAtAgx_ij(:,len_gamma);
0145 iAtAgx_ij(:,len_gamma) = temp_col;
0146
0147 AtAgx = AtAgx_ij(1:len_gamma-1,1:len_gamma-1);
0148 iAtAgx = update_inverse(AtAgx_ij, iAtAgx_ij,2);
0149
0150 xp_h(itheta) = 0;
0151 end
0152
0153 e0 = (theta+e0);
0154
0155 pk_old = pk+theta*dk;
0156 pk_old([gamma_xh; itheta]) = sign(pk_old([gamma_xh; itheta]))*tau;
0157
0158 end
0159 cpu = cputime-t0;
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192
0193
0194
0195
0196
0197
0198
0199