|
Hello,
I spent last weekend trying to run this piece of code (and a lot of variations too): suppressPackageStartupMessages(require(inline)) suppressPackageStartupMessages(require(Rcpp)) vero.empi.cpp <- ' Rcpp::NumericVector xa(vpf) ; Rcpp::NumericVector xb(vpe) ; Rcpp::NumericVector xc(tempo) ; Rcpp::NumericVector xd(evento) ; int n_xa = xa.size(), n_xb = xb.size(), n_xd = xd.size() ; Rcpp::NumericMatrix vero(n_xa,n_xb) Rcpp::Function d(fun1) ; Rcpp::Function S(fun2) ; float aux ; for (int i = 0; i < n_xa; i++){ for (int j = 0; j < n_xb; j++){ aux = 0 ; for(int k = 0; k < n_xd; k++){ aux = aux*(d(xc[k], xa[i], xb[j])^xd[k])*(S(xc[k], xa[i], xb[j])^(1- xd[k])) ; } vero[i , j] = aux ; } } return vero; ' vero.empi <- cxxfunction( signature(vpf="numeric", vpe="numeric", tempo="numeric", evento="numeric", fun1 = "function", fun2 = "function"), vero.empi.cpp, plugin="Rcpp", include = "using namespace Rcpp; ") The purpose here is to generate a matrix of empirical values of a likelihood. For a first trial, I would like to use the R functions dweibull() and pweibull() in fun1 and fun2, respectively. But it didn't work for some reason I cannot see. Is this possible? Thanks, Prof. Hermes PS.: Sorry for my bad English! |
_______________________________________________ Rcpp-devel mailing list [email protected] https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
