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: 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,,, question A: can I use the -inline- "cfunction" without resorting to the Rcpp functionality? -- 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? questionB: is it true that the working with the -inline- function you have to have only void return type code? -- if this is false, questionB2: do you have a simple example of this? Many thanks Sergio Barrios -- View this message in context: http://n4.nabble.com/Inline-Package-void-vs-return-type-functions-tp1838423p1838423.html Sent from the R help mailing list archive at Nabble.com.
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
On 13 April 2010 at 05:46, satu wrote: | 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: | | 1) my C/ C++ code has a return type (let say a double[][] or a user define | class) It can;t with the .Call interface from R which requires SEXP. | 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,,, | | question A: can I use the -inline- "cfunction" without resorting to the Rcpp | functionality? Sure. Inline existed before Rcpp. It can now cooperate (very nicely) with Rcpp, but is not dependent upon it. | -- 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? You could use Rcpp to (more easily) write accessors for your library. You don;t modify the library, but you write Rcpp-using function that access it and report back to R. | questionB: is it true that the working with the -inline- function you have | to have only void return type code? False, see above about SEXP and .Call. | -- if this is false, questionB2: do you have a simple example of this? There are _hundreds_ of examples in the Rcpp unit tests and a couple more in the numerous examples. Rcpp questions should go to the rcpp-devel list; subscribe before posting. Dirk | Many thanks | | Sergio Barrios | -- | View this message in context: http://n4.nabble.com/Inline-Package-void-vs-return-type-functions-tp1838423p1838423.html | Sent from the R help mailing list archive at Nabble.com. | | ______________________________________________ | R-help at r-project.org mailing list | https://stat.ethz.ch/mailman/listinfo/r-help | PLEASE do read the posting guide http://www.R-project.org/posting-guide.html | and provide commented, minimal, self-contained, reproducible code. -- Registration is open for the 2nd International conference R / Finance 2010 See http://www.RinFinance.com for details, and see you in Chicago in April!
Many Thanks for your help Best, Sergio -- View this message in context: http://n4.nabble.com/Inline-Package-void-vs-return-type-functions-tp1838423p2015898.html Sent from the R help mailing list archive at Nabble.com.