Skip to content
Back to formatted view

Raw Message

Message-ID: <CAGkGB67vUymw87jA4fASk7zdFJiGas5djdjLYgg-ym+V63hbPw@mail.gmail.com>
Date: 2017-02-22T14:58:35Z
From: Eridk Poliruyt
Subject: [Rcpp-devel] Rcpp sugar for double?

Hi, I just tried to calculate the density of a normal variable using dnorm.
I found that if the input is of type NumericVector, then it was fine. But
if the input is of type double, it yielded error in compilation. For
example:

 // [[Rcpp::export]]
NumericVector test5(NumericVector x)
{
  NumericVector y = dnorm(x,5.0,2.0,true);
  return(y);
}

and

// [[Rcpp::export]]
double test6(double x)
{
  double y = dnorm(x,5.0,2.0,true);
  return(y);
}

May I ask why and how can I calculate this density (and call other common
functions like dbeta, dt, beta, gamma, lbeta, lgamma, etc...) on double
input?

Many thanks,
Eridk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20170222/61f9ac15/attachment.html>