Questions tagged [rcpparmadillo]

204 questions
0
votes
0 answers

converting const mat to NumericVector in Rcpp

I'm trying to improve the performance of a row-wise custom distance measure over a large matrix using the parallelDist R package and RcppArmadillo. The example they provide works with…
0
votes
1 answer

How to install RcppArmadillo in AWS EMR version 5.29

I am trying to install RcppArmadillo using sparkR shell in AWS EMR version 5.29. Here is my sessionInfo() - R version 3.4.1 (2017-06-30) Platform: x86_64-redhat-linux-gnu (64-bit) Running under: Amazon Linux AMI 2018.03 Matrix products:…
Regressor
  • 1,843
  • 4
  • 27
  • 67
0
votes
1 answer

Why do the two functions give different results?

I defined two functions using RcppArmadillo package and save them into the file cxxFuns.cpp. The only difference between f01 and f02 is the positions of V(0, 0): #include using namespace Rcpp; // [[Rcpp::export]] arma::mat f01…
zengc
  • 97
  • 9
0
votes
1 answer

Faster way to generate multiple adjacency matrix

Suppose I have a arbitrary probability matrix P like below, P = matrix(c(0.3,0.2,0.2,0.2,0.3,0.2,0.2,0.2,0.3),3,3) P [,1] [,2] [,3] [1,] 0.3 0.2 0.2 [2,] 0.2 0.3 0.2 [3,] 0.2 0.2 0.3 For single adjacency matrix, it is generated like…
Nicolas H
  • 535
  • 3
  • 13
0
votes
1 answer

Handling extremely large and sparse matrices in RcppArmadillo

I'm trying to pass a diagonal matrix W to an Rcpp function. The problem is that W has size 1,000,000 by 1,000,000, which is (I think) well outside the limits Armadillo allows (even when using a C++11 compiler with ARMA_64BIT_WORD enabled). Since W…
ralph
  • 223
  • 1
  • 4
0
votes
0 answers

Armadillo slower than RcppArmadillo

I'm trying to understand why calling arma::pinv of Armadillo takes significantly more time when called in c++ directly (Visual Studio) compared to the same function being called in R via RcppArmadillo. In R I just followed a super basic approach…
horos
  • 1
0
votes
2 answers

About the use of .shed_row/.shed_col in RcppArmadillo

I am now trying to convert R code to Rcpp code. The R code is hh <- function(A,B,j){ aa <- A[j,-j] %*% B[j,-j] ## A and B are n*m matrixes return(aa) } > set.seed(123) > A <- matrix(runif(30),5,6) > B <- matrix(rnorm(30),5,6) > j <- 2 >…
cheng
  • 85
  • 1
  • 11
0
votes
0 answers

Rcpp (function with default null parameter): Not compatible with requested type: [type=NULL; target=double]

My Rcpp code is shown here, I have used sourceCpp to compile the cpp file. No error is reported, just some warnings there. When I tried to implement the function softImpute using softImpute(m1, NULL, mr1, mr2, 0, -1), the reported error is Not…
cheng
  • 85
  • 1
  • 11
0
votes
1 answer

Error "*** was not declared in this scope"

In this post, I defined a function called soft. When I used sourceCpp to compile it, reported errors are ZH was not declared in this scope alpha0H was not declared in this scope maxRankH was not declared in this scope I have tried many approaches…
cheng
  • 85
  • 1
  • 11
0
votes
1 answer

RcppArmadillo: conflicting declaration of C function 'SEXPREC* sourceCpp_1_hh(SEXP, SEXP, SEXP)'

My code is the following #include #include using namespace std; using namespace Rcpp; using namespace arma; //RNGScope scope; // [[Rcpp::depends(RcppArmadillo)]] // [[Rcpp::export]] arma::mat hh(arma::mat Z, int n,…
cheng
  • 85
  • 1
  • 11
0
votes
1 answer

How can I multiply an Armadillo matrix with a NumericVector obtained from qnorm()?

When I try to multiply an arma::mat and a NumericVector in Rcpp using operator*, I get the following error: no match for operator* Here is an example of what I'm trying to multiply: NumericVector exampleNumericVector(L-1); arma::mat…
Ron Snow
  • 239
  • 1
  • 7
0
votes
1 answer

RcppArmadillo function cpu times do not seem to scale linearly by increasing the data dimension and data size

I have written a function in both R and Rcpp, which basically just takes in a data-set x, a scale parameter gamma and a vector parameter beta, and hence returns the fitted probabilities. Below is the my code in…
0
votes
0 answers

What are _Rf_cons and _Rf_allocVector3?

I'm working on an R package that uses Rcpp and RcppArmadillo, and I'm trying to profile one of the main functions in the package to improve its runtime. I'm using gperftools as recommended by Dirk and specifically as described in this blog post. The…
Matt Stone
  • 185
  • 1
  • 1
  • 8
0
votes
0 answers

Error in .Call(tXPMCpp, x) : first argument must be a string (of length 1) or native symbol reference

I've following R Code tXPM <- function(x) { .Call(tXPMCpp, x) } and following RCPP code SEXP tXPMCpp (SEXP xSEXP){ arma::mat GeneExp = Rcpp::as(xSEXP); arma::rowvec ColumnSums = sum(GeneExp, 0); int_fast32_t i=0, n=0; arma::mat::iterator…
0
votes
1 answer

Non-contiguous subsetting of matrix with RcppArmadillo

Hello and sorry for the probably stupid question. I studied a bit of C++ in my past but in the last years I've only used R. I need to transform some R code for a package I wrote using Rcpp and in particular, I'm using RcppArmadillo. Now I checked…
Andrew
  • 11