Variables not detected
aronandersson opened this issue · 6 comments
I denna filen är det en massa variabler som inte upptäcks.
%¢Â¢Â¢Â¢Â¢Â¢Â¢Â¢Â¢Â¢Â¢Â¢Â¢Â¢Â¢Â¢Â¢Â¢Â¢Â¢Â¢Â¢Â¢Â¢Â¢Â¢Â¢Â¢Â¢Â¢Â¢Â¢Â¢Â¢Â¢Â¢Â¢Â¢Â¢Â¢Â
function [x_ommp iter_count] = islsp_EstgOMP(y, Phi, K, S, zero_threshold)
% Check the parameters
S = max(K/4, 1);
zero_threshold = 1e-6;
% Initialize the variables
[nRows nCols] = size(Phi);
x_ommp = zeros(size(Phi,2), 1);
residual_prev = y;
supp = [];
iter_count = 0;
while (norm(residual_prev) > zero_threshold && iter_count < K)
iter_count = iter_count+1;
[supp_mag supp_idx] = sort(abs(Phi'*residual_prev), 'descend');
supp_n = union(supp, supp_idx(1:S));
if (length(supp_n) ~= length(supp)) && (length(supp_n) < nRows )
x_hat = Phi(:,supp_n)\y;
residual_prev = y - Phi(:,supp_n)*x_hat;
supp = supp_n;
else
break;
end
end
e.g. residual_prev, supp saknas:
x_ommp(supp) = Phi(:,supp)\y;
end
scope = {}
islsp_EstgOMP = scope["islsp_EstgOMP"] = {}
islsp_EstgOMP["supp_mag"] = ""
islsp_EstgOMP["Phi"] = ""
islsp_EstgOMP["nCols"] = "" # int
islsp_EstgOMP["zero_threshold"] = "" # double
islsp_EstgOMP["x_ommp"] = ""
islsp_EstgOMP["iter_count"] = ""
islsp_EstgOMP["nRows"] = "" # int
islsp_EstgOMP["S"] = ""
islsp_EstgOMP["supp_idx"] = ""
islsp_EstgOMP["y"] = ""
islsp_EstgOMP["K"] = ""
Usikker på hva dette er.
Jeg konverterer koden din med mconvert z.m -rs
:
function [x_ommp iter_count] = islsp_EstgOMP(y, Phi, K, S, zero_threshold)
% Check the parameters
S = max(K/4, 1);
zero_threshold = 1e-6;
% Initialize the variables
[nRows nCols] = size(Phi);
x_ommp = zeros(size(Phi,2), 1);
residual_prev = y;
supp = [];
iter_count = 0;
while (norm(residual_prev) > zero_threshold && iter_count < K)
iter_count = iter_count+1;
[supp_mag supp_idx] = sort(abs(Phi'*residual_prev), 'descend');
supp_n = union(supp, supp_idx(1:S));
if (length(supp_n) ~= length(supp)) && (length(supp_n) < nRows )
x_hat = Phi(:,supp_n)\y;
residual_prev = y - Phi(:,supp_n)*x_hat;
supp = supp_n;
else
break;
end
end
Og får:
# Supplement file
#
# Valid inputs:
#
# uword int float double cx_double
# uvec ivec fvec vec cx_vec
# urowvec irowvec frowvec rowvec cx_rowvec
# umat imat fmat mat cx_mat
# ucube icube fcube cube cx_cube
#
# char struct func_lambda
scope = {}
islsp_EstgOMP = scope["islsp_EstgOMP"] = {}
islsp_EstgOMP["supp_mag"] = ""
islsp_EstgOMP["residual_prev"] = ""
islsp_EstgOMP["x_hat"] = ""
islsp_EstgOMP["nCols"] = "int"
islsp_EstgOMP["supp"] = ""
islsp_EstgOMP["x_ommp"] = "mat"
islsp_EstgOMP["iter_count"] = ""
islsp_EstgOMP["Phi"] = ""
islsp_EstgOMP["nRows"] = "int"
islsp_EstgOMP["zero_threshold"] = "double"
islsp_EstgOMP["S"] = ""
islsp_EstgOMP["supp_idx"] = ""
islsp_EstgOMP["y"] = ""
islsp_EstgOMP["supp_n"] = ""
islsp_EstgOMP["K"] = ""
Jeg ser ikke noen variabler som mangler her.
Ok. Problemet verkar bero på att det sitter tabs mitt i raden. Går det att filtrera bort alla tabs utan att det skapar problem?
Tabs skal håndteres, så hvis det er problemet, skal jeg fikse.
Kan du vedlegge fil som skaper problemet?
On Mon, Jun 8, 2015 at 1:23 PM, aronandersson notifications@github.com
wrote:
Ok. Problemet verkar bero på att det sitter tabs mitt i raden. Går det att
filtrera bort alla tabs utan att det skapar problem?—
Reply to this email directly or view it on GitHub
#63 (comment).
2015-06-08 13:25 GMT+02:00 jonathf notifications@github.com:
Tabs skal håndteres, så hvis det er problemet, skal jeg fikse.
Kan du vedlegge fil som skaper problemet?On Mon, Jun 8, 2015 at 1:23 PM, aronandersson notifications@github.com
wrote:Ok. Problemet verkar bero på att det sitter tabs mitt i raden. Går det
att
filtrera bort alla tabs utan att det skapar problem?—
Reply to this email directly or view it on GitHub
<#63 (comment)
.—
Reply to this email directly or view it on GitHub
#63 (comment).
%◈◈◈◈◈◈◈◈◈◈◈◈◈◈◈◈◈◈◈◈◈◈◈◈◈◈◈◈◈◈◈◈◈◈◈◈◈◈◈◈
% Estimate the sparse signal x using generalized OMP
%
% y : observation
% Phi : sensing matrix
% K : sparsity
% S : selection length
%
% Output parameters
% x_omp : estimated signal
% iter_count: iteration count during estimating
%
% Written by Suhyuk (Seokbeop) Kwon
% Information System Lab., Korea Univ.
% http://isl.korea.ac.kr
%◈◈◈◈◈◈◈◈◈◈◈◈◈◈◈◈◈◈◈◈◈◈◈◈◈◈◈◈◈◈◈◈◈◈◈◈◈◈◈◈
function [x_ommp iter_count] = islsp_EstgOMP(y, Phi, K, S, zero_threshold)
% Check the parameters
if nargin < 3
error('islsp_EstgOMP : Input arguments y ,Phi and K must be specified.');
end
if nargin < 4
S = max(K/4, 1);
end
if nargin < 5
zero_threshold = 1e-6;
end
% Initialize the variables
[nRows nCols] = size(Phi);
x_ommp = zeros(size(Phi,2), 1);
residual_prev = y;
supp = [];
iter_count = 0;
while (norm(residual_prev) > zero_threshold && iter_count < K)
iter_count = iter_count+1;
[supp_mag supp_idx] = sort(abs(Phi'*residual_prev), 'descend');
supp_n = union(supp, supp_idx(1:S));
if (length(supp_n) ~= length(supp)) && (length(supp_n) < nRows )
x_hat = Phi(:,supp_n)\y;
residual_prev = y - Phi(:,supp_n)*x_hat;
supp = supp_n;
else
break;
end
end
x_ommp(supp) = Phi(:,supp)\y;
if nargout < 2
clear('iter_count');
end
end
Här är för övrigt koden konverterad efter att jag tog bort tabbarna för hand, se kommentarer i koden:
void islsp_EstgOMP(cx_vec y, cx_mat Phi, int K, int S, double zero_threshold, mat x_ommp, int iter_count)
{
//Output variables (x_ommp, iter_count) are not passed by reference, and are redeclared
int nRows, nCols, iter_count ;
vec supp_mag ;
cx_vec residual_prev, x_hat ;
mat x_ommp ;
uvec supp, supp_idx, supp_n ;
S = arma::max(K/4, 1) ; //should be std::max
zero_threshold = 1e-6 ;
nRows = Phi.n_rows ;
nCols = Phi.n_cols ;
x_ommp = arma::zeros<mat>(Phi.n_cols, 1) ;
residual_prev = y ;
supp.reset() ;
iter_count = 0 ;
while (norm(residual_prev)>zero_threshold&iter_count<K)
{
iter_count ; //??
iter_count+1 ;
//Use u = arma::sort_index(x); y = x(u); to emulate [y,u] = sort(x).
//String argument for sort direction work the same way in armadillo
[supp_mag, supp_idx] = sort(abs(arma::trans(Phi)*residual_prev), "descend") ;
supp_n = union(supp, supp_idx(span(0, S-1))) ;//use m2cpp::setunion
if (length(supp_n)~=length(supp)) //use m2cpp::length and != operator
{
x_hat = arma::vectorise(y/Phi(span::all, supp_n)) ;//matlab code is x_hat = Phi(:,supp_n)\y, should use arma::solve
residual_prev = arma::vectorise(y-Phi(span::all, supp_n)*x_hat) ;//not sure what the point is of "vectorise"
supp = supp_n ;
}
else
{
break ;
}
}
x_ommp(supp-1) = y/Phi(span::all, supp) ;
if (nargout<2)
{
// clear("iter_count") ;
}
}
Fikset