[Rcpp-devel] Fwd: List of uniform_int_distribution objects
aakremena at aol.com
aakremena at aol.com
Wed Apr 27 00:07:03 CEST 2016
Hi all,
I have decided to follow Dirk's advice and use more classical STL containers rather than Rcpp::List one.
It works for me but I admit that I am still in the dark as to why the Rcpp::List way doesn't work.
Thus, I consider this topic closed.
Thanks.
Anguel
-----Original Message-----
From: Dirk Eddelbuettel <edd at debian.org>
To: aakremena <aakremena at aol.com>
Cc: rcpp-devel <rcpp-devel at lists.r-forge.r-project.org>
Sent: Tue, Apr 26, 2016 1:52 pm
Subject: Re: [Rcpp-devel] List of uniform_int_distribution objects
On 26 April 2016 at 14:45, aakremena at aol.com wrote:
| Hi everybody,
|
| 1. I am trying to create an Rcpp list, each of whose elements contain an
| uniform_int_distribution object.
|
| 2. My understanding is that since an uniform_int_distribution object is a
| non-SEXP one, I need to create a specialization of wrap() first.
|
| 3. To this end, I am using the following (sample) piece of code:
|
| #include <RcppCommon.h>
| #include <random>
| namespace Rcpp {
| template <> SEXP wrap(const std::uniform_int_distribution<int> &d);
| }
| #include <Rcpp.h>
| using namespace Rcpp;
|
| // [[Rcpp::export]]
| Rcpp::List List_of_Distributions() {
| Rcpp::List DISTR(2);
| std::uniform_int_distribution<int> dist_1(0, 5);
| std::uniform_int_distribution<int> dist_2(0, 6);
| DISTR[0] = Rcpp::wrap(dist_1); DISTR[1] = Rcpp::wrap(dist_2);
|
| return DISTR;
| }
|
| /*** R
| List_of_Distributions()
| */
|
| 4. The compilation fails with a message
|
| Error in dyn.load("/var/folders/12/bqytpkx93w97r3s3_h9q9k_00000gn/T//Rtmpm2tVkx
| /sourcecpp_f9e75ec42b87/sourceCpp_220.so") :
| unable to load shared object '/var/folders/12/bqytpkx93w97r3s3_h9q9k_00000gn/
| T//Rtmpm2tVkx/sourcecpp_f9e75ec42b87/sourceCpp_220.so':
| dlopen(/var/folders/12/bqytpkx93w97r3s3_h9q9k_00000gn/T//Rtmpm2tVkx/
| sourcecpp_f9e75ec42b87/sourceCpp_220.so, 6): Symbol not found:
| __ZN4Rcpp4wrapINSt3__124uniform_int_distributionIiEEEEP7SEXPRECRKT_
| Referenced from: /var/folders/12/bqytpkx93w97r3s3_h9q9k_00000gn/T//Rtmpm2tVkx
| /sourcecpp_f9e75ec42b87/sourceCpp_220.so
| Expected in: flat namespace
| in /var/folders/12/bqytpkx93w97r3s3_h9q9k_00000gn/T//Rtmpm2tVkx/
| sourcecpp_f9e75ec42b87/sourceCpp_220.so
|
| 5. I am working on OS X Mavericks and use clang-omp compiler
|
| Can somebody possibly direct me to what I may be doing wrong here. Apologies
| if the question seems too basic to you.
We attempt to stress in our presentations that _everything_ really happens
within the confines of
SEXP .Call("somefunc", SEXP a, SEXP b, SEXP c, ...)
as this is the _only_ interface that R offers.
We have vignettes expanding on this -- but in short you failed to convert a
type only you and the compiler know to one which R and Rcpp know too. There
are means to do this. But a faster and easier way may just be to copy into a
standard STL container (std::vector<double>, say).
Dirk
|
| Thank you in advance.
|
| Anguel
|
|
|
| _______________________________________________
| Rcpp-devel mailing list
| Rcpp-devel at lists.r-forge.r-project.org
| https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
--
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20160426/6a9ba7c9/attachment-0001.html>
More information about the Rcpp-devel
mailing list