I'm having difficulty to find "How-to" documentation; the papers and presentations (including the RcppExamples package) are exciting, but focus on marketing use, rather than providing instructions. I'd appreciate any help to get started to: 1. Code C++ using the Rcpp, RcppGSL and RcppArmadillo libraries. a. May I link my IDE (netbeans) to the lib.a files and use the appropriate .h files for composing C++ code for compilation in R? b. Do RcppGSL and RcppArmadillo contain the Rcpp classes or should the header files from both be included (e.g. #include Rcpp.h, #include RcppArmadillo.h) c. The matrix and vector classes, including views, Rcpp implementation of the C library GSL employs new C++ capabilities and different syntax (e.g. extraction of pointers from matrix or vector view objects). Is there detailed documentation with examples for these class implementations. The differences from GSL disable using that documentation. d. Should RcppExport be used in place of 'extern C' in C++ under Rcpp whenever we wish to input R data types such as matrix, vector and list (due to need to call .Call)? 2. Compile and debug code using Inline or other preferred alternatives. a. The illustrations in presentations seem to copy and paste the entire code from C++ in single quotes with an assignment to a variable subsequently used with inline in R. My code (a Bayesian MCMC implementation) will be on the order of 600 lines long with about 10 input variables. Is there a better way to use inline? b. Is there any help on code debugging? (e.g. some equivalent of 'gdb'). 3. Writing a package. a. What is the 'LinkingTo' declaration - what purpose does it serve and where is it used? b. Same for Makevars and Makevars.win? Thanks, Terrance Savitsky __________________________________________________________________________ This email message is for the sole use of the intended recipient(s) and may contain confidential information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20101208/602074cc/attachment-0001.htm>
[Rcpp-devel] Step-by-Step Plan to Code Writing and Testing with Rcpp, RcppGSL or RcppArmadillo
6 messages · Dirk Eddelbuettel, Savitsky, Terrance
On 8 December 2010 at 17:44, Savitsky, Terrance wrote:
| I?m having difficulty to find ?How-to? documentation; the papers and | presentations (including the RcppExamples package) are exciting, but focus on | marketing use, Nice way to start a dialogue with us by telling us we're idiots. Keep going. | rather than providing instructions. I?d appreciate any help to | get started to: | | 1. Code C++ using the Rcpp, RcppGSL and RcppArmadillo libraries. I don't know how many example we posted on blogs, this list and in presentations. Exactly which did not work? | a. May I link my IDE (netbeans) to the lib.a files and use the | appropriate .h files for composing C++ code for compilation in R? Don't know, don't care. Ex-ant this is for __R__ where the command is 'R CMD ...' and/or Makefiles. If you need netbeans, you get to figure out netbeans. Exiciting to be trailblazer, eh? | b. Do RcppGSL and RcppArmadillo contain the Rcpp classes or should the | header files from both be included (e.g. #include Rcpp.h, #include | RcppArmadillo.h) Have you looked at the examples. They work, and they provide the anwwer. | c. The matrix and vector classes, including views, Rcpp implementation of | the C library GSL employs new C++ capabilities and different syntax (e.g. | extraction of pointers from matrix or vector view objects). Is there detailed | documentation with examples for these class implementations. The differences | from GSL disable using that documentation. I have no idea what you are trying to say here. You are mixing two core APIs (Views in Rcpp only exist in the classic API) and two 'glued-on' libraries one of which is C --- so there are bound to differences. | d. Should RcppExport be used in place of ?extern C? in C++ under Rcpp | whenever we wish to input R data types such as matrix, vector and list (due to | need to call .Call)? Look at the definiton and decide for yourself. Using the define has the advantage that should we ever change it ... | 2. Compile and debug code using Inline or other preferred alternatives. | | a. The illustrations in presentations seem to copy and paste the entire | code from C++ in single quotes with an assignment to a variable subsequently | used with inline in R. My code (a Bayesian MCMC implementation) will be on the | order of 600 lines long with about 10 input variables. Is there a better way | to use inline? Up to you. Inline is for experimentation. We had a MCMC example on the list following Whit's question. Did you look at it? | b. Is there any help on code debugging? (e.g. some equivalent of ?gdb?). How could there not be debugging support with gdb if g++ is used? | 3. Writing a package. Seen the Vignette? | a. What is the ?LinkingTo? declaration ? what purpose does it serve and | where is it used? | | b. Same for Makevars and Makevars.win? See 'Writing R Extensions' Dirk | Thanks, Terrance Savitsky | | | | | __________________________________________________________________________ | | This email message is for the sole use of the intended recipient(s) and | may contain confidential information. Any unauthorized review, use, | disclosure or distribution is prohibited. If you are not the intended | recipient, please contact the sender by reply email and destroy all copies | of the original message. | | ---------------------------------------------------------------------- | _______________________________________________ | Rcpp-devel mailing list | Rcpp-devel at lists.r-forge.r-project.org | https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
Hello Dirk, I sincerely apologize for how I started the dialogue. May I have a do-over? I am an inexperienced developer. So I'm looking forward to using Rcpp to improve my productivity and output quality with writing C++ for R implementation. I will re-read the documents and presentations you've publicly posted. My interest in examples is focused towards imitation before innovation. I'll seek out archived examples for this, which will hopefully focus my start-up efforts. I do, however, have a couple of f/u questions: To your point, "How could there not be debugging support with gdb if g++ is used?" - Does R CMD use the g++ compiler? Since my code is quite long, I just want to find a way to efficiently debug. I can't compile my Rcpp C++ code (with wrappers around R SEXP objects) outside of R, so I'm looking for how to compile with debugging support in R. I typically write C code and compile and run (via cygwin gcc in Windows) with gdb. It's not obvious to me how this process would work when writing Rcpp C++ code for compilation and implementation in R. What IDE do Windows users typically choose for their Rcpp C++ code writing? Is it any different from the IDE they would use for non-Rcpp standalone C/C++ code not interfaced with R? Terrance Savitsky
On 8 December 2010 at 17:44, Savitsky, Terrance wrote:
| I?m having difficulty to find ?How-to? documentation; the papers and | presentations (including the RcppExamples package) are exciting, but focus on | marketing use, Nice way to start a dialogue with us by telling us we're idiots. Keep going. | rather than providing instructions. I?d appreciate any help to | get started to: | | 1. Code C++ using the Rcpp, RcppGSL and RcppArmadillo libraries. I don't know how many example we posted on blogs, this list and in presentations. Exactly which did not work? | a. May I link my IDE (netbeans) to the lib.a files and use the | appropriate .h files for composing C++ code for compilation in R? Don't know, don't care. Ex-ant this is for __R__ where the command is 'R CMD ...' and/or Makefiles. If you need netbeans, you get to figure out netbeans. Exiciting to be trailblazer, eh? | b. Do RcppGSL and RcppArmadillo contain the Rcpp classes or should the | header files from both be included (e.g. #include Rcpp.h, #include | RcppArmadillo.h) Have you looked at the examples. They work, and they provide the anwwer. | c. The matrix and vector classes, including views, Rcpp implementation of | the C library GSL employs new C++ capabilities and different syntax (e.g. | extraction of pointers from matrix or vector view objects). Is there detailed | documentation with examples for these class implementations. The differences | from GSL disable using that documentation. I have no idea what you are trying to say here. You are mixing two core APIs (Views in Rcpp only exist in the classic API) and two 'glued-on' libraries one of which is C --- so there are bound to differences. | d. Should RcppExport be used in place of ?extern C? in C++ under Rcpp | whenever we wish to input R data types such as matrix, vector and list (due to | need to call .Call)? Look at the definiton and decide for yourself. Using the define has the advantage that should we ever change it ... | 2. Compile and debug code using Inline or other preferred alternatives. | | a. The illustrations in presentations seem to copy and paste the entire | code from C++ in single quotes with an assignment to a variable subsequently | used with inline in R. My code (a Bayesian MCMC implementation) will be on the | order of 600 lines long with about 10 input variables. Is there a better way | to use inline? Up to you. Inline is for experimentation. We had a MCMC example on the list following Whit's question. Did you look at it? | b. Is there any help on code debugging? (e.g. some equivalent of ?gdb?). How could there not be debugging support with gdb if g++ is used? | 3. Writing a package. Seen the Vignette? | a. What is the ?LinkingTo? declaration ? what purpose does it serve and | where is it used? | | b. Same for Makevars and Makevars.win? See 'Writing R Extensions' Dirk | Thanks, Terrance Savitsky | | | | | ________________________________________________________________________ __ | | This email message is for the sole use of the intended recipient(s) and | may contain confidential information. Any unauthorized review, use, | disclosure or distribution is prohibited. If you are not the intended | recipient, please contact the sender by reply email and destroy all copies | of the original message. | | ---------------------------------------------------------------------- | _______________________________________________ | Rcpp-devel mailing list | Rcpp-devel at lists.r-forge.r-project.org | https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
On 8 December 2010 at 20:05, Savitsky, Terrance wrote:
| Hello Dirk, I sincerely apologize for how I started the dialogue. May | I have a do-over? Sure. | I am an inexperienced developer. So I'm looking | forward to using Rcpp to improve my productivity and output quality with | writing C++ for R implementation. I will re-read the documents and | presentations you've publicly posted. | | My interest in examples is focused towards imitation before innovation. We actually think along the same lines. What you dismissed earlier as "marketing" is, seen from another angle, a fairly large set of working examples. So let's focus on those. For now, forget RcppArmadillo, RcppGSL, ... and concentrate on just Rcpp. There are numerous examples in the package itself -- see the examples/ subdirectory. Let's get those to work first. | I'll seek out archived examples for this, which will hopefully focus my | start-up efforts. I do, however, have a couple of f/u questions: | | To your point, "How could there not be debugging support with gdb if g++ | is used?" - Does R CMD use the g++ compiler? Since my code is quite Yes. It is essentially the only C++ compiler R uses by default. | long, I just want to find a way to efficiently debug. I can't compile | my Rcpp C++ code (with wrappers around R SEXP objects) outside of R, so Why? We do it all the time with Makefiles. See the examples/ mentioned above. | I'm looking for how to compile with debugging support in R. I typically | write C code and compile and run (via cygwin gcc in Windows) with gdb. Have you ever written any C/C++ code for R? Do you know Cygwin is not supported? When I say 'Rtools' do you have a Pavlovian reflex to the Murdock-Sutherland site? You better do ... See 'Writing R Extensions' for starters. In a nutshell you need a set of compilers etc just for R. Luckily these have been setup. | It's not obvious to me how this process would work when writing Rcpp C++ | code for compilation and implementation in R. | | What IDE do Windows users typically choose for their Rcpp C++ code | writing? Is it any different from the IDE they would use for non-Rcpp | standalone C/C++ code not interfaced with R? Well personally speaking I use the same IDE on all platforms: Emacs. Within the Rcpp Core team, some of us work on OS X and some work on Linux. But it should not matter: R and R add-ons like Rcpp work on Windows, OS X and Linux. Use whichever platform you find easiest. Personally, I like Ubuntu and Debian a lot. Dirk | | Terrance Savitsky | | |
| On 8 December 2010 at 17:44, Savitsky, Terrance wrote:
| | I?m having difficulty to find ?How-to? documentation; the papers and | | presentations (including the RcppExamples package) are exciting, but | focus on | | marketing use, | | Nice way to start a dialogue with us by telling us we're idiots. Keep | going. | | | rather than providing instructions. I?d appreciate any help to | | get started to: | | | | 1. Code C++ using the Rcpp, RcppGSL and RcppArmadillo libraries. | | | I don't know how many example we posted on blogs, this list and in | presentations. Exactly which did not work? | | | | | a. May I link my IDE (netbeans) to the lib.a files and use the | | appropriate .h files for composing C++ code for compilation in R? | | Don't know, don't care. Ex-ant this is for __R__ where the command is | 'R CMD ...' | and/or Makefiles. | | If you need netbeans, you get to figure out netbeans. Exiciting to be | trailblazer, eh? | | | b. Do RcppGSL and RcppArmadillo contain the Rcpp classes or | should the | | header files from both be included (e.g. #include Rcpp.h, #include | | RcppArmadillo.h) | | Have you looked at the examples. They work, and they provide the anwwer. | | | c. The matrix and vector classes, including views, Rcpp | implementation of | | the C library GSL employs new C++ capabilities and different syntax | (e.g. | | extraction of pointers from matrix or vector view objects). Is there | detailed | | documentation with examples for these class implementations. The | differences | | from GSL disable using that documentation. | | I have no idea what you are trying to say here. You are mixing two core | APIs | (Views in Rcpp only exist in the classic API) and two 'glued-on' | libraries | one of which is C --- so there are bound to differences. | | | d. Should RcppExport be used in place of ?extern C? in C++ under | Rcpp | | whenever we wish to input R data types such as matrix, vector and list | (due to | | need to call .Call)? | | Look at the definiton and decide for yourself. Using the define has the | advantage that should we ever change it ... | | | 2. Compile and debug code using Inline or other preferred | alternatives. | | | | a. The illustrations in presentations seem to copy and paste the | entire | | code from C++ in single quotes with an assignment to a variable | subsequently | | used with inline in R. My code (a Bayesian MCMC implementation) will | be on the | | order of 600 lines long with about 10 input variables. Is there a | better way | | to use inline? | | Up to you. Inline is for experimentation. We had a MCMC example on the | list | following Whit's question. Did you look at it? | | | b. Is there any help on code debugging? (e.g. some equivalent of | ?gdb?). | | How could there not be debugging support with gdb if g++ is used? | | | 3. Writing a package. | | Seen the Vignette? | | | a. What is the ?LinkingTo? declaration ? what purpose does it | serve and | | where is it used? | | | | b. Same for Makevars and Makevars.win? | | See 'Writing R Extensions' | | Dirk | | | | Thanks, Terrance Savitsky | | | | | | | | | | | ________________________________________________________________________ | __ | | | | This email message is for the sole use of the intended recipient(s) | and | | may contain confidential information. Any unauthorized review, use, | | disclosure or distribution is prohibited. If you are not the intended | | recipient, please contact the sender by reply email and destroy all | copies | | of the original message. | | | | ---------------------------------------------------------------------- | | _______________________________________________ | | Rcpp-devel mailing list | | Rcpp-devel at lists.r-forge.r-project.org | | | https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel | | -- | Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
Hi again, Thanks for your very helpful suggestions; you're right - I need to just concentrate on Rcpp. To that end, I followed the process in the appendix of the R extensions manual, including your point point to seek out and install Rtools from Murdoch-Sutherland. I then tried a simple inline example without any library reference it built and executed fine. When I attempted to compile the inline example that includes the GSL library, it wasn't able to find any GSL header file locations to make the build. In particular, I received the following error message: fatal error: gsl/gsl_rng.h: No such file or directory When running firstExample() from RccpInlineWithLibsExamples.r. Since I'm able to build, link, execute with Rcpp when not using the GSL library, I know this problem may not be appropriate for this forum, but I'm hoping you may have some insight. My installation of GSL comes via cygwin and I've added the appropriate links (to C:\cygwin\bin and C:\cygwin\usr) in the PATH environment variable, as well as creating two additional environment variables, GSL_INC and GSL_LIB with the appropriate path locations for the GSL include and library files. Yet, nothing seems to work. So I'd be very thankful if you have any ideas on what I might next try. -----Original Message----- From: Dirk Eddelbuettel [mailto:edd at debian.org] Sent: Wednesday, December 08, 2010 8:42 PM To: Savitsky, Terrance Cc: Dirk Eddelbuettel; rcpp-devel at r-forge.wu-wien.ac.at Subject: RE: [Rcpp-devel] Step-by-Step Plan to Code Writing and Testing withRcpp, RcppGSL or RcppArmadillo
On 8 December 2010 at 20:05, Savitsky, Terrance wrote:
| Hello Dirk, I sincerely apologize for how I started the dialogue. May | I have a do-over? Sure. | I am an inexperienced developer. So I'm looking | forward to using Rcpp to improve my productivity and output quality with | writing C++ for R implementation. I will re-read the documents and | presentations you've publicly posted. | | My interest in examples is focused towards imitation before innovation. We actually think along the same lines. What you dismissed earlier as "marketing" is, seen from another angle, a fairly large set of working examples. So let's focus on those. For now, forget RcppArmadillo, RcppGSL, ... and concentrate on just Rcpp. There are numerous examples in the package itself -- see the examples/ subdirectory. Let's get those to work first. | I'll seek out archived examples for this, which will hopefully focus my | start-up efforts. I do, however, have a couple of f/u questions: | | To your point, "How could there not be debugging support with gdb if g++ | is used?" - Does R CMD use the g++ compiler? Since my code is quite Yes. It is essentially the only C++ compiler R uses by default. | long, I just want to find a way to efficiently debug. I can't compile | my Rcpp C++ code (with wrappers around R SEXP objects) outside of R, so Why? We do it all the time with Makefiles. See the examples/ mentioned above. | I'm looking for how to compile with debugging support in R. I typically | write C code and compile and run (via cygwin gcc in Windows) with gdb. Have you ever written any C/C++ code for R? Do you know Cygwin is not supported? When I say 'Rtools' do you have a Pavlovian reflex to the Murdock-Sutherland site? You better do ... See 'Writing R Extensions' for starters. In a nutshell you need a set of compilers etc just for R. Luckily these have been setup. | It's not obvious to me how this process would work when writing Rcpp C++ | code for compilation and implementation in R. | | What IDE do Windows users typically choose for their Rcpp C++ code | writing? Is it any different from the IDE they would use for non-Rcpp | standalone C/C++ code not interfaced with R? Well personally speaking I use the same IDE on all platforms: Emacs. Within the Rcpp Core team, some of us work on OS X and some work on Linux. But it should not matter: R and R add-ons like Rcpp work on Windows, OS X and Linux. Use whichever platform you find easiest. Personally, I like Ubuntu and Debian a lot. Dirk | | Terrance Savitsky | | |
| On 8 December 2010 at 17:44, Savitsky, Terrance wrote:
| | I?m having difficulty to find ?How-to? documentation; the papers and | | presentations (including the RcppExamples package) are exciting, but | focus on | | marketing use, | | Nice way to start a dialogue with us by telling us we're idiots. Keep | going. | | | rather than providing instructions. I?d appreciate any help to | | get started to: | | | | 1. Code C++ using the Rcpp, RcppGSL and RcppArmadillo libraries. | | | I don't know how many example we posted on blogs, this list and in | presentations. Exactly which did not work? | | | | | a. May I link my IDE (netbeans) to the lib.a files and use the | | appropriate .h files for composing C++ code for compilation in R? | | Don't know, don't care. Ex-ant this is for __R__ where the command is | 'R CMD ...' | and/or Makefiles. | | If you need netbeans, you get to figure out netbeans. Exiciting to be | trailblazer, eh? | | | b. Do RcppGSL and RcppArmadillo contain the Rcpp classes or | should the | | header files from both be included (e.g. #include Rcpp.h, #include | | RcppArmadillo.h) | | Have you looked at the examples. They work, and they provide the anwwer. | | | c. The matrix and vector classes, including views, Rcpp | implementation of | | the C library GSL employs new C++ capabilities and different syntax | (e.g. | | extraction of pointers from matrix or vector view objects). Is there | detailed | | documentation with examples for these class implementations. The | differences | | from GSL disable using that documentation. | | I have no idea what you are trying to say here. You are mixing two core | APIs | (Views in Rcpp only exist in the classic API) and two 'glued-on' | libraries | one of which is C --- so there are bound to differences. | | | d. Should RcppExport be used in place of ?extern C? in C++ under | Rcpp | | whenever we wish to input R data types such as matrix, vector and list | (due to | | need to call .Call)? | | Look at the definiton and decide for yourself. Using the define has the | advantage that should we ever change it ... | | | 2. Compile and debug code using Inline or other preferred | alternatives. | | | | a. The illustrations in presentations seem to copy and paste the | entire | | code from C++ in single quotes with an assignment to a variable | subsequently | | used with inline in R. My code (a Bayesian MCMC implementation) will | be on the | | order of 600 lines long with about 10 input variables. Is there a | better way | | to use inline? | | Up to you. Inline is for experimentation. We had a MCMC example on the | list | following Whit's question. Did you look at it? | | | b. Is there any help on code debugging? (e.g. some equivalent of | ?gdb?). | | How could there not be debugging support with gdb if g++ is used? | | | 3. Writing a package. | | Seen the Vignette? | | | a. What is the ?LinkingTo? declaration ? what purpose does it | serve and | | where is it used? | | | | b. Same for Makevars and Makevars.win? | | See 'Writing R Extensions' | | Dirk | | | | Thanks, Terrance Savitsky | | | | | | | | | | | ________________________________________________________________________ | __ | | | | This email message is for the sole use of the intended recipient(s) | and | | may contain confidential information. Any unauthorized review, use, | | disclosure or distribution is prohibited. If you are not the intended | | recipient, please contact the sender by reply email and destroy all | copies | | of the original message. | | | | ---------------------------------------------------------------------- | | _______________________________________________ | | Rcpp-devel mailing list | | Rcpp-devel at lists.r-forge.r-project.org | | | https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel | | -- | Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com __________________________________________________________________________ This email message is for the sole use of the intended recipient(s) and may contain confidential information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
On 9 December 2010 at 19:48, Savitsky, Terrance wrote:
| Hi again, Thanks for your very helpful suggestions; you're right - I
| need to just concentrate on Rcpp. To that end, I followed the process
| in the appendix of the R extensions manual, including your point point
| to seek out and install Rtools from Murdoch-Sutherland. I then tried a
| simple inline example without any library reference it built and
| executed fine.
Good -- it is an important milestone to be able to run of some of these.
| When I attempted to compile the inline example that
| includes the GSL library, it wasn't able to find any GSL header file
| locations to make the build. In particular, I received the following
| error message:
|
| fatal error: gsl/gsl_rng.h: No such file or directory
Yes -- these are old and less polished examples. In particular, note the
lines
cppargs="-I/usr/include",
libargs="-lgsl -lgslcblas")
which happen to work on Linux systems such as mine.
At a minimum, you will need something like
cppargs="-IC:/gsl/include",
libargs="-LC:/gsl/lib -lgsl -lgslcblas")
but also read on.
| When running firstExample() from RccpInlineWithLibsExamples.r. Since
| I'm able to build, link, execute with Rcpp when not using the GSL
| library, I know this problem may not be appropriate for this forum, but
| I'm hoping you may have some insight. My installation of GSL comes via
| cygwin and I've added the appropriate links (to C:\cygwin\bin and
| C:\cygwin\usr) in the PATH environment variable, as well as creating two
| additional environment variables, GSL_INC and GSL_LIB with the
| appropriate path locations for the GSL include and library files. Yet,
| nothing seems to work. So I'd be very thankful if you have any ideas on
| what I might next try.
As I alluded to yesterday, Cygwin != MinGW. You may have to rebuild the GSL
just to use it with MinGW and R. That's how it is on Windows...
That problem is however not Rcpp-specific, so it might be best to seek help
elsewhere. In essence, you need to be to able to build a R package using the
GSL on Windows. Last we check (quite recently) that comprises a dozen
packages: copula, dynamo, gsl, gstat, magnets, mvabund, QRMlib, RBrownie,
RDieHarder, RHmm, segclust, surveillance, and topicmodels.
Some of these have other Depends: and you don't want that -- more work just
for testing. Pick a simple one, and see if you can build it from source.
Lastly, if you just need linear algebra, RNGs, ... then Armadillo can help
and RcppArmadillo gives it to you via Templates -- no libraries needed.
Dirk
|
| -----Original Message-----
| From: Dirk Eddelbuettel [mailto:edd at debian.org]
| Sent: Wednesday, December 08, 2010 8:42 PM
| To: Savitsky, Terrance
| Cc: Dirk Eddelbuettel; rcpp-devel at r-forge.wu-wien.ac.at
| Subject: RE: [Rcpp-devel] Step-by-Step Plan to Code Writing and Testing
| withRcpp, RcppGSL or RcppArmadillo
|
|
| On 8 December 2010 at 20:05, Savitsky, Terrance wrote:
| | Hello Dirk, I sincerely apologize for how I started the dialogue. | May | | I have a do-over? | | Sure. | | | I am an inexperienced developer. So I'm looking | | forward to using Rcpp to improve my productivity and output quality | with | | writing C++ for R implementation. I will re-read the documents and | | presentations you've publicly posted. | | | | My interest in examples is focused towards imitation before | innovation. | | We actually think along the same lines. What you dismissed earlier as | "marketing" is, seen from another angle, a fairly large set of working | examples. So let's focus on those. | | For now, forget RcppArmadillo, RcppGSL, ... and concentrate on just | Rcpp. | There are numerous examples in the package itself -- see the examples/ | subdirectory. Let's get those to work first. | | | I'll seek out archived examples for this, which will hopefully focus | my | | start-up efforts. I do, however, have a couple of f/u questions: | | | | To your point, "How could there not be debugging support with gdb if | g++ | | is used?" - Does R CMD use the g++ compiler? Since my code is quite | | Yes. It is essentially the only C++ compiler R uses by default. | | | long, I just want to find a way to efficiently debug. I can't compile | | my Rcpp C++ code (with wrappers around R SEXP objects) outside of R, | so | | Why? We do it all the time with Makefiles. See the examples/ mentioned | above. | | | I'm looking for how to compile with debugging support in R. I | typically | | write C code and compile and run (via cygwin gcc in Windows) with gdb. | | Have you ever written any C/C++ code for R? Do you know Cygwin is not | supported? | | When I say 'Rtools' do you have a Pavlovian reflex to the | Murdock-Sutherland | site? You better do ... See 'Writing R Extensions' for starters. | | In a nutshell you need a set of compilers etc just for R. Luckily these | have | been setup. | | | It's not obvious to me how this process would work when writing Rcpp | C++ | | code for compilation and implementation in R. | | | | What IDE do Windows users typically choose for their Rcpp C++ code | | writing? Is it any different from the IDE they would use for non-Rcpp | | standalone C/C++ code not interfaced with R? | | Well personally speaking I use the same IDE on all platforms: Emacs. | Within | the Rcpp Core team, some of us work on OS X and some work on Linux. But | it | should not matter: R and R add-ons like Rcpp work on Windows, OS X and | Linux. | Use whichever platform you find easiest. Personally, I like Ubuntu and | Debian a lot. | | Dirk | | | | | | Terrance Savitsky | | | | | |
| | On 8 December 2010 at 17:44, Savitsky, Terrance wrote:
| | | I?m having difficulty to find ?How-to? documentation; the papers | and | | | presentations (including the RcppExamples package) are exciting, but | | focus on | | | marketing use, | | | | Nice way to start a dialogue with us by telling us we're idiots. Keep | | going. | | | | | rather than providing instructions. I?d appreciate any help to | | | get started to: | | | | | | 1. Code C++ using the Rcpp, RcppGSL and RcppArmadillo | libraries. | | | | | | I don't know how many example we posted on blogs, this list and in | | presentations. Exactly which did not work? | | | | | | | | | a. May I link my IDE (netbeans) to the lib.a files and use the | | | appropriate .h files for composing C++ code for compilation in R? | | | | Don't know, don't care. Ex-ant this is for __R__ where the command is | | 'R CMD ...' | | and/or Makefiles. | | | | If you need netbeans, you get to figure out netbeans. Exiciting to be | | trailblazer, eh? | | | | | b. Do RcppGSL and RcppArmadillo contain the Rcpp classes or | | should the | | | header files from both be included (e.g. #include Rcpp.h, #include | | | RcppArmadillo.h) | | | | Have you looked at the examples. They work, and they provide the | anwwer. | | | | | c. The matrix and vector classes, including views, Rcpp | | implementation of | | | the C library GSL employs new C++ capabilities and different syntax | | (e.g. | | | extraction of pointers from matrix or vector view objects). Is | there | | detailed | | | documentation with examples for these class implementations. The | | differences | | | from GSL disable using that documentation. | | | | I have no idea what you are trying to say here. You are mixing two | core | | APIs | | (Views in Rcpp only exist in the classic API) and two 'glued-on' | | libraries | | one of which is C --- so there are bound to differences. | | | | | d. Should RcppExport be used in place of ?extern C? in C++ | under | | Rcpp | | | whenever we wish to input R data types such as matrix, vector and | list | | (due to | | | need to call .Call)? | | | | Look at the definiton and decide for yourself. Using the define has | the | | advantage that should we ever change it ... | | | | | 2. Compile and debug code using Inline or other preferred | | alternatives. | | | | | | a. The illustrations in presentations seem to copy and paste | the | | entire | | | code from C++ in single quotes with an assignment to a variable | | subsequently | | | used with inline in R. My code (a Bayesian MCMC implementation) | will | | be on the | | | order of 600 lines long with about 10 input variables. Is there a | | better way | | | to use inline? | | | | Up to you. Inline is for experimentation. We had a MCMC example on the | | list | | following Whit's question. Did you look at it? | | | | | b. Is there any help on code debugging? (e.g. some equivalent | of | | ?gdb?). | | | | How could there not be debugging support with gdb if g++ is used? | | | | | 3. Writing a package. | | | | Seen the Vignette? | | | | | a. What is the ?LinkingTo? declaration ? what purpose does it | | serve and | | | where is it used? | | | | | | b. Same for Makevars and Makevars.win? | | | | See 'Writing R Extensions' | | | | Dirk | | | | | | | Thanks, Terrance Savitsky | | | | | | | | | | | | | | | | | | ________________________________________________________________________ | | __ | | | | | | This email message is for the sole use of the intended recipient(s) | | and | | | may contain confidential information. Any unauthorized review, use, | | | disclosure or distribution is prohibited. If you are not the | intended | | | recipient, please contact the sender by reply email and destroy all | | copies | | | of the original message. | | | | | | | ---------------------------------------------------------------------- | | | _______________________________________________ | | | Rcpp-devel mailing list | | | Rcpp-devel at lists.r-forge.r-project.org | | | | | | https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel | | | | -- | | Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com | | -- | Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com | | __________________________________________________________________________ | | This email message is for the sole use of the intended recipient(s) and | may contain confidential information. Any unauthorized review, use, | disclosure or distribution is prohibited. If you are not the intended | recipient, please contact the sender by reply email and destroy all copies | of the original message. |
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com