Questions tagged [rcpparmadillo]
204 questions
3
votes
1 answer
Armadillo's print() method and cout are inconsistent in order when called from Rcpp
Lately, I've been using RcppArmadillo, but I've noticed some inconsistencies in the print order of certain objects. Particularly, when using cout and print(). Sometimes, print() will be printed first, then cout; and other times it's the other way…

Mario Becerra
- 514
- 1
- 6
- 16
3
votes
1 answer
Unable to build the RcppArmadillo.package.skeleton test package: Multiple definition of `R_init_'
I was trying to build the RcppArmadillo.package.skeleton test package. As usual, I do in R:
> library("Rcpp")
> library("RcppArmadillo")
> RcppArmadillo.package.skeleton("test")
> compileAttributes()
> library(tools)
>…

0range
- 2,088
- 1
- 24
- 32
2
votes
1 answer
Catching LAPACK errors in Armadillo
I'm attempting to calculate the SVD of a matrix using RcppArmadillo.svd() is supposed to return 0 if the SVD failed. However, I have encountered a matrix for which I get the error code BLAS/LAPACK routine 'DLASCL' gave error code -4.
I think the bug…

Wilbur
- 457
- 1
- 5
- 14
2
votes
0 answers
Ideas for fast rank-two update of symmetric positive definite matrix
I have the following task: Let Sigma be a dxd covariance matrix, let B be a dx2 matrix of arbitrary columns of Sigma and let H be a symmetric 2x2 matrix.
I need to make the following update of Sigma
Sigma <- Sigma - B %*% H %*% t(B)
I have…

Søren Højsgaard
- 73
- 3
2
votes
1 answer
Negative subscripts in matrix indexing
In Rcpp/RcppArmadillo I want to do the following: From an n x n matrix A, I would like to extract a submatrix A[-j, -j] where j is a vector of indices: In R it can go like
A = matrix(1:16, 4, 4)
j = c(2, 3)
A[-j, -j]
Seems that this functionality…

Søren Højsgaard
- 73
- 3
2
votes
1 answer
Faster anova of regression models
I have the following toy data -
data<-data.frame(y=rnorm(1000),x1=rnorm(1000), x2=rnorm(1000), x3=rnorm(1000), x4=rnorm(1000))
On this data, I am creating two models as below -
fit1 = lm(y ~ x1 + x3, data)
fit2 = lm(y ~ x2 + x3 + x4,…

Saurabh
- 1,566
- 10
- 23
2
votes
0 answers
Error with RcppArmadillo: requested size is too large; suggest to enable ARMA_64BIT_WORD
I am trying to run a function that uses BiocParallel and RcppArmadillo. The function runs to 50% completion but then throws the error:
Error: BiocParallel errors
element index: 1
first error: Mat::init(): requested size is too large; suggest to…

OLC
- 21
- 1
2
votes
1 answer
Rcpp only returning the first part of return line
I'm attempting to code the the log-likelihood for e.g. linear mixed models seen in page 965 here.
I would implement this in R, quite trivially, as
R.imp <- function(Y, X, Z, V, b, beta, mi){
-mi/2 * log(2*pi) - 1/2 * log(det(V)) - 1/2 * crossprod(Y…

jmurray
- 23
- 4
2
votes
0 answers
How can I build an R package using RcppArmadillo and SuperLU?
I have a project in R which uses C++ functions to speed up computations. In my src-folder I have a C++ file which calls functions I have defined in different header files and C++ files in the same folder. To provide a minimum working example I have…

daniel
- 88
- 1
- 6
2
votes
2 answers
How to install RcppArmadillo on Apple Silicon (M1) Macs
I've been trying many different ways to install RcppArmadillo, but I don't get it to work
install.packages(c('Rcpp'))
Sys.setenv("PKG_CXXFLAGS"="-std=c++11")
install.packages(c('RcppArmadillo'),type = "source")
It gives me this error:
ld: warning:…

M. Beausoleil
- 3,141
- 6
- 29
- 61
2
votes
1 answer
How do I force installation of R package from custom repo?
There's a dependency of dependency which fails to compile when pulled from CRAN at the moment, so the maintainer provided an alternative Cannot compile RcppArmadillo.
I've tried to install RcppArmadillo from that path like…
user468311
2
votes
1 answer
Cannot compile RcppArmadillo
RcppArmadillo is a dependency of a few packages I'm trying to install. I get this error on compilation of RcppArmadillo version 0.10.1.0.0 (which is what R automatically pulls from CRAN when it finds that RcppArmadillo is a…

TheFoss
- 65
- 6
2
votes
0 answers
Problems in using qr decomposition with RcppArmadillo
I need qr decomposition from Armadillo thru Rcpp. The following R code (with the economic QR) does run:
# test matrix:
m<-5; n<-4
set.seed(123)
X <- replicate(n, runif(m))
sourceCpp(code='
#include
#include
//…

Antonio Piemontese
- 107
- 5
2
votes
1 answer
RcppArmadillo: Negative indexing in for-loop
I'm new to Rcpp and am trying to perform computations based on negative indexing in a for()-loop using RcppArmadillo.
I already found out that negative indexing in RcppArmadillo is not so straightforward, but that it can be done via the vector of…

Suzanne
- 83
- 9
2
votes
1 answer
How to make a C++ function that performs an in-place operation available to another R package using Rcpp?
Say I have an R package called "packA" that contains the following file "funcA.cpp":
// [[Rcpp::depends(RcppArmadillo)]]
// [[Rcpp::interfaces(r, cpp)]]
#include
using namespace Rcpp;
// [[Rcpp::export]]
void funcA (arma::vec& x)…

NeferkareII
- 21
- 2