Questions tagged [rcpparmadillo]

204 questions
1
vote
1 answer

Fail to call ones or eye function when using RcppArmadillo

I want to use one or eye function in Armadillo to construct matrices or vectors. However, it does not allow me to do so. Here is a sample code: #include // [[Rcpp::depends(RcppArmadillo)]] using namespace Rcpp; //…
tobinz
  • 117
  • 1
  • 9
1
vote
1 answer

Use RcppArmadillo to calculate the tail sum of the vector

I wrote an R code to calculate the tail sum of a vector: tailsum <- function(x){ sum(x) + x - cumsum(x) } I hope to improve the efficiency of this function through RcppArmadillo, so I wrote #include //…
Chen Huang
  • 11
  • 1
1
vote
1 answer

(Rcpp)armadillos abs() function outputs false values when used with c++ double while std::abs works

Consider this R function: r_abs <- function(x,y,z){ 2 * abs((x >= y) - z) } And those 2 RcppArmadillo equivalents: // [[Rcpp::depends(RcppArmadillo)]] // [[Rcpp::depends(RcppProgress)]] #include #include #include…
BerriJ
  • 913
  • 7
  • 18
1
vote
1 answer

why are nan being produced when assigning values in a cube?

I'm having this weird issue with Armadillo and RcppArmadillo. I'm creating a cube filled with zeroes values, and I want specific elements to be turned into ones. However, when I used an assigment to do that, values of other elements changle slightly…
JMenezes
  • 1,004
  • 1
  • 6
  • 13
1
vote
1 answer

Template classes arma::Col in Rcpp Armadilllo

Dear fellow programmers, in order to write a bootstrapped regression version for a seminar at university I tried to implement my R-version into Rcpp (this is for comparison of R to C++/Rcpp). However, I'm stuck with the error messages I receive,…
Erin Sprünken
  • 400
  • 2
  • 13
1
vote
0 answers

How can I calculate the time interval in rcpp?

I want to record my computing time for a for loop function. I write the function by rcpp, and use std::clock to measure the time interval. The rcpp code is as follow: // [[Rcpp::depends(RcppArmadillo)]] #include…
Xia.Song
  • 416
  • 3
  • 15
1
vote
1 answer

Cannot install RcppArmadillo with R 4.0.3 and RedHat Linux 6.10

I have just installed R 4.0.3 on my local directory, on a computing cluster. I'm using gcc 5.1.0 and I have set Sys.setenv("PKG_CXXFLAGS"="-std=c++11") Rcpp installed fine. But with RcppArmadillo, I get hundreds of lines of error messages like…
Drumy
  • 450
  • 2
  • 16
1
vote
0 answers

R package compilation problem due to LAPACK on Ubuntu 20.04 after upgrade from 18.04

I have upgraded Ubuntu from 18.04 to 20.04 and now some of my R packages fail to compile/load. One example is shown below: ** testing if installed package can be loaded from temporary location Error: package or namespace load failed for 'myPackage'…
Samo
  • 2,065
  • 20
  • 41
1
vote
1 answer

Is there a way to mute warning in RcppArmadillo `arma::solve`?

When X is singular, the following code throws a warning. Is there a way of muting it? "warning: solve(): system seems singular; attempting approx solution" Function: // [[Rcpp::depends(RcppArmadillo)]] #include using namespace…
JacobJacox
  • 917
  • 5
  • 14
1
vote
0 answers

Error compiling C++ code in R 4.0 on Mac OS X Catalina

I'm trying to compile C++ code in R so I can install packages from source. I’m running R 4.0.2 on Mac OS X Catalina (10.15.6). I've followed instructions here for installing R Compiler Tools for Rcpp on Mac OS. However, when following the…
itpetersen
  • 1,475
  • 3
  • 13
  • 32
1
vote
1 answer

Errors when using OptimLib in Rcpp

I encountered an error when using OptimLib library in Rcpp.First I copied sphere_fn function online in order to use it later in optim function. However, this shere_fn didn't work. Error: can not initialize a member subobject of type…
Mohan Zhao
  • 45
  • 6
1
vote
0 answers

How to use both OpenMP and OpenBlas in RcppArmadillo?

I need to compute singular value decomposition (SVD) of an array of matrices stored in a RcppArmadillo cube. I would like to do the SVDs in parallel for each matrix and want to enable multi-threading in calculating the SVDs via OpenBLAS. For that I…
1
vote
2 answers

fatal error: 'RcppArmadillo.h' file not found

Rcpp::sourceCpp('~/Desktop/my.cpp') Was working on some stand alone Rcpparmadillo files and came across this error: fatal error: 'RcppArmadillo.h' file not found #include ^~~~~~~~~~~~~~~~~ The example "my.cpp": //…
skatz
  • 115
  • 7
1
vote
1 answer

Rcpp function with List arguments returning a matrix

I have a section of code in r that is running quite slowly, and so I'm hoping to rewrite the function in rcpp, however, this is my first attempt using Rcpp, and I cannot get the code to compile or run. In R, the section I am trying to rewrite is …
mes
  • 43
  • 7
1
vote
1 answer

Error when installing bife package on Mac: RcppArmadillo

I am trying to install the package 'bife' using Rstudio but get the following error message: install.packages("bife") also installing the dependency ‘RcppArmadillo’ trying URL…
Rnovice
  • 333
  • 1
  • 5
  • 18