[Rcpp-devel] Step-by-Step Plan to Code Writing and Testing withRcpp, RcppGSL or RcppArmadillo

Savitsky, Terrance savitsky at rand.org
Thu Dec 9 05:05:51 CET 2010


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


More information about the Rcpp-devel mailing list