I am writing a Rcpp code as below:
// [[Rcpp::depends(RcppArmadillo)]]
// [[Rcpp::depends(BH)]]
// [[Rcpp::plugins(cpp11)]]
#include
#in
I suggest this to be closed or deleted by OP. The question simply exhibits some allowed-but-not-recommended C++ usage:
cmath
and math.h
, and as stated here you do not need eitherWith this, your code looks like this (still containing a call for C++11 which is not used, but does no harm):
// [[Rcpp::depends(RcppArmadillo)]]
// [[Rcpp::depends(BH)]]
// [[Rcpp::plugins(cpp11)]]
#include <RcppArmadillo.h>
#include <boost/random.hpp>
#include <boost/random/uniform_real_distribution.hpp>
// [[Rcpp::export]]
double ks(const double k, const double alpha, const double mag, const double M0){
double ksres;
ksres= k* std::exp ( alpha*(mag-M0) );
return(ksres);
}
/*** R
ks(1.0, 2.0, 3.0, 4.0)
*/
This compiles without any warning whatsoever on my box (with stringent compiler warnings turned on, output not shown here) and runs as expected too:
R> Rcpp::sourceCpp("/tmp/soQ.cpp")
R> ks(1.0, 2.0, 3.0, 4.0)
[1] 0.135335
R>