Rcpp Version 0.12.12
unif.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 // auto generated file (from script/stats.R)
4 //
5 // unif.h: Rcpp R/C++ interface class library --
6 //
7 // Copyright (C) 2010 - 2016 Douglas Bates, Dirk Eddelbuettel and Romain Francois
8 //
9 // This file is part of Rcpp.
10 //
11 // Rcpp is free software: you can redistribute it and/or modify it
12 // under the terms of the GNU General Public License as published by
13 // the Free Software Foundation, either version 2 of the License, or
14 // (at your option) any later version.
15 //
16 // Rcpp is distributed in the hope that it will be useful, but
17 // WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU General Public License for more details.
20 //
21 // You should have received a copy of the GNU General Public License
22 // along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
23 
24 #ifndef Rcpp__stats__unif_h
25 #define Rcpp__stats__unif_h
26 
27 namespace Rcpp {
28 namespace stats {
29 
30 inline double dunif_1(double x, double a/*, double b [=1.]*/ ,
31  int give_log) {
32  return ::Rf_dunif(x, a, 1.0, give_log ) ;
33 }
34 inline double dunif_0( double x /*, double a [=0.], double b [=1.]*/ ,
35  int give_log) {
36 #ifdef IEEE_754
37  if (ISNAN(x) )
38  return x + 1.0 ;
39 #endif
40 
41  if (0.0 <= x && x <= 1.0) return give_log ? 0.0 : 1.0 ;
42  return R_D__0;
43 }
44 
45 
46 inline double punif_1(double x, double a /*, double b [=1.0]*/,
47  int lower_tail, int log_p) {
48  return ::Rf_punif( x, a, 1.0, lower_tail, log_p ) ;
49 }
50 inline double punif_0(double x /*, double a [=0.0], double b [=1.0]*/,
51  int lower_tail, int log_p) {
52 #ifdef IEEE_754
53  if (ISNAN(x))
54  return x + 1.0 ;
55 #endif
56  if (x >= 1.0)
57  return R_DT_1;
58  if (x <= 0.0)
59  return R_DT_0;
60  if (lower_tail) return R_D_val(x);
61  else return R_D_val(1-x);
62 
63 }
64 
65 inline double qunif_1(double p, double a /*, double b [=1.0] */,
66  int lower_tail, int log_p) {
67 #ifdef IEEE_754
68  if (ISNAN(p) || ISNAN(a) )
69  return p + a + 1.0 ;
70 #endif
71  R_Q_P01_check(p);
72  if (!R_FINITE(a) ) return R_NaN;
73  if (1.0 < a) return R_NaN;
74  if (1.0 == a) return a;
75 
76  return a + R_DT_qIv(p) * (1.0 - a);
77 }
78 
79 inline double qunif_0(double p /*, double a [=0.0], double b [=1.0] */,
80  int lower_tail, int log_p) {
81 #ifdef IEEE_754
82  if (ISNAN(p) )
83  return p + 1.0 ;
84 #endif
85  R_Q_P01_check(p);
86 
87  return R_DT_qIv(p) ;
88 }
89 
90 
91 } // stats
92 } // Rcpp
93 
96 RCPP_DPQ_2(unif, ::Rf_dunif, ::Rf_punif, ::Rf_qunif )
97 
98 #endif
99 
double punif_0(double x, int lower_tail, int log_p)
Definition: unif.h:50
#define R_DT_qIv(p)
Definition: macros.h:52
#define R_Q_P01_check(p)
Definition: macros.h:68
double qunif_0(double p, int lower_tail, int log_p)
Definition: unif.h:79
#define RCPP_DPQ_1(__NAME__, __D__, __P__, __Q__)
Definition: dpq.h:340
double punif_1(double x, double a, int lower_tail, int log_p)
Definition: unif.h:46
#define R_DT_0
Definition: macros.h:29
#define R_DT_1
Definition: macros.h:30
#define give_log
Definition: macros.h:24
double dunif_1(double x, double a, int give_log)
Definition: unif.h:30
#define RCPP_DPQ_2(__NAME__, __D__, __P__, __Q__)
Definition: dpq.h:363
double dunif_0(double x, int give_log)
Definition: unif.h:34
#define R_D__0
Definition: macros.h:27
double qunif_1(double p, double a, int lower_tail, int log_p)
Definition: unif.h:65
Rcpp API.
Definition: algo.h:28
#define R_D_val(x)
Definition: macros.h:36
#define RCPP_DPQ_0(__NAME__, __D__, __P__, __Q__)
Definition: dpq.h:318