[Rcpp-devel] Call R function
bbonit at tin.it
bbonit at tin.it
Wed Jun 20 07:52:42 CEST 2012
Hello i would like to compute the following code ;
Where R_user_F is a R function (i could write this function directly inin line but is only for example because i want to call an R function more complex):
so when compile appear this error message: error:
"cannot convert 'Rcpp::sugar::Comparator_With_One_Value<14, Rcpp::sugar::greater_or_equal<14>, true, Rcpp::sugar::Minus_Vector_Vector<14, true, Rcpp::Vector<14>, true, Rcpp::Vector<14> > >' to 'bool' in initialization."
I can do for solve this problem? Thank You.
The code:
R_user_F<-function (par) {
y<-par[1]
x<-par[2]
dnorm(x)*dnorm(y)
}
require(inline)
code <- '
NumericVector f1;
NumericVector f2;
NumericVector par1;
NumericVector par2;
NumericVector a=2;
NumericVector b=3;
NumericVector par =par;
par1=par*b;
par2=par*a;
Function R_userf(fun);
f1=R_userf(par1);
f2=R_userf(par2);
bool u = (Rf_runif(0.0,1.0) <= f2-f1 );
'
RcppGibbs <- cxxfunction(signature( par ="NumericVector", fun="function"),
code,
include='#include <math.h>',
plugin="Rcpp")<-function (par) {
y<-par[1]
x<-par[2]
dnorm(x)*dnorm(y)
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20120620/61559d9c/attachment.html>
More information about the Rcpp-devel
mailing list