Skip to content
Back to formatted view

Raw Message

Message-ID: <22701.45385.701457.754049@max.eddelbuettel.com>
Date: 2017-02-22T15:42:01Z
From: Dirk Eddelbuettel
Subject: [Rcpp-devel] Rcpp sugar for double?
In-Reply-To: <CAGkGB67vUymw87jA4fASk7zdFJiGas5djdjLYgg-ym+V63hbPw@mail.gmail.com>

Eridk,

See these Rcpp Gallery article from 2012 for worked examples:

 -  http://gallery.rcpp.org/articles/using-rmath-functions/  
    has an example on pnorm that applies to your dnorm case
    
 -  http://gallery.rcpp.org/articles/random-number-generation/
    discusses the RNGs, but the d/p/q functions behave the same way.

You can search at the Gallery too ...  

So we have all the scalar functions in the R:: namespace, sugar ones in
Rcpp::, you can of course call the R functions as well (though I'd use R::(
plus you get access from Armadillo, Boost, GSL, ... via other packages.

But you need to look closely at the signatures of functions you are calling.
Those expecting a 'double' cannot magically be resolved with a
'Rcpp::NumericVector' as those are different types.

Dirk

-- 
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org