Rcpp Version 1.0.14
Loading...
Searching...
No Matches
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
25VECTORIZED_MATH_1(exp,::exp)
26VECTORIZED_MATH_1(acos,::acos)
27VECTORIZED_MATH_1(asin,::asin)
28VECTORIZED_MATH_1(atan,::atan)
29VECTORIZED_MATH_1(ceil,::ceil)
30VECTORIZED_MATH_1(ceiling,::ceil)
31VECTORIZED_MATH_1(cos,::cos)
32VECTORIZED_MATH_1(cosh,::cosh)
33VECTORIZED_MATH_1(floor,::floor)
34VECTORIZED_MATH_1(log,::log)
35VECTORIZED_MATH_1(log10,::log10)
36VECTORIZED_MATH_1(sqrt,::sqrt)
37VECTORIZED_MATH_1(sin,::sin)
38VECTORIZED_MATH_1(sinh,::sinh)
39VECTORIZED_MATH_1(tan,::tan)
40VECTORIZED_MATH_1(tanh,::tanh)
41
42VECTORIZED_MATH_1(abs,::fabs)
43
44VECTORIZED_MATH_1(gamma , ::Rf_gammafn )
45VECTORIZED_MATH_1(lgamma , ::Rf_lgammafn )
46VECTORIZED_MATH_1(digamma , ::Rf_digamma )
47VECTORIZED_MATH_1(trigamma , ::Rf_trigamma )
48VECTORIZED_MATH_1(tetragamma , ::Rf_tetragamma )
49VECTORIZED_MATH_1(pentagamma , ::Rf_pentagamma )
50VECTORIZED_MATH_1(expm1 , ::expm1 )
51VECTORIZED_MATH_1(log1p , ::log1p )
52
53namespace 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
62SUGAR_BLOCK_2(choose , ::Rf_choose )
63SUGAR_BLOCK_2(lchoose , ::Rf_lchoose )
64SUGAR_BLOCK_2(beta , ::Rf_beta )
65SUGAR_BLOCK_2(lbeta , ::Rf_lbeta )
66SUGAR_BLOCK_2(psigamma , ::Rf_psigamma )
67
68VECTORIZED_MATH_1(trunc, ::Rf_ftrunc) // truncates to zero (cf Writing R Extension, 6.7.3 Numerical Utilities)
69SUGAR_BLOCK_2(round, ::Rf_fround) // rounds 'x' to 'digits' decimals digits (used by R's round())
70SUGAR_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__)
#define VECTORIZED_MATH_1(__NAME__, __SYMBOL__)
double lfactorial(double x)
Definition math.h:56
double factorial(double x)
Definition math.h:55
Rcpp API.
Definition algo.h:28