Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert uses of inline::cxxfunction to attributes. #56

Closed
romainfrancois opened this issue Nov 15, 2013 · 10 comments
Closed

Convert uses of inline::cxxfunction to attributes. #56

romainfrancois opened this issue Nov 15, 2013 · 10 comments

Comments

@romainfrancois
Copy link
Contributor

There are lots of examples still using cxxfunction.

We need to replace this by uses of sourceCpp or cppFunction.

@coatless
Copy link
Contributor

Listing of cxxfunction() within Rcpp:

grep -rnw '.' -e "cxxfunction"
./inst/examples/FastLM/lmArmadillo.R:52:    fun <- cxxfunction(signature(Ysexp="numeric", Xsexp="numeric"),
./inst/examples/FastLM/lmGSL.R:65:    fun <- cxxfunction(signature(Ysexp="numeric", Xsexp="numeric"),
./inst/examples/functionCallback/newApiExample.r:27:funx <- cxxfunction(signature(N = "integer" , xvec = "numeric", fun = "function" ),
./inst/examples/Misc/ifelseLooped.r:40:funRcpp <- cxxfunction(signature(zs="numeric"), plugin="Rcpp", body="
./inst/examples/Misc/ifelseLooped.r:73:    funRcppI <- cxxfunction(signature(zs="integer"), plugin="Rcpp", body="
./inst/examples/OpenMP/OpenMPandInline.r:15:funSerial <- cxxfunction(signature(xs="numeric"), body=serialCode, plugin="Rcpp")
./inst/examples/OpenMP/OpenMPandInline.r:22:funSerialStdAlg <- cxxfunction(signature(xs="numeric"), body=serialStdAlgCode, plugin="Rcpp")
./inst/examples/OpenMP/OpenMPandInline.r:34:funSerialRcpp <- cxxfunction(signature(xs="numeric"), body=serialRcppCode, plugin="Rcpp")
./inst/examples/OpenMP/OpenMPandInline.r:41:funSerialStdAlgRcpp <- cxxfunction(signature(xs="numeric"), body=serialStdAlgRcppCode, plugin="Rcpp")
./inst/examples/OpenMP/OpenMPandInline.r:47:funSerialImportTransRcpp <- cxxfunction(signature(xs="numeric"), body=serialImportTransRcppCode, plugin="Rcpp")
./inst/examples/OpenMP/OpenMPandInline.r:55:funSugarRcpp <- cxxfunction(signature(xs="numeric"), body=sugarRcppCode, plugin="Rcpp")
./inst/examples/OpenMP/OpenMPandInline.r:74:funOpenMP <- cxxfunction(signature(xs="numeric"), body=openMPCode, plugin="Rcpp", settings=settings)
./inst/examples/performance/extractors.R:32:fx <- cxxfunction( 
./inst/examples/performance/performance.R:26:fx <- cxxfunction( signatures, bodies, plugin = "Rcpp" )
./inst/examples/RcppGibbs/RcppGibbs.R:117:RcppGibbs <- cxxfunction(signature(n="int", thin = "int"),
./inst/examples/RcppGibbs/RcppGibbs.R:149:GSLGibbs <- cxxfunction(signature(ns="int", thns = "int"),
./inst/examples/RcppGibbs/timeRNGs.R:6:rcppGamma <- cxxfunction(signature(xs="numeric"), plugin="Rcpp", body='
./inst/examples/RcppGibbs/timeRNGs.R:23:gslGamma <- cxxfunction(signature(xs="numeric"), plugin="RcppGSL",
./inst/examples/RcppGibbs/timeRNGs.R:42:rcppNormal <- cxxfunction(signature(xs="numeric"), plugin="Rcpp", body='
./inst/examples/RcppGibbs/timeRNGs.R:59:gslNormal <- cxxfunction(signature(xs="numeric"), plugin="RcppGSL",
./inst/examples/RcppInline/external_pointer.r:23:funx <- cxxfunction(signature(), '
./inst/examples/RcppInline/external_pointer.r:43:funx <- cxxfunction(signature(x = "externalptr" ), '
./inst/examples/RcppInline/RcppInlineExample.r:18:funx <- cxxfunction(signature(), foo, plugin = "Rcpp" )
./inst/examples/RcppInline/RcppInlineWithLibsExamples.r:44:    funx <- cxxfunction(signature(), gslrng,
./inst/examples/RcppInline/RcppInlineWithLibsExamples.r:81:    funx <- cxxfunction(signature(par="numeric"), gslrng,
./inst/examples/RcppInline/RcppInlineWithLibsExamples.r:92:    funx <- cxxfunction(signature(par="numeric"), gslrng,
./inst/examples/RcppInline/RcppInlineWithLibsExamples.r:126:    funx <- cxxfunction(signature(s="numeric", n="numeric"),
./inst/examples/RcppInline/RcppInlineWithLibsExamples.r:161:    funx <- cxxfunction(signature(s="numeric", n="numeric"),
./inst/examples/RcppInline/UncaughtExceptions.r:22:funx <- cxxfunction( 
./inst/examples/SugarPerformance/sugarBenchmarks.R:83:  fun <- cxxfunction(signature(runss="integer", expr = "language", env = "environment" ),
./inst/NEWS.Rd:1095:    \item New Rcpp-FAQ entry on simple way to set compiler option for cxxfunction
./inst/NEWS.Rd:1168:             cxxfunction(), and on setting row and column names for matrices
./inst/NEWS.Rd:1369:        each to cxxfunction() (covering multiple tests) resulting in a
./inst/NEWS.Rd:1450:             flexible cxxfunction in the inline package (0.3.5). Rcpp no longer
./inst/NEWS.Rd:1455:                cppfunction <- function(...) cxxfunction( ..., plugin = "Rcpp" )
./vignettes/Rcpp-extending.Rnw:115:fx <- cxxfunction( signature( input_ = "list"),
./vignettes/Rcpp-FAQ.Rnw:233:\rdoc{inline}{cfunction} and \rdoc{inline}{cxxfunction}. Below is a simple
./vignettes/Rcpp-FAQ.Rnw:238:fx <- cxxfunction(signature(x = "numeric"),
./vignettes/Rcpp-FAQ.Rnw:260:fx <- cxxfunction(signature(), paste(readLines("myfile.cpp"), collapse="\n"),
./vignettes/Rcpp-FAQ.Rnw:264:The \texttt{verbose} argument of \rdoc{inline}{cxxfunction} is very
./vignettes/Rcpp-FAQ.Rnw:586:\rdoc{Rcpp}{cxxfunction} function.
./vignettes/Rcpp-FAQ.Rnw:730:fun <- cxxfunction(signature(xs="numeric", is="integer"),
./vignettes/Rcpp-FAQ.Rnw:815:fx <- cxxfunction(signature(x_="numeric", Y_="matrix", z_="numeric" ),
./vignettes/Rcpp-FAQ.Rnw:881:fx <- cxxfunction(signature(), 
./vignettes/Rcpp-FAQ.Rnw:925:fun <- cxxfunction(signature(), src, plugin="Rcpp")
./vignettes/Rcpp-FAQ.Rnw:958:mmult <- cxxfunction(signature(A="numeric", B="numeric"),
./vignettes/Rcpp-FAQ.Rnw:1026:fun <- cxxfunction(signature(par="numeric"), gslrng, plugin="gslDemo")
./vignettes/Rcpp-FAQ.Rnw:1051:f <- cxxfunction(signature(), settings=myplugin, body='
./vignettes/Rcpp-FAQ.Rnw:1082:fun <- cxxfunction(signature(), body=src, plugin="Rcpp")
./vignettes/Rcpp-FAQ.Rnw:1114:BigInts <- cxxfunction(signature(),
./vignettes/Rcpp-introduction.Rnw:662:using simple functions \code{cfunction} and \code{cxxfunction}.  The latter provides an extension which
./vignettes/Rcpp-introduction.Rnw:708:R> fun <- cxxfunction(signature(a = "numeric", b = "numeric"),
./vignettes/Rcpp-introduction.Rnw:718:\code{cxxfunction} (provided by the \pkg{inline} package), we have created a new \proglang{R}
./vignettes/Rcpp-introduction.Rnw:753:R> cpp_lapply <- cxxfunction(signature(data = "list", fun = "function"),
./vignettes/Rcpp-modules.Rnw:204:Using \code{cxxfunction()} from the \pkg{inline} package, we can build this
./vignettes/Rcpp-modules.Rnw:213:f1 <- cxxfunction( , "", includes = unifModCode, plugin = "Rcpp" )
./vignettes/Rcpp-modules.Rnw:303:fx <- cxxfunction(signature(), plugin="Rcpp", include=inc)
./vignettes/Rcpp-modules.Rnw:308:module was returned by the \code{cxxfunction()} (from the \pkg{inline}
./vignettes/Rcpp-modules.Rnw:556:## assumes   fx_unif <- cxxfunction(...)   has ben run
./vignettes/Rcpp-modules.Rnw:880:## for code compiled on the fly using cxxfunction() into 'fx_vec', we use
./vignettes/Rcpp-quickref.Rnw:157:testfun = cxxfunction(

@eddelbuettel
Copy link
Member

eddelbuettel commented Jul 16, 2016

Yes, sadly (empirically speaking) this is apparently not really all that relevant it would appear as nobody stepped forward to rewrite all of these in the meantime.

To take but one example: FastLM started here, but we have better versions, often in three or four styles, in the different packages. So what is needed is maybe not so much an erasing of all of the old scattershot approaches banning them all, but maybe a targeted focus addressing one example (or vignette) at a time.

Not sure how to get from here to there.

@coatless
Copy link
Contributor

So what is needed is maybe not so much an erasing of all of the old scattershot approaches banning them all, but maybe a targeted focus addressing one example (or vignette) at a time.

Does this mean you would be open to an "Rcpp Examples" vignette? Where each package highlights its own implementation of FastLM?

By the way, I also wrote a short snippet on the calculation procedure of lm:

The source behind lm() does many things from creating the design matrix to figuring out the regression coefficients and covariance matrix.
To do the later, R developers use a modified LINPACK computation with a level 1 basic linear algebra system (BLAS) per a QR Column Pivot Factorization also known as a QR Factorization with Householder Transformations.
Specifically, within the lm.fit component has a call to the c++ function C_Cdqrls to which masks the actual computation done in the dqrls fortran routine. The function specifically uses both dqrdc (modified QR Householder) and dqrsl (least square projections).

@coatless
Copy link
Contributor

@eddelbuettel

Plan:

  1. Gather different versions across Eigen, GSL, and Armadillo
  2. Replace Examples with updated versions in inst/
  3. Create a vignette called Rcpp Examples containing updated versions of the codebase from across packages.
  4. ??
  5. Profit!

Thoughts?

Also inline usage within FAQ, modules, and introduction cannot be remove without changing the meaning of the document greatly. (Renumbered sections as attributes typically follows after the use of inline is discussed.

@eddelbuettel
Copy link
Member

Commenting backwards:

  • Rcpp introduction is frozen. As discussed, could be renamed Rcpp JSS Paper or something.
  • Modules and FAQ do have inline code, but I'd prefer to leave it, annotate it as 'how we used to do things' and outshine it with better examples
  • I am afraid I am not a fan of one huge 'sumo' documentation for all. These are different packages with different audiences.

@coatless
Copy link
Contributor

coatless commented Aug 3, 2016

Okay, so to fulfill this:

Is this okay @eddelbuettel ?

@eddelbuettel
Copy link
Member

I would prefer to do things one at a time. Let's looks at converting a vignette at a time.

Also let's not change all examples all at once, but maybe by directory. We could also consider just removing them, or completely rewrite them, or move them to RcppExamples. Needs some thought and discussion first, I think.

@coatless
Copy link
Contributor

coatless commented Aug 3, 2016

@eddelbuettel :

I meant to say, 1 PR per bullet tied to this issue. Clear on individual PRs for vignette changes.

I remember a long time ago on a different issue there were potential issues with moving examples out of a package due to pre-existing links. (I know this is shooting the revamp of the examples in the foot... But...)

As this is directly associated with examples, I vote to have the discussion around either moving the examples / completely rewriting them here.

I'm only in favor of a rewrite to modernize the examples. I think moving them into RcppExamples is too much.

@eddelbuettel
Copy link
Member

All those points sound good to me. I have done similar stuff eg here for an RcppGSL example. This one has four example --- because things got better incrementally. So we could keep what is there (preserving links, a plus), keep the old example (being honest) but promote a better newer one.

@github-actions
Copy link

This issue is stale (365 days without activity) and will be closed in 31 days unless new activity is seen. Please feel free to re-open it is still a concern, possibly with additional data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants