rcpp

efficient distance calculations in armadillo

偶尔善良 提交于 2021-02-08 06:36:37
问题 I'm new to armadillo. I have the below code, which I assume is inefficient. Any suggestions to make it more memory efficient and/or speedy? Following the armadillo docs and Rcpp gallery, I was unable to get .colptr 's, uvec 's, or batch insertion to work. But I assume any of them would be improvements. With an input of X (~100 x 30000), even my stupidly large work VM crashes. Linux release 7.3.1611 (Core) 117GB RAM / 0GB SWAP (24 x 2.494 GHz) processor(s) R version 3.3.2 (2016-10-31) Platform

Memory-efficient method to create dist object from distance matrix

人走茶凉 提交于 2021-02-08 03:27:08
问题 I'm trying to create dist objects from large distance matrices. I'm running out of memory using stats::as.dist . For example, I have around 128 Gb available on current machine but as.dist runs out of memory when processing a 73,000 x 73,000 matrix (approx 42Gb). Given that the final dist object should be less than half the size of the matrix (i.e. it is the lower triangle, stored as a vector) it seems to me that it should be possible to do this calculation in a more memory-efficient way -

Memory-efficient method to create dist object from distance matrix

空扰寡人 提交于 2021-02-08 03:26:26
问题 I'm trying to create dist objects from large distance matrices. I'm running out of memory using stats::as.dist . For example, I have around 128 Gb available on current machine but as.dist runs out of memory when processing a 73,000 x 73,000 matrix (approx 42Gb). Given that the final dist object should be less than half the size of the matrix (i.e. it is the lower triangle, stored as a vector) it seems to me that it should be possible to do this calculation in a more memory-efficient way -

CRAN-acceptable way of linking to OpenMP some C code called from Rcpp

拥有回忆 提交于 2021-02-07 14:43:37
问题 I’m building an R package that has some .c files with code that uses OpenMP, and these C functions are called from .cpp files, but the .cpp files themselves don’t make any use of OpenMP. e.g. cfile.c : int parallel_function(double *x, int n) { int i; #pragma omp parallel for firstprivate(x, n) for (i = 0; i < n; i++){ x[i] *= 2; } } cppfile.cpp : #include <Rcpp.h> using namespace Rcpp; extern “C” { int parallel_function(double *x, int n); } // [[Rcpp::export]] void multiply_by_two

CRAN-acceptable way of linking to OpenMP some C code called from Rcpp

﹥>﹥吖頭↗ 提交于 2021-02-07 14:43:15
问题 I’m building an R package that has some .c files with code that uses OpenMP, and these C functions are called from .cpp files, but the .cpp files themselves don’t make any use of OpenMP. e.g. cfile.c : int parallel_function(double *x, int n) { int i; #pragma omp parallel for firstprivate(x, n) for (i = 0; i < n; i++){ x[i] *= 2; } } cppfile.cpp : #include <Rcpp.h> using namespace Rcpp; extern “C” { int parallel_function(double *x, int n); } // [[Rcpp::export]] void multiply_by_two

CRAN-acceptable way of linking to OpenMP some C code called from Rcpp

拜拜、爱过 提交于 2021-02-07 14:42:12
问题 I’m building an R package that has some .c files with code that uses OpenMP, and these C functions are called from .cpp files, but the .cpp files themselves don’t make any use of OpenMP. e.g. cfile.c : int parallel_function(double *x, int n) { int i; #pragma omp parallel for firstprivate(x, n) for (i = 0; i < n; i++){ x[i] *= 2; } } cppfile.cpp : #include <Rcpp.h> using namespace Rcpp; extern “C” { int parallel_function(double *x, int n); } // [[Rcpp::export]] void multiply_by_two

Using C++ libraries in an R package

我的未来我决定 提交于 2021-02-05 20:27:55
问题 What is the best way to make use of a C++ library in R, hopefully preserving the C++ data structures. I'm not at all a C++ user, so I'm not clear on the relative merits of the available approaches. The R-ext manual seems to suggest wrapping every C++ function in C. However, at least four or five other means of incorporating C++ exist. Two ways are packages w/ similar lineage, the Rcpp (maintained by the prolific overflower Dirk Eddelbuettel) and RcppTemplate packages (both on CRAN), what are

Using C++ libraries in an R package

£可爱£侵袭症+ 提交于 2021-02-05 20:26:58
问题 What is the best way to make use of a C++ library in R, hopefully preserving the C++ data structures. I'm not at all a C++ user, so I'm not clear on the relative merits of the available approaches. The R-ext manual seems to suggest wrapping every C++ function in C. However, at least four or five other means of incorporating C++ exist. Two ways are packages w/ similar lineage, the Rcpp (maintained by the prolific overflower Dirk Eddelbuettel) and RcppTemplate packages (both on CRAN), what are

Using C++ libraries in an R package

泪湿孤枕 提交于 2021-02-05 20:26:38
问题 What is the best way to make use of a C++ library in R, hopefully preserving the C++ data structures. I'm not at all a C++ user, so I'm not clear on the relative merits of the available approaches. The R-ext manual seems to suggest wrapping every C++ function in C. However, at least four or five other means of incorporating C++ exist. Two ways are packages w/ similar lineage, the Rcpp (maintained by the prolific overflower Dirk Eddelbuettel) and RcppTemplate packages (both on CRAN), what are

Get error when use Rcpp remove rows of matrix

。_饼干妹妹 提交于 2021-02-05 09:37:40
问题 #include <RcppArmadillo.h> // [[Rcpp::depends(RcppArmadillo)]] using namespace Rcpp; // [[Rcpp::export]] arma::mat fed(arma::mat x){ arma::mat zz=x.shed_rows(0,2); return(zz); } Just want remove some rows from matrix, get error as follows. conversion from 'void' to non-scalar type 'arma::Mat} requested' 回答1: Two points: Please don't post error messages as image. Use Text instead. As the error indicates, the shed_rows() method does not return anything. Instead it alters the matrix it acts on,