Thanks.

 I did not understand this code

 # C++ source code to operate on function and vector
 cpp<- '
  int n = as<int>(N);
  NumericVector numvec(xvec) ;
  Function f(fun) ;
  for( int i=0; i<n; i++){
   numvec = f( numvec ) ;
  }
  return numvec ;

 I see that f is a Function object but what is fun? And why the looping over 
numvec rather than elements of numvec? Finally, how to use RcppArmadillo to do 
the C++ computations on the R function?

 Best.



On 1/25/2011 12:17 PM, Dirk Eddelbuettel wrote:
On 25 January 2011 at 12:01, Siddhartha Chib wrote:
| Is it possible to pass a user defined function
| written in R for use in rccparma.  For example, is it possible to have a

(What is rccparma?)

| function
| SEXP myfunction(SEXP g, SEXP a)
| where g is a function object and a is a
| matrix, the argument of g?

Have you looked at

      examples/functionCallback/newApiExample.r

which installed with your copy of Rcpp -- it uses Rcpp to sweep a
user-supplied R function over a vector.  Doing this with a matrix is close.

And just for completeness, there is more in other place; my RcppDE riff on
the the DEoptim software allows you to pass objective functions as either R
or C++ functions; the C++ side then needs external pointers.

Hope this helps,  Dirk


--
Siddhartha Chib
Harry C. Hartkopf Professor of Econometrics and Statistics
Olin Business School, Campus Box 1133
Washington University in St. Louis
1 Brookings Dr
St. Louis, MO 63130
(314) 935-4657;    (314) 935-6359 [Fax]
c...@wustl.edu
http://www.olin.wustl.edu/faculty/chib/

_______________________________________________
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

Reply via email to