RAPI
Rmath.h
Go to the documentation of this file.
00001 /* -*- C -*-
00002  *  Mathlib : A C Library of Special Functions
00003  *  Copyright (C) 1998-2016  The R Core Team
00004  *  Copyright (C) 2004       The R Foundation
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU Lesser General Public License as published by
00008  *  the Free Software Foundation; either version 2.1 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU Lesser General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU Lesser General Public License
00017  *  along with this program; if not, a copy is available at
00018  *  https://www.R-project.org/Licenses/
00019  *
00020 
00021  * Rmath.h  should contain ALL headers from R's C code in `src/nmath'
00022    -------  such that ``the Math library'' can be used by simply
00023 
00024    ``#include <Rmath.h> ''
00025 
00026    and nothing else.
00027 
00028    It is part of the API and supports 'standalone Rmath'.
00029 
00030 */
00031 #ifndef RMATH_H
00032 #define RMATH_H
00033 
00034 /* Note that on some systems you need to include math.h before the
00035    defines below. If so, define this yourself. */
00036 #ifndef NO_C_HEADERS
00037 /* needed for cospi etc */
00038 # ifndef __STDC_WANT_IEC_60559_FUNCS_EXT__
00039 #  define __STDC_WANT_IEC_60559_FUNCS_EXT__ 1
00040 # endif
00041 /* See the comment in R.h */
00042 # ifdef __SUNPRO_CC
00043 #  define DO_NOT_USE_CXX_HEADERS
00044 # endif
00045 # if defined(__cplusplus) && !defined(DO_NOT_USE_CXX_HEADERS)
00046 #  include <cmath>
00047 # else
00048 #  include <math.h>
00049 # endif
00050 #endif
00051 
00052 /*-- Mathlib as part of R --  define this for standalone : */
00053 /* #undef MATHLIB_STANDALONE */
00054 
00055 #define R_VERSION_STRING "3.4.0"
00056 
00057 #ifndef HAVE_EXPM1
00058 # define HAVE_EXPM1 1
00059 #endif
00060 
00061 #ifndef HAVE_HYPOT
00062 # define HAVE_HYPOT 1
00063 #endif
00064 
00065 #ifndef HAVE_LOG1P
00066 # define HAVE_LOG1P 1
00067 #endif
00068 
00069 #ifndef HAVE_WORKING_LOG1P
00070 # define HAVE_WORKING_LOG1P 1
00071 #endif
00072 
00073 #if defined(HAVE_LOG1P) && !defined(HAVE_WORKING_LOG1P)
00074 /* remap to avoid problems with getting the right entry point */
00075 double  Rlog1p(double);
00076 #define log1p Rlog1p
00077 #endif
00078 
00079 
00080     /* Undo SGI Madness */
00081 
00082 #ifdef __sgi
00083 # ifdef ftrunc
00084 #  undef ftrunc
00085 # endif
00086 # ifdef qexp
00087 #  undef qexp
00088 # endif
00089 # ifdef qgamma
00090 #  undef qgamma
00091 # endif
00092 #endif
00093 
00094 
00095 /* ----- The following constants and entry points are part of the R API ---- */
00096 
00097 /* 30 Decimal-place constants */
00098 /* Computed with bc -l (scale=32; proper round) */
00099 
00100 /* SVID & X/Open Constants */
00101 /* Names from Solaris math.h */
00102 
00103 #ifndef M_E
00104 #define M_E     2.718281828459045235360287471353    /* e */
00105 #endif
00106 
00107 #ifndef M_LOG2E
00108 #define M_LOG2E     1.442695040888963407359924681002    /* log2(e) */
00109 #endif
00110 
00111 #ifndef M_LOG10E
00112 #define M_LOG10E    0.434294481903251827651128918917    /* log10(e) */
00113 #endif
00114 
00115 #ifndef M_LN2
00116 #define M_LN2       0.693147180559945309417232121458    /* ln(2) */
00117 #endif
00118 
00119 #ifndef M_LN10
00120 #define M_LN10      2.302585092994045684017991454684    /* ln(10) */
00121 #endif
00122 
00123 #ifndef M_PI
00124 #define M_PI        3.141592653589793238462643383280    /* pi */
00125 #endif
00126 
00127 #ifndef M_2PI
00128 #define M_2PI       6.283185307179586476925286766559    /* 2*pi */
00129 #endif
00130 
00131 #ifndef M_PI_2
00132 #define M_PI_2      1.570796326794896619231321691640    /* pi/2 */
00133 #endif
00134 
00135 #ifndef M_PI_4
00136 #define M_PI_4      0.785398163397448309615660845820    /* pi/4 */
00137 #endif
00138 
00139 #ifndef M_1_PI
00140 #define M_1_PI      0.318309886183790671537767526745    /* 1/pi */
00141 #endif
00142 
00143 #ifndef M_2_PI
00144 #define M_2_PI      0.636619772367581343075535053490    /* 2/pi */
00145 #endif
00146 
00147 #ifndef M_2_SQRTPI
00148 #define M_2_SQRTPI  1.128379167095512573896158903122    /* 2/sqrt(pi) */
00149 #endif
00150 
00151 #ifndef M_SQRT2
00152 #define M_SQRT2     1.414213562373095048801688724210    /* sqrt(2) */
00153 #endif
00154 
00155 #ifndef M_SQRT1_2
00156 #define M_SQRT1_2   0.707106781186547524400844362105    /* 1/sqrt(2) */
00157 #endif
00158 
00159 /* R-Specific Constants */
00160 
00161 #ifndef M_SQRT_3
00162 #define M_SQRT_3    1.732050807568877293527446341506    /* sqrt(3) */
00163 #endif
00164 
00165 #ifndef M_SQRT_32
00166 #define M_SQRT_32   5.656854249492380195206754896838    /* sqrt(32) */
00167 #endif
00168 
00169 #ifndef M_LOG10_2
00170 #define M_LOG10_2   0.301029995663981195213738894724    /* log10(2) */
00171 #endif
00172 
00173 #ifndef M_SQRT_PI
00174 #define M_SQRT_PI   1.772453850905516027298167483341    /* sqrt(pi) */
00175 #endif
00176 
00177 #ifndef M_1_SQRT_2PI
00178 #define M_1_SQRT_2PI    0.398942280401432677939946059934    /* 1/sqrt(2pi) */
00179 #endif
00180 
00181 #ifndef M_SQRT_2dPI
00182 #define M_SQRT_2dPI 0.797884560802865355879892119869    /* sqrt(2/pi) */
00183 #endif
00184 
00185 
00186 #ifndef M_LN_2PI
00187 #define M_LN_2PI    1.837877066409345483560659472811    /* log(2*pi) */
00188 #endif
00189 
00190 #ifndef M_LN_SQRT_PI
00191 #define M_LN_SQRT_PI    0.572364942924700087071713675677    /* log(sqrt(pi))
00192                                    == log(pi)/2 */
00193 #endif
00194 
00195 #ifndef M_LN_SQRT_2PI
00196 #define M_LN_SQRT_2PI   0.918938533204672741780329736406    /* log(sqrt(2*pi))
00197                                  == log(2*pi)/2 */
00198 #endif
00199 
00200 #ifndef M_LN_SQRT_PId2
00201 #define M_LN_SQRT_PId2  0.225791352644727432363097614947    /* log(sqrt(pi/2))
00202                                    == log(pi/2)/2 */
00203 #endif
00204 
00205 
00206 #ifdef MATHLIB_STANDALONE
00207 # ifndef R_EXT_BOOLEAN_H_
00208 /* "copy-paste" R_ext/Boolean.h if not already included: */
00209  #define R_EXT_BOOLEAN_H_
00210  #undef FALSE
00211  #undef TRUE
00212  typedef enum { FALSE = 0, TRUE } Rboolean;
00213 # endif
00214 #else
00215 # include <R_ext/Boolean.h>
00216 #endif
00217 
00218 
00219 #if !defined(MATHLIB_STANDALONE) && !defined(R_NO_REMAP_RMATH)
00220 #define bessel_i    Rf_bessel_i
00221 #define bessel_j    Rf_bessel_j
00222 #define bessel_k    Rf_bessel_k
00223 #define bessel_y    Rf_bessel_y
00224 #define bessel_i_ex Rf_bessel_i_ex
00225 #define bessel_j_ex Rf_bessel_j_ex
00226 #define bessel_k_ex Rf_bessel_k_ex
00227 #define bessel_y_ex Rf_bessel_y_ex
00228 #define beta        Rf_beta
00229 #define choose      Rf_choose
00230 #define dbeta       Rf_dbeta
00231 #define dbinom      Rf_dbinom
00232 #define dbinom_raw  Rf_dbinom_raw
00233 #define dcauchy     Rf_dcauchy
00234 #define dchisq      Rf_dchisq
00235 #define dexp        Rf_dexp
00236 #define df      Rf_df
00237 #define dgamma      Rf_dgamma
00238 #define dgeom       Rf_dgeom
00239 #define dhyper      Rf_dhyper
00240 #define digamma     Rf_digamma
00241 #define dlnorm      Rf_dlnorm
00242 #define dlogis      Rf_dlogis
00243 #define dnbeta      Rf_dnbeta
00244 #define dnbinom     Rf_dnbinom
00245 #define dnbinom_mu  Rf_dnbinom_mu
00246 #define dnchisq     Rf_dnchisq
00247 #define dnf     Rf_dnf
00248 #define dnorm4      Rf_dnorm4
00249 #define dnt     Rf_dnt
00250 #define dpois_raw   Rf_dpois_raw
00251 #define dpois       Rf_dpois
00252 #define dpsifn      Rf_dpsifn
00253 #define dsignrank   Rf_dsignrank
00254 #define dt      Rf_dt
00255 #define dtukey      Rf_dtukey
00256 #define dunif       Rf_dunif
00257 #define dweibull    Rf_dweibull
00258 #define dwilcox     Rf_dwilcox
00259 #define fmax2       Rf_fmax2
00260 #define fmin2       Rf_fmin2
00261 #define fprec       Rf_fprec
00262 #define fround      Rf_fround
00263 #define ftrunc      Rf_ftrunc
00264 #define fsign       Rf_fsign
00265 #define gammafn     Rf_gammafn
00266 #define imax2       Rf_imax2
00267 #define imin2       Rf_imin2
00268 #define lbeta       Rf_lbeta
00269 #define lchoose     Rf_lchoose
00270 #define lgammafn    Rf_lgammafn
00271 #define lgammafn_sign   Rf_lgammafn_sign
00272 #define lgamma1p    Rf_lgamma1p
00273 #define log1pexp        Rf_log1pexp
00274 #define log1pmx     Rf_log1pmx
00275 #define logspace_add    Rf_logspace_add
00276 #define logspace_sub    Rf_logspace_sub
00277 #define logspace_sum    Rf_logspace_sum
00278 #define pbeta       Rf_pbeta
00279 #define pbeta_raw   Rf_pbeta_raw
00280 #define pbinom      Rf_pbinom
00281 #define pcauchy     Rf_pcauchy
00282 #define pchisq      Rf_pchisq
00283 #define pentagamma  Rf_pentagamma
00284 #define pexp        Rf_pexp
00285 #define pf      Rf_pf
00286 #define pgamma      Rf_pgamma
00287 #define pgeom       Rf_pgeom
00288 #define phyper      Rf_phyper
00289 #define plnorm      Rf_plnorm
00290 #define plogis      Rf_plogis
00291 #define pnbeta      Rf_pnbeta
00292 #define pnbinom     Rf_pnbinom
00293 #define pnbinom_mu      Rf_pnbinom_mu
00294 #define pnchisq     Rf_pnchisq
00295 #define pnf     Rf_pnf
00296 #define pnorm5      Rf_pnorm5
00297 #define pnorm_both  Rf_pnorm_both
00298 #define pnt     Rf_pnt
00299 #define ppois       Rf_ppois
00300 #define psignrank   Rf_psignrank
00301 #define psigamma    Rf_psigamma
00302 #define pt      Rf_pt
00303 #define ptukey      Rf_ptukey
00304 #define punif       Rf_punif
00305 #define pythag      Rf_pythag
00306 #define pweibull    Rf_pweibull
00307 #define pwilcox     Rf_pwilcox
00308 #define qbeta       Rf_qbeta
00309 #define qbinom      Rf_qbinom
00310 #define qcauchy     Rf_qcauchy
00311 #define qchisq      Rf_qchisq
00312 #define qchisq_appr Rf_qchisq_appr
00313 #define qexp        Rf_qexp
00314 #define qf      Rf_qf
00315 #define qgamma      Rf_qgamma
00316 #define qgeom       Rf_qgeom
00317 #define qhyper      Rf_qhyper
00318 #define qlnorm      Rf_qlnorm
00319 #define qlogis      Rf_qlogis
00320 #define qnbeta      Rf_qnbeta
00321 #define qnbinom     Rf_qnbinom
00322 #define qnbinom_mu      Rf_qnbinom_mu
00323 #define qnchisq     Rf_qnchisq
00324 #define qnf     Rf_qnf
00325 #define qnorm5      Rf_qnorm5
00326 #define qnt     Rf_qnt
00327 #define qpois       Rf_qpois
00328 #define qsignrank   Rf_qsignrank
00329 #define qt      Rf_qt
00330 #define qtukey      Rf_qtukey
00331 #define qunif       Rf_qunif
00332 #define qweibull    Rf_qweibull
00333 #define qwilcox     Rf_qwilcox
00334 #define rbeta       Rf_rbeta
00335 #define rbinom      Rf_rbinom
00336 #define rcauchy     Rf_rcauchy
00337 #define rchisq      Rf_rchisq
00338 #define rexp        Rf_rexp
00339 #define rf      Rf_rf
00340 #define rgamma      Rf_rgamma
00341 #define rgeom       Rf_rgeom
00342 #define rhyper      Rf_rhyper
00343 #define rlnorm      Rf_rlnorm
00344 #define rlogis      Rf_rlogis
00345 #define rmultinom   Rf_rmultinom
00346 #define rnbeta      Rf_rnbeta
00347 #define rnbinom     Rf_rnbinom
00348 #define rnbinom_mu      Rf_rnbinom_mu
00349 #define rnchisq     Rf_rnchisq
00350 #define rnf     Rf_rnf
00351 #define rnorm       Rf_rnorm
00352 #define rnt     Rf_rnt
00353 #define rpois       Rf_rpois
00354 #define rsignrank   Rf_rsignrank
00355 #define rt      Rf_rt
00356 #define rtukey      Rf_rtukey
00357 #define runif       Rf_runif
00358 #define rweibull    Rf_rweibull
00359 #define rwilcox     Rf_rwilcox
00360 #define sign        Rf_sign
00361 #define tetragamma  Rf_tetragamma
00362 #define trigamma    Rf_trigamma
00363 #endif
00364 
00365 #define dnorm dnorm4
00366 #define pnorm pnorm5
00367 #define qnorm qnorm5
00368 
00369 #ifdef  __cplusplus
00370 extern "C" {
00371 #endif
00372     /* R's versions with !R_FINITE checks */
00373 
00374 double R_pow(double x, double y);
00375 double R_pow_di(double, int);
00376 
00377     /* Random Number Generators */
00378 
00379 double  norm_rand(void);
00380 double  unif_rand(void);
00381 double  exp_rand(void);
00382 #ifdef MATHLIB_STANDALONE
00383 void    set_seed(unsigned int, unsigned int);
00384 void    get_seed(unsigned int *, unsigned int *);
00385 #endif
00386 
00387     /* Normal Distribution */
00388 
00389 double  dnorm(double, double, double, int);
00390 double  pnorm(double, double, double, int, int);
00391 double  qnorm(double, double, double, int, int);
00392 double  rnorm(double, double);
00393 void    pnorm_both(double, double *, double *, int, int);/* both tails */
00394 
00395     /* Uniform Distribution */
00396 
00397 double  dunif(double, double, double, int);
00398 double  punif(double, double, double, int, int);
00399 double  qunif(double, double, double, int, int);
00400 double  runif(double, double);
00401 
00402     /* Gamma Distribution */
00403 
00404 double  dgamma(double, double, double, int);
00405 double  pgamma(double, double, double, int, int);
00406 double  qgamma(double, double, double, int, int);
00407 double  rgamma(double, double);
00408 
00409 double  log1pmx(double);
00410 double  log1pexp(double); // <-- ../nmath/plogis.c
00411 double  lgamma1p(double);
00412 double  logspace_add(double, double);
00413 double  logspace_sub(double, double);
00414 double  logspace_sum(const double *, int);
00415 
00416     /* Beta Distribution */
00417 
00418 double  dbeta(double, double, double, int);
00419 double  pbeta(double, double, double, int, int);
00420 double  qbeta(double, double, double, int, int);
00421 double  rbeta(double, double);
00422 
00423     /* Lognormal Distribution */
00424 
00425 double  dlnorm(double, double, double, int);
00426 double  plnorm(double, double, double, int, int);
00427 double  qlnorm(double, double, double, int, int);
00428 double  rlnorm(double, double);
00429 
00430     /* Chi-squared Distribution */
00431 
00432 double  dchisq(double, double, int);
00433 double  pchisq(double, double, int, int);
00434 double  qchisq(double, double, int, int);
00435 double  rchisq(double);
00436 
00437     /* Non-central Chi-squared Distribution */
00438 
00439 double  dnchisq(double, double, double, int);
00440 double  pnchisq(double, double, double, int, int);
00441 double  qnchisq(double, double, double, int, int);
00442 double  rnchisq(double, double);
00443 
00444     /* F Distibution */
00445 
00446 double  df(double, double, double, int);
00447 double  pf(double, double, double, int, int);
00448 double  qf(double, double, double, int, int);
00449 double  rf(double, double);
00450 
00451     /* Student t Distibution */
00452 
00453 double  dt(double, double, int);
00454 double  pt(double, double, int, int);
00455 double  qt(double, double, int, int);
00456 double  rt(double);
00457 
00458     /* Binomial Distribution */
00459 
00460 double  dbinom_raw(double x, double n, double p, double q, int give_log);
00461 double  dbinom(double, double, double, int);
00462 double  pbinom(double, double, double, int, int);
00463 double  qbinom(double, double, double, int, int);
00464 double  rbinom(double, double);
00465 
00466     /* Multnomial Distribution */
00467 
00468 void    rmultinom(int, double*, int, int*);
00469 
00470     /* Cauchy Distribution */
00471 
00472 double  dcauchy(double, double, double, int);
00473 double  pcauchy(double, double, double, int, int);
00474 double  qcauchy(double, double, double, int, int);
00475 double  rcauchy(double, double);
00476 
00477     /* Exponential Distribution */
00478 
00479 double  dexp(double, double, int);
00480 double  pexp(double, double, int, int);
00481 double  qexp(double, double, int, int);
00482 double  rexp(double);
00483 
00484     /* Geometric Distribution */
00485 
00486 double  dgeom(double, double, int);
00487 double  pgeom(double, double, int, int);
00488 double  qgeom(double, double, int, int);
00489 double  rgeom(double);
00490 
00491     /* Hypergeometric Distibution */
00492 
00493 double  dhyper(double, double, double, double, int);
00494 double  phyper(double, double, double, double, int, int);
00495 double  qhyper(double, double, double, double, int, int);
00496 double  rhyper(double, double, double);
00497 
00498     /* Negative Binomial Distribution */
00499 
00500 double  dnbinom(double, double, double, int);
00501 double  pnbinom(double, double, double, int, int);
00502 double  qnbinom(double, double, double, int, int);
00503 double  rnbinom(double, double);
00504 
00505 double  dnbinom_mu(double, double, double, int);
00506 double  pnbinom_mu(double, double, double, int, int);
00507 double  qnbinom_mu(double, double, double, int, int);
00508 double  rnbinom_mu(double, double);
00509 
00510     /* Poisson Distribution */
00511 
00512 double  dpois_raw (double, double, int);
00513 double  dpois(double, double, int);
00514 double  ppois(double, double, int, int);
00515 double  qpois(double, double, int, int);
00516 double  rpois(double);
00517 
00518     /* Weibull Distribution */
00519 
00520 double  dweibull(double, double, double, int);
00521 double  pweibull(double, double, double, int, int);
00522 double  qweibull(double, double, double, int, int);
00523 double  rweibull(double, double);
00524 
00525     /* Logistic Distribution */
00526 
00527 double  dlogis(double, double, double, int);
00528 double  plogis(double, double, double, int, int);
00529 double  qlogis(double, double, double, int, int);
00530 double  rlogis(double, double);
00531 
00532     /* Non-central Beta Distribution */
00533 
00534 double  dnbeta(double, double, double, double, int);
00535 double  pnbeta(double, double, double, double, int, int);
00536 double  qnbeta(double, double, double, double, int, int);
00537 double  rnbeta(double, double, double);
00538 
00539     /* Non-central F Distribution */
00540 
00541 double  dnf(double, double, double, double, int);
00542 double  pnf(double, double, double, double, int, int);
00543 double  qnf(double, double, double, double, int, int);
00544 
00545     /* Non-central Student t Distribution */
00546 
00547 double  dnt(double, double, double, int);
00548 double  pnt(double, double, double, int, int);
00549 double  qnt(double, double, double, int, int);
00550 
00551     /* Studentized Range Distribution */
00552 
00553 double  ptukey(double, double, double, double, int, int);
00554 double  qtukey(double, double, double, double, int, int);
00555 
00556     /* Wilcoxon Rank Sum Distribution */
00557 
00558 double dwilcox(double, double, double, int);
00559 double pwilcox(double, double, double, int, int);
00560 double qwilcox(double, double, double, int, int);
00561 double rwilcox(double, double);
00562 
00563     /* Wilcoxon Signed Rank Distribution */
00564 
00565 double dsignrank(double, double, int);
00566 double psignrank(double, double, int, int);
00567 double qsignrank(double, double, int, int);
00568 double rsignrank(double);
00569 
00570     /* Gamma and Related Functions */
00571 double  gammafn(double);
00572 double  lgammafn(double);
00573 double  lgammafn_sign(double, int*);
00574 void    dpsifn(double, int, int, int, double*, int*, int*);
00575 double  psigamma(double, double);
00576 double  digamma(double);
00577 double  trigamma(double);
00578 double  tetragamma(double);
00579 double  pentagamma(double);
00580 
00581 double  beta(double, double);
00582 double  lbeta(double, double);
00583 
00584 double  choose(double, double);
00585 double  lchoose(double, double);
00586 
00587     /* Bessel Functions */
00588 
00589 double  bessel_i(double, double, double);
00590 double  bessel_j(double, double);
00591 double  bessel_k(double, double, double);
00592 double  bessel_y(double, double);
00593 double  bessel_i_ex(double, double, double, double *);
00594 double  bessel_j_ex(double, double, double *);
00595 double  bessel_k_ex(double, double, double, double *);
00596 double  bessel_y_ex(double, double, double *);
00597 
00598 
00599     /* General Support Functions */
00600 
00601 #ifndef HAVE_HYPOT
00602 double  hypot(double, double);
00603 #endif
00604 double  pythag(double, double);
00605 #ifndef HAVE_EXPM1
00606 double  expm1(double); /* = exp(x)-1 {care for small x} */
00607 #endif
00608 #ifndef HAVE_LOG1P
00609 double  log1p(double); /* = log(1+x) {care for small x} */
00610 #endif
00611 int imax2(int, int);
00612 int imin2(int, int);
00613 double  fmax2(double, double);
00614 double  fmin2(double, double);
00615 double  sign(double);
00616 double  fprec(double, double);
00617 double  fround(double, double);
00618 double  fsign(double, double);
00619 double  ftrunc(double);
00620 
00621 double  log1pmx(double); /* Accurate log(1+x) - x, {care for small x} */
00622 double  lgamma1p(double);/* accurate log(gamma(x+1)), small x (0 < x < 0.5) */
00623 
00624 /* More accurate cos(pi*x), sin(pi*x), tan(pi*x)
00625 
00626    In future these declarations could clash with system headers if
00627    someone had already included math.h with
00628    __STDC_WANT_IEC_60559_FUNCS_EXT__ defined.
00629    We can add a check for that via the value of
00630    __STDC_IEC_60559_FUNCS__ (>= 201ymmL, exact value not yet known).
00631 */
00632 double cospi(double);
00633 double sinpi(double);
00634 double tanpi(double);
00635 
00636 /* Compute the log of a sum or difference from logs of terms, i.e.,
00637  *
00638  *     log (exp (logx) + exp (logy))
00639  * or  log (exp (logx) - exp (logy))
00640  *
00641  * without causing overflows or throwing away too much accuracy:
00642  */
00643 double  logspace_add(double logx, double logy);
00644 double  logspace_sub(double logx, double logy);
00645 
00646 
00647 /* ----------------- Private part of the header file ------------------- */
00648 
00649     /* old-R Compatibility */
00650 
00651 #ifdef OLD_RMATH_COMPAT
00652 # define snorm  norm_rand
00653 # define sunif  unif_rand
00654 # define sexp   exp_rand
00655 #endif
00656 
00657 #if defined(MATHLIB_STANDALONE) && !defined(MATHLIB_PRIVATE_H)
00658 /* second is defined by nmath.h */
00659 
00660 /* If isnan is a macro, as C99 specifies, the C++
00661    math header will undefine it. This happens on macOS */
00662 # ifdef __cplusplus
00663   int R_isnancpp(double); /* in mlutils.c */
00664 #  define ISNAN(x)     R_isnancpp(x)
00665 # else
00666 #  define ISNAN(x)     (isnan(x)!=0)
00667 # endif
00668 
00669 # define R_FINITE(x)    R_finite(x)
00670 int R_finite(double);
00671 
00672 # ifdef _WIN32  /* not Win32 as no config information */
00673 #  ifdef RMATH_DLL
00674 #   define R_EXTERN extern __declspec(dllimport)
00675 #  else
00676 #   define R_EXTERN extern
00677 #  endif
00678 R_EXTERN double NA_REAL;
00679 R_EXTERN double R_PosInf;
00680 R_EXTERN double R_NegInf;
00681 R_EXTERN int N01_kind;
00682 #  undef R_EXTERN
00683 #else
00684 extern int N01_kind;
00685 # endif
00686 
00687 #endif /* MATHLIB_STANDALONE */
00688 
00689 #ifdef  __cplusplus
00690 }
00691 #endif
00692 
00693 #endif /* RMATH_H */
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines