?? perf_test_online.asv
字號:
clear;
rand('seed', 1);
randn('seed', 1);
m = 2000;
CS_iter_Time = 2;
GS_iter_Time = 1;
block = 0;
SNR = 10000;
countNoise = 1;
testTime = 200;
testK = [10, 40, 100];
for kIdx = 1:3
slotNum = [];
miniResidual = [];
k = testK(kIdx);
miniResidual = 0;
avgSlotNum = 0;
for testIdx = 1 : testTime
% generate the matrix and signal
signal = zeros(m,1);
signal(1:k) = 1;
meas = randn(m,m);
Y = meas * signal + rand(m,1)/sqrt(SNR);
% initialization
A(1:60,:)*Y(1:60)
% solve it increamentally
for sampNum = 60:20:m
currErr = norm(Y(1:sampNum)-meas(1:sampNum,:)*x);
if currErr / norm(Y(1:sampNum)) < 1e-2
break;
end
% solve using the current observations
oldA = A(1:sampNum-20,:);
oldy = Y(1:sampNum-20);
newA = A(sampNum_19:sampNum,:);
newy = Y(sampNum_19:sampNum);
[x, J, cJ, lambda] = onlineHomotopy(oldA, oldy, oldx, newA, newy, lambda, J, cJ);
% determine whether reset the initial value
currErr = norm(Y(1:sampNum)-meas(1:sampNum,:)*x);
end
miniResidual = [miniResidual, norm(x-signal)];
slotNum = [slotNum, sampNum];
[kIdx, testIdx, norm(x-signal), sampNum]
end
% record results
filename = sprintf('ol_GSresult_%d_%d_%.3f_%d.txt', GS_iter_Time,CS_iter_Time,SNR, countNoise);
fp = fopen(filename,'a');
fprintf(fp,'%d %d %d ', GS_iter_Time,CS_iter_Time, k);
fprintf(fp,'%f ', miniResidual / testTime);
for t = 1 : length(slotNum)
fprintf(fp,'%d ', slotNum(t));
end
fprintf(fp,'\n');
fclose(fp);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -