You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Generated C++ code:
int main(int argc, char** argv)
{
double b ;
mat a ;
a = arma::randu(5, 5) ;
b = double(arma::as_scalar(arma::sum(arma:vectorize(a(span(0, a.n_rows-1)))))) ;
return 0 ;
}
Corrected C++ code:
int main(int argc, char** argv)
{
double b;
mat a;
a = arma::randu(5, 5);
b = double(arma::as_scalar(arma::sum(arma::vectorise(a))));
return 0;
}
There are 3 issues here:
Armadillo uses 'vectorise' instead of 'vectorize' as the function name. I guess it's a typo but ...
the generated code missed one column ':' after arma. It should be arma::vectorise().
a(span(0, a.n_rows-1)) is not right since it's a mat. You can simply use a, doesn't need indexing. Like:
arma::vectorise(a)
Thanks.
The text was updated successfully, but these errors were encountered:
Matlab code:
a = rand(5,5);
b = sum(a(:));
Generated C++ code:
int main(int argc, char** argv)
{
double b ;
mat a ;
a = arma::randu(5, 5) ;
b = double(arma::as_scalar(arma::sum(arma:vectorize(a(span(0, a.n_rows-1)))))) ;
return 0 ;
}
Corrected C++ code:
int main(int argc, char** argv)
{
double b;
mat a;
a = arma::randu(5, 5);
b = double(arma::as_scalar(arma::sum(arma::vectorise(a))));
return 0;
}
There are 3 issues here:
arma::vectorise(a)
Thanks.
The text was updated successfully, but these errors were encountered: