0001
0002
0003
0004
0005
0006
0007
0008
0009 clear; clc;
0010
0011
0012
0013
0014
0015
0016
0017 N = 512;
0018
0019 T = 40;
0020
0021 M = 350;
0022
0023
0024 x = zeros(N,1);
0025 q = randperm(N);
0026 x(q(1:T)) = randn(T,1);
0027
0028
0029 A = randn(M,N)/sqrt(M);
0030
0031
0032 sigma = .01;
0033 e = randn(M,1)*sigma;
0034 y = A*x + e;
0035
0036
0037 tau = 0.005*max(abs(A'*y));
0038 if sigma>0
0039 tau = sigma * sqrt(log(N)*2);
0040
0041 end
0042
0043
0044 [xp, gamma_x, xp_iter, t1] = BPDN_homotopy_function(A, y, tau,4*N);
0045
0046
0047 dx_model = 1;
0048
0049
0050 switch dx_model
0051 case 1
0052
0053 dx = zeros(N,1);
0054 dx(q(1:T)) = randn*.1;
0055 T_in = round(T/10);
0056 T_out = round(T/10);
0057 qin = randperm(N);
0058
0059 dx(qin(1:T_in)) = (randn(T_in,1));
0060
0061 qout = randperm(T);
0062 oldx_indices = q(1:T);
0063 dx(oldx_indices(qout(1:T_out))) = -x(oldx_indices(qout(1:T_out)));
0064
0065 case 2;
0066
0067 oldx_indices = q(1:T);
0068 dx = zeros(N,1);
0069 dx(oldx_indices) = randn(T,1)*.2;
0070 otherwise
0071 disp('Nooooo');
0072 end
0073
0074 xt = x+dx;
0075 yt = y+A*dx;
0076
0077
0078 AtAgx = A(:,gamma_x)'*A(:,gamma_x);
0079 iAtAgx = inv(AtAgx);
0080 pk = A'*(A*xp-y);
0081
0082 [xp_h, gamma_xh, xp_h_iter, th] = DynamicX_BPDN_function(A, AtAgx, iAtAgx, y, yt, xp, gamma_x, pk, tau, 4*N);
0083
0084 [xp2, gamma_x2, xp2_iter, t2] = BPDN_homotopy_function(A, yt, tau, 4*N);
0085
0086
0087 Cputime_comparison = [t1 t2 th]
0088 Iteration_comparison = [xp_iter xp2_iter xp_h_iter]
0089
0090