Le 24/11/10 19:38, Andrew Redd a écrit :
I'm having a problem with sugar expressions that I can't figure out.
I have these two functions that are sampling and prior functions for
two different parameters of an MCMC model. BTW this is part of my big
CUDA project, so I pass these as pointers into other functions.
---
numeric rb1(numeric a, numeric b){return Rcpp::rbeta(1,a,b)[0];}
numeric pr_trans(numeric x){return Rcpp::dnorm(x,0.0, 1024.0)[0];}
---
the first works fine but the second gives a compile error that
error: no matching function for call to ‘dnorm4(numeric&, double, double)’
numeric is typedef double. I don't see why this fails. Any ideas?
thanks,
Andrew
The first argument of dnorm is a numeric sugar expression (for example
NumericVector).
Try this :
numeric pr_trans(numeric x){return dnorm( NumericVector::create(x)
,0.0, 1024.0)[0];}
Romain
--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://bit.ly/9VOd3l : ZAT! 2010
|- http://bit.ly/c6DzuX : Impressionnism with R
`- http://bit.ly/czHPM7 : Rcpp Google tech talk on youtube
_______________________________________________
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