Rcpp Version 0.12.12
math.h
Go to the documentation of this file.
1 // -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*-
2 //
3 // SugarBlock.h: Rcpp R/C++ interface class library -- sugar functions
4 //
5 // Copyright (C) 2010 - 2011 Dirk Eddelbuettel and Romain Francois
6 //
7 // This file is part of Rcpp.
8 //
9 // Rcpp is free software: you can redistribute it and/or modify it
10 // under the terms of the GNU General Public License as published by
11 // the Free Software Foundation, either version 2 of the License, or
12 // (at your option) any later version.
13 //
14 // Rcpp is distributed in the hope that it will be useful, but
15 // WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 // GNU General Public License for more details.
18 //
19 // You should have received a copy of the GNU General Public License
20 // along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
21 
22 #ifndef RCPP_SUGAR_MATH_H
23 #define RCPP_SUGAR_MATH_H
24 
26 VECTORIZED_MATH_1(acos,::acos)
27 VECTORIZED_MATH_1(asin,::asin)
28 VECTORIZED_MATH_1(atan,::atan)
29 VECTORIZED_MATH_1(ceil,::ceil)
30 VECTORIZED_MATH_1(ceiling,::ceil)
31 VECTORIZED_MATH_1(cos,::cos)
32 VECTORIZED_MATH_1(cosh,::cosh)
33 VECTORIZED_MATH_1(floor,::floor)
35 VECTORIZED_MATH_1(log10,::log10)
36 VECTORIZED_MATH_1(sqrt,::sqrt)
37 VECTORIZED_MATH_1(sin,::sin)
38 VECTORIZED_MATH_1(sinh,::sinh)
39 VECTORIZED_MATH_1(tan,::tan)
40 VECTORIZED_MATH_1(tanh,::tanh)
41 
42 VECTORIZED_MATH_1(abs,::fabs)
43 
44 VECTORIZED_MATH_1(gamma , ::Rf_gammafn )
45 VECTORIZED_MATH_1(lgamma , ::Rf_lgammafn )
46 VECTORIZED_MATH_1(digamma , ::Rf_digamma )
47 VECTORIZED_MATH_1(trigamma , ::Rf_trigamma )
48 VECTORIZED_MATH_1(tetragamma , ::Rf_tetragamma )
49 VECTORIZED_MATH_1(pentagamma , ::Rf_pentagamma )
50 VECTORIZED_MATH_1(expm1 , ::expm1 )
51 VECTORIZED_MATH_1(log1p , ::log1p )
52 
53 namespace Rcpp{
54  namespace internal{
55  extern "C" inline double factorial( double x ){ return ::Rf_gammafn( x + 1.0 ) ; }
56  extern "C" inline double lfactorial( double x ){ return ::Rf_lgammafn( x + 1.0 ) ; }
57  }
58 }
61 
62 SUGAR_BLOCK_2(choose , ::Rf_choose )
63 SUGAR_BLOCK_2(lchoose , ::Rf_lchoose )
64 SUGAR_BLOCK_2(beta , ::Rf_beta )
65 SUGAR_BLOCK_2(lbeta , ::Rf_lbeta )
66 SUGAR_BLOCK_2(psigamma , ::Rf_psigamma )
67 
68 VECTORIZED_MATH_1(trunc, ::Rf_ftrunc) // truncates to zero (cf Writing R Extension, 6.7.3 Numerical Utilities)
69 SUGAR_BLOCK_2(round, ::Rf_fround) // rounds 'x' to 'digits' decimals digits (used by R's round())
70 SUGAR_BLOCK_2(signif, ::Rf_fprec) // rounds 'x' to 'digits' significant digits (used by R's signif())
71 
72 #endif
#define SUGAR_BLOCK_2(__NAME__, __SYMBOL__)
Definition: SugarBlock_2.h:92
void sqrt(InputIterator begin, InputIterator end, OutputIterator out)
Definition: algorithm.h:479
double digamma(double x)
Definition: Rmath.h:197
double pentagamma(double x)
Definition: Rmath.h:200
double lbeta(double a, double b)
Definition: Rmath.h:203
void exp(InputIterator begin, InputIterator end, OutputIterator out)
Definition: algorithm.h:474
double psigamma(double x, double deriv)
Definition: Rmath.h:196
double trigamma(double x)
Definition: Rmath.h:198
double expm1(double x)
double beta(double a, double b)
Definition: Rmath.h:202
double lchoose(double n, double k)
Definition: Rmath.h:206
double log1p(double x)
double choose(double n, double k)
Definition: Rmath.h:205
double lfactorial(double x)
Definition: math.h:56
void log(InputIterator begin, InputIterator end, OutputIterator out)
Definition: algorithm.h:469
VECTORIZED_MATH_1(trunc,::Rf_ftrunc) SUGAR_BLOCK_2(round
Rcpp API.
Definition: algo.h:28
double factorial(double x)
Definition: math.h:55
double tetragamma(double x)
Definition: Rmath.h:199