Dirk, Maybe I didn't explain it well enough. The question absolutely pertains to using the inline functionality.
As each new data arrives, I want to pass it to my C++ function. If this were a pure C++ implementation, then I would just append an STL vector and pass a pointer of that vector to the function. However, since this is R, I don't see how to do that. I can, of course, keep a vector in R and pass the entire vector to the C++ function. That will, however slow things down significantly. Ultimately, I'dl like to have R pass each new data point to the C++ function, and have that function manage keeping the appropriate length window of past data points. (Again, trivial to do in pure C++). This really is an issue of persistent object and passing between R and C++. I want a persistent C++ vector, not an R data structure. (Having C++ manage the vector will be much faster.) -- Noah Silverman UCLA Department of Statistics 8117 Math Sciences Building #8208 Los Angeles, CA 90095 On Sep 7, 2011, at 2:56 PM, Dirk Eddelbuettel wrote: > > On 7 September 2011 at 14:46, Noah Silverman wrote: > | Hi, > | > | > | I'm writing a function using Rcpp through inline. This function will be a > | filter on an incoming data stream. > | > | I need to keep the past several data values so that they are accessible to > the > | function each time it is called. This is easy to do with a data structure > in > | R (and then passing subsequent structure to the C++ function) but that seems > | rather slow. Is there some way to define a persistent object that is > | accessible to an Inline function using Rcpp? > | > | > | If the code was in pure C++, it would be trivial to have an object and then > | just pass a pointer to that object. I can't figure out how to do the same > | thing with R+Rcpp+inline. > > i) Read up on the 'static' argument for variable declarations in C and C++. > > ii) Rethink your architecture, maybe have an 'agent' operate on the stream > and report to a persisting 'broker' that keeps state. > > iii) Read up on persisting data as a general issue. > > > This has little to do with Rcpp and your preference of inline over packages, > but rather with how to think in code (and/or C++) and that is NOT a topic > covered on this list. > > Let's please try to keep focus on Rcpp and related questions here. > > Dirk > > > | Thanks! > | > | -- > | Noah Silverman > | UCLA Department of Statistics > | 8117 Math Sciences Building #8208 > | Los Angeles, CA 90095 > | > | > | ---------------------------------------------------------------------- > | _______________________________________________ > | Rcpp-devel mailing list > | Rcpp-devel@lists.r-forge.r-project.org > | https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel > -- > Two new Rcpp master classes for R and C++ integration scheduled for > New York (Sep 24) and San Francisco (Oct 8), more details are at > http://dirk.eddelbuettel.com/blog/2011/08/04#rcpp_classes_2011-09_and_2011-10 > http://www.revolutionanalytics.com/products/training/public/rcpp-master-class.php
_______________________________________________ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel