| 1 | /* specfunc/bessel_In.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_bessel.h"cxx . . $ `<file>/external/gsl/gsl_sf_bessel.h`/ |
| 26 | |
| 27 | #include "gsl_specfunc__error.h"cxx . . $ `<file>/external/gsl/gsl_specfunc__error.h`/ |
| 28 | |
| 29 | #include "gsl_specfunc__bessel.h"cxx . . $ `<file>/external/gsl/gsl_specfunc__bessel.h`/ |
| 30 | |
| 31 | /*-*-*-*-*-*-*-*-*-*-*-* Functions with Error Codes *-*-*-*-*-*-*-*-*-*-*-*/ |
| 32 | |
| 33 | |
| 34 | int |
| 35 | gsl_sf_bessel_In_scaled_ecxx . . $ gsl_sf_bessel_In_scaled_e(6e0db8bf56396db2).(int n, const double x, gsl_sf_resultcxx . . $ gsl_sf_result# * result) |
| 36 | { |
| 37 | const double ax = fabs(x); |
| 38 | |
| 39 | n = abscxx . . $ abs(7864480464b09eea).(n); /* I(-n, z) = I(n, z) */ |
| 40 | |
| 41 | /* CHECK_POINTER(result) */ |
| 42 | |
| 43 | if(n == 0) { |
| 44 | return gsl_sf_bessel_I0_scaled_ecxx . . $ gsl_sf_bessel_I0_scaled_e(feafd9287608bc44).(x, result); |
| 45 | } |
| 46 | else if(n == 1) { |
| 47 | return gsl_sf_bessel_I1_scaled_ecxx . . $ gsl_sf_bessel_I1_scaled_e(feafd9287608bc44).(x, result); |
| 48 | } |
| 49 | else if(x == 0.0) { |
| 50 | result->valcxx . . $ gsl_sf_result_struct#val. = 0.0; |
| 51 | result->errcxx . . $ gsl_sf_result_struct#err. = 0.0; |
| 52 | return GSL_SUCCESScxx . . $ GSL_SUCCESS.; |
| 53 | } |
| 54 | else if(x*x < 10.0*(n+1.0)/M_Ecxx . . $ `<external>/11263917310783833665/math.h:1116:10`!) { |
| 55 | gsl_sf_resultcxx . . $ gsl_sf_result# t; |
| 56 | double ex = exp(-ax); |
| 57 | int stat_In = gsl_sf_bessel_IJ_taylor_ecxx . . $ gsl_sf_bessel_IJ_taylor_e(2103957cdc9cfe31).((double)n, ax, 1, 50, GSL_DBL_EPSILONcxx . . $ `external/gsl/gsl_machine.h:17:9`!, &t); |
| 58 | result->valcxx . . $ gsl_sf_result_struct#val. = t.valcxx . . $ gsl_sf_result_struct#val. * ex; |
| 59 | result->errcxx . . $ gsl_sf_result_struct#err. = t.errcxx . . $ gsl_sf_result_struct#err. * ex; |
| 60 | 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.); |
| 61 | if(x < 0.0 && GSL_IS_ODDcxx . . $ `external/gsl/gsl_math.h:112:9`!(n)) result->valcxx . . $ gsl_sf_result_struct#val. = -result->valcxx . . $ gsl_sf_result_struct#val.; |
| 62 | return stat_In; |
| 63 | } |
| 64 | else if(n < 150 && ax < 1e7) { |
| 65 | gsl_sf_resultcxx . . $ gsl_sf_result# I0_scaled; |
| 66 | int stat_I0 = gsl_sf_bessel_I0_scaled_ecxx . . $ gsl_sf_bessel_I0_scaled_e(feafd9287608bc44).(ax, &I0_scaled); |
| 67 | double rat; |
| 68 | int stat_CF1 = gsl_sf_bessel_I_CF1_sercxx . . $ gsl_sf_bessel_I_CF1_ser(55fbf6ec1f1218f9).((double)n, ax, &rat); |
| 69 | double Ikp1 = rat * GSL_SQRT_DBL_MINcxx . . $ `external/gsl/gsl_machine.h:26:9`!; |
| 70 | double Ik = GSL_SQRT_DBL_MINcxx . . $ `external/gsl/gsl_machine.h:26:9`!; |
| 71 | double Ikm1; |
| 72 | int k; |
| 73 | for(k=n; k >= 1; k--) { |
| 74 | Ikm1 = Ikp1 + 2.0*k/ax * Ik; |
| 75 | Ikp1 = Ik; |
| 76 | Ik = Ikm1; |
| 77 | } |
| 78 | result->valcxx . . $ gsl_sf_result_struct#val. = I0_scaled.valcxx . . $ gsl_sf_result_struct#val. * (GSL_SQRT_DBL_MINcxx . . $ `external/gsl/gsl_machine.h:26:9`! / Ik); |
| 79 | result->errcxx . . $ gsl_sf_result_struct#err. = I0_scaled.errcxx . . $ gsl_sf_result_struct#err. * (GSL_SQRT_DBL_MINcxx . . $ `external/gsl/gsl_machine.h:26:9`! / Ik); |
| 80 | 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.); |
| 81 | if(x < 0.0 && GSL_IS_ODDcxx . . $ `external/gsl/gsl_math.h:112:9`!(n)) result->valcxx . . $ gsl_sf_result_struct#val. = -result->valcxx . . $ gsl_sf_result_struct#val.; |
| 82 | return GSL_ERROR_SELECT_2cxx . . $ `external/gsl/gsl_errno.h:145:9`!(stat_I0, stat_CF1); |
| 83 | } |
| 84 | else if( GSL_MINcxx . . $ `external/gsl/gsl_math.h:123:9`!( 0.29/(n*n), 0.5/(n*n + x*x) ) < 0.5*GSL_ROOT3_DBL_EPSILONcxx . . $ `external/gsl/gsl_machine.h:19:9`!) { |
| 85 | int stat_as = gsl_sf_bessel_Inu_scaled_asymp_unif_ecxx . . $ gsl_sf_bessel_Inu_scaled_asymp_unif_e(38fedf92a6b14b51).((double)n, ax, result); |
| 86 | if(x < 0.0 && GSL_IS_ODDcxx . . $ `external/gsl/gsl_math.h:112:9`!(n)) result->valcxx . . $ gsl_sf_result_struct#val. = -result->valcxx . . $ gsl_sf_result_struct#val.; |
| 87 | return stat_as; |
| 88 | } |
| 89 | else { |
| 90 | const int nhi = 2 + (int) (1.2 / GSL_ROOT6_DBL_EPSILONcxx . . $ `external/gsl/gsl_machine.h:22:9`!); |
| 91 | gsl_sf_resultcxx . . $ gsl_sf_result# r_Ikp1; |
| 92 | gsl_sf_resultcxx . . $ gsl_sf_result# r_Ik; |
| 93 | int stat_a1 = gsl_sf_bessel_Inu_scaled_asymp_unif_ecxx . . $ gsl_sf_bessel_Inu_scaled_asymp_unif_e(38fedf92a6b14b51).(nhi+1.0, ax, &r_Ikp1); |
| 94 | int stat_a2 = gsl_sf_bessel_Inu_scaled_asymp_unif_ecxx . . $ gsl_sf_bessel_Inu_scaled_asymp_unif_e(38fedf92a6b14b51).((double)nhi, ax, &r_Ik); |
| 95 | double Ikp1 = r_Ikp1.valcxx . . $ gsl_sf_result_struct#val.; |
| 96 | double Ik = r_Ik.valcxx . . $ gsl_sf_result_struct#val.; |
| 97 | double Ikm1; |
| 98 | int k; |
| 99 | for(k=nhi; k > n; k--) { |
| 100 | Ikm1 = Ikp1 + 2.0*k/ax * Ik; |
| 101 | Ikp1 = Ik; |
| 102 | Ik = Ikm1; |
| 103 | } |
| 104 | result->valcxx . . $ gsl_sf_result_struct#val. = Ik; |
| 105 | result->errcxx . . $ gsl_sf_result_struct#err. = Ik * (r_Ikp1.errcxx . . $ gsl_sf_result_struct#err./r_Ikp1.valcxx . . $ gsl_sf_result_struct#val. + r_Ik.errcxx . . $ gsl_sf_result_struct#err./r_Ik.valcxx . . $ gsl_sf_result_struct#val.); |
| 106 | if(x < 0.0 && GSL_IS_ODDcxx . . $ `external/gsl/gsl_math.h:112:9`!(n)) result->valcxx . . $ gsl_sf_result_struct#val. = -result->valcxx . . $ gsl_sf_result_struct#val.; |
| 107 | return GSL_ERROR_SELECT_2cxx . . $ `external/gsl/gsl_errno.h:145:9`!(stat_a1, stat_a2); |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | |
| 112 | int |
| 113 | gsl_sf_bessel_In_scaled_arraycxx . . $ gsl_sf_bessel_In_scaled_array(fb7a5a69cfb04214).(const int nmin, const int nmax, const double x, double * result_array) |
| 114 | { |
| 115 | /* CHECK_POINTER(result_array) */ |
| 116 | |
| 117 | if(nmax < nmin || nmin < 0) { |
| 118 | int j; |
| 119 | for(j=0; j<=nmax-nmin; j++) result_array[j] = 0.0; |
| 120 | GSL_ERRORcxx . . $ `external/gsl/gsl_errno.h:104:9`! ("domain error", GSL_EDOM); |
| 121 | } |
| 122 | else if(x == 0.0) { |
| 123 | int j; |
| 124 | for(j=0; j<=nmax-nmin; j++) result_array[j] = 0.0; |
| 125 | if(nmin == 0) result_array[0] = 1.0; |
| 126 | return GSL_SUCCESScxx . . $ GSL_SUCCESS.; |
| 127 | } |
| 128 | else if(nmax == 0) { |
| 129 | gsl_sf_resultcxx . . $ gsl_sf_result# I0_scaled; |
| 130 | int stat = gsl_sf_bessel_I0_scaled_ecxx . . $ gsl_sf_bessel_I0_scaled_e(feafd9287608bc44).(x, &I0_scaled); |
| 131 | result_array[0] = I0_scaled.valcxx . . $ gsl_sf_result_struct#val.; |
| 132 | return stat; |
| 133 | } |
| 134 | else { |
| 135 | const double ax = fabs(x); |
| 136 | const double two_over_x = 2.0/ax; |
| 137 | |
| 138 | /* starting values */ |
| 139 | gsl_sf_resultcxx . . $ gsl_sf_result# r_Inp1; |
| 140 | gsl_sf_resultcxx . . $ gsl_sf_result# r_In; |
| 141 | int stat_0 = gsl_sf_bessel_In_scaled_ecxx . . $ gsl_sf_bessel_In_scaled_e(6e0db8bf56396db2).(nmax+1, ax, &r_Inp1); |
| 142 | int stat_1 = gsl_sf_bessel_In_scaled_ecxx . . $ gsl_sf_bessel_In_scaled_e(6e0db8bf56396db2).(nmax, ax, &r_In); |
| 143 | double Inp1 = r_Inp1.valcxx . . $ gsl_sf_result_struct#val.; |
| 144 | double In = r_In.valcxx . . $ gsl_sf_result_struct#val.; |
| 145 | double Inm1; |
| 146 | int n; |
| 147 | |
| 148 | for(n=nmax; n>=nmin; n--) { |
| 149 | result_array[n-nmin] = In; |
| 150 | Inm1 = Inp1 + n * two_over_x * In; |
| 151 | Inp1 = In; |
| 152 | In = Inm1; |
| 153 | } |
| 154 | |
| 155 | /* deal with signs */ |
| 156 | if(x < 0.0) { |
| 157 | for(n=nmin; n<=nmax; n++) { |
| 158 | if(GSL_IS_ODDcxx . . $ `external/gsl/gsl_math.h:112:9`!(n)) result_array[n-nmin] = -result_array[n-nmin]; |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | return GSL_ERROR_SELECT_2cxx . . $ `external/gsl/gsl_errno.h:145:9`!(stat_0, stat_1); |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | |
| 167 | int |
| 168 | gsl_sf_bessel_In_ecxx . . $ gsl_sf_bessel_In_e(6e0db8bf56396db2).(const int n_in, const double x, gsl_sf_resultcxx . . $ gsl_sf_result# * result) |
| 169 | { |
| 170 | const double ax = fabs(x); |
| 171 | const int n = abscxx . . $ abs(7864480464b09eea).(n_in); /* I(-n, z) = I(n, z) */ |
| 172 | gsl_sf_resultcxx . . $ gsl_sf_result# In_scaled; |
| 173 | const int stat_In_scaled = gsl_sf_bessel_In_scaled_ecxx . . $ gsl_sf_bessel_In_scaled_e(6e0db8bf56396db2).(n, ax, &In_scaled); |
| 174 | |
| 175 | /* In_scaled is always less than 1, |
| 176 | * so this overflow check is conservative. |
| 177 | */ |
| 178 | if(ax > GSL_LOG_DBL_MAXcxx . . $ `external/gsl/gsl_machine.h:39:9`! - 1.0) { |
| 179 | OVERFLOW_ERRORcxx . . $ `external/gsl/gsl_specfunc__error.h:1:9`!(result); |
| 180 | } |
| 181 | else { |
| 182 | const double ex = exp(ax); |
| 183 | result->valcxx . . $ gsl_sf_result_struct#val. = ex * In_scaled.valcxx . . $ gsl_sf_result_struct#val.; |
| 184 | result->errcxx . . $ gsl_sf_result_struct#err. = ex * In_scaled.errcxx . . $ gsl_sf_result_struct#err.; |
| 185 | result->errcxx . . $ gsl_sf_result_struct#err. += ax * GSL_DBL_EPSILONcxx . . $ `external/gsl/gsl_machine.h:17:9`! * fabs(result->valcxx . . $ gsl_sf_result_struct#val.); |
| 186 | if(x < 0.0 && GSL_IS_ODDcxx . . $ `external/gsl/gsl_math.h:112:9`!(n)) result->valcxx . . $ gsl_sf_result_struct#val. = -result->valcxx . . $ gsl_sf_result_struct#val.; |
| 187 | return stat_In_scaled; |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | |
| 192 | int |
| 193 | gsl_sf_bessel_In_arraycxx . . $ gsl_sf_bessel_In_array(fb7a5a69cfb04214).(const int nmin, const int nmax, const double x, double * result_array) |
| 194 | { |
| 195 | double ax = fabs(x); |
| 196 | |
| 197 | /* CHECK_POINTER(result_array) */ |
| 198 | |
| 199 | if(ax > GSL_LOG_DBL_MAXcxx . . $ `external/gsl/gsl_machine.h:39:9`! - 1.0) { |
| 200 | int j; |
| 201 | for(j=0; j<=nmax-nmin; j++) result_array[j] = 0.0; /* FIXME: should be Inf */ |
| 202 | GSL_ERRORcxx . . $ `external/gsl/gsl_errno.h:104:9`! ("overflow", GSL_EOVRFLW); |
| 203 | } |
| 204 | else { |
| 205 | int j; |
| 206 | double eax = exp(ax); |
| 207 | int status = gsl_sf_bessel_In_scaled_arraycxx . . $ gsl_sf_bessel_In_scaled_array(fb7a5a69cfb04214).(nmin, nmax, x, result_array); |
| 208 | for(j=0; j<=nmax-nmin; j++) result_array[j] *= eax; |
| 209 | return status; |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | /*-*-*-*-*-*-*-*-*-* Functions w/ Natural Prototypes *-*-*-*-*-*-*-*-*-*-*/ |
| 214 | |
| 215 | #include "gsl_specfunc__eval.h"cxx . . $ `<file>/external/gsl/gsl_specfunc__eval.h`/ |
| 216 | |
| 217 | double gsl_sf_bessel_In_scaledcxx . . $ gsl_sf_bessel_In_scaled(538a8530131fd110).(const int n, const double x) |
| 218 | { |
| 219 | EVAL_RESULTcxx . . $ `external/gsl/gsl_specfunc__eval.h:3:9`!(gsl_sf_bessel_In_scaled_e(n, x, &result)); |
| 220 | } |
| 221 | |
| 222 | double gsl_sf_bessel_Incxx . . $ gsl_sf_bessel_In(538a8530131fd110).(const int n, const double x) |
| 223 | { |
| 224 | EVAL_RESULTcxx . . $ `external/gsl/gsl_specfunc__eval.h:3:9`!(gsl_sf_bessel_In_e(n, x, &result)); |
| 225 | } |