1-
2- // -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 4 -*-
1+ // -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*-
32//
43// auto generated file (from script/stats.R)
54//
65// exp.h: Rcpp R/C++ interface class library --
76//
8- // Copyright (C) 2010 - 2011 Douglas Bates, Dirk Eddelbuettel and Romain Francois
7+ // Copyright (C) 2010 - 2016 Douglas Bates, Dirk Eddelbuettel and Romain Francois
98//
109// This file is part of Rcpp.
1110//
2726
2827namespace Rcpp {
2928namespace stats {
30- inline double d_exp_0 (double x, int give_log) {
31-
32- #ifdef IEEE_754
33- /* NaNs propagated correctly */
34- if (ISNAN (x)) return x + 1.0 ;
35- #endif
36-
37- if (x < 0 .)
38- return R_D__0;
39- return give_log ? (-x) : ::exp (-x);
40- }
41- inline double q_exp_0 (double p, int lower_tail, int log_p) {
42- #ifdef IEEE_754
43- if (ISNAN (p)) return p + 1.0 ;
44- #endif
45-
46- if ((log_p && p > 0 ) || (!log_p && (p < 0 || p > 1 ))) return R_NaN;
47- if (p == R_DT_0)
48- return 0 ;
49-
50- return - R_DT_Clog (p);
51- }
52- inline double p_exp_0 (double x, int lower_tail, int log_p) {
53- #ifdef IEEE_754
54- if (ISNAN (x)) return x + 1.0 ;
55- #endif
56-
57- if (x <= 0 .)
58- return R_DT_0;
59- /* same as weibull(shape = 1): */
60- x = -x;
61- if (lower_tail)
62- return (log_p
63- /* log(1 - exp(x)) for x < 0 : */
64- ? (x > -M_LN2 ? ::log (-::expm1 (x)) : ::log1p (-::exp (x)))
65- : -::expm1 (x));
66- /* else: !lower_tail */
67- return R_D_exp (x);
68- }
29+
30+ inline double d_exp_0 (double x, int give_log) {
31+
32+ #ifdef IEEE_754
33+ /* NaNs propagated correctly */
34+ if (ISNAN (x)) return x + 1.0 ;
35+ #endif
36+
37+ if (x < 0 .)
38+ return R_D__0;
39+ return give_log ? (-x) : ::exp (-x);
40+ }
41+
42+ inline double q_exp_0 (double p, int lower_tail, int log_p) {
43+ #ifdef IEEE_754
44+ if (ISNAN (p)) return p + 1.0 ;
45+ #endif
46+
47+ if ((log_p && p > 0 ) || (!log_p && (p < 0 || p > 1 ))) return R_NaN;
48+ if (p == R_DT_0)
49+ return 0 ;
50+
51+ return - R_DT_Clog (p);
52+ }
53+
54+ inline double p_exp_0 (double x, int lower_tail, int log_p) {
55+ #ifdef IEEE_754
56+ if (ISNAN (x)) return x + 1.0 ;
57+ #endif
58+
59+ if (x <= 0 .)
60+ return R_DT_0;
61+ /* same as weibull(shape = 1): */
62+ x = -x;
63+ if (lower_tail)
64+ return (log_p
65+ /* log(1 - exp(x)) for x < 0 : */
66+ ? (x > -M_LN2 ? ::log (-::expm1 (x)) : ::log1p (-::exp (x)))
67+ : -::expm1 (x));
68+ /* else: !lower_tail */
69+ return R_D_exp (x);
70+ }
6971
7072} // stats
7173} // Rcpp
@@ -77,17 +79,17 @@ namespace Rcpp{
7779// we cannot use the RCPP_DPQ_1 macro here because of rate and shape
7880template <bool NA, typename T>
7981inline stats::D1<REALSXP,NA,T> dexp ( const Rcpp::VectorBase<REALSXP,NA,T>& x, double shape, bool log = false ) {
80- return stats::D1<REALSXP,NA,T>( ::Rf_dexp, x, 1.0 /shape, log );
82+ return stats::D1<REALSXP,NA,T>( ::Rf_dexp, x, 1.0 /shape, log );
8183}
8284
8385template <bool NA, typename T>
8486inline stats::P1<REALSXP,NA,T> pexp ( const Rcpp::VectorBase<REALSXP,NA,T>& x, double shape, bool lower = true , bool log = false ) {
85- return stats::P1<REALSXP,NA,T>( ::Rf_pexp, x, 1.0 /shape, lower, log );
87+ return stats::P1<REALSXP,NA,T>( ::Rf_pexp, x, 1.0 /shape, lower, log );
8688}
8789
8890template <bool NA, typename T>
8991inline stats::Q1<REALSXP,NA,T> qexp ( const Rcpp::VectorBase<REALSXP,NA,T>& x, double shape, bool lower = true , bool log = false ) {
90- return stats::Q1<REALSXP,NA,T>( ::Rf_qexp, x, 1.0 /shape, lower, log );
92+ return stats::Q1<REALSXP,NA,T>( ::Rf_qexp, x, 1.0 /shape, lower, log );
9193}
9294
9395} // Rcpp
0 commit comments