Rcpp Version 0.9.10
unif.h
Go to the documentation of this file.
00001 
00002 // -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 4 -*-
00003 //
00004 // auto generated file (from script/stats.R) 
00005 //
00006 // unif.h: Rcpp R/C++ interface class library -- 
00007 //
00008 // Copyright (C) 2010 - 2011 Douglas Bates, Dirk Eddelbuettel and Romain Francois
00009 //
00010 // This file is part of Rcpp.
00011 //
00012 // Rcpp is free software: you can redistribute it and/or modify it
00013 // under the terms of the GNU General Public License as published by
00014 // the Free Software Foundation, either version 2 of the License, or
00015 // (at your option) any later version.
00016 //
00017 // Rcpp is distributed in the hope that it will be useful, but
00018 // WITHOUT ANY WARRANTY; without even the implied warranty of
00019 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020 // GNU General Public License for more details.
00021 //
00022 // You should have received a copy of the GNU General Public License
00023 // along with Rcpp.  If not, see <http://www.gnu.org/licenses/>.
00024 
00025 #ifndef Rcpp__stats__unif_h
00026 #define Rcpp__stats__unif_h
00027 
00028 namespace Rcpp {
00029 namespace stats {
00030 
00031 inline double dunif_1(double x, double a/*, double b [=1.]*/ , int give_log){
00032         return ::Rf_dunif(x, a, 1.0, give_log ) ;
00033 }
00034 inline double dunif_0( double x /*, double a [=0.], double b [=1.]*/ , int give_log){
00035 #ifdef IEEE_754
00036     if (ISNAN(x) )
00037         return x + 1.0 ;
00038 #endif
00039     
00040     if (0.0 <= x && x <= 1.0) return give_log ? 0.0 : 1.0 ;
00041     return R_D__0;
00042 }
00043 
00044 
00045 inline double punif_1(double x, double a /*, double b [=1.0]*/, int lower_tail, int log_p) {
00046         return ::Rf_punif( x, a, 1.0, lower_tail, log_p ) ;
00047 }
00048 inline double punif_0(double x /*, double a [=0.0], double b [=1.0]*/, int lower_tail, int log_p) {
00049 #ifdef IEEE_754
00050     if (ISNAN(x))
00051         return x + 1.0 ;
00052 #endif
00053     if (x >= 1.0)
00054         return R_DT_1;
00055     if (x <= 0.0)
00056         return R_DT_0;
00057     if (lower_tail) return R_D_val(x);
00058     else return R_D_val(1-x);
00059         
00060 }
00061 
00062 inline double qunif_1(double p, double a /*, double b [=1.0] */, int lower_tail, int log_p) {
00063 #ifdef IEEE_754
00064     if (ISNAN(p) || ISNAN(a) )
00065         return p + a + 1.0 ;
00066 #endif
00067     R_Q_P01_check(p);
00068     if (!R_FINITE(a) ) return R_NaN;
00069     if (1.0 < a) return R_NaN;
00070     if (1.0 == a) return a;
00071 
00072     return a + R_DT_qIv(p) * (1.0 - a);
00073 }
00074 inline double qunif_0(double p /*, double a [=0.0], double b [=1.0] */, int lower_tail, int log_p) {
00075 #ifdef IEEE_754
00076     if (ISNAN(p)  )
00077         return p + 1.0 ;
00078 #endif
00079     R_Q_P01_check(p);
00080     
00081     return R_DT_qIv(p) ;
00082 }
00083 
00084 
00085 } // stats
00086 } // Rcpp
00087 
00088 RCPP_DPQ_0(unif, Rcpp::stats::dunif_0, Rcpp::stats::punif_0, Rcpp::stats::qunif_0 )
00089 RCPP_DPQ_1(unif, Rcpp::stats::dunif_1, Rcpp::stats::punif_1, Rcpp::stats::qunif_1 )   
00090 RCPP_DPQ_2(unif, ::Rf_dunif, ::Rf_punif, ::Rf_qunif )
00091 
00092 #endif
00093 
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Defines