Debian Codegraph @

external/gsl/gsl_specfunc__beta.c

raw symbols SCIP
1 /* specfunc/beta.c
2 *
3 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or (at
8 * your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19
20 /* Author: G. Jungman */
21
22 #include "gsl__config.h"cxx . . $ `<file>/external/gsl/gsl__config.h`/
23 #include "gsl_math.h"cxx . . $ `<file>/external/gsl/gsl_math.h`/
24 #include "gsl_errno.h"cxx . . $ `<file>/external/gsl/gsl_errno.h`/
25 #include "gsl_sf_exp.h"cxx . . $ `<file>/external/gsl/gsl_sf_exp.h`/
26 #include "gsl_sf_log.h"cxx . . $ `<file>/external/gsl/gsl_sf_log.h`/
27 #include "gsl_sf_psi.h"cxx . . $ `<file>/external/gsl/gsl_sf_psi.h`/
28 #include "gsl_sf_gamma.h"cxx . . $ `<file>/external/gsl/gsl_sf_gamma.h`/
29
30 #include "gsl_specfunc__error.h"cxx . . $ `<file>/external/gsl/gsl_specfunc__error.h`/
31
32 static double
33 isnegintcxx . . $ isnegint(447c67c6676f75c3). (const double x)
34 {
35 return (x < 0) && (x == floor(x));
36 }
37
38 int
39 gsl_sf_lnbeta_ecxx . . $ gsl_sf_lnbeta_e(38fedf92a6b14b51).(const double x, const double y, gsl_sf_resultcxx . . $ gsl_sf_result# * result)
40 {
41 double sgn;
42 int status = gsl_sf_lnbeta_sgn_ecxx . . $ gsl_sf_lnbeta_sgn_e(dfc84fd666d6b44).(x,y,result,&sgn);
43 if (sgn == -1) {
44 DOMAIN_ERRORcxx . . $ `external/gsl/gsl_specfunc__error.h:9:9`!(result);
45 }
46 return status;
47 }
48
49 int
50 gsl_sf_lnbeta_sgn_ecxx . . $ gsl_sf_lnbeta_sgn_e(dfc84fd666d6b44).(const double x, const double y, gsl_sf_resultcxx . . $ gsl_sf_result# * result, double * sgn)
51 {
52 /* CHECK_POINTER(result) */
53
54 if(x == 0.0 || y == 0.0) {
55 *sgn = 0.0;
56 DOMAIN_ERRORcxx . . $ `external/gsl/gsl_specfunc__error.h:9:9`!(result);
57 } else if (isnegintcxx . . $ isnegint(447c67c6676f75c3).(x) || isnegintcxx . . $ isnegint(447c67c6676f75c3).(y)) {
58 *sgn = 0.0;
59 DOMAIN_ERRORcxx . . $ `external/gsl/gsl_specfunc__error.h:9:9`!(result); /* not defined for negative integers */
60 }
61
62 /* See if we can handle the postive case with min/max < 0.2 */
63
64 if (x > 0 && y > 0) {
65 const double max = GSL_MAXcxx . . $ `external/gsl/gsl_math.h:122:9`!(x,y);
66 const double min = GSL_MINcxx . . $ `external/gsl/gsl_math.h:123:9`!(x,y);
67 const double rat = min/max;
68
69 if(rat < 0.2) {
70 /* min << max, so be careful
71 * with the subtraction
72 */
73 double lnpre_val;
74 double lnpre_err;
75 double lnpow_val;
76 double lnpow_err;
77 double t1, t2, t3;
78 gsl_sf_resultcxx . . $ gsl_sf_result# lnopr;
79 gsl_sf_resultcxx . . $ gsl_sf_result# gsx, gsy, gsxy;
80 gsl_sf_gammastar_ecxx . . $ gsl_sf_gammastar_e(feafd9287608bc44).(x, &gsx);
81 gsl_sf_gammastar_ecxx . . $ gsl_sf_gammastar_e(feafd9287608bc44).(y, &gsy);
82 gsl_sf_gammastar_ecxx . . $ gsl_sf_gammastar_e(feafd9287608bc44).(x+y, &gsxy);
83 gsl_sf_log_1plusx_ecxx . . $ gsl_sf_log_1plusx_e(feafd9287608bc44).(rat, &lnopr);
84 lnpre_val = log(gsx.valcxx . . $ gsl_sf_result_struct#val.*gsy.valcxx . . $ gsl_sf_result_struct#val./gsxy.valcxx . . $ gsl_sf_result_struct#val. * M_SQRT2cxx . . $ `<external>/11263917310783833665/math.h:1127:10`!*M_SQRTPIcxx . . $ `external/gsl/gsl_math.h:67:9`!);
85 lnpre_err = gsx.errcxx . . $ gsl_sf_result_struct#err./gsx.valcxx . . $ gsl_sf_result_struct#val. + gsy.errcxx . . $ gsl_sf_result_struct#err./gsy.valcxx . . $ gsl_sf_result_struct#val. + gsxy.errcxx . . $ gsl_sf_result_struct#err./gsxy.valcxx . . $ gsl_sf_result_struct#val.;
86 t1 = min*log(rat);
87 t2 = 0.5*log(min);
88 t3 = (x+y-0.5)*lnopr.valcxx . . $ gsl_sf_result_struct#val.;
89 lnpow_val = t1 - t2 - t3;
90 lnpow_err = GSL_DBL_EPSILONcxx . . $ `external/gsl/gsl_machine.h:17:9`! * (fabs(t1) + fabs(t2) + fabs(t3));
91 lnpow_err += fabs(x+y-0.5) * lnopr.errcxx . . $ gsl_sf_result_struct#err.;
92 result->valcxx . . $ gsl_sf_result_struct#val. = lnpre_val + lnpow_val;
93 result->errcxx . . $ gsl_sf_result_struct#err. = lnpre_err + lnpow_err;
94 result->errcxx . . $ gsl_sf_result_struct#err. += 2.0 * GSL_DBL_EPSILONcxx . . $ `external/gsl/gsl_machine.h:17:9`! * fabs(result->valcxx . . $ gsl_sf_result_struct#val.);
95 *sgn = 1.0;
96 return GSL_SUCCESScxx . . $ GSL_SUCCESS.;
97 }
98 }
99
100 /* General case - Fallback */
101 {
102 gsl_sf_resultcxx . . $ gsl_sf_result# lgx, lgy, lgxy;
103 double sgx, sgy, sgxy, xy = x+y;
104 int stat_gx = gsl_sf_lngamma_sgn_ecxx . . $ gsl_sf_lngamma_sgn_e(c2004ae47d1ffebf).(x, &lgx, &sgx);
105 int stat_gy = gsl_sf_lngamma_sgn_ecxx . . $ gsl_sf_lngamma_sgn_e(c2004ae47d1ffebf).(y, &lgy, &sgy);
106 int stat_gxy = gsl_sf_lngamma_sgn_ecxx . . $ gsl_sf_lngamma_sgn_e(c2004ae47d1ffebf).(xy, &lgxy, &sgxy);
107 *sgn = sgx * sgy * sgxy;
108 result->valcxx . . $ gsl_sf_result_struct#val. = lgx.valcxx . . $ gsl_sf_result_struct#val. + lgy.valcxx . . $ gsl_sf_result_struct#val. - lgxy.valcxx . . $ gsl_sf_result_struct#val.;
109 result->errcxx . . $ gsl_sf_result_struct#err. = lgx.errcxx . . $ gsl_sf_result_struct#err. + lgy.errcxx . . $ gsl_sf_result_struct#err. + lgxy.errcxx . . $ gsl_sf_result_struct#err.;
110 result->errcxx . . $ gsl_sf_result_struct#err. += 2.0 * GSL_DBL_EPSILONcxx . . $ `external/gsl/gsl_machine.h:17:9`! * (fabs(lgx.valcxx . . $ gsl_sf_result_struct#val.) + fabs(lgy.valcxx . . $ gsl_sf_result_struct#val.) + fabs(lgxy.valcxx . . $ gsl_sf_result_struct#val.));
111 result->errcxx . . $ gsl_sf_result_struct#err. += 2.0 * GSL_DBL_EPSILONcxx . . $ `external/gsl/gsl_machine.h:17:9`! * fabs(result->valcxx . . $ gsl_sf_result_struct#val.);
112 return GSL_ERROR_SELECT_3cxx . . $ `external/gsl/gsl_errno.h:146:9`!(stat_gx, stat_gy, stat_gxy);
113 }
114 }
115
116
117 int
118 gsl_sf_beta_ecxx . . $ gsl_sf_beta_e(38fedf92a6b14b51).(const double x, const double y, gsl_sf_resultcxx . . $ gsl_sf_result# * result)
119 {
120 if((x > 0 && y > 0) && x < 50.0 && y < 50.0) {
121 /* Handle the easy case */
122 gsl_sf_resultcxx . . $ gsl_sf_result# gx, gy, gxy;
123 gsl_sf_gamma_ecxx . . $ gsl_sf_gamma_e(feafd9287608bc44).(x, &gx);
124 gsl_sf_gamma_ecxx . . $ gsl_sf_gamma_e(feafd9287608bc44).(y, &gy);
125 gsl_sf_gamma_ecxx . . $ gsl_sf_gamma_e(feafd9287608bc44).(x+y, &gxy);
126 result->valcxx . . $ gsl_sf_result_struct#val. = (gx.valcxx . . $ gsl_sf_result_struct#val.*gy.valcxx . . $ gsl_sf_result_struct#val.)/gxy.valcxx . . $ gsl_sf_result_struct#val.;
127 result->errcxx . . $ gsl_sf_result_struct#err. = gx.errcxx . . $ gsl_sf_result_struct#err. * fabs(gy.valcxx . . $ gsl_sf_result_struct#val./gxy.valcxx . . $ gsl_sf_result_struct#val.);
128 result->errcxx . . $ gsl_sf_result_struct#err. += gy.errcxx . . $ gsl_sf_result_struct#err. * fabs(gx.valcxx . . $ gsl_sf_result_struct#val./gxy.valcxx . . $ gsl_sf_result_struct#val.);
129 result->errcxx . . $ gsl_sf_result_struct#err. += fabs((gx.valcxx . . $ gsl_sf_result_struct#val.*gy.valcxx . . $ gsl_sf_result_struct#val.)/(gxy.valcxx . . $ gsl_sf_result_struct#val.*gxy.valcxx . . $ gsl_sf_result_struct#val.)) * gxy.errcxx . . $ gsl_sf_result_struct#err.;
130 result->errcxx . . $ gsl_sf_result_struct#err. += 2.0 * GSL_DBL_EPSILONcxx . . $ `external/gsl/gsl_machine.h:17:9`! * fabs(result->valcxx . . $ gsl_sf_result_struct#val.);
131 return GSL_SUCCESScxx . . $ GSL_SUCCESS.;
132 }
133 else if (isnegintcxx . . $ isnegint(447c67c6676f75c3).(x) || isnegintcxx . . $ isnegint(447c67c6676f75c3).(y)) {
134 DOMAIN_ERRORcxx . . $ `external/gsl/gsl_specfunc__error.h:9:9`!(result);
135 } else if (isnegintcxx . . $ isnegint(447c67c6676f75c3).(x+y)) { /* infinity in the denominator */
136 result->valcxx . . $ gsl_sf_result_struct#val. = 0.0;
137 result->errcxx . . $ gsl_sf_result_struct#err. = 0.0;
138 return GSL_SUCCESScxx . . $ GSL_SUCCESS.;
139 } else {
140 gsl_sf_resultcxx . . $ gsl_sf_result# lb;
141 double sgn;
142 int stat_lb = gsl_sf_lnbeta_sgn_ecxx . . $ gsl_sf_lnbeta_sgn_e(dfc84fd666d6b44).(x, y, &lb, &sgn);
143 if(stat_lb == GSL_SUCCESScxx . . $ GSL_SUCCESS.) {
144 int status = gsl_sf_exp_err_ecxx . . $ gsl_sf_exp_err_e(38fedf92a6b14b51).(lb.valcxx . . $ gsl_sf_result_struct#val., lb.errcxx . . $ gsl_sf_result_struct#err., result);
145 result->valcxx . . $ gsl_sf_result_struct#val. *= sgn;
146 return status;
147 }
148 else {
149 result->valcxx . . $ gsl_sf_result_struct#val. = 0.0;
150 result->errcxx . . $ gsl_sf_result_struct#err. = 0.0;
151 return stat_lb;
152 }
153 }
154 }
155
156
157 /*-*-*-*-*-*-*-*-*-* Functions w/ Natural Prototypes *-*-*-*-*-*-*-*-*-*-*/
158
159 #include "gsl_specfunc__eval.h"cxx . . $ `<file>/external/gsl/gsl_specfunc__eval.h`/
160
161 double gsl_sf_lnbetacxx . . $ gsl_sf_lnbeta(d8e7e0733fa41c87).(const double x, const double y)
162 {
163 EVAL_RESULTcxx . . $ `external/gsl/gsl_specfunc__eval.h:3:9`!(gsl_sf_lnbeta_e(x, y, &result));
164 }
165
166 double gsl_sf_betacxx . . $ gsl_sf_beta(d8e7e0733fa41c87).(const double x, const double y)
167 {
168 EVAL_RESULTcxx . . $ `external/gsl/gsl_specfunc__eval.h:3:9`!(gsl_sf_beta_e(x, y, &result));
169 }