https://doi.org/10.5201/ipol.2017.178
Tip revision: ce7312fc5141c3085e2c9a49d0904825df754c37 authored by Software Heritage on 25 May 2016, 00:00:00 UTC
ipol: Deposit 1296 in collection ipol
ipol: Deposit 1296 in collection ipol
Tip revision: ce7312f
save2file_calib.m
%% save2file_calib
% Generates input<blk_code>.txt file necessary to call ./prSAMP_Calibration in Unix or
% prSAMP_Calib.exe in Windows.
%%
function prblmid = save2file_calib(X, Y, snr, blk_code)
prblmid = round(rand*1000);
[n, p] = size(X);
m = size(Y, 1);
X = X';
Y = Y';
if(snr>50)
sigma = 1e-3;
elseif(snr>10)
sigma = 1e-2;
else
sigma = 1e-1;
end
opt.delta = sigma; % noise variation parameter
opt.priorPrms = [1, 0, 1/sqrt(n)]; % gaussian prior parameters
% 1. sparsity, 0<rho<=1 (maximum number of nonzero entries in the
% resulting vector)
% 2. mean, mu
% 3. variance, v
opt.maxIter = n/2; % maximum number of main AMP loop iteration
opt.prec = 1e-5; % convergence criterion. minimum difference between two consequent x
opt.display = 0; %display the temporary convergance results or not
opt.damp = 0.9; % how fast the algorithm converges to a local minima 0<=damp<1
opt.vnf = 0.5; % variance normalization factor
nnz = sum(sum(X));
jc = sum(X);
for i=2:length(jc)
jc(i) = jc(i)+jc(i-1);
end
jc(2:end+1) = jc;
jc(1) = 0;
ir = zeros(nnz, 1);
cnt = 1;
for j=1:size(X,2)
for i=1:size(X,1)
if(X(i,j))
ir(cnt) = i-1;
cnt = cnt + 1;
end
end
end
fileID = fopen(['input' num2str(prblmid) num2str(blk_code) '.txt'],'w');
fprintf(fileID,'%.0f\n',m);
fprintf(fileID,'%.0f\n',n);
fprintf(fileID,'%.0f\n',p);
fprintf(fileID,'%.0f\n',nnz);
fprintf(fileID,'%f\n',opt.delta);
fprintf(fileID,'%f\n',opt.priorPrms);
fprintf(fileID,'%.0f\n',opt.maxIter);
fprintf(fileID,'%f\n',opt.prec);
fprintf(fileID,'%.0f\n',opt.display);
fprintf(fileID,'%.2f\n',opt.damp);
fprintf(fileID,'%.2f\n',opt.vnf);
fprintf(fileID,'%.0f\n',jc);
fprintf(fileID,'%.0f\n',ir);
fprintf(fileID,'%.16f\n',Y);
fclose(fileID);