Questions tagged [rcpparmadillo]
204 questions
0
votes
0 answers
Check BIC via RcppArmadillo(Rcpp)
I want check the BIC usage in statistics.
My little example, which is saved as check_bic.cpp, is presented as follows:
#include
// [[Rcpp::depends(RcppArmadillo)]]
using namespace Rcpp;
using namespace arma;
//…

John Stone
- 635
- 4
- 13
0
votes
0 answers
Edit R Makevars file to get STAN to work and use Rccp and compile C++
Is it possible to change the Makevars file? I am told on the STAN forums that I need to do this to get Rccp to work as well. When I try to change it, I am locked out and it saves it as a different file name. How can I override this?
To be more…

wolfsatthedoor
- 7,163
- 18
- 46
- 90
0
votes
1 answer
sort_index() function in c++ armadillo library gives wrong result
I am using the sort_index() function in c++ armadillo, and it does not seem to give the correct result:
input vector is [3,4,2,1,5]
sorting both directions
arma::sort_index(input, "ascend").print();
arma::sort_index(input, "descend").print();
and…

segfault_101
- 51
- 1
- 3
0
votes
2 answers
Rounding a matrix to arbitrary precision using Rcpp
I would like to round a matrix M to arbitrary precision in Rcpp. It is particularly easy to do so in R:
M <- matrix(rnorm(4), 2, 2)
M
[,1] [,2]
[1,] 0.04463484 0.1455878
[2,] 1.77416096 1.0787835
round(M,2)
[,1] [,2]
[1,] 0.04…

yrx1702
- 1,619
- 15
- 27
0
votes
1 answer
Rcpp submat from a big sparse matrix
I am trying to multiply a vec by a subset of a very big sparse matrix (as the script followed), but it fails to complier when using sourceCpp, it reports error: no matching function for call to ‘arma::SpMat::submat(arma::uvec&, arma::uvec&),…

YinLL
- 287
- 1
- 3
- 5
0
votes
0 answers
Memory issue for 'as' in Rcpp
I'm a noob in Rcpp programming and here is a simple question for Rcpp.
Will it double the memory cost when using 'as' function in Rcpp? Take the following rough codes for an example, 'x' is a very big matrix. I am wondering if 'xx' and 'x' share the…

YinLL
- 287
- 1
- 3
- 5
0
votes
0 answers
Samples from RcppArmadillo and R returns different outputs
It seems that, the sample functions from RcppArmadillo and R return the same outputs when I set fixed the seed for each sample. However, I get different outcomes in my case.
Here is my code
// [[Rcpp::depends(RcppArmadillo)]]
#include…

Ari.stat
- 463
- 4
- 13
0
votes
0 answers
How can I create this in Rcpp
I was curious on how I can turn this to an Rcpp format? Because of memory problem, R's as.matrix method isn't working
sparse.cor4 <- function(x){
n <- nrow(x)
cMeans <- colMeans(x)
covmat <- (as.matrix(crossprod(x)) -…

Viktor
- 47
- 5
0
votes
1 answer
Error install RcppArmadillo on macOS Catalina
I followed the steps in R Compiler Tools for Rcpp on macOS (for R 3.6.x), but an error occurs when I try to install RcppArmadillo. I don't have Xcode.app install, and prefer to use the command line tools instead.
The answers posted here didn't help…

nalzok
- 14,965
- 21
- 72
- 139
0
votes
1 answer
Why is '&' operator not working in RcppArmadillo
I am trying to obtain a logical vector from two other logical vectors connected through elementwise '&':
//[[Rcpp::export]]
arma::uvec test1(arma::vec t1, double R1, double R2){
arma::uvec t = (t1 >= R1) & (t1 < R2);
return t;
}
It returns the…

NamelessGods
- 185
- 6
0
votes
0 answers
Compiler error when using vectorise on a sparse matrix
I was trying to create a vector from the non-zero entries of a sparse matrix and thought that the 'vectorise' function would do the trick.
The Armadillo documentation indicates that the 'vectorise' function has supported the sparse matrix format…

frank2165
- 114
- 2
- 7
0
votes
1 answer
Unable to load armadillo Cube when using RcppArmadillo
I was prepossessing data in C++ using the Armadillo library. The program end product is a ucube, which is a cube filled with unsigned integers. After its run, I want to load the ucube to R to perform some final statistical tests. To do so, I made a…

F. Correhuela
- 143
- 4
0
votes
1 answer
Installing RcppArmadillo in R
i'm having this error when trying to install RcppArmadillo in R, and is driving me crazy, i've not been able to find how to deal with it:
Error: package or namespace load failed for ‘RcppArmadillo’ in dyn.load(file, DLLpath = DLLpath, ...):
unable…

Ghost
- 1,426
- 5
- 19
- 38
0
votes
1 answer
ERROR: lazy loading failed for package RcppArmadillo on R 3.5.3
I am having some issues getting Travis-CI to install RcppArmadillo on Ubuntu 16.04 with R-oldrel (3.5.3) although it works for R-release (3.6.1) and R-devel. I get the following error:
* installing *source* package ‘RcppArmadillo’ ...
** package…

Jeffrey Girard
- 761
- 4
- 20
0
votes
1 answer
Compilation Error using RcppArmadillo package in R with rowvec
I am trying to compile the following code. Please see below what I have tried so far. Is there anything that I am missing. Any help would be appreciated.
#include
// [[Rcpp::depends(RcppArmadillo)]]
using namespace Rcpp;
//…

Hello
- 61
- 1
- 9