Rcpp Version 1.0.9
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)
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 )
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
VECTORIZED_MATH_1(trunc, ::Rf_ftrunc) SUGAR_BLOCK_2(round
double expm1(double x)
double trigamma(double x)
Definition: Rmath.h:198
double lbeta(double a, double b)
Definition: Rmath.h:203
double tetragamma(double x)
Definition: Rmath.h:199
double log1p(double x)
double lchoose(double n, double k)
Definition: Rmath.h:206
double choose(double n, double k)
Definition: Rmath.h:205
double digamma(double x)
Definition: Rmath.h:197
double beta(double a, double b)
Definition: Rmath.h:202
double psigamma(double x, double deriv)
Definition: Rmath.h:196
double pentagamma(double x)
Definition: Rmath.h:200
void exp(InputIterator begin, InputIterator end, OutputIterator out)
Definition: algorithm.h:474
void log(InputIterator begin, InputIterator end, OutputIterator out)
Definition: algorithm.h:469
void sqrt(InputIterator begin, InputIterator end, OutputIterator out)
Definition: algorithm.h:479
double lfactorial(double x)
Definition: math.h:56
double factorial(double x)
Definition: math.h:55
Rcpp API.
Definition: algo.h:28