Discussion:
[Rcpp-devel] Extract names of functions in module
Hola Kwame Adrakey
2018-03-20 12:29:24 UTC
Permalink
Dear all,

Can anyone give me advice/help on how to list the name(s) of all functions
defined within a module?

Here is an example of what I am trying to achieve:

Assuming that I have

inc <- '
using namespace Rcpp;

double SE(double alpha, double beta, double epsilon){
return alpha;
};

double EI(double alpha, double beta, double epsilon){
return beta*alpha;
};

RCPP_MODULE(yada){
function( "SE", &SE,

List::create(
_["alpha"],
_["beta"],
_["epsilon"],
_["..."]));

function( "EI", &EI,

List::create(
_["alpha"],
_["beta"],
_["epsilon"],
_["..."]));

}

'
and

fx <- cxxfunction(signature(), plugin="Rcpp", include=inc)
mod <- Module("yada", getDynLib(fx)).

I can access say, the function SE by mod$SE. However, if the functions
defined within the module are not known (user defined for instance), I can
only access them by knowing their names.

I am currently using names(***@.xData$storage), but I have noticed that
there is a sort of randomness in its behavior, as, in some occasion, the
output is NULL.

Any help will be appreciated.

Best wishes,
--
Hola Kwame ADRAKEY
Research Associate
University of Cambridge ( www.c <http://www.hw.ac.uk>am.ac.uk)
Department of Plant Sciences
Epidemiology and Modeling group
Cambridge CB2 3EA UK
Direct tel :
Fax:
Cellphone :07712254353
***@cam.ac.uk <***@aims.ac.za>
<http://www.hw.ac.uk>***@aims.ac.za

<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
Virus-free.
www.avast.com
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
Hola Kwame Adrakey
2018-03-21 22:01:56 UTC
Permalink
---------- Forwarded message ----------
From: Hola Kwame Adrakey <***@aims.ac.za>
Date: 20 March 2018 at 12:29
Subject: Extract names of functions in module
To: "rcpp-***@lists.r-forge.r-project.org" <
rcpp-***@lists.r-forge.r-project.org>


Dear all,

Can anyone give me advice/help on how to list the name(s) of all functions
defined within a module?

Here is an example of what I am trying to achieve:

Assuming that I have

inc <- '
using namespace Rcpp;

double SE(double alpha, double beta, double epsilon){
return alpha;
};

double EI(double alpha, double beta, double epsilon){
return beta*alpha;
};

RCPP_MODULE(yada){
function( "SE", &SE,

List::create(
_["alpha"],
_["beta"],
_["epsilon"],
_["..."]));

function( "EI", &EI,

List::create(
_["alpha"],
_["beta"],
_["epsilon"],
_["..."]));

}

'
and

fx <- cxxfunction(signature(), plugin="Rcpp", include=inc)
mod <- Module("yada", getDynLib(fx)).

I can access say, the function SE by mod$SE. However, if the functions
defined within the module are not known (user defined for instance), I can
only access them by knowing their names.

I am currently using names(***@.xData$storage), but I have noticed that
there is a sort of randomness in its behavior, as, in some occasion, the
output is NULL.

Any help will be appreciated.

Best wishes,
--
Hola Kwame ADRAKEY
Research Associate
University of Cambridge ( www.c <http://www.hw.ac.uk>am.ac.uk)
Department of Plant Sciences
Epidemiology and Modeling group
Cambridge CB2 3EA UK
Direct tel :
Fax:
Cellphone :07712254353 <07712%20254353>
***@cam.ac.uk <***@aims.ac.za>
<http://www.hw.ac.uk>***@aims.ac.za

<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
Virus-free.
www.avast.com
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
<#m_8615427925884677836_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
--
Hola Kwame ADRAKEY
Research Associate
University of Cambridge ( www.c <http://www.hw.ac.uk>am.ac.uk)
Department of Plant Sciences
Epidemiology and Modeling group
Cambridge CB2 3EA UK
Direct tel :
Fax:
Cellphone :07712254353
***@cam.ac.uk <***@aims.ac.za>
<http://www.hw.ac.uk>***@aims.ac.za
Dirk Eddelbuettel
2018-03-21 22:13:08 UTC
Permalink
We got your email yesterday. No need to repost.

I just don't have an answer for you. Adding reflexivity to C++ is not easy.

Dirk
--
http://dirk.eddelbuettel.com | @eddelbuettel | ***@debian.org
Loading...