[Rcpp-devel] How do instantiate an Rccpp and/or Armadillo object and then set it's underlying SEXP later?

Dirk Eddelbuettel edd at debian.org
Tue Oct 25 15:31:44 CEST 2011



On 26 October 2011 at 00:02, Slava Razbash wrote:
| I will illustrate the idea of what I want to do with an example that
| just uses an integer. So for example:
| 
| int myNumber;
| nyNumber = 5;
| 
| So can I do something with Rcpp and SEXP objects as below. I know that
| my code will be wrong but I am trying to convey an idea, so think of
| it a pseudocode.
| Pseudocode "example":
| 
| SEXP myFunction(SEXP myVector_s ) {
|    Rcpp::NumericVector myVector;
|    Rcpp::NumericVector myVector::as(myVector_s);
| 
| }

I don;t understand what that is trying "to convoy". 

| Further, will the following work with RcppArmadillo?
| 
| SEXP myFunction(SEXP myVector_s ) {
|    arma::rowvec myVector;
|    myVector = Rcpp::as<arma::rowvec>(myVector_s);
| 
| }

The second line is correct.  The first line (empty ctor) I am unsure about.
Why don't you test it?

Generally speaking, if the constructor you think you need is not there, and
you really think you need it, then you will have to write a new constructor
yourself.

Alternatively, you can rethink your problem and/or try to figure out how
others have done it.

Trying stating more clearly what you want to do, why/how you want to do it
and what you actually tried plus any applicable errors.  Also don't abuse
this list as a C++ tutorial site.  There are better ones, and we have limited
resources we like to focus on Rcpp.

Thanks, Dirk

-- 
"Outside of a dog, a book is a man's best friend. Inside of a dog, it is too
dark to read." -- Groucho Marx


More information about the Rcpp-devel mailing list