Questions tagged [rcppeigen]

28 questions
6
votes
2 answers

Matrix multiplication of an Eigen Matrix for a subset of columns

What is the fastest method for matrix multiplication of an Eigen::Matrix over a random set of column indices? Eigen::MatrixXd mat = Eigen::MatrixXd::Random(100, 1000); // vector of random indices (linspaced here for brevity) Eigen::VectorXi idx =…
zdebruine
  • 3,687
  • 6
  • 31
  • 50
4
votes
1 answer

Most efficient way to return Eigen::VectorXi with more than 2^31-1 elements to R

I have a vector x of type Eigen::VectorXi with more than 2^31-1 entries, which I would like to return to R. I can do that by copying x entry-wisely to a new vector of type Rcpp::IntegerVector, but that seems to be quite slow. I am…
3
votes
0 answers

exposing c++ class (derived from abstract) in R with Rcpp modules

I have a c++ class svol_leverage that inherits from an abstract base class BasePF (actually that's a type alias for something messy coming from a specialized class template). Using the Rcpp modules vignette and this answer, I was able to use…
Taylor
  • 1,797
  • 4
  • 26
  • 51
3
votes
1 answer

How to multiply two matrices that are sparse Matrix::csr/csc format?

The following code works as expected: matrix.cpp // [[Rcpp::depends(RcppEigen)]] #include // [[Rcpp::export]] SEXP eigenMatTrans(Eigen::MatrixXd A){ Eigen::MatrixXd C = A.transpose(); return Rcpp::wrap(C); } //…
mshaffer
  • 959
  • 1
  • 9
  • 19
2
votes
1 answer

how to create a Rcpp NumericVector from Eigen::Tensor without copying underlying data

If I create a large Tensor in Eigen, and I like to return the Tensor back to R as multi-dimension array. I know how to do it with data copy like below. Question: is it possible to do it without the data-copy step? #include #include…
David Chen
  • 41
  • 3
1
vote
1 answer

2000 lines of warnings from Eigen

I am using g++ 8.5.0 and Eigen library v-3.3.9. When building an application that utilizes Eigen, the compiler generates about 2000 lines of warnings . Below only shows a tiny fraction of them. g++ -std=gnu++17 -I"/usr/include/R" -DNDEBUG …
user2961927
  • 1,290
  • 1
  • 14
  • 22
1
vote
0 answers

how to use conditional inclusion statements in headers used in RcppEigen project

I have an RcppEigen package that has a bunch of .h header files in it that I copy/pasted from my other library. These header files exist in two places, and right now there is only one difference between copies. In the pure c++ library, I include…
Taylor
  • 1,797
  • 4
  • 26
  • 51
1
vote
1 answer

Why is my RcppEigen code almost 40 times slower than R's base LAPACK implementation?

I'm trying to implement efficient matrix LLT (or LU, whatever) decomposition for some covariance matrix shenanigans. I've been using the Eigen library (through RcppEigen) for a while and, just for fun, I wanted to see how much better it fared…
1
vote
0 answers

Faster Recode and Matrix Multiplication using Rcpp/RcppEigen

I have two large matrices where some values must be recoded and after that, these two matrices must be multiplied, as shown in the following example. Using Rcpp is faster only if multiples Threads are used. Load R Functions and Create Fake…
1
vote
1 answer

Trouble getting DADA2. Can't install package "RcppEigen"

I use CentOS 7, I have 3.6.0 version of R and I've installed "devtools" so that I can then install DADA 2 through it. However, when I put a command: devtools::install_github("benjjneb/dada2", ref="v1.16") I get an error: * installing *source*…
IceMajor
  • 37
  • 5
1
vote
1 answer

Rcpp installed but compilation error from complex code snippet

I have Rcpp and RccpEigen already installed in RStudio. I am able to run an Rcpp code (that didn't use RccpEigen) successfully as well. However the following code which uses both doesn't seem to work. Here is the code…
user1993
  • 498
  • 1
  • 10
  • 22
1
vote
1 answer

RcppEigen #define works when using sourceCpp() but ignored with R CMD build

I've noticed that sourceCpp() respects C++ #define while devtools::document() and R CMD build seems to disregard them, at least in the case of Eigen matrix initialization. Consider this .cpp file: #define…
zdebruine
  • 3,687
  • 6
  • 31
  • 50
1
vote
1 answer

RcppEigen column labels

How can one extract column labels from an Rcpp::Eigen matrix? For example, here is some R matrix mat <- matrix(1:4,ncol=2) colnames(mat) <- c("col1","col2") With Rcpp::NumericMatrix, one can simply call colnames like so: void fun_NM(const…
0
votes
0 answers

what's wrong with my plugin for inline::cxxfunction()?

I can run some example code from inline::cxxfunction()'s documentation: inline::cxxfunction(signature(x = "integer", y = "numeric"), "return wrap( as(x) * as(y));", plugin = "Rcpp" ) and that works, but the…
Taylor
  • 1,797
  • 4
  • 26
  • 51
0
votes
1 answer

Rcpp Eigen inplace matrix multiplication error

I'm new to Rcpp and Eigen and I'm trying to run a inplace matrix multiplication while I run into this error. R didn't tell me what the error is about. SEXP cpp_hom_crit( const Eigen::Map Q, Eigen::Map d,…
wut
  • 81
  • 5
1
2