I need to use beta function Beta(a, b) in my calculation in Rcpp. A simple code example I wrote is here:
cppFunction('double getbeta(double a, double b){
double res = beta(a, b);
return res;
}')
But I got an error in R saying that
no matching function for call to 'beta'
Is it because we cannot use Beta function in Rcpp? If we could, is there the corresponding function
lbeta
can be used?
Use the R::
namespace for the scalar-value functions (and Rcpp::
for vectorised sugar functions):
R> library(Rcpp)
R> cppFunction('double getbeta(double a, double b){
+ double res = R::beta(a, b);
+ return res;
+ }')
R> getbeta(1.0, 2.0)
[1] 0.5
R>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.