[Rcpp-devel] Invoking class methods via XPtr<> objects in R

2013-03-13 Thread Suresh Easwar
How does one invoke class methods via XPtr objects in R? I get this error: Error in aptr$f : object of type 'externalptr' is not subsettable: cpp file: #include struct A { void f() {} }; typedef Rcpp::XPtr APtr; APtr getAPtr() { return APtr(new A); } struct B { B(APtr) { } }; RCPP_MODULE(mytest

Re: [Rcpp-devel] Invoking class methods via XPtr<> objects in R

2013-03-13 Thread Dirk Eddelbuettel
On 13 March 2013 at 10:15, Suresh Easwar wrote: | How does one invoke class methods via XPtr objects in R? I get this error: Error in aptr$f : object of type 'externalptr' is not subsettable: I don't understand what you are trying to do below, and do not have time to understand and debug it for

Re: [Rcpp-devel] ndarray + eigen

2013-03-13 Thread Dirk Eddelbuettel
On 13 March 2013 at 14:49, Aileen Lin wrote: | Hi there, | | I need to create a multidimensional array. I tried arma::cube. It is very good | for 3d array, but I need to create 4d/5d array and cube seems not the answer. I | found a c++ library 'ndarray' that depends on eigen. I am not sure how I

Re: [Rcpp-devel] Invoking class methods via XPtr<> objects in R

2013-03-13 Thread Suresh Easwar
All I want to do is obtain a shared-pointer equivalent in R to a C++ object and be able to do two things with it - 1. Invoke methods of the object via the shared-pointer and 2. pass the shared-pointer to the methods of other C++ class objects. In Python, I am able to do this like so (Boost shar

[Rcpp-devel] not sure if it's a rcpp question or a cpp question

2013-03-13 Thread Aileen Lin
My C code: //[[Rcpp::depends("Rcpp")]] #include #include using namespace Rcpp; //[[Rcpp::export]] NumericVector sigmutest(double pd, double rsq){ double qpd = R::qnorm(pd, 0, 1, 1, 0); double sgtemp = 0.2; double sg = 0.3; double eor = 1; double w = 0; while (eor>=0.0001) {

Re: [Rcpp-devel] Invoking class methods via XPtr<> objects in R

2013-03-13 Thread Dirk Eddelbuettel
On 13 March 2013 at 18:27, Suresh Easwar wrote: | All I want to do is obtain a shared-pointer equivalent in R to a C++ object and | be able to do two things with it - 1. Invoke methods of the object via the | shared-pointer and 2. pass the shared-pointer to the methods of other C++ class | objec

Re: [Rcpp-devel] not sure if it's a rcpp question or a cpp question

2013-03-13 Thread Dirk Eddelbuettel
On 14 March 2013 at 14:42, Aileen Lin wrote: | My C code: | //[[Rcpp::depends("Rcpp")]] | #include | #include | using namespace Rcpp; |   | //[[Rcpp::export]] | NumericVector sigmutest(double pd, double rsq){ |   double qpd = R::qnorm(pd, 0, 1, 1, 0); |   double sgtemp = 0.2; |   double sg = 0.3

Re: [Rcpp-devel] not sure if it's a rcpp question or a cpp question

2013-03-13 Thread Alon Honig
I am fairly certain that this line is not kosher (and in any case it is a confusing): w = pd * 0.4 / (R::pnorm((qpd - sqrt(rsq) * (-0.42) * sgtemp), 0, 1, 1, 0)); try this instead: w = qpd - sqrt(rsq) * (-0.42) * sgtemp w = pd * 0.4 / (R::pnorm(w, 0, 1, 1, 0)); On Wed, Mar 13, 2013 at 11:42 P