Questions tagged [rcpparmadillo]
204 questions
1
vote
1 answer
Invoke the element in `Rcpp::List` for futher use directly
In an application, I use List to contain some variables (double, arma::mat and other types), and then take the arma::mat component in this list for futher use directly, such as matrix addition. However, some error is thrown.
Below is a toy example…

zengc
- 97
- 9
1
vote
3 answers
sourceCpp error: not mach-o or a static library file '/usr/local/lib/libgfortran.dylib'
I've long been a user of RcppArmadillo, but have been unable to compile any programs via sourceCpp since upgrading my OS to Monterey Version 12.3.
Getting the following error:
ld: malformed universal file: slice content is not mach-o or a static…

Alexander McLain
- 11
- 2
1
vote
1 answer
How to install gfortran for MacOS Monterey (version 12.2.1) M1?
I am trying to install Fortran on my MacBook MacOS Monterey (version 12.2.1) M1 chip laptop. I downloaded and installed the gfortran from this website (gfortran 12-Dec 18, 2021): https://github.com/fxcoudert/gfortran-for-macOS/releases with no…

Dominika Boron
- 11
- 1
- 1
- 5
1
vote
1 answer
Expose custom type to R using Rcpp Modules field produces compilation
I'm frequently using std::map in c++ so I wrote custom as and wrap templates to handle the R-C++ conversion. Below is a minimal reprex:
// [[Rcpp::depends(RcppArmadillo)]]
#include
// forward…

BerriJ
- 913
- 7
- 18
1
vote
0 answers
Helps on the package development
I am the package developer for o2plsda which is included in CRAN. I got an email saying that I need to fix the following warnings:
File ‘o2plsda/libs/o2plsda.so’:
Found ‘___assert_rtn’, possibly from ‘assert’ (C)
Objects:…

bioguo
- 61
- 4
1
vote
0 answers
Missing libSystem.B.dylib resulting in "Symbol not found: ___addtf3" error when compiling programs with Armadillo
I am trying to use the armadillo library in my C++ program. I have installed Armadillo version 10.7.4 and all its dependencies using HomeBrew on MacOS 12.0.1 Monterey that has Apple clang version 11.
The compiler does not output any errors when run…

Lie Algebra Guy
- 11
- 1
1
vote
0 answers
Compute product of large 3-D arrays in R
I am working on an optimization problem, and to supply the analytic gradient to the routine, I need to compute the gradient of large 3D arrays with respect to parameters. The largest of these arrays s are of dimensions [L,N,J] where L,J ~ 2000, and…

pbstx412
- 11
- 3
1
vote
1 answer
Armadillo Sparse Matrix Size in Bytes
I would like to assess how large Armadillo sparse matrices are. The question is related to this answer regarding dense matrices.
Consider the following example:
void some_function(unsigned int matrix_size) {
arma::sp_mat x(matrix_size,…

Chr
- 1,017
- 1
- 8
- 29
1
vote
0 answers
Rcpp, RcppArmadillo: classes that can be passed by reference
As highlighted by e.g. this post, matrices can be passed to an arma::mat object by reference:
// [[Rcpp::export]]
void arma_test_ref( arma::mat& x){}
// [[Rcpp::export]]
void arma_test_const_ref( const arma::mat& x){}
Which other classes foreign…

Chr
- 1,017
- 1
- 8
- 29
1
vote
0 answers
An Rcpp function argument being a List filled with default values
It's my first post here! Woohoo!
I would like to have an Rcpp function that would have an argument being a list with some specified default values of its entries. I would like this function to work similarly to the following R function:
> nicetry_R…

Tomasz
- 78
- 5
1
vote
0 answers
Classes with Armadillo data
Initially, I was importing some data from R directly into a C++ function like so:
#include
using namespace Rcpp;
// [[Rcpp::depends(RcppArmadillo)]]
List gibbs(List dat) {
int N = dat["N"];
arma::vec y = dat["y"];
…

Cat
- 111
- 4
1
vote
1 answer
How can I replicate R's functionality with multiplying a matrix by a vector element-wise in Rcpp or Armadillo?
In R, multiplying a matrix by a vector is element-wise by default, and works like this:
A <- matrix(c(1,2,3,4,5,6), nrow=2)
b <- c(1,3)
A * b
[,1] [,2] [,3]
[1,] 1 3 5
[2,] 6 12 18
Essentially, each element of the matrix is…

Epic_Doughnut
- 23
- 4
1
vote
1 answer
How to replicate a matrix into a cube in Armadillo or RcppArmadillo
I have a matrix (say A) of dimension (k1, k2). I want to replicate it N times and save it into a 3D array or cube called B. As a result, the dimension of B will be (k1, k2, N).
In R, I did the following to do that:
B <- replicate(N, A)
I wonder if…

Paul
- 107
- 4
1
vote
1 answer
Auto-derivative functions in rcpparmadillio?
I want to calculate the derivative of the function f by Rcpp. I just found some resources in
https://cran.r-project.org/web/packages/StanHeaders/vignettes/stanmath.html, which use stan headers and rcppEigen. Since all my program is coded by…

Xia.Song
- 416
- 3
- 15
1
vote
0 answers
Installing package from different sources gives different performance
I have tried installing the RcppArmadillo package sparta (which is on CRAN) using three different methods.
install.packages("sparta")
devtools::install() (inside the package folder)
devtools::build() and then install.package("path_to_build_file,…

mlindsk
- 37
- 5