[R] Inline Package: void vs return type functions

Romain Francois
Tue, 13 Apr 2010 15:46:48 -0000

Le 13/04/10 15:46, satu a ?crit :
> Dear all,
>
> After having a look at the "inline" package and also going
through the
> "Rcpp" package which is tighty related to it, it came to me this
question:

no.

> 1) my C/ C++ code has a return type (let say a double[][] or a user define
> class)
> 2) I am working with an extensive library built by someone else and  I
don't
> have the time/knowledge to change it by means of working with
"pointer"
> variables in order to avoid the return sentence,,,

Please at least find the time to read "Writing R Extensions"

> question A: can I use the -inline- "cfunction" without resorting
to the Rcpp
> functionality?

yes.

inline knowns about Rcpp but can work on its own. you need Rcpp if you
use the Rcpp argument of cfunction.

> -- if this is true, question A2: do I need to go deep in the source code
> coming from the library (that I am trying to use) to perform the interface
> through the Rcpp classes?

no.

> questionB: is it true that the working with the -inline- function you have
> to have only void return type code?

Which interface are we talking about ? .C, .Call ?

All the documentation is available in writing R extensions.

In .Call, which is the preferred way when you use Rcpp, the return type
must be SEXP or whatever that can be implicitely converted to SEXP. Many
classes in Rcpp do have implicit conversion to SEXP
(Rcpp::IntegerVector, Rcpp::List, etc ...)

> -- if this is false, questionB2: do you have a simple example of this?

?cfunction

Writing R extensions

> Many thanks
>
> Sergio Barrios


--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://bit.ly/9aKDM9 : embed images in Rd documents
|- http://tr.im/OIXN : raster images and RImageJ
|- http://tr.im/OcQe : Rcpp 0.7.7