Coverage Report

Created: 2026-10-16 07:07

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/r-source/src/nmath/pexp.c
Line
Count
Source
1
/*
2
 *  Mathlib : A C Library of Special Functions
3
 *  Copyright (C) 1998 Ross Ihaka
4
 *  Copyright (C) 2000-2015 The R Core Team
5
 *
6
 *  This program is free software; you can redistribute it and/or modify
7
 *  it under the terms of the GNU General Public License as published by
8
 *  the Free Software Foundation; either version 2 of the License, or
9
 *  (at your option) any later version.
10
 *
11
 *  This program is distributed in the hope that it will be useful,
12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 *  GNU General Public License for more details.
15
 *
16
 *  You should have received a copy of the GNU General Public License
17
 *  along with this program; if not, a copy is available at
18
 *  https://www.R-project.org/Licenses/
19
 *
20
 *  DESCRIPTION
21
 *
22
 *  The distribution function of the exponential distribution.
23
 */
24
#include "nmath.h"
25
#include "dpq.h"
26
27
double pexp(double x, double scale, int lower_tail, int log_p)
28
0
{
29
0
#ifdef IEEE_754
30
0
    if (ISNAN(x) || ISNAN(scale))
31
0
  return x + scale;
32
0
    if (scale < 0) ML_WARN_return_NAN;
33
#else
34
    if (scale <= 0) ML_WARN_return_NAN;
35
#endif
36
37
0
    if (x <= 0.)
38
0
  return R_DT_0;
39
    /* same as weibull( shape = 1): */
40
0
    x = -(x / scale);
41
0
    return lower_tail
42
0
  ? (log_p ? R_Log1_Exp(x) : -expm1(x))
43
0
  : R_D_exp(x);
44
0
}