%应一个朋友的约,贴一个ROMP的代码
function [vOut, numIts] = romp(n, Phi, x)
% [vOut] = romp(n, Phi, x)
%%% PARAMETERS %%%%%%%%%%%%%%%%%%%%%%%%%%%
% d = ambient dimension of the signal v
% N = number of measurements
% n = sparsity level of n
% Phi = N by d measurement matrix
% x = measurement vector (Phi * v)
% vOut = reconstructed signal
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% FUNCTION DESCRIPTION %%%%%%%%%%%%%%%%%
% romp takes parameters as described
% above. Given the sparsity level n and
% the N by d measurement matrix Phi, and
% the measurement vector x = Phi * v, romp
% reconstructs the original signal v.
% This reconstruction is the output.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear r I J J0 u b ix numIts Jvals
warning off all
N = size(Phi, 1);
d = size(Phi, 2);
% Set residual
r = x;
%Set index set to "empty"
I = zeros(1,1);
%Counter (to be used optionally)
numIts = 0;
%Run ROMP
while length(I)-1 < 2*n && norm(r) > 10^(-6)
numIts = numIts + 1;
%Find J, the biggest n coordinates of u
u = Phi' * r;
absu = abs(u);
[b, ix] = sort(absu, 'descend');
J = ix(1:n);
Jvals = b(1:n);
%Find J0, the set of comparable coordinates with maximal energy
w=1;
best = -1;
J0 = zeros(1);
while w <= n
first = Jvals(w);
firstw = w;
energy = 0;
while ( w <= n ) && ( Jvals(w) >= 1/2 * first )
energy = energy + Jvals(w)^2;
w = w+1;
end
if energy > best
best = energy;
J0 = J(firstw:w-1);
end
end
%Add J0 to the index set I
I(length(I)+1: length(I)+length(J0)) = J0;
%Update the residual
PhiSubI = Phi(:, I(2));
for c=3:length(I)
if ~isMember(I(2:c-1),I(c))
PhiSubI(:,c-1) = Phi(:, I(c));
end
end
y = lscov(PhiSubI, x);
r = x - PhiSubI * y;
end % end Run IRA
vSmall = PhiSubI \ x;
vOut = zeros(d, 1);
for c=2:length(I)
vOut(I(c)) = vSmall(c-1);
end
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
romp.zip (1个子文件)
romp.m 2KB
共 1 条
- 1
资源评论
依然风yrlf
- 粉丝: 1102
- 资源: 3118
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功