Hi,

I am trying to wrap the optim library (https://github.com/kthohr/optim) in
R via an R package using Rcpp/RcppArmadillo. Indeed, optim relies on
armadillo itself. The github repository can be found here
https://github.com/jchiquet/optimLibR

To do that, I put the headers of optim into inst/include/ and the cpp files
into src/. Then I tried to "heuristically" pull everything together in the
src/Makevars files, after my (obviously poor) understanding of the R manual
pages about Makevars and from the various examples that I copied from the
web (especially from the RcppMLPACK1 which, relies on the C++ library
MLPACK, itself based on armadillo
https://github.com/rcppmlpack/RcppMLPACK1/blob/master/src/Makevars).

The package installation (including compilation of optim) successes (at
least, the package can be installed). Then I tried to create two small Rcpp
functions for two examples available in the original optim library,
starting with the following lines

// [[Rcpp::depends(RcppArmadillo)]]// [[Rcpp::plugins(cpp11)]]
#define USE_RCPP_ARMADILLO
#include "optim.hpp"

(The #define command is an option of the optim library.)

However, when I call the corresponding R functions, I get the following
Armadillo errors in R which I do not have when running them in 'pure' C++
(I am pretty sure it is not a syntax problem, the Rcpp code and the
original C++ code are hopefully identical, except for the headers).

> library(optimLibR)> ackley_function()error: arma::memory::acquire(): out of 
> memory

> library(optimLibR)> logit_optimLib()error: Mat::init(): requested size is not 
> compatible with column vector layout

So it seems to me that the header of armadillo are correctly defined but I
am not sure that I reach the src (cpp) part of armadillo which is required
at the execution.

If anyone can confirm or help pointing the origin of the error, I would be
debtful...

Thanks for your time,

J.

Thanks for your time
_______________________________________________
Rcpp-devel mailing list
Rcpp-devel@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Reply via email to