I’m traveling without my laptop this week. I’ll take a look at the error when I return.
Best, Keith > On Jul 25, 2018, at 12:26 PM, julien chiquet <julien.chiq...@gmail.com> wrote: > >> On Wed, Jul 25, 2018 at 5:57 PM Dirk Eddelbuettel <e...@debian.org> wrote: > >> >> On 25 July 2018 at 17:30, julien chiquet wrote: >> | 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, >> >> Good news / bad news. I think the good news is that everything builds, so you >> have no linking issue. In fact, no RcppArmadillo package links to Armadillo >> as we do everything via the headers. >> >> But you seem to have run-time issues which _could_ stem from the fact that >> RcppArmadillo sets a bunch of #define variables and your use may be slightly >> different / conflict with these. Maybe you can check with Keith about how >> his optim(lib) could / should be called from R. > > Thanks for your prompt and helpful answer. At least I know I do not have to > struggle with the Makevars. > > I'll check with Keith. > > j > >> Dirk >> >> -- >> http://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org > _______________________________________________ > 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
_______________________________________________ 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