Questions tagged [rcpparmadillo]

204 questions
2
votes
0 answers

How to call an R function from an R package in c++, store the result, and use it inside c++ for further processing

I want to load the rpart package in R from inside C++, use the rpart() function in the rpart package to fit a CART model from inside C++, call the result in C++, and store it for further processing. The code that I tried is given below. I am very…
aak201
  • 21
  • 2
2
votes
0 answers

Issues with building a package with Rstan and RcppArmadillo

I have experienced the following problem during the process of building my package. I tried to search for a solution but was unsuccessful. In order to make the error reproducible, I present a minimal package that could generate the same error. I…
JKL
  • 21
  • 1
2
votes
1 answer

Not getting all() quicker using Rcpp

As I'm a bit new to Rcpp, I might be missing a trick here. Let's create two matrices: library(Rcpp) library(microbenchmark) P <- matrix(0, 200,500) for(i in 1:500) P[,i] <- rep(rep(sample(0:1), 2), 25) Parent_Check <- matrix(0, nrow(P),…
Nick
  • 3,262
  • 30
  • 44
2
votes
1 answer

Converting R matrix to arma::mat with List

I want to use arma::mat for my list of matrices. Converting R matrix to arma::mat is working well with const. But when i use List with matrices as an arguments, It takes very long time. #include //…
2
votes
0 answers

matrix not symmetric warning in Armadillo is too strict

The last version of armadillo gives a warning of matrix not symmetric when using inv_sympd. However, the matrix is a cross-product so I am sure it is symmetric. When I print A-arma::trans(A) I get that all the elements are 0 except one that is…
Roberto
  • 41
  • 7
2
votes
1 answer

Subset vector by bool vector in Rcpp

I would like to subset a vector {1,2,3,4} with a bool vector. For instance, if my bool vector was {false,true,true,true}, I would like to get vector {2,3,4}. In regular R, I could do this with sample_states<-c(1:4)[c(a,b,c,d)] where a,b,c,d…
pestopasta
  • 51
  • 6
2
votes
1 answer

Having an issue with compiling RcppArmadillo - library gfortran not found

Running: install.packages("RcppArmadillo") I get the following errors: ld: warning: directory not found for option '-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin15/6.1.0' ld: warning: directory not found for option…
Learner
  • 757
  • 3
  • 15
2
votes
1 answer

Applying a function over columns of matrix using RcppArmadillo works but returns error when applied over rows

I coded a function qSelectMbycol in Rcpp that returns the kth largest element of each column in O(n) time. This function works OK. If I try to do the same but work over rows instead of columns (function qSelectMbyrow) it returns the error "error:…
Tom Wenseleers
  • 7,535
  • 7
  • 63
  • 103
1
vote
1 answer

Can't solve Valgrind memory issues in Rcpp code

I have posted my package on CRAN and recived Valgrind's check results revealing some memory leaks (link). Unfortunately, I can't reproduce these errors. Therefore, I have some hypothesis why these errors occur but can't test them. So I need an…
Bogdan
  • 864
  • 10
  • 18
1
vote
0 answers

Roxygen2 adds `import(RcppArmadillo)` to my `NAMESPACE`

Can I stop it? That requires to add RcppArmadillo to Imports, when otherwise LinkingTo would be enough. Does this already trigger Roxygen to do this? #include "RcppArmadillo.h" // [[Rcpp::depends(RcppArmadillo)]]
inferator
  • 474
  • 3
  • 12
1
vote
1 answer

Translate outer() from base R to RcppArmadillo

Is there any way to efficiently translate the outer() function for multiplication of two vectors from R base to RcppArmadillo? I attempted to do so but it is not efficient at all. Take the following…
1
vote
1 answer

Rcpp function [actually not] much slower inside of package than outside

I recently wrote a compute intense function in Rcpp. Now, I would like to port this code to an R package. However, I notice that the code is much (~100x) slower when run inside an R package. I already read here, that this may have to do with how the…
s1624210
  • 627
  • 4
  • 11
1
vote
1 answer

How to build a package with RcppArmadillo?

I wish to build a package, but I write part of it using RcppArmadillo and now I am suffering the consequences. I am using roxygen2 and devtools to help me with DESCRIPTION and NAMESPACE. I am coding in R / Ubuntu. In the DESCRIPTION I include two…
1
vote
1 answer

Detecting R Version in Rcpp/arrayfire in makevars

I am new to building R packages so I need some help :) I am using Rcpp/arrayfire and want a line in my makevars file to detect the users R version. Currently I have it set in 4.0, but I anticipate users having different R versions. If this question…
owalt
  • 13
  • 2
1
vote
0 answers

Scale the columns of an RcppArmadillo matrix using lambda function

I want to min-max the columns of a matrix using RcppArmadillo and a lambda function, without using a for loop. I have tried this in the code below but this just returns the original matrix. How to replace the original values with the scaled…
NickSc79
  • 11
  • 3
1 2
3
13 14