| 22860 |
ripley |
1 |
/*
|
|
|
2 |
* Mathlib : A C Library of Special Functions
|
| 22931 |
ripley |
3 |
* Copyright (C) 1998-2003 The R Development Core Team
|
| 22860 |
ripley |
4 |
*
|
|
|
5 |
* This program is free software; you can redistribute it and/or modify
|
|
|
6 |
* it under the terms of the GNU Lesser General Public License as published by
|
|
|
7 |
* the Free Software Foundation; either version 2.1 of the License, or
|
|
|
8 |
* (at your option) any later version.
|
|
|
9 |
*
|
|
|
10 |
* This program is distributed in the hope that it will be useful,
|
|
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
13 |
* GNU Lesser General Public License for more details.
|
|
|
14 |
*
|
|
|
15 |
* You should have received a copy of the GNU Lesser General Public License
|
|
|
16 |
* along with this program; if not, write to the Free Software
|
|
|
17 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
18 |
*
|
|
|
19 |
|
| 25960 |
ripley |
20 |
* Rmath.h should contain ALL headers from R's C code in `src/nmath'
|
|
|
21 |
------- such that ``the Math library'' can be used by simply
|
| 22860 |
ripley |
22 |
|
|
|
23 |
``#include <Rmath.h> ''
|
|
|
24 |
|
|
|
25 |
and nothing else.
|
|
|
26 |
*/
|
|
|
27 |
#ifndef RMATH_H
|
|
|
28 |
#define RMATH_H
|
|
|
29 |
|
|
|
30 |
/*-- Mathlib as part of R -- define this for standalone : */
|
|
|
31 |
/* #undef MATHLIB_STANDALONE */
|
|
|
32 |
|
|
|
33 |
#ifndef HAVE_LOG1P
|
|
|
34 |
@RMATH_HAVE_LOG1P@
|
| 25952 |
ripley |
35 |
#endif
|
| 22860 |
ripley |
36 |
|
|
|
37 |
#ifndef HAVE_EXPM1
|
|
|
38 |
@RMATH_HAVE_EXPM1@
|
|
|
39 |
#endif
|
| 25952 |
ripley |
40 |
|
|
|
41 |
#ifndef HAVE_WORKING_LOG1P
|
|
|
42 |
@RMATH_HAVE_WORKING_LOG1P@
|
| 22860 |
ripley |
43 |
#endif
|
|
|
44 |
|
| 27523 |
martyn |
45 |
#include <errno.h>
|
|
|
46 |
#include <limits.h>
|
|
|
47 |
#include <float.h>
|
|
|
48 |
#include <math.h>
|
|
|
49 |
|
| 25952 |
ripley |
50 |
#if defined(HAVE_LOG1P) && !defined(HAVE_WORKING_LOG1P)
|
|
|
51 |
/* remap to avoid problems with getting the right entry point */
|
|
|
52 |
double Rlog1p(double);
|
|
|
53 |
#define log1p Rlog1p
|
|
|
54 |
#endif
|
|
|
55 |
|
| 22860 |
ripley |
56 |
#include <stdlib.h>
|
|
|
57 |
|
|
|
58 |
/* Undo SGI Madness */
|
|
|
59 |
|
|
|
60 |
#ifdef ftrunc
|
|
|
61 |
# undef ftrunc
|
|
|
62 |
#endif
|
|
|
63 |
#ifdef qexp
|
|
|
64 |
# undef qexp
|
|
|
65 |
#endif
|
|
|
66 |
#ifdef qgamma
|
|
|
67 |
# undef qgamma
|
|
|
68 |
#endif
|
|
|
69 |
|
|
|
70 |
|
|
|
71 |
/* ----- The following constants and entry points are part of the R API ---- */
|
|
|
72 |
|
|
|
73 |
/* 30 Decimal-place constants */
|
|
|
74 |
/* Computed with bc -l (scale=32; proper round) */
|
|
|
75 |
|
|
|
76 |
/* SVID & X/Open Constants */
|
|
|
77 |
/* Names from Solaris math.h */
|
|
|
78 |
|
|
|
79 |
#ifndef M_E
|
|
|
80 |
#define M_E 2.718281828459045235360287471353 /* e */
|
|
|
81 |
#endif
|
|
|
82 |
|
|
|
83 |
#ifndef M_LOG2E
|
|
|
84 |
#define M_LOG2E 1.442695040888963407359924681002 /* log2(e) */
|
|
|
85 |
#endif
|
|
|
86 |
|
|
|
87 |
#ifndef M_LOG10E
|
|
|
88 |
#define M_LOG10E 0.434294481903251827651128918917 /* log10(e) */
|
|
|
89 |
#endif
|
|
|
90 |
|
|
|
91 |
#ifndef M_LN2
|
|
|
92 |
#define M_LN2 0.693147180559945309417232121458 /* ln(2) */
|
|
|
93 |
#endif
|
|
|
94 |
|
|
|
95 |
#ifndef M_LN10
|
|
|
96 |
#define M_LN10 2.302585092994045684017991454684 /* ln(10) */
|
|
|
97 |
#endif
|
|
|
98 |
|
|
|
99 |
#ifndef M_PI
|
|
|
100 |
#define M_PI 3.141592653589793238462643383280 /* pi */
|
|
|
101 |
#endif
|
|
|
102 |
|
|
|
103 |
#ifndef M_2PI
|
|
|
104 |
#define M_2PI 6.283185307179586476925286766559 /* 2*pi */
|
|
|
105 |
#endif
|
|
|
106 |
|
|
|
107 |
#ifndef M_PI_2
|
|
|
108 |
#define M_PI_2 1.570796326794896619231321691640 /* pi/2 */
|
|
|
109 |
#endif
|
|
|
110 |
|
|
|
111 |
#ifndef M_PI_4
|
|
|
112 |
#define M_PI_4 0.785398163397448309615660845820 /* pi/4 */
|
|
|
113 |
#endif
|
|
|
114 |
|
|
|
115 |
#ifndef M_1_PI
|
|
|
116 |
#define M_1_PI 0.318309886183790671537767526745 /* 1/pi */
|
|
|
117 |
#endif
|
|
|
118 |
|
|
|
119 |
#ifndef M_2_PI
|
|
|
120 |
#define M_2_PI 0.636619772367581343075535053490 /* 2/pi */
|
|
|
121 |
#endif
|
|
|
122 |
|
|
|
123 |
#ifndef M_2_SQRTPI
|
|
|
124 |
#define M_2_SQRTPI 1.128379167095512573896158903122 /* 2/sqrt(pi) */
|
|
|
125 |
#endif
|
|
|
126 |
|
|
|
127 |
#ifndef M_SQRT2
|
|
|
128 |
#define M_SQRT2 1.414213562373095048801688724210 /* sqrt(2) */
|
|
|
129 |
#endif
|
|
|
130 |
|
|
|
131 |
#ifndef M_SQRT1_2
|
|
|
132 |
#define M_SQRT1_2 0.707106781186547524400844362105 /* 1/sqrt(2) */
|
|
|
133 |
#endif
|
|
|
134 |
|
|
|
135 |
/* R-Specific Constants */
|
|
|
136 |
|
|
|
137 |
#ifndef M_SQRT_3
|
|
|
138 |
#define M_SQRT_3 1.732050807568877293527446341506 /* sqrt(3) */
|
|
|
139 |
#endif
|
|
|
140 |
|
|
|
141 |
#ifndef M_SQRT_32
|
|
|
142 |
#define M_SQRT_32 5.656854249492380195206754896838 /* sqrt(32) */
|
|
|
143 |
#endif
|
|
|
144 |
|
|
|
145 |
#ifndef M_LOG10_2
|
|
|
146 |
#define M_LOG10_2 0.301029995663981195213738894724 /* log10(2) */
|
|
|
147 |
#endif
|
|
|
148 |
|
|
|
149 |
#ifndef M_SQRT_PI
|
|
|
150 |
#define M_SQRT_PI 1.772453850905516027298167483341 /* sqrt(pi) */
|
|
|
151 |
#endif
|
|
|
152 |
|
|
|
153 |
#ifndef M_1_SQRT_2PI
|
|
|
154 |
#define M_1_SQRT_2PI 0.398942280401432677939946059934 /* 1/sqrt(2pi) */
|
|
|
155 |
#endif
|
|
|
156 |
|
|
|
157 |
#ifndef M_SQRT_2dPI
|
|
|
158 |
#define M_SQRT_2dPI 0.797884560802865355879892119869 /* sqrt(2/pi) */
|
|
|
159 |
#endif
|
|
|
160 |
|
|
|
161 |
|
|
|
162 |
#ifndef M_LN_SQRT_PI
|
|
|
163 |
#define M_LN_SQRT_PI 0.572364942924700087071713675677 /* log(sqrt(pi)) */
|
|
|
164 |
#endif
|
|
|
165 |
|
|
|
166 |
#ifndef M_LN_SQRT_2PI
|
|
|
167 |
#define M_LN_SQRT_2PI 0.918938533204672741780329736406 /* log(sqrt(2*pi)) */
|
|
|
168 |
#endif
|
|
|
169 |
|
|
|
170 |
#ifndef M_LN_SQRT_PId2
|
|
|
171 |
#define M_LN_SQRT_PId2 0.225791352644727432363097614947 /* log(sqrt(pi/2)) */
|
|
|
172 |
#endif
|
|
|
173 |
|
|
|
174 |
#ifdef MATHLIB_STANDALONE
|
|
|
175 |
typedef enum { FALSE = 0, TRUE } Rboolean;
|
|
|
176 |
#else
|
|
|
177 |
# include <R_ext/Boolean.h>
|
|
|
178 |
|
|
|
179 |
/* for API back-compatibility -- DEPRECATED since R 1.2 -- */
|
|
|
180 |
#define LTRUE TRUE
|
|
|
181 |
#define LFALSE FALSE
|
|
|
182 |
#endif
|
|
|
183 |
|
|
|
184 |
|
|
|
185 |
|
| 22931 |
ripley |
186 |
#ifndef MATHLIB_STANDALONE
|
| 22860 |
ripley |
187 |
#define bessel_i Rf_bessel_i
|
|
|
188 |
#define bessel_j Rf_bessel_j
|
|
|
189 |
#define bessel_k Rf_bessel_k
|
|
|
190 |
#define bessel_y Rf_bessel_y
|
|
|
191 |
#define beta Rf_beta
|
|
|
192 |
#define choose Rf_choose
|
|
|
193 |
#define dbeta Rf_dbeta
|
|
|
194 |
#define dbinom Rf_dbinom
|
|
|
195 |
#define dcauchy Rf_dcauchy
|
|
|
196 |
#define dchisq Rf_dchisq
|
|
|
197 |
#define dexp Rf_dexp
|
|
|
198 |
#define df Rf_df
|
|
|
199 |
#define dgamma Rf_dgamma
|
|
|
200 |
#define dgeom Rf_dgeom
|
|
|
201 |
#define dhyper Rf_dhyper
|
|
|
202 |
#define digamma Rf_digamma
|
|
|
203 |
#define dlnorm Rf_dlnorm
|
|
|
204 |
#define dlogis Rf_dlogis
|
|
|
205 |
#define dnbeta Rf_dnbeta
|
|
|
206 |
#define dnbinom Rf_dnbinom
|
|
|
207 |
#define dnchisq Rf_dnchisq
|
|
|
208 |
#define dnf Rf_dnf
|
|
|
209 |
#define dnorm4 Rf_dnorm4
|
|
|
210 |
#define dnt Rf_dnt
|
|
|
211 |
#define dpois Rf_dpois
|
|
|
212 |
#define dsignrank Rf_dsignrank
|
|
|
213 |
#define dt Rf_dt
|
|
|
214 |
#define dtukey Rf_dtukey
|
|
|
215 |
#define dunif Rf_dunif
|
|
|
216 |
#define dweibull Rf_dweibull
|
|
|
217 |
#define dwilcox Rf_dwilcox
|
|
|
218 |
#define fmax2 Rf_fmax2
|
|
|
219 |
#define fmin2 Rf_fmin2
|
|
|
220 |
#define fprec Rf_fprec
|
|
|
221 |
#define fround Rf_fround
|
|
|
222 |
#define ftrunc Rf_ftrunc
|
|
|
223 |
#define fsign Rf_fsign
|
|
|
224 |
#define gammafn Rf_gammafn
|
|
|
225 |
#define imax2 Rf_imax2
|
|
|
226 |
#define imin2 Rf_imin2
|
|
|
227 |
#define lbeta Rf_lbeta
|
|
|
228 |
#define lchoose Rf_lchoose
|
|
|
229 |
#define lgammafn Rf_lgammafn
|
|
|
230 |
#define pbeta Rf_pbeta
|
|
|
231 |
#define pbeta_raw Rf_pbeta_raw
|
|
|
232 |
#define pbinom Rf_pbinom
|
|
|
233 |
#define pcauchy Rf_pcauchy
|
|
|
234 |
#define pchisq Rf_pchisq
|
|
|
235 |
#define pentagamma Rf_pentagamma
|
|
|
236 |
#define pexp Rf_pexp
|
|
|
237 |
#define pf Rf_pf
|
|
|
238 |
#define pgamma Rf_pgamma
|
|
|
239 |
#define pgeom Rf_pgeom
|
|
|
240 |
#define phyper Rf_phyper
|
|
|
241 |
#define plnorm Rf_plnorm
|
|
|
242 |
#define plogis Rf_plogis
|
|
|
243 |
#define pnbeta Rf_pnbeta
|
|
|
244 |
#define pnbinom Rf_pnbinom
|
|
|
245 |
#define pnchisq Rf_pnchisq
|
|
|
246 |
#define pnf Rf_pnf
|
|
|
247 |
#define pnorm5 Rf_pnorm5
|
|
|
248 |
#define pnorm_both Rf_pnorm_both
|
|
|
249 |
#define pnt Rf_pnt
|
|
|
250 |
#define ppois Rf_ppois
|
|
|
251 |
#define psignrank Rf_psignrank
|
|
|
252 |
#define pt Rf_pt
|
|
|
253 |
#define ptukey Rf_ptukey
|
|
|
254 |
#define punif Rf_punif
|
|
|
255 |
#define pythag Rf_pythag
|
|
|
256 |
#define pweibull Rf_pweibull
|
|
|
257 |
#define pwilcox Rf_pwilcox
|
|
|
258 |
#define qbeta Rf_qbeta
|
|
|
259 |
#define qbinom Rf_qbinom
|
|
|
260 |
#define qcauchy Rf_qcauchy
|
|
|
261 |
#define qchisq Rf_qchisq
|
|
|
262 |
#define qexp Rf_qexp
|
|
|
263 |
#define qf Rf_qf
|
|
|
264 |
#define qgamma Rf_qgamma
|
|
|
265 |
#define qgeom Rf_qgeom
|
|
|
266 |
#define qhyper Rf_qhyper
|
|
|
267 |
#define qlnorm Rf_qlnorm
|
|
|
268 |
#define qlogis Rf_qlogis
|
|
|
269 |
#define qnbeta Rf_qnbeta
|
|
|
270 |
#define qnbinom Rf_qnbinom
|
|
|
271 |
#define qnchisq Rf_qnchisq
|
|
|
272 |
#define qnf Rf_qnf
|
|
|
273 |
#define qnorm5 Rf_qnorm5
|
|
|
274 |
#define qnt Rf_qnt
|
|
|
275 |
#define qpois Rf_qpois
|
|
|
276 |
#define qsignrank Rf_qsignrank
|
|
|
277 |
#define qt Rf_qt
|
|
|
278 |
#define qtukey Rf_qtukey
|
|
|
279 |
#define qunif Rf_qunif
|
|
|
280 |
#define qweibull Rf_qweibull
|
|
|
281 |
#define qwilcox Rf_qwilcox
|
|
|
282 |
#define rbeta Rf_rbeta
|
|
|
283 |
#define rbinom Rf_rbinom
|
|
|
284 |
#define rcauchy Rf_rcauchy
|
|
|
285 |
#define rchisq Rf_rchisq
|
|
|
286 |
#define rexp Rf_rexp
|
|
|
287 |
#define rf Rf_rf
|
|
|
288 |
#define rgamma Rf_rgamma
|
|
|
289 |
#define rgeom Rf_rgeom
|
|
|
290 |
#define rhyper Rf_rhyper
|
|
|
291 |
#define rlnorm Rf_rlnorm
|
|
|
292 |
#define rlogis Rf_rlogis
|
|
|
293 |
#define rnbeta Rf_rnbeta
|
|
|
294 |
#define rnbinom Rf_rnbinom
|
|
|
295 |
#define rnchisq Rf_rnchisq
|
|
|
296 |
#define rnf Rf_rnf
|
|
|
297 |
#define rnorm Rf_rnorm
|
|
|
298 |
#define rnt Rf_rnt
|
|
|
299 |
#define rpois Rf_rpois
|
|
|
300 |
#define rsignrank Rf_rsignrank
|
|
|
301 |
#define rt Rf_rt
|
|
|
302 |
#define rtukey Rf_rtukey
|
|
|
303 |
#define runif Rf_runif
|
|
|
304 |
#define rweibull Rf_rweibull
|
|
|
305 |
#define rwilcox Rf_rwilcox
|
|
|
306 |
#define sign Rf_sign
|
|
|
307 |
#define tetragamma Rf_tetragamma
|
|
|
308 |
#define trigamma Rf_trigamma
|
|
|
309 |
#endif
|
|
|
310 |
|
|
|
311 |
#define rround fround
|
|
|
312 |
#define prec fprec
|
|
|
313 |
#undef trunc
|
|
|
314 |
#define trunc ftrunc
|
|
|
315 |
|
|
|
316 |
#ifdef __cplusplus
|
|
|
317 |
extern "C" {
|
|
|
318 |
#endif
|
|
|
319 |
|
|
|
320 |
/* R's versions with !R_FINITE checks */
|
|
|
321 |
|
|
|
322 |
double R_log(double x);
|
|
|
323 |
double R_pow(double x, double y);
|
|
|
324 |
double R_pow_di(double, int);
|
|
|
325 |
|
|
|
326 |
/* Random Number Generators */
|
|
|
327 |
|
|
|
328 |
double norm_rand(void);
|
|
|
329 |
double unif_rand(void);
|
|
|
330 |
double exp_rand(void);
|
|
|
331 |
#ifdef MATHLIB_STANDALONE
|
|
|
332 |
void set_seed(unsigned int, unsigned int);
|
| 24562 |
ripley |
333 |
void get_seed(unsigned int *, unsigned int *);
|
| 22860 |
ripley |
334 |
#endif
|
|
|
335 |
|
|
|
336 |
/* Normal Distribution */
|
|
|
337 |
|
|
|
338 |
#define pnorm pnorm5
|
|
|
339 |
#define qnorm qnorm5
|
|
|
340 |
#define dnorm dnorm4
|
|
|
341 |
|
|
|
342 |
double dnorm(double, double, double, int);
|
|
|
343 |
double pnorm(double, double, double, int, int);
|
|
|
344 |
double qnorm(double, double, double, int, int);
|
|
|
345 |
double rnorm(double, double);
|
|
|
346 |
void pnorm_both(double, double *, double *, int, int);/* both tails */
|
|
|
347 |
|
|
|
348 |
/* Uniform Distribution */
|
|
|
349 |
|
|
|
350 |
double dunif(double, double, double, int);
|
|
|
351 |
double punif(double, double, double, int, int);
|
|
|
352 |
double qunif(double, double, double, int, int);
|
|
|
353 |
double runif(double, double);
|
|
|
354 |
|
|
|
355 |
/* Gamma Distribution */
|
|
|
356 |
|
|
|
357 |
double dgamma(double, double, double, int);
|
|
|
358 |
double pgamma(double, double, double, int, int);
|
|
|
359 |
double qgamma(double, double, double, int, int);
|
|
|
360 |
double rgamma(double, double);
|
|
|
361 |
|
|
|
362 |
/* Beta Distribution */
|
|
|
363 |
|
|
|
364 |
double dbeta(double, double, double, int);
|
|
|
365 |
double pbeta(double, double, double, int, int);
|
|
|
366 |
double qbeta(double, double, double, int, int);
|
|
|
367 |
double rbeta(double, double);
|
|
|
368 |
double pbeta_raw(double, double, double, int);
|
|
|
369 |
|
|
|
370 |
/* Lognormal Distribution */
|
|
|
371 |
|
|
|
372 |
double dlnorm(double, double, double, int);
|
|
|
373 |
double plnorm(double, double, double, int, int);
|
|
|
374 |
double qlnorm(double, double, double, int, int);
|
|
|
375 |
double rlnorm(double, double);
|
|
|
376 |
|
|
|
377 |
/* Chi-squared Distribution */
|
|
|
378 |
|
|
|
379 |
double dchisq(double, double, int);
|
|
|
380 |
double pchisq(double, double, int, int);
|
|
|
381 |
double qchisq(double, double, int, int);
|
|
|
382 |
double rchisq(double);
|
|
|
383 |
|
|
|
384 |
/* Non-central Chi-squared Distribution */
|
|
|
385 |
|
|
|
386 |
double dnchisq(double, double, double, int);
|
|
|
387 |
double pnchisq(double, double, double, int, int);
|
|
|
388 |
double qnchisq(double, double, double, int, int);
|
|
|
389 |
double rnchisq(double, double);
|
|
|
390 |
|
|
|
391 |
/* F Distibution */
|
|
|
392 |
|
|
|
393 |
double df(double, double, double, int);
|
|
|
394 |
double pf(double, double, double, int, int);
|
|
|
395 |
double qf(double, double, double, int, int);
|
|
|
396 |
double rf(double, double);
|
|
|
397 |
|
|
|
398 |
/* Student t Distibution */
|
|
|
399 |
|
|
|
400 |
double dt(double, double, int);
|
|
|
401 |
double pt(double, double, int, int);
|
|
|
402 |
double qt(double, double, int, int);
|
|
|
403 |
double rt(double);
|
|
|
404 |
|
|
|
405 |
/* Binomial Distribution */
|
|
|
406 |
|
|
|
407 |
double dbinom(double, double, double, int);
|
|
|
408 |
double pbinom(double, double, double, int, int);
|
|
|
409 |
double qbinom(double, double, double, int, int);
|
|
|
410 |
double rbinom(double, double);
|
|
|
411 |
|
| 22959 |
maechler |
412 |
/* Multnomial Distribution */
|
|
|
413 |
|
|
|
414 |
void rmultinom(int, double*, int, int*);
|
|
|
415 |
|
| 22860 |
ripley |
416 |
/* Cauchy Distribution */
|
|
|
417 |
|
|
|
418 |
double dcauchy(double, double, double, int);
|
|
|
419 |
double pcauchy(double, double, double, int, int);
|
|
|
420 |
double qcauchy(double, double, double, int, int);
|
|
|
421 |
double rcauchy(double, double);
|
|
|
422 |
|
|
|
423 |
/* Exponential Distribution */
|
|
|
424 |
|
|
|
425 |
double dexp(double, double, int);
|
|
|
426 |
double pexp(double, double, int, int);
|
|
|
427 |
double qexp(double, double, int, int);
|
|
|
428 |
double rexp(double);
|
|
|
429 |
|
|
|
430 |
/* Geometric Distribution */
|
|
|
431 |
|
|
|
432 |
double dgeom(double, double, int);
|
|
|
433 |
double pgeom(double, double, int, int);
|
|
|
434 |
double qgeom(double, double, int, int);
|
|
|
435 |
double rgeom(double);
|
|
|
436 |
|
|
|
437 |
/* Hypergeometric Distibution */
|
|
|
438 |
|
|
|
439 |
double dhyper(double, double, double, double, int);
|
|
|
440 |
double phyper(double, double, double, double, int, int);
|
|
|
441 |
double qhyper(double, double, double, double, int, int);
|
|
|
442 |
double rhyper(double, double, double);
|
|
|
443 |
|
|
|
444 |
/* Negative Binomial Distribution */
|
|
|
445 |
|
|
|
446 |
double dnbinom(double, double, double, int);
|
|
|
447 |
double pnbinom(double, double, double, int, int);
|
|
|
448 |
double qnbinom(double, double, double, int, int);
|
|
|
449 |
double rnbinom(double, double);
|
|
|
450 |
|
|
|
451 |
/* Poisson Distribution */
|
|
|
452 |
|
|
|
453 |
double dpois(double, double, int);
|
|
|
454 |
double ppois(double, double, int, int);
|
|
|
455 |
double qpois(double, double, int, int);
|
|
|
456 |
double rpois(double);
|
|
|
457 |
|
|
|
458 |
/* Weibull Distribution */
|
|
|
459 |
|
|
|
460 |
double dweibull(double, double, double, int);
|
|
|
461 |
double pweibull(double, double, double, int, int);
|
|
|
462 |
double qweibull(double, double, double, int, int);
|
|
|
463 |
double rweibull(double, double);
|
|
|
464 |
|
|
|
465 |
/* Logistic Distribution */
|
|
|
466 |
|
|
|
467 |
double dlogis(double, double, double, int);
|
|
|
468 |
double plogis(double, double, double, int, int);
|
|
|
469 |
double qlogis(double, double, double, int, int);
|
|
|
470 |
double rlogis(double, double);
|
|
|
471 |
|
|
|
472 |
/* Non-central Beta Distribution */
|
|
|
473 |
|
|
|
474 |
double dnbeta(double, double, double, double, int);
|
|
|
475 |
double pnbeta(double, double, double, double, int, int);
|
|
|
476 |
double qnbeta(double, double, double, double, int, int);
|
|
|
477 |
double rnbeta(double, double, double);
|
|
|
478 |
|
|
|
479 |
/* Non-central F Distribution */
|
|
|
480 |
|
|
|
481 |
double pnf(double, double, double, double, int, int);
|
|
|
482 |
double qnf(double, double, double, double, int, int);
|
|
|
483 |
|
|
|
484 |
/* Non-central Student t Distribution */
|
|
|
485 |
|
| 25788 |
maechler |
486 |
double dnt(double, double, double, int);
|
| 22860 |
ripley |
487 |
double pnt(double, double, double, int, int);
|
|
|
488 |
double qnt(double, double, double, int, int);
|
|
|
489 |
|
|
|
490 |
/* Studentized Range Distribution */
|
|
|
491 |
|
|
|
492 |
double ptukey(double, double, double, double, int, int);
|
|
|
493 |
double qtukey(double, double, double, double, int, int);
|
|
|
494 |
|
|
|
495 |
/* Wilcoxon Rank Sum Distribution */
|
|
|
496 |
|
|
|
497 |
double dwilcox(double, double, double, int);
|
|
|
498 |
double pwilcox(double, double, double, int, int);
|
|
|
499 |
double qwilcox(double, double, double, int, int);
|
|
|
500 |
double rwilcox(double, double);
|
|
|
501 |
|
|
|
502 |
/* Wilcoxon Signed Rank Distribution */
|
|
|
503 |
|
|
|
504 |
double dsignrank(double, double, int);
|
|
|
505 |
double psignrank(double, double, int, int);
|
|
|
506 |
double qsignrank(double, double, int, int);
|
|
|
507 |
double rsignrank(double);
|
|
|
508 |
|
|
|
509 |
/* Gamma and Related Functions */
|
|
|
510 |
double gammafn(double);
|
|
|
511 |
double lgammafn(double);
|
|
|
512 |
double digamma(double);
|
|
|
513 |
double trigamma(double);
|
|
|
514 |
double tetragamma(double);
|
|
|
515 |
double pentagamma(double);
|
|
|
516 |
|
|
|
517 |
double beta(double, double);
|
|
|
518 |
double lbeta(double, double);
|
|
|
519 |
|
|
|
520 |
double choose(double, double);
|
|
|
521 |
double lchoose(double, double);
|
|
|
522 |
|
|
|
523 |
/* Bessel Functions */
|
|
|
524 |
|
|
|
525 |
double bessel_i(double, double, double);
|
|
|
526 |
double bessel_j(double, double);
|
|
|
527 |
double bessel_k(double, double, double);
|
|
|
528 |
double bessel_y(double, double);
|
|
|
529 |
|
|
|
530 |
|
|
|
531 |
/* General Support Functions */
|
|
|
532 |
|
|
|
533 |
double pythag(double, double);
|
|
|
534 |
#ifndef HAVE_EXPM1
|
|
|
535 |
double expm1(double); /* = exp(x)-1 {care for small x} */
|
|
|
536 |
#endif
|
|
|
537 |
#ifndef HAVE_LOG1P
|
|
|
538 |
double log1p(double); /* = log(1+x) {care for small x} */
|
|
|
539 |
#endif
|
|
|
540 |
int imax2(int, int);
|
|
|
541 |
int imin2(int, int);
|
|
|
542 |
double fmax2(double, double);
|
|
|
543 |
double fmin2(double, double);
|
|
|
544 |
double sign(double);
|
|
|
545 |
double fprec(double, double);
|
|
|
546 |
double fround(double, double);
|
|
|
547 |
double fsign(double, double);
|
|
|
548 |
double ftrunc(double);
|
|
|
549 |
|
|
|
550 |
|
|
|
551 |
/* ----------------- Private part of the header file ------------------- */
|
|
|
552 |
|
|
|
553 |
/* old-R Compatibility */
|
|
|
554 |
|
|
|
555 |
#define snorm norm_rand
|
|
|
556 |
#define sunif unif_rand
|
|
|
557 |
#define sexp exp_rand
|
|
|
558 |
|
|
|
559 |
#ifdef MATHLIB_PRIVATE
|
|
|
560 |
#define d1mach Rf_d1mach
|
|
|
561 |
#define gamma_cody Rf_gamma_cody
|
|
|
562 |
|
|
|
563 |
double d1mach(int);
|
|
|
564 |
double gamma_cody(double);
|
|
|
565 |
|
|
|
566 |
#endif /* MATHLIB_PRIVATE */
|
|
|
567 |
|
|
|
568 |
#ifdef MATHLIB_STANDALONE
|
|
|
569 |
#ifndef MATHLIB_PRIVATE_H
|
|
|
570 |
|
| 25128 |
luke |
571 |
#ifdef IEEE_754
|
|
|
572 |
# define ISNAN(x) (isnan(x)!=0)
|
|
|
573 |
#else
|
|
|
574 |
# define ISNAN(x) R_IsNaNorNA(x)
|
|
|
575 |
#endif
|
| 22860 |
ripley |
576 |
#define R_FINITE(x) R_finite(x)
|
|
|
577 |
int R_IsNaNorNA(double);
|
|
|
578 |
int R_finite(double);
|
|
|
579 |
|
|
|
580 |
#ifdef WIN32
|
|
|
581 |
# define NA_REAL (*_imp__NA_REAL)
|
|
|
582 |
# define R_NegInf (*_imp__R_NegInf)
|
|
|
583 |
# define R_PosInf (*_imp__R_PosInf)
|
|
|
584 |
# define N01_kind (*_imp__N01_kind)
|
|
|
585 |
# endif
|
|
|
586 |
|
|
|
587 |
#endif /* not MATHLIB_PRIVATE_H */
|
|
|
588 |
#endif /* MATHLIB_STANDALONE */
|
|
|
589 |
|
|
|
590 |
#ifdef MATHLIB_STANDALONE
|
|
|
591 |
# define REprintf fprintf(stderr,
|
|
|
592 |
#else
|
|
|
593 |
# ifndef PRTUTIL_H_
|
|
|
594 |
void REprintf(char*, ...);
|
|
|
595 |
# endif
|
|
|
596 |
#endif
|
|
|
597 |
|
|
|
598 |
#ifdef __cplusplus
|
|
|
599 |
}
|
|
|
600 |
#endif
|
|
|
601 |
|
|
|
602 |
#endif /* RMATH_H */
|