Category : rcpp

I am trying to optimize the performance of my code by utilizing both RcppArmadillo and OpenMP, however, my R session crashes when I run the code with ncores > 1. // [[Rcpp::depends(RcppArmadillo)]] // [[Rcpp::plugins(openmp)]] #include <RcppArmadillo.h> #include <iostream> #include<algorithm> #include <R.h> #include <Rinternals.h> using namespace std; using namespace Rcpp; // [[Rcpp::export]] List A_hj_Comp(const arma::mat& X, ..

Read more

In R, after I run a C++ code (through Rcpp package) to create a big text flie in my HD, my computer has a high memory usage, as shown in the results below (I get this memory allocation values exactly when the Rcpp code has finished): > memuse::Sys.meminfo() Totalram: 15.878 GiB Freeram: 1.547 GiB > ..

Read more

The computation time for the following function is very high. Is there any room for improvement? Should I be accessing the elements of matrix X differently? I appreciate any comments or suggestions. #include <RcppArmadillo.h> using namespace Rcpp; using namespace arma; // [[Rcpp::depends(RcppArmadillo)]] // [[Rcpp::export]] arma::mat myfunc(const int& n, const int& p, arma::mat& X, arma::rowvec& y, ..

Read more