| 1 | /* specfunc/pow_int.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_pow_int.h"cxx . . $ `<file>/external/gsl/gsl_sf_pow_int.h`/ |
| 26 | |
| 27 | |
| 28 | /*-*-*-*-*-*-*-*-*-*-*-* Functions w/ Error handling *-*-*-*-*-*-*-*-*-*-*-*/ |
| 29 | |
| 30 | int gsl_sf_pow_int_ecxx . . $ gsl_sf_pow_int_e(b73a0f9cf34e6f3d).(double x, int n, gsl_sf_resultcxx . . $ gsl_sf_result# * result) |
| 31 | { |
| 32 | double value = 1.0; |
| 33 | int count = 0; |
| 34 | |
| 35 | /* CHECK_POINTER(result) */ |
| 36 | |
| 37 | |
| 38 | if(n < 0) { |
| 39 | n = -n; |
| 40 | |
| 41 | if(x == 0.0) { |
| 42 | double u = 1.0 / x; |
| 43 | result->valcxx . . $ gsl_sf_result_struct#val. = (n % 2) ? u : (u * u) ; /* correct sign of infinity */ |
| 44 | result->errcxx . . $ gsl_sf_result_struct#err. = GSL_POSINFcxx . . $ `external/gsl/gsl_nan.h:24:10`!; |
| 45 | GSL_ERRORcxx . . $ `external/gsl/gsl_errno.h:104:9`! ("overflow", GSL_EOVRFLW); |
| 46 | } |
| 47 | |
| 48 | x = 1.0/x; |
| 49 | } |
| 50 | |
| 51 | /* repeated squaring method |
| 52 | * returns 0.0^0 = 1.0, so continuous in x |
| 53 | */ |
| 54 | do { |
| 55 | if(GSL_IS_ODDcxx . . $ `external/gsl/gsl_math.h:112:9`!(n)) value *= x; |
| 56 | n >>= 1; |
| 57 | x *= x; |
| 58 | ++count; |
| 59 | } while (n); |
| 60 | |
| 61 | result->valcxx . . $ gsl_sf_result_struct#val. = value; |
| 62 | result->errcxx . . $ gsl_sf_result_struct#err. = 2.0 * GSL_DBL_EPSILONcxx . . $ `external/gsl/gsl_machine.h:17:9`! * (count + 1.0) * fabscxx . . $ fabs(447c67c6676f75c3).(value); |
| 63 | |
| 64 | return GSL_SUCCESScxx . . $ GSL_SUCCESS.; |
| 65 | } |
| 66 | |
| 67 | /*-*-*-*-*-*-*-*-*-* Functions w/ Natural Prototypes *-*-*-*-*-*-*-*-*-*-*/ |
| 68 | |
| 69 | #include "gsl_specfunc__eval.h"cxx . . $ `<file>/external/gsl/gsl_specfunc__eval.h`/ |
| 70 | |
| 71 | double gsl_sf_pow_intcxx . . $ gsl_sf_pow_int(f7856f627868a823).(const double x, const int n) |
| 72 | { |
| 73 | EVAL_RESULTcxx . . $ `external/gsl/gsl_specfunc__eval.h:3:9`!(gsl_sf_pow_int_e(x, n, &result)); |
| 74 | } |