MARLEY (Model of Argon Reaction Low Energy Yields) v2.0.0
A Monte Carlo event generator for tens-of-MeV neutrino interactions
Loading...
Searching...
No Matches
marley_gsl.cc
1/*
2 * Built-in GSL fallback implementation for MARLEY.
3 *
4 * This single translation unit contains the minimal amalgamated subset of GSL
5 * needed by MARLEY when gsl-config is unavailable.
6 *
7 * MARLEY call sites:
8 * gsl_set_error_handler -- src/coulomb_wavefunctions.cc
9 * gsl_sf_coulomb_wave_FG_e -- src/coulomb_wavefunctions.cc
10 * gsl_cdf_chisq_Q -- include/marley/tests/Histogram.hh
11 * gsl_sf_coulomb_wave_FG_array -- retained for possible future use
12 *
13 * Provenance:
14 * Upstream mirror: https://github.com/sjgardiner/gsl
15 * Target tag: release-2-8 (GSL 2.8)
16 * Commit used: 17f5f257099a6a9ba539d950e95a2110279c3193 (master)
17 *
18 * Differences versus upstream:
19 * - Required content is inlined into this single source file.
20 * - gsl_sf_gamma_inc_e is omitted (would require specfunc/expint.c).
21 * - gsl_cdf_gamma_P and gsl_cdf_chisq_P are omitted; only _Q variants are
22 * needed by MARLEY.
23 * - gsl_cdf_gamma_Q and gsl_cdf_chisq_Q deliberately reject non-physical
24 * domains (a <= 0, b <= 0, nu <= 0) through the GSL error path.
25 *
26 * Files amalgamated (dependency order):
27 * err/error.c, err/stream.c
28 * sys/fdiv.c, sys/infnan.c, sys/coerce.c
29 * sys/minmax.c, sys/prec.c
30 * complex/inline.c, complex/math.c
31 * specfunc/log.c, specfunc/trig.c, specfunc/exp.c, specfunc/gamma.c
32 * specfunc/elementary.c, specfunc/zeta.c, specfunc/psi.c
33 * specfunc/airy.c, specfunc/coulomb.c
34 * specfunc/cheb_eval.c
35 * specfunc/cheb_eval_mode.c
36 * specfunc/erfc.c (partial: gsl_sf_erfc_e only)
37 * specfunc/gamma_inc.c (partial: gsl_sf_gamma_inc_P, gsl_sf_gamma_inc_Q only)
38 * cdf/gamma.c (partial: gsl_cdf_gamma_Q only)
39 * cdf/chisq.c (partial: gsl_cdf_chisq_Q only)
40 *
41 * Licensing:
42 * Upstream GSL code is licensed under GPLv3 (and parts LGPLv3).
43 * See upstream GSL licensing files for complete terms and notices.
44 */
45
46// Ignore eveything here unless we actually need to build the built-in
47// fallback for the GSL library
48#ifndef MARLEY_FOUND_GSL
49
50/* begin inlined header: specfunc/error.h */
51#ifndef MARLEY_BUILTIN_GSL_SPECFUNC_ERROR_H
52#define MARLEY_BUILTIN_GSL_SPECFUNC_ERROR_H
53#define OVERFLOW_ERROR(result) do { (result)->val = GSL_POSINF; (result)->err = GSL_POSINF; GSL_ERROR ("overflow", GSL_EOVRFLW); } while(0)
54#define UNDERFLOW_ERROR(result) do { (result)->val = 0.0; (result)->err = GSL_DBL_MIN; GSL_ERROR ("underflow", GSL_EUNDRFLW); } while(0)
55#define INTERNAL_OVERFLOW_ERROR(result) do { (result)->val = GSL_POSINF; (result)->err = GSL_POSINF; return GSL_EOVRFLW; } while(0)
56#define INTERNAL_UNDERFLOW_ERROR(result) do { (result)->val = 0.0; (result)->err = GSL_DBL_MIN; return GSL_EUNDRFLW; } while(0)
57#define DOMAIN_ERROR(result) do { (result)->val = GSL_NAN; (result)->err = GSL_NAN; GSL_ERROR ("domain error", GSL_EDOM); } while(0)
58#define DOMAIN_ERROR_MSG(msg, result) do { (result)->val = GSL_NAN; (result)->err = GSL_NAN; GSL_ERROR ((msg), GSL_EDOM); } while(0)
59#define DOMAIN_ERROR_E10(result) do { (result)->val = GSL_NAN; (result)->err = GSL_NAN; (result)->e10 = 0 ; GSL_ERROR ("domain error", GSL_EDOM); } while(0)
60#define OVERFLOW_ERROR_E10(result) do { (result)->val = GSL_POSINF; (result)->err = GSL_POSINF; (result)->e10 = 0; GSL_ERROR ("overflow", GSL_EOVRFLW); } while(0)
61#define UNDERFLOW_ERROR_E10(result) do { (result)->val = 0.0; (result)->err = GSL_DBL_MIN; (result)->e10 = 0; GSL_ERROR ("underflow", GSL_EUNDRFLW); } while(0)
62#define OVERFLOW_ERROR_2(r1,r2) do { (r1)->val = GSL_POSINF; (r1)->err = GSL_POSINF; (r2)->val = GSL_POSINF ; (r2)->err=GSL_POSINF; GSL_ERROR ("overflow", GSL_EOVRFLW); } while(0)
63#define UNDERFLOW_ERROR_2(r1,r2) do { (r1)->val = 0.0; (r1)->err = GSL_DBL_MIN; (r2)->val = 0.0 ; (r2)->err = GSL_DBL_MIN; GSL_ERROR ("underflow", GSL_EUNDRFLW); } while(0)
64#define DOMAIN_ERROR_2(r1,r2) do { (r1)->val = GSL_NAN; (r1)->err = GSL_NAN; (r2)->val = GSL_NAN; (r2)->err = GSL_NAN; GSL_ERROR ("domain error", GSL_EDOM); } while(0)
65#define MAXITER_ERROR(result) do { (result)->val = GSL_NAN; (result)->err = GSL_NAN; GSL_ERROR ("too many iterations error", GSL_EMAXITER); } while(0)
66#endif
67/* end inlined header: specfunc/error.h */
68
69/* begin inlined header: specfunc/check.h */
70#ifndef MARLEY_BUILTIN_GSL_SPECFUNC_CHECK_H
71#define MARLEY_BUILTIN_GSL_SPECFUNC_CHECK_H
72#define CHECK_UNDERFLOW(r) if (fabs((r)->val) < GSL_DBL_MIN) GSL_ERROR("underflow", GSL_EUNDRFLW);
73#endif
74/* end inlined header: specfunc/check.h */
75
76/* begin inlined header: specfunc/eval.h */
77#ifndef MARLEY_BUILTIN_GSL_SPECFUNC_EVAL_H
78#define MARLEY_BUILTIN_GSL_SPECFUNC_EVAL_H
79#define EVAL_RESULT(fn) gsl_sf_result result; int status = fn; if (status != GSL_SUCCESS) { GSL_ERROR_VAL(#fn, status, result.val); } ; return result.val;
80#define EVAL_DOUBLE(fn) int status = fn; if (status != GSL_SUCCESS) { GSL_ERROR_VAL(#fn, status, result); } ; return result;
81#endif
82/* end inlined header: specfunc/eval.h */
83
84/* begin inlined header: specfunc/chebyshev.h */
85#ifndef MARLEY_BUILTIN_GSL_CHEBYSHEV_H
86#define MARLEY_BUILTIN_GSL_CHEBYSHEV_H
88 double * c;
89 int order;
90 double a;
91 double b;
92 int order_sp;
93};
94typedef struct cheb_series_struct cheb_series;
95#endif
96/* end inlined header: specfunc/chebyshev.h */
97/* Error handling ----------------------------------------------------------*/
98/* begin inlined source: err/error.c */
99/* err/error.c
100 *
101 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, Brian Gough
102 *
103 * This program is free software; you can redistribute it and/or modify
104 * it under the terms of the GNU General Public License as published by
105 * the Free Software Foundation; either version 3 of the License, or (at
106 * your option) any later version.
107 *
108 * This program is distributed in the hope that it will be useful, but
109 * WITHOUT ANY WARRANTY; without even the implied warranty of
110 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
111 * General Public License for more details.
112 *
113 * You should have received a copy of the GNU General Public License
114 * along with this program; if not, write to the Free Software
115 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
116 */
117/* begin inlined header: config.h */
118#ifndef MARLEY_BUILTIN_GSL_CONFIG_WRAPPER_H
119#define MARLEY_BUILTIN_GSL_CONFIG_WRAPPER_H
120/* begin inlined header: gsl_config.h */
121#ifndef MARLEY_BUILTIN_GSL_CONFIG_H
122#define MARLEY_BUILTIN_GSL_CONFIG_H
123
124#define HAVE_INLINE 1
125#define HAVE_DECL_ISFINITE 1
126#define HAVE_DECL_ISNAN 1
127#define HAVE_DECL_ISINF 1
128#define GSL_COERCE_DBL(x) (x)
129
130#define GSL_DISABLE_DEPRECATED 0
131#define PACKAGE_VERSION "2.8"
132#define VERSION "2.8"
133
134#endif
135
136/* end inlined header: gsl_config.h */
137#endif
138
139/* end inlined header: config.h */
140#include <stddef.h>
141#include <stdlib.h>
142#include <stdio.h>
143/* begin inlined header: gsl/gsl_errno.h */
144/* err/gsl_errno.h
145 *
146 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, Brian Gough
147 *
148 * This program is free software; you can redistribute it and/or modify
149 * it under the terms of the GNU General Public License as published by
150 * the Free Software Foundation; either version 3 of the License, or (at
151 * your option) any later version.
152 *
153 * This program is distributed in the hope that it will be useful, but
154 * WITHOUT ANY WARRANTY; without even the implied warranty of
155 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
156 * General Public License for more details.
157 *
158 * You should have received a copy of the GNU General Public License
159 * along with this program; if not, write to the Free Software
160 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
161 */
162
163#ifndef __GSL_ERRNO_H__
164#define __GSL_ERRNO_H__
165
166#include <stdio.h>
167#include <errno.h>
168/* begin inlined header: gsl/gsl_types.h */
169/* gsl_types.h
170 *
171 * Copyright (C) 2001, 2007 Brian Gough
172 *
173 * This program is free software; you can redistribute it and/or modify
174 * it under the terms of the GNU General Public License as published by
175 * the Free Software Foundation; either version 3 of the License, or (at
176 * your option) any later version.
177 *
178 * This program is distributed in the hope that it will be useful, but
179 * WITHOUT ANY WARRANTY; without even the implied warranty of
180 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
181 * General Public License for more details.
182 *
183 * You should have received a copy of the GNU General Public License
184 * along with this program; if not, write to the Free Software
185 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
186 */
187
188#ifndef __GSL_TYPES_H__
189#define __GSL_TYPES_H__
190
191#ifndef GSL_VAR
192
193#ifdef WIN32
194# ifdef GSL_DLL
195# ifdef DLL_EXPORT
196# define GSL_VAR extern __declspec(dllexport)
197# else
198# define GSL_VAR extern __declspec(dllimport)
199# endif
200# else
201# define GSL_VAR extern
202# endif
203#else
204# define GSL_VAR extern
205#endif
206
207#endif
208
209#endif /* __GSL_TYPES_H__ */
210
211/* end inlined header: gsl/gsl_types.h */
212#undef __BEGIN_DECLS
213#undef __END_DECLS
214#ifdef __cplusplus
215# define __BEGIN_DECLS extern "C" {
216# define __END_DECLS }
217#else
218# define __BEGIN_DECLS /* empty */
219# define __END_DECLS /* empty */
220#endif
221
222__BEGIN_DECLS
223
224enum {
225 GSL_SUCCESS = 0,
226 GSL_FAILURE = -1,
227 GSL_CONTINUE = -2, /* iteration has not converged */
228 GSL_EDOM = 1, /* input domain error, e.g sqrt(-1) */
229 GSL_ERANGE = 2, /* output range error, e.g. exp(1e100) */
230 GSL_EFAULT = 3, /* invalid pointer */
231 GSL_EINVAL = 4, /* invalid argument supplied by user */
232 GSL_EFAILED = 5, /* generic failure */
233 GSL_EFACTOR = 6, /* factorization failed */
234 GSL_ESANITY = 7, /* sanity check failed - shouldn't happen */
235 GSL_ENOMEM = 8, /* malloc failed */
236 GSL_EBADFUNC = 9, /* problem with user-supplied function */
237 GSL_ERUNAWAY = 10, /* iterative process is out of control */
238 GSL_EMAXITER = 11, /* exceeded max number of iterations */
239 GSL_EZERODIV = 12, /* tried to divide by zero */
240 GSL_EBADTOL = 13, /* user specified an invalid tolerance */
241 GSL_ETOL = 14, /* failed to reach the specified tolerance */
242 GSL_EUNDRFLW = 15, /* underflow */
243 GSL_EOVRFLW = 16, /* overflow */
244 GSL_ELOSS = 17, /* loss of accuracy */
245 GSL_EROUND = 18, /* failed because of roundoff error */
246 GSL_EBADLEN = 19, /* matrix, vector lengths are not conformant */
247 GSL_ENOTSQR = 20, /* matrix not square */
248 GSL_ESING = 21, /* apparent singularity detected */
249 GSL_EDIVERGE = 22, /* integral or series is divergent */
250 GSL_EUNSUP = 23, /* requested feature is not supported by the hardware */
251 GSL_EUNIMPL = 24, /* requested feature not (yet) implemented */
252 GSL_ECACHE = 25, /* cache limit exceeded */
253 GSL_ETABLE = 26, /* table limit exceeded */
254 GSL_ENOPROG = 27, /* iteration is not making progress towards solution */
255 GSL_ENOPROGJ = 28, /* jacobian evaluations are not improving the solution */
256 GSL_ETOLF = 29, /* cannot reach the specified tolerance in F */
257 GSL_ETOLX = 30, /* cannot reach the specified tolerance in X */
258 GSL_ETOLG = 31, /* cannot reach the specified tolerance in gradient */
259 GSL_EOF = 32 /* end of file */
260} ;
261
262void gsl_error (const char * reason, const char * file, int line,
263 int gsl_errno);
264
265void gsl_stream_printf (const char *label, const char *file,
266 int line, const char *reason);
267
268typedef void gsl_error_handler_t (const char * reason, const char * file,
269 int line, int gsl_errno);
270
271gsl_error_handler_t *
272gsl_set_error_handler (gsl_error_handler_t * new_handler);
273
274/* GSL_ERROR: call the error handler, and return the error code */
275
276#define GSL_ERROR(reason, gsl_errno) \
277 do { \
278 gsl_error (reason, __FILE__, __LINE__, gsl_errno) ; \
279 return gsl_errno ; \
280 } while (0)
281
282/* GSL_ERROR_VAL: call the error handler, and return the given value */
283
284#define GSL_ERROR_VAL(reason, gsl_errno, value) \
285 do { \
286 gsl_error (reason, __FILE__, __LINE__, gsl_errno) ; \
287 return value ; \
288 } while (0)
289
290/* GSL_ERROR_VOID: call the error handler, and then return
291 (for void functions which still need to generate an error) */
292
293#define GSL_ERROR_VOID(reason, gsl_errno) \
294 do { \
295 gsl_error (reason, __FILE__, __LINE__, gsl_errno) ; \
296 return ; \
297 } while (0)
298
299/* GSL_ERROR_NULL suitable for out-of-memory conditions */
300
301#define GSL_ERROR_NULL(reason, gsl_errno) GSL_ERROR_VAL(reason, gsl_errno, 0)
302
303/* Sometimes you have several status results returned from
304 * function calls and you want to combine them in some sensible
305 * way. You cannot produce a "total" status condition, but you can
306 * pick one from a set of conditions based on an implied hierarchy.
307 *
308 * In other words:
309 * you have: status_a, status_b, ...
310 * you want: status = (status_a if it is bad, or status_b if it is bad,...)
311 *
312 * In this example you consider status_a to be more important and
313 * it is checked first, followed by the others in the order specified.
314 *
315 * Here are some dumb macros to do this.
316 */
317#define GSL_ERROR_SELECT_2(a,b) ((a) != GSL_SUCCESS ? (a) : ((b) != GSL_SUCCESS ? (b) : GSL_SUCCESS))
318#define GSL_ERROR_SELECT_3(a,b,c) ((a) != GSL_SUCCESS ? (a) : GSL_ERROR_SELECT_2(b,c))
319#define GSL_ERROR_SELECT_4(a,b,c,d) ((a) != GSL_SUCCESS ? (a) : GSL_ERROR_SELECT_3(b,c,d))
320#define GSL_ERROR_SELECT_5(a,b,c,d,e) ((a) != GSL_SUCCESS ? (a) : GSL_ERROR_SELECT_4(b,c,d,e))
321
322#define GSL_STATUS_UPDATE(sp, s) do { if ((s) != GSL_SUCCESS) *(sp) = (s);} while(0)
323
324__END_DECLS
325
326#endif /* __GSL_ERRNO_H__ */
327
328/* end inlined header: gsl/gsl_errno.h */
329gsl_error_handler_t * gsl_error_handler = NULL;
330
331void
332gsl_error (const char * reason, const char * file, int line, int gsl_errno)
333{
334 if (gsl_error_handler)
335 {
336 (*gsl_error_handler) (reason, file, line, gsl_errno);
337 return ;
338 }
339
340 gsl_stream_printf ("ERROR", file, line, reason);
341
342 fflush (stdout);
343 fprintf (stderr, "Default GSL error handler invoked.\n");
344 fflush (stderr);
345
346 abort ();
347}
348
349gsl_error_handler_t *
350gsl_set_error_handler (gsl_error_handler_t * new_handler)
351{
352 gsl_error_handler_t * previous_handler = gsl_error_handler;
353 gsl_error_handler = new_handler;
354 return previous_handler;
355}
356
357
358
359/* end inlined source: err/error.c */
360/* begin inlined source: err/stream.c */
361/* err/stream.c
362 *
363 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, Brian Gough
364 *
365 * This program is free software; you can redistribute it and/or modify
366 * it under the terms of the GNU General Public License as published by
367 * the Free Software Foundation; either version 3 of the License, or (at
368 * your option) any later version.
369 *
370 * This program is distributed in the hope that it will be useful, but
371 * WITHOUT ANY WARRANTY; without even the implied warranty of
372 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
373 * General Public License for more details.
374 *
375 * You should have received a copy of the GNU General Public License
376 * along with this program; if not, write to the Free Software
377 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
378 */
379/* begin inlined header: config.h */
380#ifndef MARLEY_BUILTIN_GSL_CONFIG_WRAPPER_H
381#define MARLEY_BUILTIN_GSL_CONFIG_WRAPPER_H
382/* begin inlined header: gsl_config.h */
383#ifndef MARLEY_BUILTIN_GSL_CONFIG_H
384#define MARLEY_BUILTIN_GSL_CONFIG_H
385
386#define HAVE_INLINE 1
387#define HAVE_DECL_ISFINITE 1
388#define HAVE_DECL_ISNAN 1
389#define HAVE_DECL_ISINF 1
390#define GSL_COERCE_DBL(x) (x)
391
392#define GSL_DISABLE_DEPRECATED 0
393#define PACKAGE_VERSION "2.8"
394#define VERSION "2.8"
395
396#endif
397
398/* end inlined header: gsl_config.h */
399#endif
400
401/* end inlined header: config.h */
402#include <stddef.h>
403#include <stdlib.h>
404#include <stdio.h>
405/* begin inlined header: gsl/gsl_errno.h */
406/* err/gsl_errno.h
407 *
408 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, Brian Gough
409 *
410 * This program is free software; you can redistribute it and/or modify
411 * it under the terms of the GNU General Public License as published by
412 * the Free Software Foundation; either version 3 of the License, or (at
413 * your option) any later version.
414 *
415 * This program is distributed in the hope that it will be useful, but
416 * WITHOUT ANY WARRANTY; without even the implied warranty of
417 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
418 * General Public License for more details.
419 *
420 * You should have received a copy of the GNU General Public License
421 * along with this program; if not, write to the Free Software
422 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
423 */
424
425#ifndef __GSL_ERRNO_H__
426#define __GSL_ERRNO_H__
427
428#include <stdio.h>
429#include <errno.h>
430/* begin inlined header: gsl/gsl_types.h */
431/* gsl_types.h
432 *
433 * Copyright (C) 2001, 2007 Brian Gough
434 *
435 * This program is free software; you can redistribute it and/or modify
436 * it under the terms of the GNU General Public License as published by
437 * the Free Software Foundation; either version 3 of the License, or (at
438 * your option) any later version.
439 *
440 * This program is distributed in the hope that it will be useful, but
441 * WITHOUT ANY WARRANTY; without even the implied warranty of
442 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
443 * General Public License for more details.
444 *
445 * You should have received a copy of the GNU General Public License
446 * along with this program; if not, write to the Free Software
447 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
448 */
449
450#ifndef __GSL_TYPES_H__
451#define __GSL_TYPES_H__
452
453#ifndef GSL_VAR
454
455#ifdef WIN32
456# ifdef GSL_DLL
457# ifdef DLL_EXPORT
458# define GSL_VAR extern __declspec(dllexport)
459# else
460# define GSL_VAR extern __declspec(dllimport)
461# endif
462# else
463# define GSL_VAR extern
464# endif
465#else
466# define GSL_VAR extern
467#endif
468
469#endif
470
471#endif /* __GSL_TYPES_H__ */
472
473/* end inlined header: gsl/gsl_types.h */
474
475__BEGIN_DECLS
476
477enum {
478 GSL_SUCCESS = 0,
479 GSL_FAILURE = -1,
480 GSL_CONTINUE = -2, /* iteration has not converged */
481 GSL_EDOM = 1, /* input domain error, e.g sqrt(-1) */
482 GSL_ERANGE = 2, /* output range error, e.g. exp(1e100) */
483 GSL_EFAULT = 3, /* invalid pointer */
484 GSL_EINVAL = 4, /* invalid argument supplied by user */
485 GSL_EFAILED = 5, /* generic failure */
486 GSL_EFACTOR = 6, /* factorization failed */
487 GSL_ESANITY = 7, /* sanity check failed - shouldn't happen */
488 GSL_ENOMEM = 8, /* malloc failed */
489 GSL_EBADFUNC = 9, /* problem with user-supplied function */
490 GSL_ERUNAWAY = 10, /* iterative process is out of control */
491 GSL_EMAXITER = 11, /* exceeded max number of iterations */
492 GSL_EZERODIV = 12, /* tried to divide by zero */
493 GSL_EBADTOL = 13, /* user specified an invalid tolerance */
494 GSL_ETOL = 14, /* failed to reach the specified tolerance */
495 GSL_EUNDRFLW = 15, /* underflow */
496 GSL_EOVRFLW = 16, /* overflow */
497 GSL_ELOSS = 17, /* loss of accuracy */
498 GSL_EROUND = 18, /* failed because of roundoff error */
499 GSL_EBADLEN = 19, /* matrix, vector lengths are not conformant */
500 GSL_ENOTSQR = 20, /* matrix not square */
501 GSL_ESING = 21, /* apparent singularity detected */
502 GSL_EDIVERGE = 22, /* integral or series is divergent */
503 GSL_EUNSUP = 23, /* requested feature is not supported by the hardware */
504 GSL_EUNIMPL = 24, /* requested feature not (yet) implemented */
505 GSL_ECACHE = 25, /* cache limit exceeded */
506 GSL_ETABLE = 26, /* table limit exceeded */
507 GSL_ENOPROG = 27, /* iteration is not making progress towards solution */
508 GSL_ENOPROGJ = 28, /* jacobian evaluations are not improving the solution */
509 GSL_ETOLF = 29, /* cannot reach the specified tolerance in F */
510 GSL_ETOLX = 30, /* cannot reach the specified tolerance in X */
511 GSL_ETOLG = 31, /* cannot reach the specified tolerance in gradient */
512 GSL_EOF = 32 /* end of file */
513} ;
514
515void gsl_error (const char * reason, const char * file, int line,
516 int gsl_errno);
517
518void gsl_stream_printf (const char *label, const char *file,
519 int line, const char *reason);
520
521typedef void gsl_error_handler_t (const char * reason, const char * file,
522 int line, int gsl_errno);
523
524gsl_error_handler_t *
525gsl_set_error_handler (gsl_error_handler_t * new_handler);
526
527/* GSL_ERROR: call the error handler, and return the error code */
528
529#define GSL_ERROR(reason, gsl_errno) \
530 do { \
531 gsl_error (reason, __FILE__, __LINE__, gsl_errno) ; \
532 return gsl_errno ; \
533 } while (0)
534
535/* GSL_ERROR_VAL: call the error handler, and return the given value */
536
537#define GSL_ERROR_VAL(reason, gsl_errno, value) \
538 do { \
539 gsl_error (reason, __FILE__, __LINE__, gsl_errno) ; \
540 return value ; \
541 } while (0)
542
543/* GSL_ERROR_VOID: call the error handler, and then return
544 (for void functions which still need to generate an error) */
545
546#define GSL_ERROR_VOID(reason, gsl_errno) \
547 do { \
548 gsl_error (reason, __FILE__, __LINE__, gsl_errno) ; \
549 return ; \
550 } while (0)
551
552/* GSL_ERROR_NULL suitable for out-of-memory conditions */
553
554#define GSL_ERROR_NULL(reason, gsl_errno) GSL_ERROR_VAL(reason, gsl_errno, 0)
555
556/* Sometimes you have several status results returned from
557 * function calls and you want to combine them in some sensible
558 * way. You cannot produce a "total" status condition, but you can
559 * pick one from a set of conditions based on an implied hierarchy.
560 *
561 * In other words:
562 * you have: status_a, status_b, ...
563 * you want: status = (status_a if it is bad, or status_b if it is bad,...)
564 *
565 * In this example you consider status_a to be more important and
566 * it is checked first, followed by the others in the order specified.
567 *
568 * Here are some dumb macros to do this.
569 */
570#define GSL_ERROR_SELECT_2(a,b) ((a) != GSL_SUCCESS ? (a) : ((b) != GSL_SUCCESS ? (b) : GSL_SUCCESS))
571#define GSL_ERROR_SELECT_3(a,b,c) ((a) != GSL_SUCCESS ? (a) : GSL_ERROR_SELECT_2(b,c))
572#define GSL_ERROR_SELECT_4(a,b,c,d) ((a) != GSL_SUCCESS ? (a) : GSL_ERROR_SELECT_3(b,c,d))
573#define GSL_ERROR_SELECT_5(a,b,c,d,e) ((a) != GSL_SUCCESS ? (a) : GSL_ERROR_SELECT_4(b,c,d,e))
574
575#define GSL_STATUS_UPDATE(sp, s) do { if ((s) != GSL_SUCCESS) *(sp) = (s);} while(0)
576
577__END_DECLS
578
579#endif /* __GSL_ERRNO_H__ */
580
581/* end inlined header: gsl/gsl_errno.h */
582FILE * gsl_stream = NULL ;
583static void (*gsl_stream_handler)(const char * label, const char * file,
584 int line, const char * reason) = NULL;
585
586void
587gsl_stream_printf (const char *label, const char *file, int line,
588 const char *reason)
589{
590 if (gsl_stream == NULL)
591 {
592 gsl_stream = stderr;
593 }
594 if (gsl_stream_handler)
595 {
596 (*gsl_stream_handler) (label, file, line, reason);
597 return;
598 }
599 fprintf (gsl_stream, "gsl: %s:%d: %s: %s\n", file, line, label, reason);
600
601}
602
603/* end inlined source: err/stream.c */
604/* System utilities --------------------------------------------------------*/
605/* begin inlined source: sys/fdiv.c */
606/* sys/fdiv.c
607 *
608 * Copyright (C) 2001, 2007 Brian Gough
609 *
610 * This program is free software; you can redistribute it and/or modify
611 * it under the terms of the GNU General Public License as published by
612 * the Free Software Foundation; either version 3 of the License, or (at
613 * your option) any later version.
614 *
615 * This program is distributed in the hope that it will be useful, but
616 * WITHOUT ANY WARRANTY; without even the implied warranty of
617 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
618 * General Public License for more details.
619 *
620 * You should have received a copy of the GNU General Public License
621 * along with this program; if not, write to the Free Software
622 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
623 */
624/* begin inlined header: config.h */
625#ifndef MARLEY_BUILTIN_GSL_CONFIG_WRAPPER_H
626#define MARLEY_BUILTIN_GSL_CONFIG_WRAPPER_H
627/* begin inlined header: gsl_config.h */
628#ifndef MARLEY_BUILTIN_GSL_CONFIG_H
629#define MARLEY_BUILTIN_GSL_CONFIG_H
630
631#define HAVE_INLINE 1
632#define HAVE_DECL_ISFINITE 1
633#define HAVE_DECL_ISNAN 1
634#define HAVE_DECL_ISINF 1
635#define GSL_COERCE_DBL(x) (x)
636
637#define GSL_DISABLE_DEPRECATED 0
638#define PACKAGE_VERSION "2.8"
639#define VERSION "2.8"
640
641#endif
642
643/* end inlined header: gsl_config.h */
644#endif
645
646/* end inlined header: config.h */
647#include <math.h>
648/* begin inlined header: gsl/gsl_sys.h */
649/* sys/gsl_sys.h
650 *
651 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, Brian Gough
652 *
653 * This program is free software; you can redistribute it and/or modify
654 * it under the terms of the GNU General Public License as published by
655 * the Free Software Foundation; either version 3 of the License, or (at
656 * your option) any later version.
657 *
658 * This program is distributed in the hope that it will be useful, but
659 * WITHOUT ANY WARRANTY; without even the implied warranty of
660 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
661 * General Public License for more details.
662 *
663 * You should have received a copy of the GNU General Public License
664 * along with this program; if not, write to the Free Software
665 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
666 */
667
668#ifndef __GSL_SYS_H__
669#define __GSL_SYS_H__
670
671__BEGIN_DECLS
672
673double gsl_log1p (const double x);
674double gsl_expm1 (const double x);
675double gsl_hypot (const double x, const double y);
676double gsl_hypot3 (const double x, const double y, const double z);
677double gsl_acosh (const double x);
678double gsl_asinh (const double x);
679double gsl_atanh (const double x);
680
681int gsl_isnan (const double x);
682int gsl_isinf (const double x);
683int gsl_finite (const double x);
684
685double gsl_nan (void);
686double gsl_posinf (void);
687double gsl_neginf (void);
688double gsl_fdiv (const double x, const double y);
689
690double gsl_coerce_double (const double x);
691float gsl_coerce_float (const float x);
692long double gsl_coerce_long_double (const long double x);
693
694double gsl_ldexp(const double x, const int e);
695double gsl_frexp(const double x, int * e);
696
697int gsl_fcmp (const double x1, const double x2, const double epsilon);
698
699__END_DECLS
700
701#endif /* __GSL_SYS_H__ */
702
703/* end inlined header: gsl/gsl_sys.h */
704double
705gsl_fdiv (const double x, const double y)
706{
707 return x / y;
708}
709/* end inlined source: sys/fdiv.c */
710/* begin inlined source: sys/infnan.c */
711/* sys/infnan.c
712 *
713 * Copyright (C) 2001, 2004, 2007, 2010 Brian Gough
714 *
715 * This program is free software; you can redistribute it and/or modify
716 * it under the terms of the GNU General Public License as published by
717 * the Free Software Foundation; either version 3 of the License, or (at
718 * your option) any later version.
719 *
720 * This program is distributed in the hope that it will be useful, but
721 * WITHOUT ANY WARRANTY; without even the implied warranty of
722 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
723 * General Public License for more details.
724 *
725 * You should have received a copy of the GNU General Public License
726 * along with this program; if not, write to the Free Software
727 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
728 */
729/* begin inlined header: config.h */
730#ifndef MARLEY_BUILTIN_GSL_CONFIG_WRAPPER_H
731#define MARLEY_BUILTIN_GSL_CONFIG_WRAPPER_H
732/* begin inlined header: gsl_config.h */
733#ifndef MARLEY_BUILTIN_GSL_CONFIG_H
734#define MARLEY_BUILTIN_GSL_CONFIG_H
735
736#define HAVE_INLINE 1
737#define HAVE_DECL_ISFINITE 1
738#define HAVE_DECL_ISNAN 1
739#define HAVE_DECL_ISINF 1
740#define GSL_COERCE_DBL(x) (x)
741
742#define GSL_DISABLE_DEPRECATED 0
743#define PACKAGE_VERSION "2.8"
744#define VERSION "2.8"
745
746#endif
747
748/* end inlined header: gsl_config.h */
749#endif
750
751/* end inlined header: config.h */
752#include <math.h>
753
754#if HAVE_IEEEFP_H
755#include <ieeefp.h>
756#endif
757/* begin inlined header: gsl/gsl_sys.h */
758/* sys/gsl_sys.h
759 *
760 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, Brian Gough
761 *
762 * This program is free software; you can redistribute it and/or modify
763 * it under the terms of the GNU General Public License as published by
764 * the Free Software Foundation; either version 3 of the License, or (at
765 * your option) any later version.
766 *
767 * This program is distributed in the hope that it will be useful, but
768 * WITHOUT ANY WARRANTY; without even the implied warranty of
769 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
770 * General Public License for more details.
771 *
772 * You should have received a copy of the GNU General Public License
773 * along with this program; if not, write to the Free Software
774 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
775 */
776
777#ifndef __GSL_SYS_H__
778#define __GSL_SYS_H__
779
780__BEGIN_DECLS
781
782double gsl_log1p (const double x);
783double gsl_expm1 (const double x);
784double gsl_hypot (const double x, const double y);
785double gsl_hypot3 (const double x, const double y, const double z);
786double gsl_acosh (const double x);
787double gsl_asinh (const double x);
788double gsl_atanh (const double x);
789
790int gsl_isnan (const double x);
791int gsl_isinf (const double x);
792int gsl_finite (const double x);
793
794double gsl_nan (void);
795double gsl_posinf (void);
796double gsl_neginf (void);
797double gsl_fdiv (const double x, const double y);
798
799double gsl_coerce_double (const double x);
800float gsl_coerce_float (const float x);
801long double gsl_coerce_long_double (const long double x);
802
803double gsl_ldexp(const double x, const int e);
804double gsl_frexp(const double x, int * e);
805
806int gsl_fcmp (const double x1, const double x2, const double epsilon);
807
808__END_DECLS
809
810#endif /* __GSL_SYS_H__ */
811
812/* end inlined header: gsl/gsl_sys.h */
813double gsl_nan (void)
814{
815 return gsl_fdiv (0.0, 0.0);
816}
817
818double gsl_posinf (void)
819{
820 return gsl_fdiv (+1.0, 0.0);
821}
822
823double gsl_neginf (void)
824{
825 return gsl_fdiv (-1.0, 0.0);
826}
827
828
829int gsl_isnan (const double x);
830int gsl_isinf (const double x);
831int gsl_finite (const double x);
832
833#if defined(_MSC_VER) /* Microsoft Visual C++ */
834#include <float.h>
835int
836gsl_isnan (const double x)
837{
838 return _isnan(x);
839}
840
841int
842gsl_isinf (const double x)
843{
844 int fpc = _fpclass(x);
845
846 if (fpc == _FPCLASS_PINF)
847 return +1;
848 else if (fpc == _FPCLASS_NINF)
849 return -1;
850 else
851 return 0;
852}
853
854int
855gsl_finite (const double x)
856{
857 return _finite(x);
858}
859#else
860
861# if HAVE_DECL_ISFINITE
862int
863gsl_finite (const double x)
864{
865 return isfinite(x);
866}
867# elif HAVE_DECL_FINITE
868int
869gsl_finite (const double x)
870{
871 return finite(x);
872}
873# elif HAVE_IEEE_COMPARISONS
874int
875gsl_finite (const double x)
876{
877 const double y = x - x;
878 int status = (y == y);
879 return status;
880}
881# else
882# error "cannot define gsl_finite without HAVE_DECL_FINITE or HAVE_IEEE_COMPARISONS"
883# endif
884
885# if HAVE_DECL_ISNAN
886int
887gsl_isnan (const double x)
888{
889 return isnan(x);
890}
891#elif HAVE_IEEE_COMPARISONS
892int
893gsl_isnan (const double x)
894{
895 int status = (x != x);
896 return status;
897}
898# else
899# error "cannot define gsl_isnan without HAVE_DECL_ISNAN or HAVE_IEEE_COMPARISONS"
900# endif
901
902# if HAVE_DECL_ISINF
903int
904gsl_isinf (const double x)
905{
906 /* isinf(3): In glibc 2.01 and earlier, isinf() returns a
907 non-zero value (actually: 1) if x is an infinity (positive or
908 negative). (This is all that C99 requires.) */
909
910 if (isinf(x))
911 {
912 return (x > 0) ? 1 : -1;
913 }
914 else
915 {
916 return 0;
917 }
918}
919# else
920
921int
922gsl_isinf (const double x)
923{
924 if (! gsl_finite(x) && ! gsl_isnan(x))
925 {
926 return (x > 0 ? +1 : -1);
927 }
928 else
929 {
930 return 0;
931 }
932}
933
934# endif
935#endif
936
937/* end inlined source: sys/infnan.c */
938/* begin inlined source: sys/coerce.c */
939/* sys/coerce.c
940 *
941 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Brian Gough
942 *
943 * This program is free software; you can redistribute it and/or modify
944 * it under the terms of the GNU General Public License as published by
945 * the Free Software Foundation; either version 3 of the License, or (at
946 * your option) any later version.
947 *
948 * This program is distributed in the hope that it will be useful, but
949 * WITHOUT ANY WARRANTY; without even the implied warranty of
950 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
951 * General Public License for more details.
952 *
953 * You should have received a copy of the GNU General Public License
954 * along with this program; if not, write to the Free Software
955 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
956 */
957/* begin inlined header: config.h */
958#ifndef MARLEY_BUILTIN_GSL_CONFIG_WRAPPER_H
959#define MARLEY_BUILTIN_GSL_CONFIG_WRAPPER_H
960/* begin inlined header: gsl_config.h */
961#ifndef MARLEY_BUILTIN_GSL_CONFIG_H
962#define MARLEY_BUILTIN_GSL_CONFIG_H
963
964#define HAVE_INLINE 1
965#define HAVE_DECL_ISFINITE 1
966#define HAVE_DECL_ISNAN 1
967#define HAVE_DECL_ISINF 1
968#define GSL_COERCE_DBL(x) (x)
969
970#define GSL_DISABLE_DEPRECATED 0
971#define PACKAGE_VERSION "2.8"
972#define VERSION "2.8"
973
974#endif
975
976/* end inlined header: gsl_config.h */
977#endif
978
979/* end inlined header: config.h */
980#include <math.h>
981/* begin inlined header: gsl/gsl_sys.h */
982/* sys/gsl_sys.h
983 *
984 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, Brian Gough
985 *
986 * This program is free software; you can redistribute it and/or modify
987 * it under the terms of the GNU General Public License as published by
988 * the Free Software Foundation; either version 3 of the License, or (at
989 * your option) any later version.
990 *
991 * This program is distributed in the hope that it will be useful, but
992 * WITHOUT ANY WARRANTY; without even the implied warranty of
993 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
994 * General Public License for more details.
995 *
996 * You should have received a copy of the GNU General Public License
997 * along with this program; if not, write to the Free Software
998 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
999 */
1000
1001#ifndef __GSL_SYS_H__
1002#define __GSL_SYS_H__
1003
1004__BEGIN_DECLS
1005
1006double gsl_log1p (const double x);
1007double gsl_expm1 (const double x);
1008double gsl_hypot (const double x, const double y);
1009double gsl_hypot3 (const double x, const double y, const double z);
1010double gsl_acosh (const double x);
1011double gsl_asinh (const double x);
1012double gsl_atanh (const double x);
1013
1014int gsl_isnan (const double x);
1015int gsl_isinf (const double x);
1016int gsl_finite (const double x);
1017
1018double gsl_nan (void);
1019double gsl_posinf (void);
1020double gsl_neginf (void);
1021double gsl_fdiv (const double x, const double y);
1022
1023double gsl_coerce_double (const double x);
1024float gsl_coerce_float (const float x);
1025long double gsl_coerce_long_double (const long double x);
1026
1027double gsl_ldexp(const double x, const int e);
1028double gsl_frexp(const double x, int * e);
1029
1030int gsl_fcmp (const double x1, const double x2, const double epsilon);
1031
1032__END_DECLS
1033
1034#endif /* __GSL_SYS_H__ */
1035
1036/* end inlined header: gsl/gsl_sys.h */
1037double
1038gsl_coerce_double (const double x)
1039{
1040 volatile double y;
1041 y = x;
1042 return y;
1043}
1044
1045float
1046gsl_coerce_float (const float x)
1047{
1048 volatile float y;
1049 y = x;
1050 return y;
1051}
1052
1053/* The following function is not needed, but is included for completeness */
1054
1055long double
1056gsl_coerce_long_double (const long double x)
1057{
1058 volatile long double y;
1059 y = x;
1060 return y;
1061}
1062
1063/* end inlined source: sys/coerce.c */
1064/* sys/minmax.c and sys/prec.c use the COMPILE_INLINE_STATIC / build.h
1065 * mechanism to emit linkable definitions for the inline helpers declared
1066 * in gsl_minmax.h / gsl_precision.h. build.h now uses a #ifndef guard
1067 * so subsequent inclusions from sys/prec.c and complex/inline.c below are
1068 * silently skipped, while the idempotent macro setup from the first
1069 * inclusion remains in force. */
1070/* begin inlined source: sys/minmax.c */
1071/* sys/minmax.c
1072 *
1073 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, Brian Gough
1074 *
1075 * This program is free software; you can redistribute it and/or modify
1076 * it under the terms of the GNU General Public License as published by
1077 * the Free Software Foundation; either version 3 of the License, or (at
1078 * your option) any later version.
1079 *
1080 * This program is distributed in the hope that it will be useful, but
1081 * WITHOUT ANY WARRANTY; without even the implied warranty of
1082 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1083 * General Public License for more details.
1084 *
1085 * You should have received a copy of the GNU General Public License
1086 * along with this program; if not, write to the Free Software
1087 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1088 */
1089/* begin inlined header: config.h */
1090#ifndef MARLEY_BUILTIN_GSL_CONFIG_WRAPPER_H
1091#define MARLEY_BUILTIN_GSL_CONFIG_WRAPPER_H
1092/* begin inlined header: gsl_config.h */
1093#ifndef MARLEY_BUILTIN_GSL_CONFIG_H
1094#define MARLEY_BUILTIN_GSL_CONFIG_H
1095
1096#define HAVE_INLINE 1
1097#define HAVE_DECL_ISFINITE 1
1098#define HAVE_DECL_ISNAN 1
1099#define HAVE_DECL_ISINF 1
1100#define GSL_COERCE_DBL(x) (x)
1101
1102#define GSL_DISABLE_DEPRECATED 0
1103#define PACKAGE_VERSION "2.8"
1104#define VERSION "2.8"
1105
1106#endif
1107
1108/* end inlined header: gsl_config.h */
1109#endif
1110
1111/* end inlined header: config.h */
1112/* Compile all the inline functions */
1113
1114#define COMPILE_INLINE_STATIC
1115/* begin inlined header: build.h */
1116/* Compile subsequent inline functions as static functions */
1117
1118/* Allow multiple inclusion in a single translation unit (needed for the
1119 * amalgamated gsl_marley.c build where sys/minmax.c, sys/prec.c, and
1120 * complex/inline.c each set COMPILE_INLINE_STATIC and include this header).
1121 * The macro setup below is idempotent, so later inclusions are harmless. */
1122#ifndef __GSL_BUILD_H__
1123#define __GSL_BUILD_H__
1124
1125#ifdef COMPILE_INLINE_STATIC
1126#ifndef HIDE_INLINE_STATIC /* skip if inline functions are hidden */
1127
1128#undef __GSL_INLINE_H__
1129#define __GSL_INLINE_H__ /* first, ignore the gsl_inline.h header file */
1130
1131#undef INLINE_DECL
1132#define INLINE_DECL /* disable inline in declarations */
1133
1134#undef INLINE_FUN
1135#define INLINE_FUN /* disable inline in definitions */
1136
1137#ifndef HAVE_INLINE /* enable compilation of definitions in .h files */
1138#define HAVE_INLINE
1139#endif
1140
1141/* Compile range checking code for inline functions used in the library */
1142#undef GSL_RANGE_CHECK
1143#define GSL_RANGE_CHECK 1
1144
1145/* Use the global variable gsl_check_range to enable/disable range checking at
1146 runtime */
1147#undef GSL_RANGE_COND
1148#define GSL_RANGE_COND(x) (gsl_check_range && (x))
1149
1150#endif
1151#else
1152#error must be called with COMPILE_INLINE_STATIC
1153#endif
1154
1155#endif /* __GSL_BUILD_H__ */
1156
1157/* end inlined header: build.h */
1158/* begin inlined header: gsl/gsl_minmax.h */
1159/* gsl_minmax.h
1160 *
1161 * Copyright (C) 2008 Gerard Jungman, Brian Gough
1162 *
1163 * This program is free software; you can redistribute it and/or modify
1164 * it under the terms of the GNU General Public License as published by
1165 * the Free Software Foundation; either version 3 of the License, or (at
1166 * your option) any later version.
1167 *
1168 * This program is distributed in the hope that it will be useful, but
1169 * WITHOUT ANY WARRANTY; without even the implied warranty of
1170 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1171 * General Public License for more details.
1172 *
1173 * You should have received a copy of the GNU General Public License
1174 * along with this program; if not, write to the Free Software
1175 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1176 */
1177
1178#ifndef __GSL_MINMAX_H__
1179#define __GSL_MINMAX_H__
1180/* begin inlined header: gsl/gsl_inline.h */
1181/* gsl_inline.h
1182 *
1183 * Copyright (C) 2008, 2009 Brian Gough
1184 *
1185 * This program is free software; you can redistribute it and/or modify
1186 * it under the terms of the GNU General Public License as published by
1187 * the Free Software Foundation; either version 3 of the License, or (at
1188 * your option) any later version.
1189 *
1190 * This program is distributed in the hope that it will be useful, but
1191 * WITHOUT ANY WARRANTY; without even the implied warranty of
1192 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1193 * General Public License for more details.
1194 *
1195 * You should have received a copy of the GNU General Public License
1196 * along with this program; if not, write to the Free Software
1197 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1198 */
1199
1200#ifndef __GSL_INLINE_H__
1201#define __GSL_INLINE_H__
1202
1203/* In recent versiions of GCC, the inline keyword has two different
1204 forms: GNU and C99.
1205
1206 In GNU mode we can use 'extern inline' to make inline functions
1207 work like macros. The function is only inlined--it is never output
1208 as a definition in an object file.
1209
1210 In the new C99 mode 'extern inline' has a different meaning--it
1211 causes the definition of the function to be output in each object
1212 file where it is used. This will result in multiple-definition
1213 errors on linking. The 'inline' keyword on its own (without
1214 extern) has the same behavior as the original GNU 'extern inline'.
1215
1216 The C99 style is the default with -std=c99 in GCC 4.3.
1217
1218 This header file allows either form of inline to be used by
1219 redefining the macros INLINE_DECL and INLINE_FUN. These are used
1220 in the public header files as
1221
1222 INLINE_DECL double gsl_foo (double x);
1223 #ifdef HAVE_INLINE
1224 INLINE_FUN double gsl_foo (double x) { return x+1.0; } ;
1225 #endif
1226
1227*/
1228
1229#ifdef HAVE_INLINE
1230# if defined(__GNUC_STDC_INLINE__) || defined(GSL_C99_INLINE) || defined(HAVE_C99_INLINE)
1231# define INLINE_DECL inline /* use C99 inline */
1232# define INLINE_FUN inline
1233# else
1234# define INLINE_DECL /* use GNU extern inline */
1235# define INLINE_FUN extern inline
1236# endif
1237#else
1238# define INLINE_DECL /* */
1239#endif
1240
1241/* Range checking conditions in headers do not require any run-time
1242 tests of the global variable gsl_check_range. They are enabled or
1243 disabled in user code at compile time with GSL_RANGE_CHECK macro.
1244 See also build.h. */
1245#define GSL_RANGE_COND(x) (x)
1246
1247#endif /* __GSL_INLINE_H__ */
1248
1249/* end inlined header: gsl/gsl_inline.h */
1250
1251__BEGIN_DECLS
1252
1253/* Define MAX and MIN macros/functions if they don't exist. */
1254
1255/* plain old macros for general use */
1256#define GSL_MAX(a,b) ((a) > (b) ? (a) : (b))
1257#define GSL_MIN(a,b) ((a) < (b) ? (a) : (b))
1258
1259/* function versions of the above, in case they are needed */
1260double gsl_max (double a, double b);
1261double gsl_min (double a, double b);
1262
1263/* inline-friendly strongly typed versions */
1264#ifdef HAVE_INLINE
1265
1266INLINE_FUN int GSL_MAX_INT (int a, int b);
1267INLINE_FUN int GSL_MIN_INT (int a, int b);
1268INLINE_FUN double GSL_MAX_DBL (double a, double b);
1269INLINE_FUN double GSL_MIN_DBL (double a, double b);
1270INLINE_FUN long double GSL_MAX_LDBL (long double a, long double b);
1271INLINE_FUN long double GSL_MIN_LDBL (long double a, long double b);
1272
1273INLINE_FUN int
1274GSL_MAX_INT (int a, int b)
1275{
1276 return GSL_MAX (a, b);
1277}
1278
1279INLINE_FUN int
1280GSL_MIN_INT (int a, int b)
1281{
1282 return GSL_MIN (a, b);
1283}
1284
1285INLINE_FUN double
1286GSL_MAX_DBL (double a, double b)
1287{
1288 return GSL_MAX (a, b);
1289}
1290
1291INLINE_FUN double
1292GSL_MIN_DBL (double a, double b)
1293{
1294 return GSL_MIN (a, b);
1295}
1296
1297INLINE_FUN long double
1298GSL_MAX_LDBL (long double a, long double b)
1299{
1300 return GSL_MAX (a, b);
1301}
1302
1303INLINE_FUN long double
1304GSL_MIN_LDBL (long double a, long double b)
1305{
1306 return GSL_MIN (a, b);
1307}
1308#else
1309#define GSL_MAX_INT(a,b) GSL_MAX(a,b)
1310#define GSL_MIN_INT(a,b) GSL_MIN(a,b)
1311#define GSL_MAX_DBL(a,b) GSL_MAX(a,b)
1312#define GSL_MIN_DBL(a,b) GSL_MIN(a,b)
1313#define GSL_MAX_LDBL(a,b) GSL_MAX(a,b)
1314#define GSL_MIN_LDBL(a,b) GSL_MIN(a,b)
1315#endif /* HAVE_INLINE */
1316
1317__END_DECLS
1318
1319#endif /* __GSL_POW_INT_H__ */
1320
1321/* end inlined header: gsl/gsl_minmax.h */
1322/* Define some static functions which are always available */
1323
1324double gsl_max (double a, double b)
1325{
1326 return GSL_MAX (a, b);
1327}
1328
1329double gsl_min (double a, double b)
1330{
1331 return GSL_MIN (a, b);
1332}
1333
1334/* end inlined source: sys/minmax.c */
1335/* begin inlined source: sys/prec.c */
1336/* sys/prec.c
1337 *
1338 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, Brian Gough
1339 *
1340 * This program is free software; you can redistribute it and/or modify
1341 * it under the terms of the GNU General Public License as published by
1342 * the Free Software Foundation; either version 3 of the License, or (at
1343 * your option) any later version.
1344 *
1345 * This program is distributed in the hope that it will be useful, but
1346 * WITHOUT ANY WARRANTY; without even the implied warranty of
1347 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1348 * General Public License for more details.
1349 *
1350 * You should have received a copy of the GNU General Public License
1351 * along with this program; if not, write to the Free Software
1352 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1353 */
1354
1355/* Author: G. Jungman */
1356/* begin inlined header: config.h */
1357#ifndef MARLEY_BUILTIN_GSL_CONFIG_WRAPPER_H
1358#define MARLEY_BUILTIN_GSL_CONFIG_WRAPPER_H
1359/* begin inlined header: gsl_config.h */
1360#ifndef MARLEY_BUILTIN_GSL_CONFIG_H
1361#define MARLEY_BUILTIN_GSL_CONFIG_H
1362
1363#define HAVE_INLINE 1
1364#define HAVE_DECL_ISFINITE 1
1365#define HAVE_DECL_ISNAN 1
1366#define HAVE_DECL_ISINF 1
1367#define GSL_COERCE_DBL(x) (x)
1368
1369#define GSL_DISABLE_DEPRECATED 0
1370#define PACKAGE_VERSION "2.8"
1371#define VERSION "2.8"
1372
1373#endif
1374
1375/* end inlined header: gsl_config.h */
1376#endif
1377
1378/* end inlined header: config.h */
1379/* begin inlined header: gsl/gsl_machine.h */
1380/* Author: B. Gough and G. Jungman */
1381#ifndef __GSL_MACHINE_H__
1382#define __GSL_MACHINE_H__
1383
1384#include <limits.h>
1385#include <float.h>
1386
1387/* magic constants; mostly for the benefit of the implementation */
1388
1389/* -*-MACHINE CONSTANTS-*-
1390 *
1391 * PLATFORM: Whiz-O-Matic 9000
1392 * FP_PLATFORM: IEEE-Virtual
1393 * HOSTNAME: nnn.lanl.gov
1394 * DATE: Fri Nov 20 17:53:26 MST 1998
1395 */
1396#define GSL_DBL_EPSILON 2.2204460492503131e-16
1397#define GSL_SQRT_DBL_EPSILON 1.4901161193847656e-08
1398#define GSL_ROOT3_DBL_EPSILON 6.0554544523933429e-06
1399#define GSL_ROOT4_DBL_EPSILON 1.2207031250000000e-04
1400#define GSL_ROOT5_DBL_EPSILON 7.4009597974140505e-04
1401#define GSL_ROOT6_DBL_EPSILON 2.4607833005759251e-03
1402#define GSL_LOG_DBL_EPSILON (-3.6043653389117154e+01)
1403
1404#define GSL_DBL_MIN 2.2250738585072014e-308
1405#define GSL_SQRT_DBL_MIN 1.4916681462400413e-154
1406#define GSL_ROOT3_DBL_MIN 2.8126442852362996e-103
1407#define GSL_ROOT4_DBL_MIN 1.2213386697554620e-77
1408#define GSL_ROOT5_DBL_MIN 2.9476022969691763e-62
1409#define GSL_ROOT6_DBL_MIN 5.3034368905798218e-52
1410#define GSL_LOG_DBL_MIN (-7.0839641853226408e+02)
1411
1412#define GSL_DBL_MAX 1.7976931348623157e+308
1413#define GSL_SQRT_DBL_MAX 1.3407807929942596e+154
1414#define GSL_ROOT3_DBL_MAX 5.6438030941222897e+102
1415#define GSL_ROOT4_DBL_MAX 1.1579208923731620e+77
1416#define GSL_ROOT5_DBL_MAX 4.4765466227572707e+61
1417#define GSL_ROOT6_DBL_MAX 2.3756689782295612e+51
1418#define GSL_LOG_DBL_MAX 7.0978271289338397e+02
1419
1420#define GSL_FLT_EPSILON 1.1920928955078125e-07
1421#define GSL_SQRT_FLT_EPSILON 3.4526698300124393e-04
1422#define GSL_ROOT3_FLT_EPSILON 4.9215666011518501e-03
1423#define GSL_ROOT4_FLT_EPSILON 1.8581361171917516e-02
1424#define GSL_ROOT5_FLT_EPSILON 4.1234622211652937e-02
1425#define GSL_ROOT6_FLT_EPSILON 7.0153878019335827e-02
1426#define GSL_LOG_FLT_EPSILON (-1.5942385152878742e+01)
1427
1428#define GSL_FLT_MIN 1.1754943508222875e-38
1429#define GSL_SQRT_FLT_MIN 1.0842021724855044e-19
1430#define GSL_ROOT3_FLT_MIN 2.2737367544323241e-13
1431#define GSL_ROOT4_FLT_MIN 3.2927225399135965e-10
1432#define GSL_ROOT5_FLT_MIN 2.5944428542140822e-08
1433#define GSL_ROOT6_FLT_MIN 4.7683715820312542e-07
1434#define GSL_LOG_FLT_MIN (-8.7336544750553102e+01)
1435
1436#define GSL_FLT_MAX 3.4028234663852886e+38
1437#define GSL_SQRT_FLT_MAX 1.8446743523953730e+19
1438#define GSL_ROOT3_FLT_MAX 6.9814635196223242e+12
1439#define GSL_ROOT4_FLT_MAX 4.2949672319999986e+09
1440#define GSL_ROOT5_FLT_MAX 5.0859007855960041e+07
1441#define GSL_ROOT6_FLT_MAX 2.6422459233807749e+06
1442#define GSL_LOG_FLT_MAX 8.8722839052068352e+01
1443
1444#define GSL_SFLT_EPSILON 4.8828125000000000e-04
1445#define GSL_SQRT_SFLT_EPSILON 2.2097086912079612e-02
1446#define GSL_ROOT3_SFLT_EPSILON 7.8745065618429588e-02
1447#define GSL_ROOT4_SFLT_EPSILON 1.4865088937534013e-01
1448#define GSL_ROOT5_SFLT_EPSILON 2.1763764082403100e-01
1449#define GSL_ROOT6_SFLT_EPSILON 2.8061551207734325e-01
1450#define GSL_LOG_SFLT_EPSILON (-7.6246189861593985e+00)
1451
1452/* !MACHINE CONSTANTS! */
1453
1454
1455/* a little internal backwards compatibility */
1456#define GSL_MACH_EPS GSL_DBL_EPSILON
1457
1458
1459
1460/* Here are the constants related to or derived from
1461 * machine constants. These are not to be confused with
1462 * the constants that define various precision levels
1463 * for the precision/error system.
1464 *
1465 * This information is determined at configure time
1466 * and is platform dependent. Edit at your own risk.
1467 *
1468 * PLATFORM: WHIZ-O-MATIC
1469 * CONFIG-DATE: Thu Nov 19 19:27:18 MST 1998
1470 * CONFIG-HOST: nnn.lanl.gov
1471 */
1472
1473/* machine precision constants */
1474/* #define GSL_MACH_EPS 1.0e-15 */
1475#define GSL_SQRT_MACH_EPS 3.2e-08
1476#define GSL_ROOT3_MACH_EPS 1.0e-05
1477#define GSL_ROOT4_MACH_EPS 0.000178
1478#define GSL_ROOT5_MACH_EPS 0.00100
1479#define GSL_ROOT6_MACH_EPS 0.00316
1480#define GSL_LOG_MACH_EPS (-34.54)
1481
1482
1483#endif /* __GSL_MACHINE_H__ */
1484
1485/* end inlined header: gsl/gsl_machine.h */
1486/* Compile all the inline functions */
1487
1488#define COMPILE_INLINE_STATIC
1489/* begin inlined header: build.h */
1490/* Compile subsequent inline functions as static functions */
1491
1492/* Allow multiple inclusion in a single translation unit (needed for the
1493 * amalgamated gsl_marley.c build where sys/minmax.c, sys/prec.c, and
1494 * complex/inline.c each set COMPILE_INLINE_STATIC and include this header).
1495 * The macro setup below is idempotent, so later inclusions are harmless. */
1496#ifndef __GSL_BUILD_H__
1497#define __GSL_BUILD_H__
1498
1499#ifdef COMPILE_INLINE_STATIC
1500#ifndef HIDE_INLINE_STATIC /* skip if inline functions are hidden */
1501
1502#undef __GSL_INLINE_H__
1503#define __GSL_INLINE_H__ /* first, ignore the gsl_inline.h header file */
1504
1505#undef INLINE_DECL
1506#define INLINE_DECL /* disable inline in declarations */
1507
1508#undef INLINE_FUN
1509#define INLINE_FUN /* disable inline in definitions */
1510
1511#ifndef HAVE_INLINE /* enable compilation of definitions in .h files */
1512#define HAVE_INLINE
1513#endif
1514
1515/* Compile range checking code for inline functions used in the library */
1516#undef GSL_RANGE_CHECK
1517#define GSL_RANGE_CHECK 1
1518
1519/* Use the global variable gsl_check_range to enable/disable range checking at
1520 runtime */
1521#undef GSL_RANGE_COND
1522#define GSL_RANGE_COND(x) (gsl_check_range && (x))
1523
1524#endif
1525#else
1526#error must be called with COMPILE_INLINE_STATIC
1527#endif
1528
1529#endif /* __GSL_BUILD_H__ */
1530
1531/* end inlined header: build.h */
1532/* begin inlined header: gsl/gsl_precision.h */
1533/* gsl_precision.h
1534 *
1535 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
1536 *
1537 * This program is free software; you can redistribute it and/or modify
1538 * it under the terms of the GNU General Public License as published by
1539 * the Free Software Foundation; either version 3 of the License, or (at
1540 * your option) any later version.
1541 *
1542 * This program is distributed in the hope that it will be useful, but
1543 * WITHOUT ANY WARRANTY; without even the implied warranty of
1544 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1545 * General Public License for more details.
1546 *
1547 * You should have received a copy of the GNU General Public License
1548 * along with this program; if not, write to the Free Software
1549 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1550 */
1551
1552/* Author: B. Gough and G. Jungman */
1553
1554#ifndef __GSL_PRECISION_H__
1555#define __GSL_PRECISION_H__
1556/* begin inlined header: gsl/gsl_types.h */
1557/* gsl_types.h
1558 *
1559 * Copyright (C) 2001, 2007 Brian Gough
1560 *
1561 * This program is free software; you can redistribute it and/or modify
1562 * it under the terms of the GNU General Public License as published by
1563 * the Free Software Foundation; either version 3 of the License, or (at
1564 * your option) any later version.
1565 *
1566 * This program is distributed in the hope that it will be useful, but
1567 * WITHOUT ANY WARRANTY; without even the implied warranty of
1568 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1569 * General Public License for more details.
1570 *
1571 * You should have received a copy of the GNU General Public License
1572 * along with this program; if not, write to the Free Software
1573 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1574 */
1575
1576#ifndef __GSL_TYPES_H__
1577#define __GSL_TYPES_H__
1578
1579#ifndef GSL_VAR
1580
1581#ifdef WIN32
1582# ifdef GSL_DLL
1583# ifdef DLL_EXPORT
1584# define GSL_VAR extern __declspec(dllexport)
1585# else
1586# define GSL_VAR extern __declspec(dllimport)
1587# endif
1588# else
1589# define GSL_VAR extern
1590# endif
1591#else
1592# define GSL_VAR extern
1593#endif
1594
1595#endif
1596
1597#endif /* __GSL_TYPES_H__ */
1598
1599/* end inlined header: gsl/gsl_types.h */
1600
1601__BEGIN_DECLS
1602
1603
1604/* A type for the precision indicator.
1605 * This is mainly for pedagogy.
1606 */
1607typedef unsigned int gsl_prec_t;
1608
1609
1610/* The number of precision types.
1611 * Remember that precision-mode
1612 * can index an array.
1613 */
1614#define _GSL_PREC_T_NUM 3
1615
1616
1617/* Arrays containing derived
1618 * precision constants for the
1619 * different precision levels.
1620 */
1621GSL_VAR const double gsl_prec_eps[];
1622GSL_VAR const double gsl_prec_sqrt_eps[];
1623GSL_VAR const double gsl_prec_root3_eps[];
1624GSL_VAR const double gsl_prec_root4_eps[];
1625GSL_VAR const double gsl_prec_root5_eps[];
1626GSL_VAR const double gsl_prec_root6_eps[];
1627
1628
1629__END_DECLS
1630
1631#endif /* __GSL_PRECISION_H__ */
1632
1633/* end inlined header: gsl/gsl_precision.h */
1634/* begin inlined header: gsl/gsl_mode.h */
1635/* gsl_mode.h
1636 *
1637 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2004 Gerard Jungman
1638 *
1639 * This program is free software; you can redistribute it and/or modify
1640 * it under the terms of the GNU General Public License as published by
1641 * the Free Software Foundation; either version 3 of the License, or (at
1642 * your option) any later version.
1643 *
1644 * This program is distributed in the hope that it will be useful, but
1645 * WITHOUT ANY WARRANTY; without even the implied warranty of
1646 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1647 * General Public License for more details.
1648 *
1649 * You should have received a copy of the GNU General Public License
1650 * along with this program; if not, write to the Free Software
1651 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1652 */
1653
1654/* Author: B. Gough and G. Jungman */
1655
1656#ifndef __GSL_MODE_H__
1657#define __GSL_MODE_H__
1658/* begin inlined header: gsl/gsl_inline.h */
1659/* gsl_inline.h
1660 *
1661 * Copyright (C) 2008, 2009 Brian Gough
1662 *
1663 * This program is free software; you can redistribute it and/or modify
1664 * it under the terms of the GNU General Public License as published by
1665 * the Free Software Foundation; either version 3 of the License, or (at
1666 * your option) any later version.
1667 *
1668 * This program is distributed in the hope that it will be useful, but
1669 * WITHOUT ANY WARRANTY; without even the implied warranty of
1670 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1671 * General Public License for more details.
1672 *
1673 * You should have received a copy of the GNU General Public License
1674 * along with this program; if not, write to the Free Software
1675 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1676 */
1677
1678#ifndef __GSL_INLINE_H__
1679#define __GSL_INLINE_H__
1680
1681/* In recent versiions of GCC, the inline keyword has two different
1682 forms: GNU and C99.
1683
1684 In GNU mode we can use 'extern inline' to make inline functions
1685 work like macros. The function is only inlined--it is never output
1686 as a definition in an object file.
1687
1688 In the new C99 mode 'extern inline' has a different meaning--it
1689 causes the definition of the function to be output in each object
1690 file where it is used. This will result in multiple-definition
1691 errors on linking. The 'inline' keyword on its own (without
1692 extern) has the same behavior as the original GNU 'extern inline'.
1693
1694 The C99 style is the default with -std=c99 in GCC 4.3.
1695
1696 This header file allows either form of inline to be used by
1697 redefining the macros INLINE_DECL and INLINE_FUN. These are used
1698 in the public header files as
1699
1700 INLINE_DECL double gsl_foo (double x);
1701 #ifdef HAVE_INLINE
1702 INLINE_FUN double gsl_foo (double x) { return x+1.0; } ;
1703 #endif
1704
1705*/
1706
1707#ifdef HAVE_INLINE
1708# if defined(__GNUC_STDC_INLINE__) || defined(GSL_C99_INLINE) || defined(HAVE_C99_INLINE)
1709# define INLINE_DECL inline /* use C99 inline */
1710# define INLINE_FUN inline
1711# else
1712# define INLINE_DECL /* use GNU extern inline */
1713# define INLINE_FUN extern inline
1714# endif
1715#else
1716# define INLINE_DECL /* */
1717#endif
1718
1719/* Range checking conditions in headers do not require any run-time
1720 tests of the global variable gsl_check_range. They are enabled or
1721 disabled in user code at compile time with GSL_RANGE_CHECK macro.
1722 See also build.h. */
1723#define GSL_RANGE_COND(x) (x)
1724
1725#endif /* __GSL_INLINE_H__ */
1726
1727/* end inlined header: gsl/gsl_inline.h */
1728
1729__BEGIN_DECLS
1730
1731
1732/* Some functions can take a mode argument. This
1733 * is a rough method to do things like control
1734 * the precision of the algorithm. This mainly
1735 * occurs in special functions, but we figured
1736 * it was ok to have a general facility.
1737 *
1738 * The mode type is 32-bit field. Most of
1739 * the fields are currently unused. Users
1740 * '|' various predefined constants to get
1741 * a desired mode.
1742 */
1743typedef unsigned int gsl_mode_t;
1744
1745
1746/* Here are the predefined constants.
1747 * Note that the precision constants
1748 * are special because they are used
1749 * to index arrays, so do not change
1750 * them. The precision information is
1751 * in the low order 3 bits of gsl_mode_t
1752 * (the third bit is currently unused).
1753 */
1754
1755/* Note that "0" is double precision,
1756 * so that you get that by default if
1757 * you forget a flag.
1758 */
1759#define GSL_PREC_DOUBLE 0
1760#define GSL_PREC_SINGLE 1
1761#define GSL_PREC_APPROX 2
1762
1763#ifdef HAVE_INLINE
1764INLINE_FUN unsigned int GSL_MODE_PREC(gsl_mode_t mt);
1765
1766INLINE_FUN unsigned int
1767GSL_MODE_PREC(gsl_mode_t mt)
1768{ return (mt & (unsigned int)7); }
1769#else /* HAVE_INLINE */
1770#define GSL_MODE_PREC(mt) ((mt) & (unsigned int)7)
1771#endif /* HAVE_INLINE */
1772
1773
1774/* Here are some predefined generic modes.
1775 */
1776#define GSL_MODE_DEFAULT 0
1777
1778
1779__END_DECLS
1780
1781#endif /* __GSL_MODE_H__ */
1782
1783/* end inlined header: gsl/gsl_mode.h */
1784const double gsl_prec_eps[_GSL_PREC_T_NUM] = {
1785 GSL_DBL_EPSILON,
1786 GSL_FLT_EPSILON,
1787 GSL_SFLT_EPSILON
1788};
1789
1790const double gsl_prec_sqrt_eps[_GSL_PREC_T_NUM] = {
1791 GSL_SQRT_DBL_EPSILON,
1792 GSL_SQRT_FLT_EPSILON,
1793 GSL_SQRT_SFLT_EPSILON
1794};
1795
1796const double gsl_prec_root3_eps[_GSL_PREC_T_NUM] = {
1797 GSL_ROOT3_DBL_EPSILON,
1798 GSL_ROOT3_FLT_EPSILON,
1799 GSL_ROOT3_SFLT_EPSILON
1800};
1801
1802const double gsl_prec_root4_eps[_GSL_PREC_T_NUM] = {
1803 GSL_ROOT4_DBL_EPSILON,
1804 GSL_ROOT4_FLT_EPSILON,
1805 GSL_ROOT4_SFLT_EPSILON
1806};
1807
1808const double gsl_prec_root5_eps[_GSL_PREC_T_NUM] = {
1809 GSL_ROOT5_DBL_EPSILON,
1810 GSL_ROOT5_FLT_EPSILON,
1811 GSL_ROOT5_SFLT_EPSILON
1812};
1813
1814const double gsl_prec_root6_eps[_GSL_PREC_T_NUM] = {
1815 GSL_ROOT6_DBL_EPSILON,
1816 GSL_ROOT6_FLT_EPSILON,
1817 GSL_ROOT6_SFLT_EPSILON
1818};
1819
1820/* end inlined source: sys/prec.c */
1821
1822/* Complex arithmetic ------------------------------------------------------*/
1823/* complex/inline.c also uses build.h (skipped on second inclusion) and
1824 * gsl_complex_math.h (skipped by its own include guard); it exists solely
1825 * to emit linkable versions of the complex inline helpers, which are not
1826 * needed in this single-TU build. Including it is harmless. */
1827/* begin inlined source: complex/inline.c */
1828/* complex/inline.c
1829 *
1830 * Copyright (C) 2008 Brian Gough
1831 *
1832 * This program is free software; you can redistribute it and/or modify
1833 * it under the terms of the GNU General Public License as published by
1834 * the Free Software Foundation; either version 3 of the License, or (at
1835 * your option) any later version.
1836 *
1837 * This program is distributed in the hope that it will be useful, but
1838 * WITHOUT ANY WARRANTY; without even the implied warranty of
1839 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1840 * General Public License for more details.
1841 *
1842 * You should have received a copy of the GNU General Public License
1843 * along with this program; if not, write to the Free Software
1844 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1845 */
1846
1847/* Compile all the inline functions */
1848
1849#define COMPILE_INLINE_STATIC
1850/* begin inlined header: build.h */
1851/* Compile subsequent inline functions as static functions */
1852
1853/* Allow multiple inclusion in a single translation unit (needed for the
1854 * amalgamated gsl_marley.c build where sys/minmax.c, sys/prec.c, and
1855 * complex/inline.c each set COMPILE_INLINE_STATIC and include this header).
1856 * The macro setup below is idempotent, so later inclusions are harmless. */
1857#ifndef __GSL_BUILD_H__
1858#define __GSL_BUILD_H__
1859
1860#ifdef COMPILE_INLINE_STATIC
1861#ifndef HIDE_INLINE_STATIC /* skip if inline functions are hidden */
1862
1863#undef __GSL_INLINE_H__
1864#define __GSL_INLINE_H__ /* first, ignore the gsl_inline.h header file */
1865
1866#undef INLINE_DECL
1867#define INLINE_DECL /* disable inline in declarations */
1868
1869#undef INLINE_FUN
1870#define INLINE_FUN /* disable inline in definitions */
1871
1872#ifndef HAVE_INLINE /* enable compilation of definitions in .h files */
1873#define HAVE_INLINE
1874#endif
1875
1876/* Compile range checking code for inline functions used in the library */
1877#undef GSL_RANGE_CHECK
1878#define GSL_RANGE_CHECK 1
1879
1880/* Use the global variable gsl_check_range to enable/disable range checking at
1881 runtime */
1882#undef GSL_RANGE_COND
1883#define GSL_RANGE_COND(x) (gsl_check_range && (x))
1884
1885#endif
1886#else
1887#error must be called with COMPILE_INLINE_STATIC
1888#endif
1889
1890#endif /* __GSL_BUILD_H__ */
1891
1892/* end inlined header: build.h */
1893/* begin inlined header: gsl/gsl_complex_math.h */
1894/* complex/gsl_complex_math.h
1895 *
1896 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2004, 2007 Jorma Olavi T�htinen, Brian Gough
1897 *
1898 * This program is free software; you can redistribute it and/or modify
1899 * it under the terms of the GNU General Public License as published by
1900 * the Free Software Foundation; either version 3 of the License, or (at
1901 * your option) any later version.
1902 *
1903 * This program is distributed in the hope that it will be useful, but
1904 * WITHOUT ANY WARRANTY; without even the implied warranty of
1905 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1906 * General Public License for more details.
1907 *
1908 * You should have received a copy of the GNU General Public License
1909 * along with this program; if not, write to the Free Software
1910 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1911 */
1912
1913#ifndef __GSL_COMPLEX_MATH_H__
1914#define __GSL_COMPLEX_MATH_H__
1915/* begin inlined header: gsl/gsl_inline.h */
1916/* gsl_inline.h
1917 *
1918 * Copyright (C) 2008, 2009 Brian Gough
1919 *
1920 * This program is free software; you can redistribute it and/or modify
1921 * it under the terms of the GNU General Public License as published by
1922 * the Free Software Foundation; either version 3 of the License, or (at
1923 * your option) any later version.
1924 *
1925 * This program is distributed in the hope that it will be useful, but
1926 * WITHOUT ANY WARRANTY; without even the implied warranty of
1927 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1928 * General Public License for more details.
1929 *
1930 * You should have received a copy of the GNU General Public License
1931 * along with this program; if not, write to the Free Software
1932 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1933 */
1934
1935#ifndef __GSL_INLINE_H__
1936#define __GSL_INLINE_H__
1937
1938/* In recent versiions of GCC, the inline keyword has two different
1939 forms: GNU and C99.
1940
1941 In GNU mode we can use 'extern inline' to make inline functions
1942 work like macros. The function is only inlined--it is never output
1943 as a definition in an object file.
1944
1945 In the new C99 mode 'extern inline' has a different meaning--it
1946 causes the definition of the function to be output in each object
1947 file where it is used. This will result in multiple-definition
1948 errors on linking. The 'inline' keyword on its own (without
1949 extern) has the same behavior as the original GNU 'extern inline'.
1950
1951 The C99 style is the default with -std=c99 in GCC 4.3.
1952
1953 This header file allows either form of inline to be used by
1954 redefining the macros INLINE_DECL and INLINE_FUN. These are used
1955 in the public header files as
1956
1957 INLINE_DECL double gsl_foo (double x);
1958 #ifdef HAVE_INLINE
1959 INLINE_FUN double gsl_foo (double x) { return x+1.0; } ;
1960 #endif
1961
1962*/
1963
1964#ifdef HAVE_INLINE
1965# if defined(__GNUC_STDC_INLINE__) || defined(GSL_C99_INLINE) || defined(HAVE_C99_INLINE)
1966# define INLINE_DECL inline /* use C99 inline */
1967# define INLINE_FUN inline
1968# else
1969# define INLINE_DECL /* use GNU extern inline */
1970# define INLINE_FUN extern inline
1971# endif
1972#else
1973# define INLINE_DECL /* */
1974#endif
1975
1976/* Range checking conditions in headers do not require any run-time
1977 tests of the global variable gsl_check_range. They are enabled or
1978 disabled in user code at compile time with GSL_RANGE_CHECK macro.
1979 See also build.h. */
1980#define GSL_RANGE_COND(x) (x)
1981
1982#endif /* __GSL_INLINE_H__ */
1983
1984/* end inlined header: gsl/gsl_inline.h */
1985/* begin inlined header: gsl/gsl_complex.h */
1986/* complex/gsl_complex.h
1987 *
1988 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, Brian Gough
1989 * Copyright (C) 2020, 2021 Patrick Alken
1990 *
1991 * This program is free software; you can redistribute it and/or modify
1992 * it under the terms of the GNU General Public License as published by
1993 * the Free Software Foundation; either version 3 of the License, or (at
1994 * your option) any later version.
1995 *
1996 * This program is distributed in the hope that it will be useful, but
1997 * WITHOUT ANY WARRANTY; without even the implied warranty of
1998 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1999 * General Public License for more details.
2000 *
2001 * You should have received a copy of the GNU General Public License
2002 * along with this program; if not, write to the Free Software
2003 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2004 */
2005
2006#ifndef __GSL_COMPLEX_H__
2007#define __GSL_COMPLEX_H__
2008
2009__BEGIN_DECLS
2010
2011
2012/* two consecutive built-in types as a complex number */
2013typedef double * gsl_complex_packed ;
2014typedef float * gsl_complex_packed_float ;
2015typedef long double * gsl_complex_packed_long_double ;
2016
2017typedef const double * gsl_const_complex_packed ;
2018typedef const float * gsl_const_complex_packed_float ;
2019typedef const long double * gsl_const_complex_packed_long_double ;
2020
2021
2022/* 2N consecutive built-in types as N complex numbers */
2023typedef double * gsl_complex_packed_array ;
2024typedef float * gsl_complex_packed_array_float ;
2025typedef long double * gsl_complex_packed_array_long_double ;
2026
2027typedef const double * gsl_const_complex_packed_array ;
2028typedef const float * gsl_const_complex_packed_array_float ;
2029typedef const long double * gsl_const_complex_packed_array_long_double ;
2030
2031
2032/* Yes... this seems weird. Trust us. The point is just that
2033 sometimes you want to make it obvious that something is
2034 an output value. The fact that it lacks a 'const' may not
2035 be enough of a clue for people in some contexts.
2036 */
2037typedef double * gsl_complex_packed_ptr ;
2038typedef float * gsl_complex_packed_float_ptr ;
2039typedef long double * gsl_complex_packed_long_double_ptr ;
2040
2041typedef const double * gsl_const_complex_packed_ptr ;
2042typedef const float * gsl_const_complex_packed_float_ptr ;
2043typedef const long double * gsl_const_complex_packed_long_double_ptr ;
2044
2045/*
2046 * If <complex.h> is included, use the C99 complex type. Otherwise
2047 * define a type bit-compatible with C99 complex. The GSL_REAL and GSL_IMAG
2048 * macros require C11 functionality also (_Generic)
2049 */
2050
2051/* older gcc compilers claim to be C11 compliant but do not support _Generic */
2052#if defined(__GNUC__) && (__GNUC__ < 7)
2053# define GSL_COMPLEX_LEGACY 1
2054#endif
2055
2056#if !defined(GSL_COMPLEX_LEGACY) && \
2057 defined(_Complex_I) && \
2058 defined(complex) && \
2059 defined(I) && \
2060 defined(__STDC__) && (__STDC__ == 1) && \
2061 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) /* C11 */
2062
2063# define GSL_COMPLEX_DEFINE(R, C) typedef R _Complex C ;
2064
2065# define GSL_COMPLEX_P(zp) (&(zp))
2066# define GSL_COMPLEX_EQ(z1,z2) ((z1) == (z2))
2067# define GSL_SET_COMPLEX(zp,x,y) (*(zp) = (x) + I * (y))
2068
2069# define GSL_REAL(z) (_Generic((z), \
2070 complex float : ((float *) &(z)), \
2071 complex double : ((double *) &(z)), \
2072 complex long double : ((long double *) &(z)))[0])
2073
2074# define GSL_IMAG(z) (_Generic((z), \
2075 complex float : ((float *) &(z)), \
2076 complex double : ((double *) &(z)), \
2077 complex long double : ((long double *) &(z)))[1])
2078
2079# define GSL_COMPLEX_P_REAL(zp) GSL_REAL(*(zp))
2080# define GSL_COMPLEX_P_IMAG(zp) GSL_IMAG(*(zp))
2081# define GSL_SET_REAL(zp,x) do { GSL_REAL(*(zp)) = (x); } while(0)
2082# define GSL_SET_IMAG(zp,x) do { GSL_IMAG(*(zp)) = (x); } while(0)
2083
2084#else /* legacy complex definitions */
2085
2086/*
2087 * According to the C17 standard, 6.2.5 paragraph 13:
2088 *
2089 * "Each complex type has the same representation and alignment requirements
2090 * as an array type containing exactly two elements of the corresponding real
2091 * type; the first element is equal to the real part, and the second element to
2092 * the imaginary part, of the complex number."
2093 */
2094
2095/*# define GSL_COMPLEX_DEFINE(R, C) typedef R C[2]*/
2096# define GSL_COMPLEX_DEFINE(R, C) typedef struct { R dat[2]; } C ;
2097
2098# define GSL_REAL(z) ((z).dat[0])
2099# define GSL_IMAG(z) ((z).dat[1])
2100# define GSL_COMPLEX_P(zp) ((zp)->dat)
2101# define GSL_COMPLEX_P_REAL(zp) ((zp)->dat[0])
2102# define GSL_COMPLEX_P_IMAG(zp) ((zp)->dat[1])
2103# define GSL_COMPLEX_EQ(z1,z2) (((z1).dat[0] == (z2).dat[0]) && ((z1).dat[1] == (z2).dat[1]))
2104
2105# define GSL_SET_COMPLEX(zp,x,y) do {(zp)->dat[0]=(x); (zp)->dat[1]=(y);} while(0)
2106# define GSL_SET_REAL(zp,x) do {(zp)->dat[0]=(x);} while(0)
2107# define GSL_SET_IMAG(zp,y) do {(zp)->dat[1]=(y);} while(0)
2108
2109#endif
2110
2111GSL_COMPLEX_DEFINE(double, gsl_complex)
2112GSL_COMPLEX_DEFINE(long double, gsl_complex_long_double)
2113GSL_COMPLEX_DEFINE(float, gsl_complex_float)
2114
2115#define GSL_SET_COMPLEX_PACKED(zp,n,x,y) do {*((zp)+2*(n))=(x); *((zp)+(2*(n)+1))=(y);} while(0)
2116
2117__END_DECLS
2118
2119#endif /* __GSL_COMPLEX_H__ */
2120
2121/* end inlined header: gsl/gsl_complex.h */
2122
2123__BEGIN_DECLS
2124
2125/* Complex numbers */
2126
2127gsl_complex gsl_complex_polar (double r, double theta); /* r= r e^(i theta) */
2128
2129INLINE_DECL gsl_complex gsl_complex_rect (double x, double y); /* r= real+i*imag */
2130
2131#ifdef HAVE_INLINE
2132INLINE_FUN gsl_complex
2133gsl_complex_rect (double x, double y)
2134{ /* return z = x + i y */
2135 gsl_complex z;
2136 GSL_SET_COMPLEX (&z, x, y);
2137 return z;
2138}
2139#endif
2140
2141#define GSL_COMPLEX_ONE (gsl_complex_rect(1.0,0.0))
2142#define GSL_COMPLEX_ZERO (gsl_complex_rect(0.0,0.0))
2143#define GSL_COMPLEX_NEGONE (gsl_complex_rect(-1.0,0.0))
2144
2145/* Properties of complex numbers */
2146
2147double gsl_complex_arg (gsl_complex z); /* return arg(z), -pi< arg(z) <=+pi */
2148double gsl_complex_abs (gsl_complex z); /* return |z| */
2149double gsl_complex_abs2 (gsl_complex z); /* return |z|^2 */
2150double gsl_complex_logabs (gsl_complex z); /* return log|z| */
2151
2152/* Complex arithmetic operators */
2153
2154gsl_complex gsl_complex_add (gsl_complex a, gsl_complex b); /* r=a+b */
2155gsl_complex gsl_complex_sub (gsl_complex a, gsl_complex b); /* r=a-b */
2156gsl_complex gsl_complex_mul (gsl_complex a, gsl_complex b); /* r=a*b */
2157gsl_complex gsl_complex_div (gsl_complex a, gsl_complex b); /* r=a/b */
2158
2159gsl_complex gsl_complex_add_real (gsl_complex a, double x); /* r=a+x */
2160gsl_complex gsl_complex_sub_real (gsl_complex a, double x); /* r=a-x */
2161gsl_complex gsl_complex_mul_real (gsl_complex a, double x); /* r=a*x */
2162gsl_complex gsl_complex_div_real (gsl_complex a, double x); /* r=a/x */
2163
2164gsl_complex gsl_complex_add_imag (gsl_complex a, double y); /* r=a+iy */
2165gsl_complex gsl_complex_sub_imag (gsl_complex a, double y); /* r=a-iy */
2166gsl_complex gsl_complex_mul_imag (gsl_complex a, double y); /* r=a*iy */
2167gsl_complex gsl_complex_div_imag (gsl_complex a, double y); /* r=a/iy */
2168
2169gsl_complex gsl_complex_conjugate (gsl_complex z); /* r=conj(z) */
2170gsl_complex gsl_complex_inverse (gsl_complex a); /* r=1/a */
2171gsl_complex gsl_complex_negative (gsl_complex a); /* r=-a */
2172
2173/* Elementary Complex Functions */
2174
2175gsl_complex gsl_complex_sqrt (gsl_complex z); /* r=sqrt(z) */
2176gsl_complex gsl_complex_sqrt_real (double x); /* r=sqrt(x) (x<0 ok) */
2177
2178gsl_complex gsl_complex_pow (gsl_complex a, gsl_complex b); /* r=a^b */
2179gsl_complex gsl_complex_pow_real (gsl_complex a, double b); /* r=a^b */
2180
2181gsl_complex gsl_complex_exp (gsl_complex a); /* r=exp(a) */
2182gsl_complex gsl_complex_log (gsl_complex a); /* r=log(a) (base e) */
2183gsl_complex gsl_complex_log10 (gsl_complex a); /* r=log10(a) (base 10) */
2184gsl_complex gsl_complex_log_b (gsl_complex a, gsl_complex b); /* r=log_b(a) (base=b) */
2185
2186/* Complex Trigonometric Functions */
2187
2188gsl_complex gsl_complex_sin (gsl_complex a); /* r=sin(a) */
2189gsl_complex gsl_complex_cos (gsl_complex a); /* r=cos(a) */
2190gsl_complex gsl_complex_sec (gsl_complex a); /* r=sec(a) */
2191gsl_complex gsl_complex_csc (gsl_complex a); /* r=csc(a) */
2192gsl_complex gsl_complex_tan (gsl_complex a); /* r=tan(a) */
2193gsl_complex gsl_complex_cot (gsl_complex a); /* r=cot(a) */
2194
2195/* Inverse Complex Trigonometric Functions */
2196
2197gsl_complex gsl_complex_arcsin (gsl_complex a); /* r=arcsin(a) */
2198gsl_complex gsl_complex_arcsin_real (double a); /* r=arcsin(a) */
2199gsl_complex gsl_complex_arccos (gsl_complex a); /* r=arccos(a) */
2200gsl_complex gsl_complex_arccos_real (double a); /* r=arccos(a) */
2201gsl_complex gsl_complex_arcsec (gsl_complex a); /* r=arcsec(a) */
2202gsl_complex gsl_complex_arcsec_real (double a); /* r=arcsec(a) */
2203gsl_complex gsl_complex_arccsc (gsl_complex a); /* r=arccsc(a) */
2204gsl_complex gsl_complex_arccsc_real (double a); /* r=arccsc(a) */
2205gsl_complex gsl_complex_arctan (gsl_complex a); /* r=arctan(a) */
2206gsl_complex gsl_complex_arccot (gsl_complex a); /* r=arccot(a) */
2207
2208/* Complex Hyperbolic Functions */
2209
2210gsl_complex gsl_complex_sinh (gsl_complex a); /* r=sinh(a) */
2211gsl_complex gsl_complex_cosh (gsl_complex a); /* r=coshh(a) */
2212gsl_complex gsl_complex_sech (gsl_complex a); /* r=sech(a) */
2213gsl_complex gsl_complex_csch (gsl_complex a); /* r=csch(a) */
2214gsl_complex gsl_complex_tanh (gsl_complex a); /* r=tanh(a) */
2215gsl_complex gsl_complex_coth (gsl_complex a); /* r=coth(a) */
2216
2217/* Inverse Complex Hyperbolic Functions */
2218
2219gsl_complex gsl_complex_arcsinh (gsl_complex a); /* r=arcsinh(a) */
2220gsl_complex gsl_complex_arccosh (gsl_complex a); /* r=arccosh(a) */
2221gsl_complex gsl_complex_arccosh_real (double a); /* r=arccosh(a) */
2222gsl_complex gsl_complex_arcsech (gsl_complex a); /* r=arcsech(a) */
2223gsl_complex gsl_complex_arccsch (gsl_complex a); /* r=arccsch(a) */
2224gsl_complex gsl_complex_arctanh (gsl_complex a); /* r=arctanh(a) */
2225gsl_complex gsl_complex_arctanh_real (double a); /* r=arctanh(a) */
2226gsl_complex gsl_complex_arccoth (gsl_complex a); /* r=arccoth(a) */
2227
2228__END_DECLS
2229
2230#endif /* __GSL_COMPLEX_MATH_H__ */
2231
2232/* end inlined header: gsl/gsl_complex_math.h */
2233/* end inlined source: complex/inline.c */
2234/* begin inlined source: complex/math.c */
2235/* complex/math.c
2236 *
2237 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Jorma Olavi T�htinen, Brian Gough
2238 *
2239 * This program is free software; you can redistribute it and/or modify
2240 * it under the terms of the GNU General Public License as published by
2241 * the Free Software Foundation; either version 3 of the License, or (at
2242 * your option) any later version.
2243 *
2244 * This program is distributed in the hope that it will be useful, but
2245 * WITHOUT ANY WARRANTY; without even the implied warranty of
2246 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2247 * General Public License for more details.
2248 *
2249 * You should have received a copy of the GNU General Public License
2250 * along with this program; if not, write to the Free Software
2251 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2252 */
2253
2254/* Basic complex arithmetic functions
2255
2256 * Original version by Jorma Olavi T�htinen <[email protected]>
2257 *
2258 * Modified for GSL by Brian Gough, 3/2000
2259 */
2260
2261/* The following references describe the methods used in these
2262 * functions,
2263 *
2264 * T. E. Hull and Thomas F. Fairgrieve and Ping Tak Peter Tang,
2265 * "Implementing Complex Elementary Functions Using Exception
2266 * Handling", ACM Transactions on Mathematical Software, Volume 20
2267 * (1994), pp 215-244, Corrigenda, p553
2268 *
2269 * Hull et al, "Implementing the complex arcsin and arccosine
2270 * functions using exception handling", ACM Transactions on
2271 * Mathematical Software, Volume 23 (1997) pp 299-335
2272 *
2273 * Abramowitz and Stegun, Handbook of Mathematical Functions, "Inverse
2274 * Circular Functions in Terms of Real and Imaginary Parts", Formulas
2275 * 4.4.37, 4.4.38, 4.4.39
2276 */
2277/* begin inlined header: config.h */
2278#ifndef MARLEY_BUILTIN_GSL_CONFIG_WRAPPER_H
2279#define MARLEY_BUILTIN_GSL_CONFIG_WRAPPER_H
2280/* begin inlined header: gsl_config.h */
2281#ifndef MARLEY_BUILTIN_GSL_CONFIG_H
2282#define MARLEY_BUILTIN_GSL_CONFIG_H
2283
2284#define HAVE_INLINE 1
2285#define HAVE_DECL_ISFINITE 1
2286#define HAVE_DECL_ISNAN 1
2287#define HAVE_DECL_ISINF 1
2288#define GSL_COERCE_DBL(x) (x)
2289
2290#define GSL_DISABLE_DEPRECATED 0
2291#define PACKAGE_VERSION "2.8"
2292#define VERSION "2.8"
2293
2294#endif
2295
2296/* end inlined header: gsl_config.h */
2297#endif
2298
2299/* end inlined header: config.h */
2300#include <math.h>
2301/* begin inlined header: gsl/gsl_math.h */
2302/* gsl_math.h
2303 *
2304 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2004, 2007 Gerard Jungman, Brian Gough
2305 *
2306 * This program is free software; you can redistribute it and/or modify
2307 * it under the terms of the GNU General Public License as published by
2308 * the Free Software Foundation; either version 3 of the License, or (at
2309 * your option) any later version.
2310 *
2311 * This program is distributed in the hope that it will be useful, but
2312 * WITHOUT ANY WARRANTY; without even the implied warranty of
2313 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2314 * General Public License for more details.
2315 *
2316 * You should have received a copy of the GNU General Public License
2317 * along with this program; if not, write to the Free Software
2318 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2319 */
2320
2321#ifndef __GSL_MATH_H__
2322#define __GSL_MATH_H__
2323#include <math.h>
2324/* begin inlined header: gsl/gsl_sys.h */
2325/* sys/gsl_sys.h
2326 *
2327 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, Brian Gough
2328 *
2329 * This program is free software; you can redistribute it and/or modify
2330 * it under the terms of the GNU General Public License as published by
2331 * the Free Software Foundation; either version 3 of the License, or (at
2332 * your option) any later version.
2333 *
2334 * This program is distributed in the hope that it will be useful, but
2335 * WITHOUT ANY WARRANTY; without even the implied warranty of
2336 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2337 * General Public License for more details.
2338 *
2339 * You should have received a copy of the GNU General Public License
2340 * along with this program; if not, write to the Free Software
2341 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2342 */
2343
2344#ifndef __GSL_SYS_H__
2345#define __GSL_SYS_H__
2346
2347__BEGIN_DECLS
2348
2349double gsl_log1p (const double x);
2350double gsl_expm1 (const double x);
2351double gsl_hypot (const double x, const double y);
2352double gsl_hypot3 (const double x, const double y, const double z);
2353double gsl_acosh (const double x);
2354double gsl_asinh (const double x);
2355double gsl_atanh (const double x);
2356
2357int gsl_isnan (const double x);
2358int gsl_isinf (const double x);
2359int gsl_finite (const double x);
2360
2361double gsl_nan (void);
2362double gsl_posinf (void);
2363double gsl_neginf (void);
2364double gsl_fdiv (const double x, const double y);
2365
2366double gsl_coerce_double (const double x);
2367float gsl_coerce_float (const float x);
2368long double gsl_coerce_long_double (const long double x);
2369
2370double gsl_ldexp(const double x, const int e);
2371double gsl_frexp(const double x, int * e);
2372
2373int gsl_fcmp (const double x1, const double x2, const double epsilon);
2374
2375__END_DECLS
2376
2377#endif /* __GSL_SYS_H__ */
2378
2379/* end inlined header: gsl/gsl_sys.h */
2380/* begin inlined header: gsl/gsl_inline.h */
2381/* gsl_inline.h
2382 *
2383 * Copyright (C) 2008, 2009 Brian Gough
2384 *
2385 * This program is free software; you can redistribute it and/or modify
2386 * it under the terms of the GNU General Public License as published by
2387 * the Free Software Foundation; either version 3 of the License, or (at
2388 * your option) any later version.
2389 *
2390 * This program is distributed in the hope that it will be useful, but
2391 * WITHOUT ANY WARRANTY; without even the implied warranty of
2392 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2393 * General Public License for more details.
2394 *
2395 * You should have received a copy of the GNU General Public License
2396 * along with this program; if not, write to the Free Software
2397 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2398 */
2399
2400#ifndef __GSL_INLINE_H__
2401#define __GSL_INLINE_H__
2402
2403/* In recent versiions of GCC, the inline keyword has two different
2404 forms: GNU and C99.
2405
2406 In GNU mode we can use 'extern inline' to make inline functions
2407 work like macros. The function is only inlined--it is never output
2408 as a definition in an object file.
2409
2410 In the new C99 mode 'extern inline' has a different meaning--it
2411 causes the definition of the function to be output in each object
2412 file where it is used. This will result in multiple-definition
2413 errors on linking. The 'inline' keyword on its own (without
2414 extern) has the same behavior as the original GNU 'extern inline'.
2415
2416 The C99 style is the default with -std=c99 in GCC 4.3.
2417
2418 This header file allows either form of inline to be used by
2419 redefining the macros INLINE_DECL and INLINE_FUN. These are used
2420 in the public header files as
2421
2422 INLINE_DECL double gsl_foo (double x);
2423 #ifdef HAVE_INLINE
2424 INLINE_FUN double gsl_foo (double x) { return x+1.0; } ;
2425 #endif
2426
2427*/
2428
2429#ifdef HAVE_INLINE
2430# if defined(__GNUC_STDC_INLINE__) || defined(GSL_C99_INLINE) || defined(HAVE_C99_INLINE)
2431# define INLINE_DECL inline /* use C99 inline */
2432# define INLINE_FUN inline
2433# else
2434# define INLINE_DECL /* use GNU extern inline */
2435# define INLINE_FUN extern inline
2436# endif
2437#else
2438# define INLINE_DECL /* */
2439#endif
2440
2441/* Range checking conditions in headers do not require any run-time
2442 tests of the global variable gsl_check_range. They are enabled or
2443 disabled in user code at compile time with GSL_RANGE_CHECK macro.
2444 See also build.h. */
2445#define GSL_RANGE_COND(x) (x)
2446
2447#endif /* __GSL_INLINE_H__ */
2448
2449/* end inlined header: gsl/gsl_inline.h */
2450/* begin inlined header: gsl/gsl_machine.h */
2451/* Author: B. Gough and G. Jungman */
2452#ifndef __GSL_MACHINE_H__
2453#define __GSL_MACHINE_H__
2454
2455#include <limits.h>
2456#include <float.h>
2457
2458/* magic constants; mostly for the benefit of the implementation */
2459
2460/* -*-MACHINE CONSTANTS-*-
2461 *
2462 * PLATFORM: Whiz-O-Matic 9000
2463 * FP_PLATFORM: IEEE-Virtual
2464 * HOSTNAME: nnn.lanl.gov
2465 * DATE: Fri Nov 20 17:53:26 MST 1998
2466 */
2467#define GSL_DBL_EPSILON 2.2204460492503131e-16
2468#define GSL_SQRT_DBL_EPSILON 1.4901161193847656e-08
2469#define GSL_ROOT3_DBL_EPSILON 6.0554544523933429e-06
2470#define GSL_ROOT4_DBL_EPSILON 1.2207031250000000e-04
2471#define GSL_ROOT5_DBL_EPSILON 7.4009597974140505e-04
2472#define GSL_ROOT6_DBL_EPSILON 2.4607833005759251e-03
2473#define GSL_LOG_DBL_EPSILON (-3.6043653389117154e+01)
2474
2475#define GSL_DBL_MIN 2.2250738585072014e-308
2476#define GSL_SQRT_DBL_MIN 1.4916681462400413e-154
2477#define GSL_ROOT3_DBL_MIN 2.8126442852362996e-103
2478#define GSL_ROOT4_DBL_MIN 1.2213386697554620e-77
2479#define GSL_ROOT5_DBL_MIN 2.9476022969691763e-62
2480#define GSL_ROOT6_DBL_MIN 5.3034368905798218e-52
2481#define GSL_LOG_DBL_MIN (-7.0839641853226408e+02)
2482
2483#define GSL_DBL_MAX 1.7976931348623157e+308
2484#define GSL_SQRT_DBL_MAX 1.3407807929942596e+154
2485#define GSL_ROOT3_DBL_MAX 5.6438030941222897e+102
2486#define GSL_ROOT4_DBL_MAX 1.1579208923731620e+77
2487#define GSL_ROOT5_DBL_MAX 4.4765466227572707e+61
2488#define GSL_ROOT6_DBL_MAX 2.3756689782295612e+51
2489#define GSL_LOG_DBL_MAX 7.0978271289338397e+02
2490
2491#define GSL_FLT_EPSILON 1.1920928955078125e-07
2492#define GSL_SQRT_FLT_EPSILON 3.4526698300124393e-04
2493#define GSL_ROOT3_FLT_EPSILON 4.9215666011518501e-03
2494#define GSL_ROOT4_FLT_EPSILON 1.8581361171917516e-02
2495#define GSL_ROOT5_FLT_EPSILON 4.1234622211652937e-02
2496#define GSL_ROOT6_FLT_EPSILON 7.0153878019335827e-02
2497#define GSL_LOG_FLT_EPSILON (-1.5942385152878742e+01)
2498
2499#define GSL_FLT_MIN 1.1754943508222875e-38
2500#define GSL_SQRT_FLT_MIN 1.0842021724855044e-19
2501#define GSL_ROOT3_FLT_MIN 2.2737367544323241e-13
2502#define GSL_ROOT4_FLT_MIN 3.2927225399135965e-10
2503#define GSL_ROOT5_FLT_MIN 2.5944428542140822e-08
2504#define GSL_ROOT6_FLT_MIN 4.7683715820312542e-07
2505#define GSL_LOG_FLT_MIN (-8.7336544750553102e+01)
2506
2507#define GSL_FLT_MAX 3.4028234663852886e+38
2508#define GSL_SQRT_FLT_MAX 1.8446743523953730e+19
2509#define GSL_ROOT3_FLT_MAX 6.9814635196223242e+12
2510#define GSL_ROOT4_FLT_MAX 4.2949672319999986e+09
2511#define GSL_ROOT5_FLT_MAX 5.0859007855960041e+07
2512#define GSL_ROOT6_FLT_MAX 2.6422459233807749e+06
2513#define GSL_LOG_FLT_MAX 8.8722839052068352e+01
2514
2515#define GSL_SFLT_EPSILON 4.8828125000000000e-04
2516#define GSL_SQRT_SFLT_EPSILON 2.2097086912079612e-02
2517#define GSL_ROOT3_SFLT_EPSILON 7.8745065618429588e-02
2518#define GSL_ROOT4_SFLT_EPSILON 1.4865088937534013e-01
2519#define GSL_ROOT5_SFLT_EPSILON 2.1763764082403100e-01
2520#define GSL_ROOT6_SFLT_EPSILON 2.8061551207734325e-01
2521#define GSL_LOG_SFLT_EPSILON (-7.6246189861593985e+00)
2522
2523/* !MACHINE CONSTANTS! */
2524
2525
2526/* a little internal backwards compatibility */
2527#define GSL_MACH_EPS GSL_DBL_EPSILON
2528
2529
2530
2531/* Here are the constants related to or derived from
2532 * machine constants. These are not to be confused with
2533 * the constants that define various precision levels
2534 * for the precision/error system.
2535 *
2536 * This information is determined at configure time
2537 * and is platform dependent. Edit at your own risk.
2538 *
2539 * PLATFORM: WHIZ-O-MATIC
2540 * CONFIG-DATE: Thu Nov 19 19:27:18 MST 1998
2541 * CONFIG-HOST: nnn.lanl.gov
2542 */
2543
2544/* machine precision constants */
2545/* #define GSL_MACH_EPS 1.0e-15 */
2546#define GSL_SQRT_MACH_EPS 3.2e-08
2547#define GSL_ROOT3_MACH_EPS 1.0e-05
2548#define GSL_ROOT4_MACH_EPS 0.000178
2549#define GSL_ROOT5_MACH_EPS 0.00100
2550#define GSL_ROOT6_MACH_EPS 0.00316
2551#define GSL_LOG_MACH_EPS (-34.54)
2552
2553
2554#endif /* __GSL_MACHINE_H__ */
2555
2556/* end inlined header: gsl/gsl_machine.h */
2557/* begin inlined header: gsl/gsl_precision.h */
2558/* gsl_precision.h
2559 *
2560 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
2561 *
2562 * This program is free software; you can redistribute it and/or modify
2563 * it under the terms of the GNU General Public License as published by
2564 * the Free Software Foundation; either version 3 of the License, or (at
2565 * your option) any later version.
2566 *
2567 * This program is distributed in the hope that it will be useful, but
2568 * WITHOUT ANY WARRANTY; without even the implied warranty of
2569 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2570 * General Public License for more details.
2571 *
2572 * You should have received a copy of the GNU General Public License
2573 * along with this program; if not, write to the Free Software
2574 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2575 */
2576
2577/* Author: B. Gough and G. Jungman */
2578
2579#ifndef __GSL_PRECISION_H__
2580#define __GSL_PRECISION_H__
2581/* begin inlined header: gsl/gsl_types.h */
2582/* gsl_types.h
2583 *
2584 * Copyright (C) 2001, 2007 Brian Gough
2585 *
2586 * This program is free software; you can redistribute it and/or modify
2587 * it under the terms of the GNU General Public License as published by
2588 * the Free Software Foundation; either version 3 of the License, or (at
2589 * your option) any later version.
2590 *
2591 * This program is distributed in the hope that it will be useful, but
2592 * WITHOUT ANY WARRANTY; without even the implied warranty of
2593 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2594 * General Public License for more details.
2595 *
2596 * You should have received a copy of the GNU General Public License
2597 * along with this program; if not, write to the Free Software
2598 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2599 */
2600
2601#ifndef __GSL_TYPES_H__
2602#define __GSL_TYPES_H__
2603
2604#ifndef GSL_VAR
2605
2606#ifdef WIN32
2607# ifdef GSL_DLL
2608# ifdef DLL_EXPORT
2609# define GSL_VAR extern __declspec(dllexport)
2610# else
2611# define GSL_VAR extern __declspec(dllimport)
2612# endif
2613# else
2614# define GSL_VAR extern
2615# endif
2616#else
2617# define GSL_VAR extern
2618#endif
2619
2620#endif
2621
2622#endif /* __GSL_TYPES_H__ */
2623
2624/* end inlined header: gsl/gsl_types.h */
2625
2626__BEGIN_DECLS
2627
2628
2629/* A type for the precision indicator.
2630 * This is mainly for pedagogy.
2631 */
2632typedef unsigned int gsl_prec_t;
2633
2634
2635/* The number of precision types.
2636 * Remember that precision-mode
2637 * can index an array.
2638 */
2639#define _GSL_PREC_T_NUM 3
2640
2641
2642/* Arrays containing derived
2643 * precision constants for the
2644 * different precision levels.
2645 */
2646GSL_VAR const double gsl_prec_eps[];
2647GSL_VAR const double gsl_prec_sqrt_eps[];
2648GSL_VAR const double gsl_prec_root3_eps[];
2649GSL_VAR const double gsl_prec_root4_eps[];
2650GSL_VAR const double gsl_prec_root5_eps[];
2651GSL_VAR const double gsl_prec_root6_eps[];
2652
2653
2654__END_DECLS
2655
2656#endif /* __GSL_PRECISION_H__ */
2657
2658/* end inlined header: gsl/gsl_precision.h */
2659/* begin inlined header: gsl/gsl_nan.h */
2660/* gsl_nan.h
2661 *
2662 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, Brian Gough
2663 *
2664 * This program is free software; you can redistribute it and/or modify
2665 * it under the terms of the GNU General Public License as published by
2666 * the Free Software Foundation; either version 3 of the License, or (at
2667 * your option) any later version.
2668 *
2669 * This program is distributed in the hope that it will be useful, but
2670 * WITHOUT ANY WARRANTY; without even the implied warranty of
2671 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2672 * General Public License for more details.
2673 *
2674 * You should have received a copy of the GNU General Public License
2675 * along with this program; if not, write to the Free Software
2676 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2677 */
2678
2679#ifndef __GSL_NAN_H__
2680#define __GSL_NAN_H__
2681
2682#ifdef INFINITY
2683# define GSL_POSINF INFINITY
2684# define GSL_NEGINF (-INFINITY)
2685#elif defined(HUGE_VAL)
2686# define GSL_POSINF HUGE_VAL
2687# define GSL_NEGINF (-HUGE_VAL)
2688#else
2689# define GSL_POSINF (gsl_posinf())
2690# define GSL_NEGINF (gsl_neginf())
2691#endif
2692
2693#ifdef NAN
2694# define GSL_NAN NAN
2695#elif defined(INFINITY)
2696# define GSL_NAN (INFINITY/INFINITY)
2697#else
2698# define GSL_NAN (gsl_nan())
2699#endif
2700
2701#define GSL_POSZERO (+0.0)
2702#define GSL_NEGZERO (-0.0)
2703
2704#endif /* __GSL_NAN_H__ */
2705
2706/* end inlined header: gsl/gsl_nan.h */
2707/* begin inlined header: gsl/gsl_pow_int.h */
2708/* gsl_pow_int.h
2709 *
2710 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2004, 2007 Gerard Jungman, Brian Gough
2711 *
2712 * This program is free software; you can redistribute it and/or modify
2713 * it under the terms of the GNU General Public License as published by
2714 * the Free Software Foundation; either version 3 of the License, or (at
2715 * your option) any later version.
2716 *
2717 * This program is distributed in the hope that it will be useful, but
2718 * WITHOUT ANY WARRANTY; without even the implied warranty of
2719 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2720 * General Public License for more details.
2721 *
2722 * You should have received a copy of the GNU General Public License
2723 * along with this program; if not, write to the Free Software
2724 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2725 */
2726
2727#ifndef __GSL_POW_INT_H__
2728#define __GSL_POW_INT_H__
2729/* begin inlined header: gsl/gsl_inline.h */
2730/* gsl_inline.h
2731 *
2732 * Copyright (C) 2008, 2009 Brian Gough
2733 *
2734 * This program is free software; you can redistribute it and/or modify
2735 * it under the terms of the GNU General Public License as published by
2736 * the Free Software Foundation; either version 3 of the License, or (at
2737 * your option) any later version.
2738 *
2739 * This program is distributed in the hope that it will be useful, but
2740 * WITHOUT ANY WARRANTY; without even the implied warranty of
2741 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2742 * General Public License for more details.
2743 *
2744 * You should have received a copy of the GNU General Public License
2745 * along with this program; if not, write to the Free Software
2746 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2747 */
2748
2749#ifndef __GSL_INLINE_H__
2750#define __GSL_INLINE_H__
2751
2752/* In recent versiions of GCC, the inline keyword has two different
2753 forms: GNU and C99.
2754
2755 In GNU mode we can use 'extern inline' to make inline functions
2756 work like macros. The function is only inlined--it is never output
2757 as a definition in an object file.
2758
2759 In the new C99 mode 'extern inline' has a different meaning--it
2760 causes the definition of the function to be output in each object
2761 file where it is used. This will result in multiple-definition
2762 errors on linking. The 'inline' keyword on its own (without
2763 extern) has the same behavior as the original GNU 'extern inline'.
2764
2765 The C99 style is the default with -std=c99 in GCC 4.3.
2766
2767 This header file allows either form of inline to be used by
2768 redefining the macros INLINE_DECL and INLINE_FUN. These are used
2769 in the public header files as
2770
2771 INLINE_DECL double gsl_foo (double x);
2772 #ifdef HAVE_INLINE
2773 INLINE_FUN double gsl_foo (double x) { return x+1.0; } ;
2774 #endif
2775
2776*/
2777
2778#ifdef HAVE_INLINE
2779# if defined(__GNUC_STDC_INLINE__) || defined(GSL_C99_INLINE) || defined(HAVE_C99_INLINE)
2780# define INLINE_DECL inline /* use C99 inline */
2781# define INLINE_FUN inline
2782# else
2783# define INLINE_DECL /* use GNU extern inline */
2784# define INLINE_FUN extern inline
2785# endif
2786#else
2787# define INLINE_DECL /* */
2788#endif
2789
2790/* Range checking conditions in headers do not require any run-time
2791 tests of the global variable gsl_check_range. They are enabled or
2792 disabled in user code at compile time with GSL_RANGE_CHECK macro.
2793 See also build.h. */
2794#define GSL_RANGE_COND(x) (x)
2795
2796#endif /* __GSL_INLINE_H__ */
2797
2798/* end inlined header: gsl/gsl_inline.h */
2799
2800__BEGIN_DECLS
2801
2802INLINE_DECL double gsl_pow_2(const double x);
2803INLINE_DECL double gsl_pow_3(const double x);
2804INLINE_DECL double gsl_pow_4(const double x);
2805INLINE_DECL double gsl_pow_5(const double x);
2806INLINE_DECL double gsl_pow_6(const double x);
2807INLINE_DECL double gsl_pow_7(const double x);
2808INLINE_DECL double gsl_pow_8(const double x);
2809INLINE_DECL double gsl_pow_9(const double x);
2810
2811#ifdef HAVE_INLINE
2812INLINE_FUN double gsl_pow_2(const double x) { return x*x; }
2813INLINE_FUN double gsl_pow_3(const double x) { return x*x*x; }
2814INLINE_FUN double gsl_pow_4(const double x) { double x2 = x*x; return x2*x2; }
2815INLINE_FUN double gsl_pow_5(const double x) { double x2 = x*x; return x2*x2*x; }
2816INLINE_FUN double gsl_pow_6(const double x) { double x2 = x*x; return x2*x2*x2; }
2817INLINE_FUN double gsl_pow_7(const double x) { double x3 = x*x*x; return x3*x3*x; }
2818INLINE_FUN double gsl_pow_8(const double x) { double x2 = x*x; double x4 = x2*x2; return x4*x4; }
2819INLINE_FUN double gsl_pow_9(const double x) { double x3 = x*x*x; return x3*x3*x3; }
2820#endif
2821
2822double gsl_pow_int(double x, int n);
2823double gsl_pow_uint(double x, unsigned int n);
2824
2825__END_DECLS
2826
2827#endif /* __GSL_POW_INT_H__ */
2828
2829/* end inlined header: gsl/gsl_pow_int.h */
2830/* begin inlined header: gsl/gsl_minmax.h */
2831/* gsl_minmax.h
2832 *
2833 * Copyright (C) 2008 Gerard Jungman, Brian Gough
2834 *
2835 * This program is free software; you can redistribute it and/or modify
2836 * it under the terms of the GNU General Public License as published by
2837 * the Free Software Foundation; either version 3 of the License, or (at
2838 * your option) any later version.
2839 *
2840 * This program is distributed in the hope that it will be useful, but
2841 * WITHOUT ANY WARRANTY; without even the implied warranty of
2842 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2843 * General Public License for more details.
2844 *
2845 * You should have received a copy of the GNU General Public License
2846 * along with this program; if not, write to the Free Software
2847 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2848 */
2849
2850#ifndef __GSL_MINMAX_H__
2851#define __GSL_MINMAX_H__
2852/* begin inlined header: gsl/gsl_inline.h */
2853/* gsl_inline.h
2854 *
2855 * Copyright (C) 2008, 2009 Brian Gough
2856 *
2857 * This program is free software; you can redistribute it and/or modify
2858 * it under the terms of the GNU General Public License as published by
2859 * the Free Software Foundation; either version 3 of the License, or (at
2860 * your option) any later version.
2861 *
2862 * This program is distributed in the hope that it will be useful, but
2863 * WITHOUT ANY WARRANTY; without even the implied warranty of
2864 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2865 * General Public License for more details.
2866 *
2867 * You should have received a copy of the GNU General Public License
2868 * along with this program; if not, write to the Free Software
2869 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2870 */
2871
2872#ifndef __GSL_INLINE_H__
2873#define __GSL_INLINE_H__
2874
2875/* In recent versiions of GCC, the inline keyword has two different
2876 forms: GNU and C99.
2877
2878 In GNU mode we can use 'extern inline' to make inline functions
2879 work like macros. The function is only inlined--it is never output
2880 as a definition in an object file.
2881
2882 In the new C99 mode 'extern inline' has a different meaning--it
2883 causes the definition of the function to be output in each object
2884 file where it is used. This will result in multiple-definition
2885 errors on linking. The 'inline' keyword on its own (without
2886 extern) has the same behavior as the original GNU 'extern inline'.
2887
2888 The C99 style is the default with -std=c99 in GCC 4.3.
2889
2890 This header file allows either form of inline to be used by
2891 redefining the macros INLINE_DECL and INLINE_FUN. These are used
2892 in the public header files as
2893
2894 INLINE_DECL double gsl_foo (double x);
2895 #ifdef HAVE_INLINE
2896 INLINE_FUN double gsl_foo (double x) { return x+1.0; } ;
2897 #endif
2898
2899*/
2900
2901#ifdef HAVE_INLINE
2902# if defined(__GNUC_STDC_INLINE__) || defined(GSL_C99_INLINE) || defined(HAVE_C99_INLINE)
2903# define INLINE_DECL inline /* use C99 inline */
2904# define INLINE_FUN inline
2905# else
2906# define INLINE_DECL /* use GNU extern inline */
2907# define INLINE_FUN extern inline
2908# endif
2909#else
2910# define INLINE_DECL /* */
2911#endif
2912
2913/* Range checking conditions in headers do not require any run-time
2914 tests of the global variable gsl_check_range. They are enabled or
2915 disabled in user code at compile time with GSL_RANGE_CHECK macro.
2916 See also build.h. */
2917#define GSL_RANGE_COND(x) (x)
2918
2919#endif /* __GSL_INLINE_H__ */
2920
2921/* end inlined header: gsl/gsl_inline.h */
2922
2923__BEGIN_DECLS
2924
2925/* Define MAX and MIN macros/functions if they don't exist. */
2926
2927/* plain old macros for general use */
2928#define GSL_MAX(a,b) ((a) > (b) ? (a) : (b))
2929#define GSL_MIN(a,b) ((a) < (b) ? (a) : (b))
2930
2931/* function versions of the above, in case they are needed */
2932double gsl_max (double a, double b);
2933double gsl_min (double a, double b);
2934
2935/* inline-friendly strongly typed versions */
2936#ifdef HAVE_INLINE
2937
2938INLINE_FUN int GSL_MAX_INT (int a, int b);
2939INLINE_FUN int GSL_MIN_INT (int a, int b);
2940INLINE_FUN double GSL_MAX_DBL (double a, double b);
2941INLINE_FUN double GSL_MIN_DBL (double a, double b);
2942INLINE_FUN long double GSL_MAX_LDBL (long double a, long double b);
2943INLINE_FUN long double GSL_MIN_LDBL (long double a, long double b);
2944
2945INLINE_FUN int
2946GSL_MAX_INT (int a, int b)
2947{
2948 return GSL_MAX (a, b);
2949}
2950
2951INLINE_FUN int
2952GSL_MIN_INT (int a, int b)
2953{
2954 return GSL_MIN (a, b);
2955}
2956
2957INLINE_FUN double
2958GSL_MAX_DBL (double a, double b)
2959{
2960 return GSL_MAX (a, b);
2961}
2962
2963INLINE_FUN double
2964GSL_MIN_DBL (double a, double b)
2965{
2966 return GSL_MIN (a, b);
2967}
2968
2969INLINE_FUN long double
2970GSL_MAX_LDBL (long double a, long double b)
2971{
2972 return GSL_MAX (a, b);
2973}
2974
2975INLINE_FUN long double
2976GSL_MIN_LDBL (long double a, long double b)
2977{
2978 return GSL_MIN (a, b);
2979}
2980#else
2981#define GSL_MAX_INT(a,b) GSL_MAX(a,b)
2982#define GSL_MIN_INT(a,b) GSL_MIN(a,b)
2983#define GSL_MAX_DBL(a,b) GSL_MAX(a,b)
2984#define GSL_MIN_DBL(a,b) GSL_MIN(a,b)
2985#define GSL_MAX_LDBL(a,b) GSL_MAX(a,b)
2986#define GSL_MIN_LDBL(a,b) GSL_MIN(a,b)
2987#endif /* HAVE_INLINE */
2988
2989__END_DECLS
2990
2991#endif /* __GSL_POW_INT_H__ */
2992
2993/* end inlined header: gsl/gsl_minmax.h */
2994#ifndef M_E
2995#define M_E 2.71828182845904523536028747135 /* e */
2996#endif
2997
2998#ifndef M_LOG2E
2999#define M_LOG2E 1.44269504088896340735992468100 /* log_2 (e) */
3000#endif
3001
3002#ifndef M_LOG10E
3003#define M_LOG10E 0.43429448190325182765112891892 /* log_10 (e) */
3004#endif
3005
3006#ifndef M_SQRT2
3007#define M_SQRT2 1.41421356237309504880168872421 /* sqrt(2) */
3008#endif
3009
3010#ifndef M_SQRT1_2
3011#define M_SQRT1_2 0.70710678118654752440084436210 /* sqrt(1/2) */
3012#endif
3013
3014
3015#ifndef M_SQRT3
3016#define M_SQRT3 1.73205080756887729352744634151 /* sqrt(3) */
3017#endif
3018
3019#ifndef M_PI
3020#define M_PI 3.14159265358979323846264338328 /* pi */
3021#endif
3022
3023#ifndef M_PI_2
3024#define M_PI_2 1.57079632679489661923132169164 /* pi/2 */
3025#endif
3026
3027#ifndef M_PI_4
3028#define M_PI_4 0.78539816339744830961566084582 /* pi/4 */
3029#endif
3030
3031#ifndef M_SQRTPI
3032#define M_SQRTPI 1.77245385090551602729816748334 /* sqrt(pi) */
3033#endif
3034
3035#ifndef M_2_SQRTPI
3036#define M_2_SQRTPI 1.12837916709551257389615890312 /* 2/sqrt(pi) */
3037#endif
3038
3039#ifndef M_1_PI
3040#define M_1_PI 0.31830988618379067153776752675 /* 1/pi */
3041#endif
3042
3043#ifndef M_2_PI
3044#define M_2_PI 0.63661977236758134307553505349 /* 2/pi */
3045#endif
3046
3047#ifndef M_LN10
3048#define M_LN10 2.30258509299404568401799145468 /* ln(10) */
3049#endif
3050
3051#ifndef M_LN2
3052#define M_LN2 0.69314718055994530941723212146 /* ln(2) */
3053#endif
3054
3055#ifndef M_LNPI
3056#define M_LNPI 1.14472988584940017414342735135 /* ln(pi) */
3057#endif
3058
3059#ifndef M_EULER
3060#define M_EULER 0.57721566490153286060651209008 /* Euler constant */
3061#endif
3062
3063__BEGIN_DECLS
3064
3065/* other needlessly compulsive abstractions */
3066
3067#define GSL_IS_ODD(n) ((n) & 1)
3068#define GSL_IS_EVEN(n) (!(GSL_IS_ODD(n)))
3069#define GSL_SIGN(x) ((x) >= 0.0 ? 1 : -1)
3070
3071/* Return nonzero if x is a real number, i.e. non NaN or infinite. */
3072#define GSL_IS_REAL(x) (gsl_finite(x))
3073
3074/* Definition of an arbitrary function with parameters */
3075
3077{
3078 double (* function) (double x, void * params);
3079 void * params;
3080};
3081
3082typedef struct gsl_function_struct gsl_function ;
3083
3084#define GSL_FN_EVAL(F,x) (*((F)->function))(x,(F)->params)
3085
3086/* Definition of an arbitrary function returning two values, r1, r2 */
3087
3089{
3090 double (* f) (double x, void * params);
3091 double (* df) (double x, void * params);
3092 void (* fdf) (double x, void * params, double * f, double * df);
3093 void * params;
3094};
3095
3096typedef struct gsl_function_fdf_struct gsl_function_fdf ;
3097
3098#define GSL_FN_FDF_EVAL_F(FDF,x) (*((FDF)->f))(x,(FDF)->params)
3099#define GSL_FN_FDF_EVAL_DF(FDF,x) (*((FDF)->df))(x,(FDF)->params)
3100#define GSL_FN_FDF_EVAL_F_DF(FDF,x,y,dy) (*((FDF)->fdf))(x,(FDF)->params,(y),(dy))
3101
3102
3103/* Definition of an arbitrary vector-valued function with parameters */
3104
3106{
3107 int (* function) (double x, double y[], void * params);
3108 void * params;
3109};
3110
3111typedef struct gsl_function_vec_struct gsl_function_vec ;
3112
3113#define GSL_FN_VEC_EVAL(F,x,y) (*((F)->function))(x,y,(F)->params)
3114
3115__END_DECLS
3116
3117#endif /* __GSL_MATH_H__ */
3118
3119/* end inlined header: gsl/gsl_math.h */
3120/* begin inlined header: gsl/gsl_complex.h */
3121/* complex/gsl_complex.h
3122 *
3123 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, Brian Gough
3124 * Copyright (C) 2020, 2021 Patrick Alken
3125 *
3126 * This program is free software; you can redistribute it and/or modify
3127 * it under the terms of the GNU General Public License as published by
3128 * the Free Software Foundation; either version 3 of the License, or (at
3129 * your option) any later version.
3130 *
3131 * This program is distributed in the hope that it will be useful, but
3132 * WITHOUT ANY WARRANTY; without even the implied warranty of
3133 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3134 * General Public License for more details.
3135 *
3136 * You should have received a copy of the GNU General Public License
3137 * along with this program; if not, write to the Free Software
3138 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
3139 */
3140
3141#ifndef __GSL_COMPLEX_H__
3142#define __GSL_COMPLEX_H__
3143
3144__BEGIN_DECLS
3145
3146
3147/* two consecutive built-in types as a complex number */
3148typedef double * gsl_complex_packed ;
3149typedef float * gsl_complex_packed_float ;
3150typedef long double * gsl_complex_packed_long_double ;
3151
3152typedef const double * gsl_const_complex_packed ;
3153typedef const float * gsl_const_complex_packed_float ;
3154typedef const long double * gsl_const_complex_packed_long_double ;
3155
3156
3157/* 2N consecutive built-in types as N complex numbers */
3158typedef double * gsl_complex_packed_array ;
3159typedef float * gsl_complex_packed_array_float ;
3160typedef long double * gsl_complex_packed_array_long_double ;
3161
3162typedef const double * gsl_const_complex_packed_array ;
3163typedef const float * gsl_const_complex_packed_array_float ;
3164typedef const long double * gsl_const_complex_packed_array_long_double ;
3165
3166
3167/* Yes... this seems weird. Trust us. The point is just that
3168 sometimes you want to make it obvious that something is
3169 an output value. The fact that it lacks a 'const' may not
3170 be enough of a clue for people in some contexts.
3171 */
3172typedef double * gsl_complex_packed_ptr ;
3173typedef float * gsl_complex_packed_float_ptr ;
3174typedef long double * gsl_complex_packed_long_double_ptr ;
3175
3176typedef const double * gsl_const_complex_packed_ptr ;
3177typedef const float * gsl_const_complex_packed_float_ptr ;
3178typedef const long double * gsl_const_complex_packed_long_double_ptr ;
3179
3180/*
3181 * If <complex.h> is included, use the C99 complex type. Otherwise
3182 * define a type bit-compatible with C99 complex. The GSL_REAL and GSL_IMAG
3183 * macros require C11 functionality also (_Generic)
3184 */
3185
3186/* older gcc compilers claim to be C11 compliant but do not support _Generic */
3187#if defined(__GNUC__) && (__GNUC__ < 7)
3188# define GSL_COMPLEX_LEGACY 1
3189#endif
3190
3191#if !defined(GSL_COMPLEX_LEGACY) && \
3192 defined(_Complex_I) && \
3193 defined(complex) && \
3194 defined(I) && \
3195 defined(__STDC__) && (__STDC__ == 1) && \
3196 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) /* C11 */
3197
3198# define GSL_COMPLEX_DEFINE(R, C) typedef R _Complex C ;
3199
3200# define GSL_COMPLEX_P(zp) (&(zp))
3201# define GSL_COMPLEX_EQ(z1,z2) ((z1) == (z2))
3202# define GSL_SET_COMPLEX(zp,x,y) (*(zp) = (x) + I * (y))
3203
3204# define GSL_REAL(z) (_Generic((z), \
3205 complex float : ((float *) &(z)), \
3206 complex double : ((double *) &(z)), \
3207 complex long double : ((long double *) &(z)))[0])
3208
3209# define GSL_IMAG(z) (_Generic((z), \
3210 complex float : ((float *) &(z)), \
3211 complex double : ((double *) &(z)), \
3212 complex long double : ((long double *) &(z)))[1])
3213
3214# define GSL_COMPLEX_P_REAL(zp) GSL_REAL(*(zp))
3215# define GSL_COMPLEX_P_IMAG(zp) GSL_IMAG(*(zp))
3216# define GSL_SET_REAL(zp,x) do { GSL_REAL(*(zp)) = (x); } while(0)
3217# define GSL_SET_IMAG(zp,x) do { GSL_IMAG(*(zp)) = (x); } while(0)
3218
3219#else /* legacy complex definitions */
3220
3221/*
3222 * According to the C17 standard, 6.2.5 paragraph 13:
3223 *
3224 * "Each complex type has the same representation and alignment requirements
3225 * as an array type containing exactly two elements of the corresponding real
3226 * type; the first element is equal to the real part, and the second element to
3227 * the imaginary part, of the complex number."
3228 */
3229
3230/*# define GSL_COMPLEX_DEFINE(R, C) typedef R C[2]*/
3231# define GSL_COMPLEX_DEFINE(R, C) typedef struct { R dat[2]; } C ;
3232
3233# define GSL_REAL(z) ((z).dat[0])
3234# define GSL_IMAG(z) ((z).dat[1])
3235# define GSL_COMPLEX_P(zp) ((zp)->dat)
3236# define GSL_COMPLEX_P_REAL(zp) ((zp)->dat[0])
3237# define GSL_COMPLEX_P_IMAG(zp) ((zp)->dat[1])
3238# define GSL_COMPLEX_EQ(z1,z2) (((z1).dat[0] == (z2).dat[0]) && ((z1).dat[1] == (z2).dat[1]))
3239
3240# define GSL_SET_COMPLEX(zp,x,y) do {(zp)->dat[0]=(x); (zp)->dat[1]=(y);} while(0)
3241# define GSL_SET_REAL(zp,x) do {(zp)->dat[0]=(x);} while(0)
3242# define GSL_SET_IMAG(zp,y) do {(zp)->dat[1]=(y);} while(0)
3243
3244#endif
3245
3246GSL_COMPLEX_DEFINE(double, gsl_complex)
3247GSL_COMPLEX_DEFINE(long double, gsl_complex_long_double)
3248GSL_COMPLEX_DEFINE(float, gsl_complex_float)
3249
3250#define GSL_SET_COMPLEX_PACKED(zp,n,x,y) do {*((zp)+2*(n))=(x); *((zp)+(2*(n)+1))=(y);} while(0)
3251
3252__END_DECLS
3253
3254#endif /* __GSL_COMPLEX_H__ */
3255
3256/* end inlined header: gsl/gsl_complex.h */
3257/* begin inlined header: gsl/gsl_complex_math.h */
3258/* complex/gsl_complex_math.h
3259 *
3260 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2004, 2007 Jorma Olavi T�htinen, Brian Gough
3261 *
3262 * This program is free software; you can redistribute it and/or modify
3263 * it under the terms of the GNU General Public License as published by
3264 * the Free Software Foundation; either version 3 of the License, or (at
3265 * your option) any later version.
3266 *
3267 * This program is distributed in the hope that it will be useful, but
3268 * WITHOUT ANY WARRANTY; without even the implied warranty of
3269 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3270 * General Public License for more details.
3271 *
3272 * You should have received a copy of the GNU General Public License
3273 * along with this program; if not, write to the Free Software
3274 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
3275 */
3276
3277#ifndef __GSL_COMPLEX_MATH_H__
3278#define __GSL_COMPLEX_MATH_H__
3279/* begin inlined header: gsl/gsl_inline.h */
3280/* gsl_inline.h
3281 *
3282 * Copyright (C) 2008, 2009 Brian Gough
3283 *
3284 * This program is free software; you can redistribute it and/or modify
3285 * it under the terms of the GNU General Public License as published by
3286 * the Free Software Foundation; either version 3 of the License, or (at
3287 * your option) any later version.
3288 *
3289 * This program is distributed in the hope that it will be useful, but
3290 * WITHOUT ANY WARRANTY; without even the implied warranty of
3291 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3292 * General Public License for more details.
3293 *
3294 * You should have received a copy of the GNU General Public License
3295 * along with this program; if not, write to the Free Software
3296 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
3297 */
3298
3299#ifndef __GSL_INLINE_H__
3300#define __GSL_INLINE_H__
3301
3302/* In recent versiions of GCC, the inline keyword has two different
3303 forms: GNU and C99.
3304
3305 In GNU mode we can use 'extern inline' to make inline functions
3306 work like macros. The function is only inlined--it is never output
3307 as a definition in an object file.
3308
3309 In the new C99 mode 'extern inline' has a different meaning--it
3310 causes the definition of the function to be output in each object
3311 file where it is used. This will result in multiple-definition
3312 errors on linking. The 'inline' keyword on its own (without
3313 extern) has the same behavior as the original GNU 'extern inline'.
3314
3315 The C99 style is the default with -std=c99 in GCC 4.3.
3316
3317 This header file allows either form of inline to be used by
3318 redefining the macros INLINE_DECL and INLINE_FUN. These are used
3319 in the public header files as
3320
3321 INLINE_DECL double gsl_foo (double x);
3322 #ifdef HAVE_INLINE
3323 INLINE_FUN double gsl_foo (double x) { return x+1.0; } ;
3324 #endif
3325
3326*/
3327
3328#ifdef HAVE_INLINE
3329# if defined(__GNUC_STDC_INLINE__) || defined(GSL_C99_INLINE) || defined(HAVE_C99_INLINE)
3330# define INLINE_DECL inline /* use C99 inline */
3331# define INLINE_FUN inline
3332# else
3333# define INLINE_DECL /* use GNU extern inline */
3334# define INLINE_FUN extern inline
3335# endif
3336#else
3337# define INLINE_DECL /* */
3338#endif
3339
3340/* Range checking conditions in headers do not require any run-time
3341 tests of the global variable gsl_check_range. They are enabled or
3342 disabled in user code at compile time with GSL_RANGE_CHECK macro.
3343 See also build.h. */
3344#define GSL_RANGE_COND(x) (x)
3345
3346#endif /* __GSL_INLINE_H__ */
3347
3348/* end inlined header: gsl/gsl_inline.h */
3349/* begin inlined header: gsl/gsl_complex.h */
3350/* complex/gsl_complex.h
3351 *
3352 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, Brian Gough
3353 * Copyright (C) 2020, 2021 Patrick Alken
3354 *
3355 * This program is free software; you can redistribute it and/or modify
3356 * it under the terms of the GNU General Public License as published by
3357 * the Free Software Foundation; either version 3 of the License, or (at
3358 * your option) any later version.
3359 *
3360 * This program is distributed in the hope that it will be useful, but
3361 * WITHOUT ANY WARRANTY; without even the implied warranty of
3362 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3363 * General Public License for more details.
3364 *
3365 * You should have received a copy of the GNU General Public License
3366 * along with this program; if not, write to the Free Software
3367 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
3368 */
3369
3370#ifndef __GSL_COMPLEX_H__
3371#define __GSL_COMPLEX_H__
3372
3373__BEGIN_DECLS
3374
3375
3376/* two consecutive built-in types as a complex number */
3377typedef double * gsl_complex_packed ;
3378typedef float * gsl_complex_packed_float ;
3379typedef long double * gsl_complex_packed_long_double ;
3380
3381typedef const double * gsl_const_complex_packed ;
3382typedef const float * gsl_const_complex_packed_float ;
3383typedef const long double * gsl_const_complex_packed_long_double ;
3384
3385
3386/* 2N consecutive built-in types as N complex numbers */
3387typedef double * gsl_complex_packed_array ;
3388typedef float * gsl_complex_packed_array_float ;
3389typedef long double * gsl_complex_packed_array_long_double ;
3390
3391typedef const double * gsl_const_complex_packed_array ;
3392typedef const float * gsl_const_complex_packed_array_float ;
3393typedef const long double * gsl_const_complex_packed_array_long_double ;
3394
3395
3396/* Yes... this seems weird. Trust us. The point is just that
3397 sometimes you want to make it obvious that something is
3398 an output value. The fact that it lacks a 'const' may not
3399 be enough of a clue for people in some contexts.
3400 */
3401typedef double * gsl_complex_packed_ptr ;
3402typedef float * gsl_complex_packed_float_ptr ;
3403typedef long double * gsl_complex_packed_long_double_ptr ;
3404
3405typedef const double * gsl_const_complex_packed_ptr ;
3406typedef const float * gsl_const_complex_packed_float_ptr ;
3407typedef const long double * gsl_const_complex_packed_long_double_ptr ;
3408
3409/*
3410 * If <complex.h> is included, use the C99 complex type. Otherwise
3411 * define a type bit-compatible with C99 complex. The GSL_REAL and GSL_IMAG
3412 * macros require C11 functionality also (_Generic)
3413 */
3414
3415/* older gcc compilers claim to be C11 compliant but do not support _Generic */
3416#if defined(__GNUC__) && (__GNUC__ < 7)
3417# define GSL_COMPLEX_LEGACY 1
3418#endif
3419
3420#if !defined(GSL_COMPLEX_LEGACY) && \
3421 defined(_Complex_I) && \
3422 defined(complex) && \
3423 defined(I) && \
3424 defined(__STDC__) && (__STDC__ == 1) && \
3425 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) /* C11 */
3426
3427# define GSL_COMPLEX_DEFINE(R, C) typedef R _Complex C ;
3428
3429# define GSL_COMPLEX_P(zp) (&(zp))
3430# define GSL_COMPLEX_EQ(z1,z2) ((z1) == (z2))
3431# define GSL_SET_COMPLEX(zp,x,y) (*(zp) = (x) + I * (y))
3432
3433# define GSL_REAL(z) (_Generic((z), \
3434 complex float : ((float *) &(z)), \
3435 complex double : ((double *) &(z)), \
3436 complex long double : ((long double *) &(z)))[0])
3437
3438# define GSL_IMAG(z) (_Generic((z), \
3439 complex float : ((float *) &(z)), \
3440 complex double : ((double *) &(z)), \
3441 complex long double : ((long double *) &(z)))[1])
3442
3443# define GSL_COMPLEX_P_REAL(zp) GSL_REAL(*(zp))
3444# define GSL_COMPLEX_P_IMAG(zp) GSL_IMAG(*(zp))
3445# define GSL_SET_REAL(zp,x) do { GSL_REAL(*(zp)) = (x); } while(0)
3446# define GSL_SET_IMAG(zp,x) do { GSL_IMAG(*(zp)) = (x); } while(0)
3447
3448#else /* legacy complex definitions */
3449
3450/*
3451 * According to the C17 standard, 6.2.5 paragraph 13:
3452 *
3453 * "Each complex type has the same representation and alignment requirements
3454 * as an array type containing exactly two elements of the corresponding real
3455 * type; the first element is equal to the real part, and the second element to
3456 * the imaginary part, of the complex number."
3457 */
3458
3459/*# define GSL_COMPLEX_DEFINE(R, C) typedef R C[2]*/
3460# define GSL_COMPLEX_DEFINE(R, C) typedef struct { R dat[2]; } C ;
3461
3462# define GSL_REAL(z) ((z).dat[0])
3463# define GSL_IMAG(z) ((z).dat[1])
3464# define GSL_COMPLEX_P(zp) ((zp)->dat)
3465# define GSL_COMPLEX_P_REAL(zp) ((zp)->dat[0])
3466# define GSL_COMPLEX_P_IMAG(zp) ((zp)->dat[1])
3467# define GSL_COMPLEX_EQ(z1,z2) (((z1).dat[0] == (z2).dat[0]) && ((z1).dat[1] == (z2).dat[1]))
3468
3469# define GSL_SET_COMPLEX(zp,x,y) do {(zp)->dat[0]=(x); (zp)->dat[1]=(y);} while(0)
3470# define GSL_SET_REAL(zp,x) do {(zp)->dat[0]=(x);} while(0)
3471# define GSL_SET_IMAG(zp,y) do {(zp)->dat[1]=(y);} while(0)
3472
3473#endif
3474
3475GSL_COMPLEX_DEFINE(double, gsl_complex)
3476GSL_COMPLEX_DEFINE(long double, gsl_complex_long_double)
3477GSL_COMPLEX_DEFINE(float, gsl_complex_float)
3478
3479#define GSL_SET_COMPLEX_PACKED(zp,n,x,y) do {*((zp)+2*(n))=(x); *((zp)+(2*(n)+1))=(y);} while(0)
3480
3481__END_DECLS
3482
3483#endif /* __GSL_COMPLEX_H__ */
3484
3485/* end inlined header: gsl/gsl_complex.h */
3486
3487__BEGIN_DECLS
3488
3489/* Complex numbers */
3490
3491gsl_complex gsl_complex_polar (double r, double theta); /* r= r e^(i theta) */
3492
3493INLINE_DECL gsl_complex gsl_complex_rect (double x, double y); /* r= real+i*imag */
3494
3495#ifdef HAVE_INLINE
3496INLINE_FUN gsl_complex
3497gsl_complex_rect (double x, double y)
3498{ /* return z = x + i y */
3499 gsl_complex z;
3500 GSL_SET_COMPLEX (&z, x, y);
3501 return z;
3502}
3503#endif
3504
3505#define GSL_COMPLEX_ONE (gsl_complex_rect(1.0,0.0))
3506#define GSL_COMPLEX_ZERO (gsl_complex_rect(0.0,0.0))
3507#define GSL_COMPLEX_NEGONE (gsl_complex_rect(-1.0,0.0))
3508
3509/* Properties of complex numbers */
3510
3511double gsl_complex_arg (gsl_complex z); /* return arg(z), -pi< arg(z) <=+pi */
3512double gsl_complex_abs (gsl_complex z); /* return |z| */
3513double gsl_complex_abs2 (gsl_complex z); /* return |z|^2 */
3514double gsl_complex_logabs (gsl_complex z); /* return log|z| */
3515
3516/* Complex arithmetic operators */
3517
3518gsl_complex gsl_complex_add (gsl_complex a, gsl_complex b); /* r=a+b */
3519gsl_complex gsl_complex_sub (gsl_complex a, gsl_complex b); /* r=a-b */
3520gsl_complex gsl_complex_mul (gsl_complex a, gsl_complex b); /* r=a*b */
3521gsl_complex gsl_complex_div (gsl_complex a, gsl_complex b); /* r=a/b */
3522
3523gsl_complex gsl_complex_add_real (gsl_complex a, double x); /* r=a+x */
3524gsl_complex gsl_complex_sub_real (gsl_complex a, double x); /* r=a-x */
3525gsl_complex gsl_complex_mul_real (gsl_complex a, double x); /* r=a*x */
3526gsl_complex gsl_complex_div_real (gsl_complex a, double x); /* r=a/x */
3527
3528gsl_complex gsl_complex_add_imag (gsl_complex a, double y); /* r=a+iy */
3529gsl_complex gsl_complex_sub_imag (gsl_complex a, double y); /* r=a-iy */
3530gsl_complex gsl_complex_mul_imag (gsl_complex a, double y); /* r=a*iy */
3531gsl_complex gsl_complex_div_imag (gsl_complex a, double y); /* r=a/iy */
3532
3533gsl_complex gsl_complex_conjugate (gsl_complex z); /* r=conj(z) */
3534gsl_complex gsl_complex_inverse (gsl_complex a); /* r=1/a */
3535gsl_complex gsl_complex_negative (gsl_complex a); /* r=-a */
3536
3537/* Elementary Complex Functions */
3538
3539gsl_complex gsl_complex_sqrt (gsl_complex z); /* r=sqrt(z) */
3540gsl_complex gsl_complex_sqrt_real (double x); /* r=sqrt(x) (x<0 ok) */
3541
3542gsl_complex gsl_complex_pow (gsl_complex a, gsl_complex b); /* r=a^b */
3543gsl_complex gsl_complex_pow_real (gsl_complex a, double b); /* r=a^b */
3544
3545gsl_complex gsl_complex_exp (gsl_complex a); /* r=exp(a) */
3546gsl_complex gsl_complex_log (gsl_complex a); /* r=log(a) (base e) */
3547gsl_complex gsl_complex_log10 (gsl_complex a); /* r=log10(a) (base 10) */
3548gsl_complex gsl_complex_log_b (gsl_complex a, gsl_complex b); /* r=log_b(a) (base=b) */
3549
3550/* Complex Trigonometric Functions */
3551
3552gsl_complex gsl_complex_sin (gsl_complex a); /* r=sin(a) */
3553gsl_complex gsl_complex_cos (gsl_complex a); /* r=cos(a) */
3554gsl_complex gsl_complex_sec (gsl_complex a); /* r=sec(a) */
3555gsl_complex gsl_complex_csc (gsl_complex a); /* r=csc(a) */
3556gsl_complex gsl_complex_tan (gsl_complex a); /* r=tan(a) */
3557gsl_complex gsl_complex_cot (gsl_complex a); /* r=cot(a) */
3558
3559/* Inverse Complex Trigonometric Functions */
3560
3561gsl_complex gsl_complex_arcsin (gsl_complex a); /* r=arcsin(a) */
3562gsl_complex gsl_complex_arcsin_real (double a); /* r=arcsin(a) */
3563gsl_complex gsl_complex_arccos (gsl_complex a); /* r=arccos(a) */
3564gsl_complex gsl_complex_arccos_real (double a); /* r=arccos(a) */
3565gsl_complex gsl_complex_arcsec (gsl_complex a); /* r=arcsec(a) */
3566gsl_complex gsl_complex_arcsec_real (double a); /* r=arcsec(a) */
3567gsl_complex gsl_complex_arccsc (gsl_complex a); /* r=arccsc(a) */
3568gsl_complex gsl_complex_arccsc_real (double a); /* r=arccsc(a) */
3569gsl_complex gsl_complex_arctan (gsl_complex a); /* r=arctan(a) */
3570gsl_complex gsl_complex_arccot (gsl_complex a); /* r=arccot(a) */
3571
3572/* Complex Hyperbolic Functions */
3573
3574gsl_complex gsl_complex_sinh (gsl_complex a); /* r=sinh(a) */
3575gsl_complex gsl_complex_cosh (gsl_complex a); /* r=coshh(a) */
3576gsl_complex gsl_complex_sech (gsl_complex a); /* r=sech(a) */
3577gsl_complex gsl_complex_csch (gsl_complex a); /* r=csch(a) */
3578gsl_complex gsl_complex_tanh (gsl_complex a); /* r=tanh(a) */
3579gsl_complex gsl_complex_coth (gsl_complex a); /* r=coth(a) */
3580
3581/* Inverse Complex Hyperbolic Functions */
3582
3583gsl_complex gsl_complex_arcsinh (gsl_complex a); /* r=arcsinh(a) */
3584gsl_complex gsl_complex_arccosh (gsl_complex a); /* r=arccosh(a) */
3585gsl_complex gsl_complex_arccosh_real (double a); /* r=arccosh(a) */
3586gsl_complex gsl_complex_arcsech (gsl_complex a); /* r=arcsech(a) */
3587gsl_complex gsl_complex_arccsch (gsl_complex a); /* r=arccsch(a) */
3588gsl_complex gsl_complex_arctanh (gsl_complex a); /* r=arctanh(a) */
3589gsl_complex gsl_complex_arctanh_real (double a); /* r=arctanh(a) */
3590gsl_complex gsl_complex_arccoth (gsl_complex a); /* r=arccoth(a) */
3591
3592__END_DECLS
3593
3594#endif /* __GSL_COMPLEX_MATH_H__ */
3595
3596/* end inlined header: gsl/gsl_complex_math.h */
3597/**********************************************************************
3598 * Complex numbers
3599 **********************************************************************/
3600
3601gsl_complex
3602gsl_complex_polar (double r, double theta)
3603{ /* return z = r exp(i theta) */
3604 gsl_complex z;
3605 GSL_SET_COMPLEX (&z, r * cos (theta), r * sin (theta));
3606 return z;
3607}
3608
3609/**********************************************************************
3610 * Properties of complex numbers
3611 **********************************************************************/
3612
3613double
3614gsl_complex_arg (gsl_complex z)
3615{ /* return arg(z), -pi < arg(z) <= +pi */
3616 double x = GSL_REAL (z);
3617 double y = GSL_IMAG (z);
3618
3619 if (x == 0.0 && y == 0.0)
3620 {
3621 return 0;
3622 }
3623
3624 return atan2 (y, x);
3625}
3626
3627double
3628gsl_complex_abs (gsl_complex z)
3629{ /* return |z| */
3630 return hypot (GSL_REAL (z), GSL_IMAG (z));
3631}
3632
3633double
3634gsl_complex_abs2 (gsl_complex z)
3635{ /* return |z|^2 */
3636 double x = GSL_REAL (z);
3637 double y = GSL_IMAG (z);
3638
3639 return (x * x + y * y);
3640}
3641
3642double
3643gsl_complex_logabs (gsl_complex z)
3644{ /* return log|z| */
3645 double xabs = fabs (GSL_REAL (z));
3646 double yabs = fabs (GSL_IMAG (z));
3647 double max, u;
3648
3649 if (xabs >= yabs)
3650 {
3651 max = xabs;
3652 u = yabs / xabs;
3653 }
3654 else
3655 {
3656 max = yabs;
3657 u = xabs / yabs;
3658 }
3659
3660 /* Handle underflow when u is close to 0 */
3661
3662 return log (max) + 0.5 * log1p (u * u);
3663}
3664
3665
3666/***********************************************************************
3667 * Complex arithmetic operators
3668 ***********************************************************************/
3669
3670gsl_complex
3671gsl_complex_add (gsl_complex a, gsl_complex b)
3672{ /* z=a+b */
3673 double ar = GSL_REAL (a), ai = GSL_IMAG (a);
3674 double br = GSL_REAL (b), bi = GSL_IMAG (b);
3675
3676 gsl_complex z;
3677 GSL_SET_COMPLEX (&z, ar + br, ai + bi);
3678 return z;
3679}
3680
3681gsl_complex
3682gsl_complex_add_real (gsl_complex a, double x)
3683{ /* z=a+x */
3684 gsl_complex z;
3685 GSL_SET_COMPLEX (&z, GSL_REAL (a) + x, GSL_IMAG (a));
3686 return z;
3687}
3688
3689gsl_complex
3690gsl_complex_add_imag (gsl_complex a, double y)
3691{ /* z=a+iy */
3692 gsl_complex z;
3693 GSL_SET_COMPLEX (&z, GSL_REAL (a), GSL_IMAG (a) + y);
3694 return z;
3695}
3696
3697
3698gsl_complex
3699gsl_complex_sub (gsl_complex a, gsl_complex b)
3700{ /* z=a-b */
3701 double ar = GSL_REAL (a), ai = GSL_IMAG (a);
3702 double br = GSL_REAL (b), bi = GSL_IMAG (b);
3703
3704 gsl_complex z;
3705 GSL_SET_COMPLEX (&z, ar - br, ai - bi);
3706 return z;
3707}
3708
3709gsl_complex
3710gsl_complex_sub_real (gsl_complex a, double x)
3711{ /* z=a-x */
3712 gsl_complex z;
3713 GSL_SET_COMPLEX (&z, GSL_REAL (a) - x, GSL_IMAG (a));
3714 return z;
3715}
3716
3717gsl_complex
3718gsl_complex_sub_imag (gsl_complex a, double y)
3719{ /* z=a-iy */
3720 gsl_complex z;
3721 GSL_SET_COMPLEX (&z, GSL_REAL (a), GSL_IMAG (a) - y);
3722 return z;
3723}
3724
3725gsl_complex
3726gsl_complex_mul (gsl_complex a, gsl_complex b)
3727{ /* z=a*b */
3728 double ar = GSL_REAL (a), ai = GSL_IMAG (a);
3729 double br = GSL_REAL (b), bi = GSL_IMAG (b);
3730
3731 gsl_complex z;
3732 GSL_SET_COMPLEX (&z, ar * br - ai * bi, ar * bi + ai * br);
3733 return z;
3734}
3735
3736gsl_complex
3737gsl_complex_mul_real (gsl_complex a, double x)
3738{ /* z=a*x */
3739 gsl_complex z;
3740 GSL_SET_COMPLEX (&z, x * GSL_REAL (a), x * GSL_IMAG (a));
3741 return z;
3742}
3743
3744gsl_complex
3745gsl_complex_mul_imag (gsl_complex a, double y)
3746{ /* z=a*iy */
3747 gsl_complex z;
3748 GSL_SET_COMPLEX (&z, -y * GSL_IMAG (a), y * GSL_REAL (a));
3749 return z;
3750}
3751
3752gsl_complex
3753gsl_complex_div (gsl_complex a, gsl_complex b)
3754{ /* z=a/b */
3755 double ar = GSL_REAL (a), ai = GSL_IMAG (a);
3756 double br = GSL_REAL (b), bi = GSL_IMAG (b);
3757
3758 double s = 1.0 / gsl_complex_abs (b);
3759
3760 double sbr = s * br;
3761 double sbi = s * bi;
3762
3763 double zr = (ar * sbr + ai * sbi) * s;
3764 double zi = (ai * sbr - ar * sbi) * s;
3765
3766 gsl_complex z;
3767 GSL_SET_COMPLEX (&z, zr, zi);
3768 return z;
3769}
3770
3771gsl_complex
3772gsl_complex_div_real (gsl_complex a, double x)
3773{ /* z=a/x */
3774 gsl_complex z;
3775 GSL_SET_COMPLEX (&z, GSL_REAL (a) / x, GSL_IMAG (a) / x);
3776 return z;
3777}
3778
3779gsl_complex
3780gsl_complex_div_imag (gsl_complex a, double y)
3781{ /* z=a/(iy) */
3782 gsl_complex z;
3783 GSL_SET_COMPLEX (&z, GSL_IMAG (a) / y, - GSL_REAL (a) / y);
3784 return z;
3785}
3786
3787gsl_complex
3788gsl_complex_conjugate (gsl_complex a)
3789{ /* z=conj(a) */
3790 gsl_complex z;
3791 GSL_SET_COMPLEX (&z, GSL_REAL (a), -GSL_IMAG (a));
3792 return z;
3793}
3794
3795gsl_complex
3796gsl_complex_negative (gsl_complex a)
3797{ /* z=-a */
3798 gsl_complex z;
3799 GSL_SET_COMPLEX (&z, -GSL_REAL (a), -GSL_IMAG (a));
3800 return z;
3801}
3802
3803gsl_complex
3804gsl_complex_inverse (gsl_complex a)
3805{ /* z=1/a */
3806 double s = 1.0 / gsl_complex_abs (a);
3807
3808 gsl_complex z;
3809 GSL_SET_COMPLEX (&z, (GSL_REAL (a) * s) * s, -(GSL_IMAG (a) * s) * s);
3810 return z;
3811}
3812
3813/**********************************************************************
3814 * Elementary complex functions
3815 **********************************************************************/
3816
3817gsl_complex
3818gsl_complex_sqrt (gsl_complex a)
3819{ /* z=sqrt(a) */
3820 gsl_complex z;
3821
3822 if (GSL_REAL (a) == 0.0 && GSL_IMAG (a) == 0.0)
3823 {
3824 GSL_SET_COMPLEX (&z, 0, 0);
3825 }
3826 else
3827 {
3828 double x = fabs (GSL_REAL (a));
3829 double y = fabs (GSL_IMAG (a));
3830 double w;
3831
3832 if (x >= y)
3833 {
3834 double t = y / x;
3835 w = sqrt (x) * sqrt (0.5 * (1.0 + sqrt (1.0 + t * t)));
3836 }
3837 else
3838 {
3839 double t = x / y;
3840 w = sqrt (y) * sqrt (0.5 * (t + sqrt (1.0 + t * t)));
3841 }
3842
3843 if (GSL_REAL (a) >= 0.0)
3844 {
3845 double ai = GSL_IMAG (a);
3846 GSL_SET_COMPLEX (&z, w, ai / (2.0 * w));
3847 }
3848 else
3849 {
3850 double ai = GSL_IMAG (a);
3851 double vi = (ai >= 0) ? w : -w;
3852 GSL_SET_COMPLEX (&z, ai / (2.0 * vi), vi);
3853 }
3854 }
3855
3856 return z;
3857}
3858
3859gsl_complex
3860gsl_complex_sqrt_real (double x)
3861{ /* z=sqrt(x) */
3862 gsl_complex z;
3863
3864 if (x >= 0)
3865 {
3866 GSL_SET_COMPLEX (&z, sqrt (x), 0.0);
3867 }
3868 else
3869 {
3870 GSL_SET_COMPLEX (&z, 0.0, sqrt (-x));
3871 }
3872
3873 return z;
3874}
3875
3876gsl_complex
3877gsl_complex_exp (gsl_complex a)
3878{ /* z=exp(a) */
3879 double rho = exp (GSL_REAL (a));
3880 double theta = GSL_IMAG (a);
3881
3882 gsl_complex z;
3883 GSL_SET_COMPLEX (&z, rho * cos (theta), rho * sin (theta));
3884 return z;
3885}
3886
3887gsl_complex
3888gsl_complex_pow (gsl_complex a, gsl_complex b)
3889{ /* z=a^b */
3890 gsl_complex z;
3891
3892 if (GSL_REAL (a) == 0 && GSL_IMAG (a) == 0.0)
3893 {
3894 if (GSL_REAL (b) == 0 && GSL_IMAG (b) == 0.0)
3895 {
3896 GSL_SET_COMPLEX (&z, 1.0, 0.0);
3897 }
3898 else
3899 {
3900 GSL_SET_COMPLEX (&z, 0.0, 0.0);
3901 }
3902 }
3903 else if (GSL_REAL (b) == 1.0 && GSL_IMAG (b) == 0.0)
3904 {
3905 return a;
3906 }
3907 else if (GSL_REAL (b) == -1.0 && GSL_IMAG (b) == 0.0)
3908 {
3909 return gsl_complex_inverse (a);
3910 }
3911 else
3912 {
3913 double logr = gsl_complex_logabs (a);
3914 double theta = gsl_complex_arg (a);
3915
3916 double br = GSL_REAL (b), bi = GSL_IMAG (b);
3917
3918 double rho = exp (logr * br - bi * theta);
3919 double beta = theta * br + bi * logr;
3920
3921 GSL_SET_COMPLEX (&z, rho * cos (beta), rho * sin (beta));
3922 }
3923
3924 return z;
3925}
3926
3927gsl_complex
3928gsl_complex_pow_real (gsl_complex a, double b)
3929{ /* z=a^b */
3930 gsl_complex z;
3931
3932 if (GSL_REAL (a) == 0 && GSL_IMAG (a) == 0)
3933 {
3934 if (b == 0)
3935 {
3936 GSL_SET_COMPLEX (&z, 1, 0);
3937 }
3938 else
3939 {
3940 GSL_SET_COMPLEX (&z, 0, 0);
3941 }
3942 }
3943 else
3944 {
3945 double logr = gsl_complex_logabs (a);
3946 double theta = gsl_complex_arg (a);
3947 double rho = exp (logr * b);
3948 double beta = theta * b;
3949 GSL_SET_COMPLEX (&z, rho * cos (beta), rho * sin (beta));
3950 }
3951
3952 return z;
3953}
3954
3955gsl_complex
3956gsl_complex_log (gsl_complex a)
3957{ /* z=log(a) */
3958 double logr = gsl_complex_logabs (a);
3959 double theta = gsl_complex_arg (a);
3960
3961 gsl_complex z;
3962 GSL_SET_COMPLEX (&z, logr, theta);
3963 return z;
3964}
3965
3966gsl_complex
3967gsl_complex_log10 (gsl_complex a)
3968{ /* z = log10(a) */
3969 return gsl_complex_mul_real (gsl_complex_log (a), 1 / log (10.));
3970}
3971
3972gsl_complex
3973gsl_complex_log_b (gsl_complex a, gsl_complex b)
3974{
3975 return gsl_complex_div (gsl_complex_log (a), gsl_complex_log (b));
3976}
3977
3978/***********************************************************************
3979 * Complex trigonometric functions
3980 ***********************************************************************/
3981
3982gsl_complex
3983gsl_complex_sin (gsl_complex a)
3984{ /* z = sin(a) */
3985 double R = GSL_REAL (a), I = GSL_IMAG (a);
3986
3987 gsl_complex z;
3988
3989 if (I == 0.0)
3990 {
3991 /* avoid returing negative zero (-0.0) for the imaginary part */
3992
3993 GSL_SET_COMPLEX (&z, sin (R), 0.0);
3994 }
3995 else
3996 {
3997 GSL_SET_COMPLEX (&z, sin (R) * cosh (I), cos (R) * sinh (I));
3998 }
3999
4000 return z;
4001}
4002
4003gsl_complex
4004gsl_complex_cos (gsl_complex a)
4005{ /* z = cos(a) */
4006 double R = GSL_REAL (a), I = GSL_IMAG (a);
4007
4008 gsl_complex z;
4009
4010 if (I == 0.0)
4011 {
4012 /* avoid returing negative zero (-0.0) for the imaginary part */
4013
4014 GSL_SET_COMPLEX (&z, cos (R), 0.0);
4015 }
4016 else
4017 {
4018 GSL_SET_COMPLEX (&z, cos (R) * cosh (I), sin (R) * sinh (-I));
4019 }
4020
4021 return z;
4022}
4023
4024gsl_complex
4025gsl_complex_tan (gsl_complex a)
4026{ /* z = tan(a) */
4027 double R = GSL_REAL (a), I = GSL_IMAG (a);
4028
4029 gsl_complex z;
4030
4031 if (fabs (I) < 1)
4032 {
4033 double D = pow (cos (R), 2.0) + pow (sinh (I), 2.0);
4034
4035 GSL_SET_COMPLEX (&z, 0.5 * sin (2 * R) / D, 0.5 * sinh (2 * I) / D);
4036 }
4037 else
4038 {
4039 double D = pow (cos (R), 2.0) + pow (sinh (I), 2.0);
4040 double F = 1 + pow(cos (R)/sinh (I), 2.0);
4041
4042 GSL_SET_COMPLEX (&z, 0.5 * sin (2 * R) / D, 1 / (tanh (I) * F));
4043 }
4044
4045 return z;
4046}
4047
4048gsl_complex
4049gsl_complex_sec (gsl_complex a)
4050{ /* z = sec(a) */
4051 gsl_complex z = gsl_complex_cos (a);
4052 return gsl_complex_inverse (z);
4053}
4054
4055gsl_complex
4056gsl_complex_csc (gsl_complex a)
4057{ /* z = csc(a) */
4058 gsl_complex z = gsl_complex_sin (a);
4059 return gsl_complex_inverse(z);
4060}
4061
4062
4063gsl_complex
4064gsl_complex_cot (gsl_complex a)
4065{ /* z = cot(a) */
4066 gsl_complex z = gsl_complex_tan (a);
4067 return gsl_complex_inverse (z);
4068}
4069
4070/**********************************************************************
4071 * Inverse Complex Trigonometric Functions
4072 **********************************************************************/
4073
4074gsl_complex
4075gsl_complex_arcsin (gsl_complex a)
4076{ /* z = arcsin(a) */
4077 double R = GSL_REAL (a), I = GSL_IMAG (a);
4078 gsl_complex z;
4079
4080 if (I == 0)
4081 {
4082 z = gsl_complex_arcsin_real (R);
4083 }
4084 else
4085 {
4086 double x = fabs (R), y = fabs (I);
4087 double r = hypot (x + 1, y), s = hypot (x - 1, y);
4088 double A = 0.5 * (r + s);
4089 double B = x / A;
4090 double y2 = y * y;
4091
4092 double real, imag;
4093
4094 const double A_crossover = 1.5, B_crossover = 0.6417;
4095
4096 if (B <= B_crossover)
4097 {
4098 real = asin (B);
4099 }
4100 else
4101 {
4102 if (x <= 1)
4103 {
4104 double D = 0.5 * (A + x) * (y2 / (r + x + 1) + (s + (1 - x)));
4105 real = atan (x / sqrt (D));
4106 }
4107 else
4108 {
4109 double Apx = A + x;
4110 double D = 0.5 * (Apx / (r + x + 1) + Apx / (s + (x - 1)));
4111 real = atan (x / (y * sqrt (D)));
4112 }
4113 }
4114
4115 if (A <= A_crossover)
4116 {
4117 double Am1;
4118
4119 if (x < 1)
4120 {
4121 Am1 = 0.5 * (y2 / (r + (x + 1)) + y2 / (s + (1 - x)));
4122 }
4123 else
4124 {
4125 Am1 = 0.5 * (y2 / (r + (x + 1)) + (s + (x - 1)));
4126 }
4127
4128 imag = log1p (Am1 + sqrt (Am1 * (A + 1)));
4129 }
4130 else
4131 {
4132 imag = log (A + sqrt (A * A - 1));
4133 }
4134
4135 GSL_SET_COMPLEX (&z, (R >= 0) ? real : -real, (I >= 0) ? imag : -imag);
4136 }
4137
4138 return z;
4139}
4140
4141gsl_complex
4142gsl_complex_arcsin_real (double a)
4143{ /* z = arcsin(a) */
4144 gsl_complex z;
4145
4146 if (fabs (a) <= 1.0)
4147 {
4148 GSL_SET_COMPLEX (&z, asin (a), 0.0);
4149 }
4150 else
4151 {
4152 if (a < 0.0)
4153 {
4154 GSL_SET_COMPLEX (&z, -M_PI_2, acosh (-a));
4155 }
4156 else
4157 {
4158 GSL_SET_COMPLEX (&z, M_PI_2, -acosh (a));
4159 }
4160 }
4161
4162 return z;
4163}
4164
4165gsl_complex
4166gsl_complex_arccos (gsl_complex a)
4167{ /* z = arccos(a) */
4168 double R = GSL_REAL (a), I = GSL_IMAG (a);
4169 gsl_complex z;
4170
4171 if (I == 0)
4172 {
4173 z = gsl_complex_arccos_real (R);
4174 }
4175 else
4176 {
4177 double x = fabs (R), y = fabs (I);
4178 double r = hypot (x + 1, y), s = hypot (x - 1, y);
4179 double A = 0.5 * (r + s);
4180 double B = x / A;
4181 double y2 = y * y;
4182
4183 double real, imag;
4184
4185 const double A_crossover = 1.5, B_crossover = 0.6417;
4186
4187 if (B <= B_crossover)
4188 {
4189 real = acos (B);
4190 }
4191 else
4192 {
4193 if (x <= 1)
4194 {
4195 double D = 0.5 * (A + x) * (y2 / (r + x + 1) + (s + (1 - x)));
4196 real = atan (sqrt (D) / x);
4197 }
4198 else
4199 {
4200 double Apx = A + x;
4201 double D = 0.5 * (Apx / (r + x + 1) + Apx / (s + (x - 1)));
4202 real = atan ((y * sqrt (D)) / x);
4203 }
4204 }
4205
4206 if (A <= A_crossover)
4207 {
4208 double Am1;
4209
4210 if (x < 1)
4211 {
4212 Am1 = 0.5 * (y2 / (r + (x + 1)) + y2 / (s + (1 - x)));
4213 }
4214 else
4215 {
4216 Am1 = 0.5 * (y2 / (r + (x + 1)) + (s + (x - 1)));
4217 }
4218
4219 imag = log1p (Am1 + sqrt (Am1 * (A + 1)));
4220 }
4221 else
4222 {
4223 imag = log (A + sqrt (A * A - 1));
4224 }
4225
4226 GSL_SET_COMPLEX (&z, (R >= 0) ? real : M_PI - real, (I >= 0) ? -imag : imag);
4227 }
4228
4229 return z;
4230}
4231
4232gsl_complex
4233gsl_complex_arccos_real (double a)
4234{ /* z = arccos(a) */
4235 gsl_complex z;
4236
4237 if (fabs (a) <= 1.0)
4238 {
4239 GSL_SET_COMPLEX (&z, acos (a), 0);
4240 }
4241 else
4242 {
4243 if (a < 0.0)
4244 {
4245 GSL_SET_COMPLEX (&z, M_PI, -acosh (-a));
4246 }
4247 else
4248 {
4249 GSL_SET_COMPLEX (&z, 0, acosh (a));
4250 }
4251 }
4252
4253 return z;
4254}
4255
4256gsl_complex
4257gsl_complex_arctan (gsl_complex a)
4258{ /* z = arctan(a) */
4259 double R = GSL_REAL (a), I = GSL_IMAG (a);
4260 gsl_complex z;
4261
4262 if (I == 0)
4263 {
4264 GSL_SET_COMPLEX (&z, atan (R), 0);
4265 }
4266 else
4267 {
4268 /* FIXME: This is a naive implementation which does not fully
4269 take into account cancellation errors, overflow, underflow
4270 etc. It would benefit from the Hull et al treatment. */
4271
4272 double r = hypot (R, I);
4273
4274 double imag;
4275
4276 double u = 2 * I / (1 + r * r);
4277
4278 /* FIXME: the following cross-over should be optimized but 0.1
4279 seems to work ok */
4280
4281 if (fabs (u) < 0.1)
4282 {
4283 imag = 0.25 * (log1p (u) - log1p (-u));
4284 }
4285 else
4286 {
4287 double A = hypot (R, I + 1);
4288 double B = hypot (R, I - 1);
4289 imag = 0.5 * log (A / B);
4290 }
4291
4292 if (R == 0)
4293 {
4294 if (I > 1)
4295 {
4296 GSL_SET_COMPLEX (&z, M_PI_2, imag);
4297 }
4298 else if (I < -1)
4299 {
4300 GSL_SET_COMPLEX (&z, -M_PI_2, imag);
4301 }
4302 else
4303 {
4304 GSL_SET_COMPLEX (&z, 0, imag);
4305 };
4306 }
4307 else
4308 {
4309 GSL_SET_COMPLEX (&z, 0.5 * atan2 (2 * R, ((1 + r) * (1 - r))), imag);
4310 }
4311 }
4312
4313 return z;
4314}
4315
4316gsl_complex
4317gsl_complex_arcsec (gsl_complex a)
4318{ /* z = arcsec(a) */
4319 gsl_complex z = gsl_complex_inverse (a);
4320 return gsl_complex_arccos (z);
4321}
4322
4323gsl_complex
4324gsl_complex_arcsec_real (double a)
4325{ /* z = arcsec(a) */
4326 gsl_complex z;
4327
4328 if (a <= -1.0 || a >= 1.0)
4329 {
4330 GSL_SET_COMPLEX (&z, acos (1 / a), 0.0);
4331 }
4332 else
4333 {
4334 if (a >= 0.0)
4335 {
4336 GSL_SET_COMPLEX (&z, 0, acosh (1 / a));
4337 }
4338 else
4339 {
4340 GSL_SET_COMPLEX (&z, M_PI, -acosh (-1 / a));
4341 }
4342 }
4343
4344 return z;
4345}
4346
4347gsl_complex
4348gsl_complex_arccsc (gsl_complex a)
4349{ /* z = arccsc(a) */
4350 gsl_complex z = gsl_complex_inverse (a);
4351 return gsl_complex_arcsin (z);
4352}
4353
4354gsl_complex
4355gsl_complex_arccsc_real (double a)
4356{ /* z = arccsc(a) */
4357 gsl_complex z;
4358
4359 if (a <= -1.0 || a >= 1.0)
4360 {
4361 GSL_SET_COMPLEX (&z, asin (1 / a), 0.0);
4362 }
4363 else
4364 {
4365 if (a >= 0.0)
4366 {
4367 GSL_SET_COMPLEX (&z, M_PI_2, -acosh (1 / a));
4368 }
4369 else
4370 {
4371 GSL_SET_COMPLEX (&z, -M_PI_2, acosh (-1 / a));
4372 }
4373 }
4374
4375 return z;
4376}
4377
4378gsl_complex
4379gsl_complex_arccot (gsl_complex a)
4380{ /* z = arccot(a) */
4381 gsl_complex z;
4382
4383 if (GSL_REAL (a) == 0.0 && GSL_IMAG (a) == 0.0)
4384 {
4385 GSL_SET_COMPLEX (&z, M_PI_2, 0);
4386 }
4387 else
4388 {
4389 z = gsl_complex_inverse (a);
4390 z = gsl_complex_arctan (z);
4391 }
4392
4393 return z;
4394}
4395
4396/**********************************************************************
4397 * Complex Hyperbolic Functions
4398 **********************************************************************/
4399
4400gsl_complex
4401gsl_complex_sinh (gsl_complex a)
4402{ /* z = sinh(a) */
4403 double R = GSL_REAL (a), I = GSL_IMAG (a);
4404
4405 gsl_complex z;
4406 GSL_SET_COMPLEX (&z, sinh (R) * cos (I), cosh (R) * sin (I));
4407 return z;
4408}
4409
4410gsl_complex
4411gsl_complex_cosh (gsl_complex a)
4412{ /* z = cosh(a) */
4413 double R = GSL_REAL (a), I = GSL_IMAG (a);
4414
4415 gsl_complex z;
4416 GSL_SET_COMPLEX (&z, cosh (R) * cos (I), sinh (R) * sin (I));
4417 return z;
4418}
4419
4420gsl_complex
4421gsl_complex_tanh (gsl_complex a)
4422{ /* z = tanh(a) */
4423 double R = GSL_REAL (a), I = GSL_IMAG (a);
4424
4425 gsl_complex z;
4426
4427 if (fabs(R) < 1.0)
4428 {
4429 double D = pow (cos (I), 2.0) + pow (sinh (R), 2.0);
4430
4431 GSL_SET_COMPLEX (&z, sinh (R) * cosh (R) / D, 0.5 * sin (2 * I) / D);
4432 }
4433 else
4434 {
4435 double D = pow (cos (I), 2.0) + pow (sinh (R), 2.0);
4436 double F = 1 + pow (cos (I) / sinh (R), 2.0);
4437
4438 GSL_SET_COMPLEX (&z, 1.0 / (tanh (R) * F), 0.5 * sin (2 * I) / D);
4439 }
4440
4441 return z;
4442}
4443
4444gsl_complex
4445gsl_complex_sech (gsl_complex a)
4446{ /* z = sech(a) */
4447 gsl_complex z = gsl_complex_cosh (a);
4448 return gsl_complex_inverse (z);
4449}
4450
4451gsl_complex
4452gsl_complex_csch (gsl_complex a)
4453{ /* z = csch(a) */
4454 gsl_complex z = gsl_complex_sinh (a);
4455 return gsl_complex_inverse (z);
4456}
4457
4458gsl_complex
4459gsl_complex_coth (gsl_complex a)
4460{ /* z = coth(a) */
4461 gsl_complex z = gsl_complex_tanh (a);
4462 return gsl_complex_inverse (z);
4463}
4464
4465/**********************************************************************
4466 * Inverse Complex Hyperbolic Functions
4467 **********************************************************************/
4468
4469gsl_complex
4470gsl_complex_arcsinh (gsl_complex a)
4471{ /* z = arcsinh(a) */
4472 gsl_complex z = gsl_complex_mul_imag(a, 1.0);
4473 z = gsl_complex_arcsin (z);
4474 z = gsl_complex_mul_imag (z, -1.0);
4475 return z;
4476}
4477
4478gsl_complex
4479gsl_complex_arccosh (gsl_complex a)
4480{ /* z = arccosh(a) */
4481 gsl_complex z = gsl_complex_arccos (a);
4482 z = gsl_complex_mul_imag (z, GSL_IMAG(z) > 0 ? -1.0 : 1.0);
4483 return z;
4484}
4485
4486gsl_complex
4487gsl_complex_arccosh_real (double a)
4488{ /* z = arccosh(a) */
4489 gsl_complex z;
4490
4491 if (a >= 1)
4492 {
4493 GSL_SET_COMPLEX (&z, acosh (a), 0);
4494 }
4495 else
4496 {
4497 if (a >= -1.0)
4498 {
4499 GSL_SET_COMPLEX (&z, 0, acos (a));
4500 }
4501 else
4502 {
4503 GSL_SET_COMPLEX (&z, acosh (-a), M_PI);
4504 }
4505 }
4506
4507 return z;
4508}
4509
4510gsl_complex
4511gsl_complex_arctanh (gsl_complex a)
4512{ /* z = arctanh(a) */
4513 if (GSL_IMAG (a) == 0.0)
4514 {
4515 return gsl_complex_arctanh_real (GSL_REAL (a));
4516 }
4517 else
4518 {
4519 gsl_complex z = gsl_complex_mul_imag(a, 1.0);
4520 z = gsl_complex_arctan (z);
4521 z = gsl_complex_mul_imag (z, -1.0);
4522 return z;
4523 }
4524}
4525
4526gsl_complex
4527gsl_complex_arctanh_real (double a)
4528{ /* z = arctanh(a) */
4529 gsl_complex z;
4530
4531 if (a > -1.0 && a < 1.0)
4532 {
4533 GSL_SET_COMPLEX (&z, atanh (a), 0);
4534 }
4535 else
4536 {
4537 GSL_SET_COMPLEX (&z, atanh (1 / a), (a < 0) ? M_PI_2 : -M_PI_2);
4538 }
4539
4540 return z;
4541}
4542
4543gsl_complex
4544gsl_complex_arcsech (gsl_complex a)
4545{ /* z = arcsech(a); */
4546 gsl_complex t = gsl_complex_inverse (a);
4547 return gsl_complex_arccosh (t);
4548}
4549
4550gsl_complex
4551gsl_complex_arccsch (gsl_complex a)
4552{ /* z = arccsch(a) */
4553 gsl_complex t = gsl_complex_inverse (a);
4554 return gsl_complex_arcsinh (t);
4555}
4556
4557gsl_complex
4558gsl_complex_arccoth (gsl_complex a)
4559{ /* z = arccoth(a) */
4560 gsl_complex t = gsl_complex_inverse (a);
4561 return gsl_complex_arctanh (t);
4562}
4563/* end inlined source: complex/math.c */
4564
4565/* Special functions -------------------------------------------------------
4566 * Inlined in bottom-up dependency order so that each file's callee
4567 * definitions precede the callers. */
4568/* begin inlined source: specfunc/log.c */
4569/* specfunc/log.c
4570 *
4571 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
4572 *
4573 * This program is free software; you can redistribute it and/or modify
4574 * it under the terms of the GNU General Public License as published by
4575 * the Free Software Foundation; either version 3 of the License, or (at
4576 * your option) any later version.
4577 *
4578 * This program is distributed in the hope that it will be useful, but
4579 * WITHOUT ANY WARRANTY; without even the implied warranty of
4580 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4581 * General Public License for more details.
4582 *
4583 * You should have received a copy of the GNU General Public License
4584 * along with this program; if not, write to the Free Software
4585 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
4586 */
4587
4588/* Author: G. Jungman */
4589/* begin inlined header: config.h */
4590#ifndef MARLEY_BUILTIN_GSL_CONFIG_WRAPPER_H
4591#define MARLEY_BUILTIN_GSL_CONFIG_WRAPPER_H
4592/* begin inlined header: gsl_config.h */
4593#ifndef MARLEY_BUILTIN_GSL_CONFIG_H
4594#define MARLEY_BUILTIN_GSL_CONFIG_H
4595
4596#define HAVE_INLINE 1
4597#define HAVE_DECL_ISFINITE 1
4598#define HAVE_DECL_ISNAN 1
4599#define HAVE_DECL_ISINF 1
4600#define GSL_COERCE_DBL(x) (x)
4601
4602#define GSL_DISABLE_DEPRECATED 0
4603#define PACKAGE_VERSION "2.8"
4604#define VERSION "2.8"
4605
4606#endif
4607
4608/* end inlined header: gsl_config.h */
4609#endif
4610
4611/* end inlined header: config.h */
4612/* begin inlined header: gsl/gsl_math.h */
4613/* gsl_math.h
4614 *
4615 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2004, 2007 Gerard Jungman, Brian Gough
4616 *
4617 * This program is free software; you can redistribute it and/or modify
4618 * it under the terms of the GNU General Public License as published by
4619 * the Free Software Foundation; either version 3 of the License, or (at
4620 * your option) any later version.
4621 *
4622 * This program is distributed in the hope that it will be useful, but
4623 * WITHOUT ANY WARRANTY; without even the implied warranty of
4624 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4625 * General Public License for more details.
4626 *
4627 * You should have received a copy of the GNU General Public License
4628 * along with this program; if not, write to the Free Software
4629 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
4630 */
4631
4632#ifndef __GSL_MATH_H__
4633#define __GSL_MATH_H__
4634#include <math.h>
4635/* begin inlined header: gsl/gsl_sys.h */
4636/* sys/gsl_sys.h
4637 *
4638 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, Brian Gough
4639 *
4640 * This program is free software; you can redistribute it and/or modify
4641 * it under the terms of the GNU General Public License as published by
4642 * the Free Software Foundation; either version 3 of the License, or (at
4643 * your option) any later version.
4644 *
4645 * This program is distributed in the hope that it will be useful, but
4646 * WITHOUT ANY WARRANTY; without even the implied warranty of
4647 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4648 * General Public License for more details.
4649 *
4650 * You should have received a copy of the GNU General Public License
4651 * along with this program; if not, write to the Free Software
4652 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
4653 */
4654
4655#ifndef __GSL_SYS_H__
4656#define __GSL_SYS_H__
4657
4658__BEGIN_DECLS
4659
4660double gsl_log1p (const double x);
4661double gsl_expm1 (const double x);
4662double gsl_hypot (const double x, const double y);
4663double gsl_hypot3 (const double x, const double y, const double z);
4664double gsl_acosh (const double x);
4665double gsl_asinh (const double x);
4666double gsl_atanh (const double x);
4667
4668int gsl_isnan (const double x);
4669int gsl_isinf (const double x);
4670int gsl_finite (const double x);
4671
4672double gsl_nan (void);
4673double gsl_posinf (void);
4674double gsl_neginf (void);
4675double gsl_fdiv (const double x, const double y);
4676
4677double gsl_coerce_double (const double x);
4678float gsl_coerce_float (const float x);
4679long double gsl_coerce_long_double (const long double x);
4680
4681double gsl_ldexp(const double x, const int e);
4682double gsl_frexp(const double x, int * e);
4683
4684int gsl_fcmp (const double x1, const double x2, const double epsilon);
4685
4686__END_DECLS
4687
4688#endif /* __GSL_SYS_H__ */
4689
4690/* end inlined header: gsl/gsl_sys.h */
4691/* begin inlined header: gsl/gsl_inline.h */
4692/* gsl_inline.h
4693 *
4694 * Copyright (C) 2008, 2009 Brian Gough
4695 *
4696 * This program is free software; you can redistribute it and/or modify
4697 * it under the terms of the GNU General Public License as published by
4698 * the Free Software Foundation; either version 3 of the License, or (at
4699 * your option) any later version.
4700 *
4701 * This program is distributed in the hope that it will be useful, but
4702 * WITHOUT ANY WARRANTY; without even the implied warranty of
4703 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4704 * General Public License for more details.
4705 *
4706 * You should have received a copy of the GNU General Public License
4707 * along with this program; if not, write to the Free Software
4708 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
4709 */
4710
4711#ifndef __GSL_INLINE_H__
4712#define __GSL_INLINE_H__
4713
4714/* In recent versiions of GCC, the inline keyword has two different
4715 forms: GNU and C99.
4716
4717 In GNU mode we can use 'extern inline' to make inline functions
4718 work like macros. The function is only inlined--it is never output
4719 as a definition in an object file.
4720
4721 In the new C99 mode 'extern inline' has a different meaning--it
4722 causes the definition of the function to be output in each object
4723 file where it is used. This will result in multiple-definition
4724 errors on linking. The 'inline' keyword on its own (without
4725 extern) has the same behavior as the original GNU 'extern inline'.
4726
4727 The C99 style is the default with -std=c99 in GCC 4.3.
4728
4729 This header file allows either form of inline to be used by
4730 redefining the macros INLINE_DECL and INLINE_FUN. These are used
4731 in the public header files as
4732
4733 INLINE_DECL double gsl_foo (double x);
4734 #ifdef HAVE_INLINE
4735 INLINE_FUN double gsl_foo (double x) { return x+1.0; } ;
4736 #endif
4737
4738*/
4739
4740#ifdef HAVE_INLINE
4741# if defined(__GNUC_STDC_INLINE__) || defined(GSL_C99_INLINE) || defined(HAVE_C99_INLINE)
4742# define INLINE_DECL inline /* use C99 inline */
4743# define INLINE_FUN inline
4744# else
4745# define INLINE_DECL /* use GNU extern inline */
4746# define INLINE_FUN extern inline
4747# endif
4748#else
4749# define INLINE_DECL /* */
4750#endif
4751
4752/* Range checking conditions in headers do not require any run-time
4753 tests of the global variable gsl_check_range. They are enabled or
4754 disabled in user code at compile time with GSL_RANGE_CHECK macro.
4755 See also build.h. */
4756#define GSL_RANGE_COND(x) (x)
4757
4758#endif /* __GSL_INLINE_H__ */
4759
4760/* end inlined header: gsl/gsl_inline.h */
4761/* begin inlined header: gsl/gsl_machine.h */
4762/* Author: B. Gough and G. Jungman */
4763#ifndef __GSL_MACHINE_H__
4764#define __GSL_MACHINE_H__
4765
4766#include <limits.h>
4767#include <float.h>
4768
4769/* magic constants; mostly for the benefit of the implementation */
4770
4771/* -*-MACHINE CONSTANTS-*-
4772 *
4773 * PLATFORM: Whiz-O-Matic 9000
4774 * FP_PLATFORM: IEEE-Virtual
4775 * HOSTNAME: nnn.lanl.gov
4776 * DATE: Fri Nov 20 17:53:26 MST 1998
4777 */
4778#define GSL_DBL_EPSILON 2.2204460492503131e-16
4779#define GSL_SQRT_DBL_EPSILON 1.4901161193847656e-08
4780#define GSL_ROOT3_DBL_EPSILON 6.0554544523933429e-06
4781#define GSL_ROOT4_DBL_EPSILON 1.2207031250000000e-04
4782#define GSL_ROOT5_DBL_EPSILON 7.4009597974140505e-04
4783#define GSL_ROOT6_DBL_EPSILON 2.4607833005759251e-03
4784#define GSL_LOG_DBL_EPSILON (-3.6043653389117154e+01)
4785
4786#define GSL_DBL_MIN 2.2250738585072014e-308
4787#define GSL_SQRT_DBL_MIN 1.4916681462400413e-154
4788#define GSL_ROOT3_DBL_MIN 2.8126442852362996e-103
4789#define GSL_ROOT4_DBL_MIN 1.2213386697554620e-77
4790#define GSL_ROOT5_DBL_MIN 2.9476022969691763e-62
4791#define GSL_ROOT6_DBL_MIN 5.3034368905798218e-52
4792#define GSL_LOG_DBL_MIN (-7.0839641853226408e+02)
4793
4794#define GSL_DBL_MAX 1.7976931348623157e+308
4795#define GSL_SQRT_DBL_MAX 1.3407807929942596e+154
4796#define GSL_ROOT3_DBL_MAX 5.6438030941222897e+102
4797#define GSL_ROOT4_DBL_MAX 1.1579208923731620e+77
4798#define GSL_ROOT5_DBL_MAX 4.4765466227572707e+61
4799#define GSL_ROOT6_DBL_MAX 2.3756689782295612e+51
4800#define GSL_LOG_DBL_MAX 7.0978271289338397e+02
4801
4802#define GSL_FLT_EPSILON 1.1920928955078125e-07
4803#define GSL_SQRT_FLT_EPSILON 3.4526698300124393e-04
4804#define GSL_ROOT3_FLT_EPSILON 4.9215666011518501e-03
4805#define GSL_ROOT4_FLT_EPSILON 1.8581361171917516e-02
4806#define GSL_ROOT5_FLT_EPSILON 4.1234622211652937e-02
4807#define GSL_ROOT6_FLT_EPSILON 7.0153878019335827e-02
4808#define GSL_LOG_FLT_EPSILON (-1.5942385152878742e+01)
4809
4810#define GSL_FLT_MIN 1.1754943508222875e-38
4811#define GSL_SQRT_FLT_MIN 1.0842021724855044e-19
4812#define GSL_ROOT3_FLT_MIN 2.2737367544323241e-13
4813#define GSL_ROOT4_FLT_MIN 3.2927225399135965e-10
4814#define GSL_ROOT5_FLT_MIN 2.5944428542140822e-08
4815#define GSL_ROOT6_FLT_MIN 4.7683715820312542e-07
4816#define GSL_LOG_FLT_MIN (-8.7336544750553102e+01)
4817
4818#define GSL_FLT_MAX 3.4028234663852886e+38
4819#define GSL_SQRT_FLT_MAX 1.8446743523953730e+19
4820#define GSL_ROOT3_FLT_MAX 6.9814635196223242e+12
4821#define GSL_ROOT4_FLT_MAX 4.2949672319999986e+09
4822#define GSL_ROOT5_FLT_MAX 5.0859007855960041e+07
4823#define GSL_ROOT6_FLT_MAX 2.6422459233807749e+06
4824#define GSL_LOG_FLT_MAX 8.8722839052068352e+01
4825
4826#define GSL_SFLT_EPSILON 4.8828125000000000e-04
4827#define GSL_SQRT_SFLT_EPSILON 2.2097086912079612e-02
4828#define GSL_ROOT3_SFLT_EPSILON 7.8745065618429588e-02
4829#define GSL_ROOT4_SFLT_EPSILON 1.4865088937534013e-01
4830#define GSL_ROOT5_SFLT_EPSILON 2.1763764082403100e-01
4831#define GSL_ROOT6_SFLT_EPSILON 2.8061551207734325e-01
4832#define GSL_LOG_SFLT_EPSILON (-7.6246189861593985e+00)
4833
4834/* !MACHINE CONSTANTS! */
4835
4836
4837/* a little internal backwards compatibility */
4838#define GSL_MACH_EPS GSL_DBL_EPSILON
4839
4840
4841
4842/* Here are the constants related to or derived from
4843 * machine constants. These are not to be confused with
4844 * the constants that define various precision levels
4845 * for the precision/error system.
4846 *
4847 * This information is determined at configure time
4848 * and is platform dependent. Edit at your own risk.
4849 *
4850 * PLATFORM: WHIZ-O-MATIC
4851 * CONFIG-DATE: Thu Nov 19 19:27:18 MST 1998
4852 * CONFIG-HOST: nnn.lanl.gov
4853 */
4854
4855/* machine precision constants */
4856/* #define GSL_MACH_EPS 1.0e-15 */
4857#define GSL_SQRT_MACH_EPS 3.2e-08
4858#define GSL_ROOT3_MACH_EPS 1.0e-05
4859#define GSL_ROOT4_MACH_EPS 0.000178
4860#define GSL_ROOT5_MACH_EPS 0.00100
4861#define GSL_ROOT6_MACH_EPS 0.00316
4862#define GSL_LOG_MACH_EPS (-34.54)
4863
4864
4865#endif /* __GSL_MACHINE_H__ */
4866
4867/* end inlined header: gsl/gsl_machine.h */
4868/* begin inlined header: gsl/gsl_precision.h */
4869/* gsl_precision.h
4870 *
4871 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
4872 *
4873 * This program is free software; you can redistribute it and/or modify
4874 * it under the terms of the GNU General Public License as published by
4875 * the Free Software Foundation; either version 3 of the License, or (at
4876 * your option) any later version.
4877 *
4878 * This program is distributed in the hope that it will be useful, but
4879 * WITHOUT ANY WARRANTY; without even the implied warranty of
4880 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4881 * General Public License for more details.
4882 *
4883 * You should have received a copy of the GNU General Public License
4884 * along with this program; if not, write to the Free Software
4885 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
4886 */
4887
4888/* Author: B. Gough and G. Jungman */
4889
4890#ifndef __GSL_PRECISION_H__
4891#define __GSL_PRECISION_H__
4892/* begin inlined header: gsl/gsl_types.h */
4893/* gsl_types.h
4894 *
4895 * Copyright (C) 2001, 2007 Brian Gough
4896 *
4897 * This program is free software; you can redistribute it and/or modify
4898 * it under the terms of the GNU General Public License as published by
4899 * the Free Software Foundation; either version 3 of the License, or (at
4900 * your option) any later version.
4901 *
4902 * This program is distributed in the hope that it will be useful, but
4903 * WITHOUT ANY WARRANTY; without even the implied warranty of
4904 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4905 * General Public License for more details.
4906 *
4907 * You should have received a copy of the GNU General Public License
4908 * along with this program; if not, write to the Free Software
4909 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
4910 */
4911
4912#ifndef __GSL_TYPES_H__
4913#define __GSL_TYPES_H__
4914
4915#ifndef GSL_VAR
4916
4917#ifdef WIN32
4918# ifdef GSL_DLL
4919# ifdef DLL_EXPORT
4920# define GSL_VAR extern __declspec(dllexport)
4921# else
4922# define GSL_VAR extern __declspec(dllimport)
4923# endif
4924# else
4925# define GSL_VAR extern
4926# endif
4927#else
4928# define GSL_VAR extern
4929#endif
4930
4931#endif
4932
4933#endif /* __GSL_TYPES_H__ */
4934
4935/* end inlined header: gsl/gsl_types.h */
4936
4937__BEGIN_DECLS
4938
4939
4940/* A type for the precision indicator.
4941 * This is mainly for pedagogy.
4942 */
4943typedef unsigned int gsl_prec_t;
4944
4945
4946/* The number of precision types.
4947 * Remember that precision-mode
4948 * can index an array.
4949 */
4950#define _GSL_PREC_T_NUM 3
4951
4952
4953/* Arrays containing derived
4954 * precision constants for the
4955 * different precision levels.
4956 */
4957GSL_VAR const double gsl_prec_eps[];
4958GSL_VAR const double gsl_prec_sqrt_eps[];
4959GSL_VAR const double gsl_prec_root3_eps[];
4960GSL_VAR const double gsl_prec_root4_eps[];
4961GSL_VAR const double gsl_prec_root5_eps[];
4962GSL_VAR const double gsl_prec_root6_eps[];
4963
4964
4965__END_DECLS
4966
4967#endif /* __GSL_PRECISION_H__ */
4968
4969/* end inlined header: gsl/gsl_precision.h */
4970/* begin inlined header: gsl/gsl_nan.h */
4971/* gsl_nan.h
4972 *
4973 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, Brian Gough
4974 *
4975 * This program is free software; you can redistribute it and/or modify
4976 * it under the terms of the GNU General Public License as published by
4977 * the Free Software Foundation; either version 3 of the License, or (at
4978 * your option) any later version.
4979 *
4980 * This program is distributed in the hope that it will be useful, but
4981 * WITHOUT ANY WARRANTY; without even the implied warranty of
4982 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4983 * General Public License for more details.
4984 *
4985 * You should have received a copy of the GNU General Public License
4986 * along with this program; if not, write to the Free Software
4987 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
4988 */
4989
4990#ifndef __GSL_NAN_H__
4991#define __GSL_NAN_H__
4992
4993#ifdef INFINITY
4994# define GSL_POSINF INFINITY
4995# define GSL_NEGINF (-INFINITY)
4996#elif defined(HUGE_VAL)
4997# define GSL_POSINF HUGE_VAL
4998# define GSL_NEGINF (-HUGE_VAL)
4999#else
5000# define GSL_POSINF (gsl_posinf())
5001# define GSL_NEGINF (gsl_neginf())
5002#endif
5003
5004#ifdef NAN
5005# define GSL_NAN NAN
5006#elif defined(INFINITY)
5007# define GSL_NAN (INFINITY/INFINITY)
5008#else
5009# define GSL_NAN (gsl_nan())
5010#endif
5011
5012#define GSL_POSZERO (+0.0)
5013#define GSL_NEGZERO (-0.0)
5014
5015#endif /* __GSL_NAN_H__ */
5016
5017/* end inlined header: gsl/gsl_nan.h */
5018/* begin inlined header: gsl/gsl_pow_int.h */
5019/* gsl_pow_int.h
5020 *
5021 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2004, 2007 Gerard Jungman, Brian Gough
5022 *
5023 * This program is free software; you can redistribute it and/or modify
5024 * it under the terms of the GNU General Public License as published by
5025 * the Free Software Foundation; either version 3 of the License, or (at
5026 * your option) any later version.
5027 *
5028 * This program is distributed in the hope that it will be useful, but
5029 * WITHOUT ANY WARRANTY; without even the implied warranty of
5030 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5031 * General Public License for more details.
5032 *
5033 * You should have received a copy of the GNU General Public License
5034 * along with this program; if not, write to the Free Software
5035 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
5036 */
5037
5038#ifndef __GSL_POW_INT_H__
5039#define __GSL_POW_INT_H__
5040/* begin inlined header: gsl/gsl_inline.h */
5041/* gsl_inline.h
5042 *
5043 * Copyright (C) 2008, 2009 Brian Gough
5044 *
5045 * This program is free software; you can redistribute it and/or modify
5046 * it under the terms of the GNU General Public License as published by
5047 * the Free Software Foundation; either version 3 of the License, or (at
5048 * your option) any later version.
5049 *
5050 * This program is distributed in the hope that it will be useful, but
5051 * WITHOUT ANY WARRANTY; without even the implied warranty of
5052 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5053 * General Public License for more details.
5054 *
5055 * You should have received a copy of the GNU General Public License
5056 * along with this program; if not, write to the Free Software
5057 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
5058 */
5059
5060#ifndef __GSL_INLINE_H__
5061#define __GSL_INLINE_H__
5062
5063/* In recent versiions of GCC, the inline keyword has two different
5064 forms: GNU and C99.
5065
5066 In GNU mode we can use 'extern inline' to make inline functions
5067 work like macros. The function is only inlined--it is never output
5068 as a definition in an object file.
5069
5070 In the new C99 mode 'extern inline' has a different meaning--it
5071 causes the definition of the function to be output in each object
5072 file where it is used. This will result in multiple-definition
5073 errors on linking. The 'inline' keyword on its own (without
5074 extern) has the same behavior as the original GNU 'extern inline'.
5075
5076 The C99 style is the default with -std=c99 in GCC 4.3.
5077
5078 This header file allows either form of inline to be used by
5079 redefining the macros INLINE_DECL and INLINE_FUN. These are used
5080 in the public header files as
5081
5082 INLINE_DECL double gsl_foo (double x);
5083 #ifdef HAVE_INLINE
5084 INLINE_FUN double gsl_foo (double x) { return x+1.0; } ;
5085 #endif
5086
5087*/
5088
5089#ifdef HAVE_INLINE
5090# if defined(__GNUC_STDC_INLINE__) || defined(GSL_C99_INLINE) || defined(HAVE_C99_INLINE)
5091# define INLINE_DECL inline /* use C99 inline */
5092# define INLINE_FUN inline
5093# else
5094# define INLINE_DECL /* use GNU extern inline */
5095# define INLINE_FUN extern inline
5096# endif
5097#else
5098# define INLINE_DECL /* */
5099#endif
5100
5101/* Range checking conditions in headers do not require any run-time
5102 tests of the global variable gsl_check_range. They are enabled or
5103 disabled in user code at compile time with GSL_RANGE_CHECK macro.
5104 See also build.h. */
5105#define GSL_RANGE_COND(x) (x)
5106
5107#endif /* __GSL_INLINE_H__ */
5108
5109/* end inlined header: gsl/gsl_inline.h */
5110
5111__BEGIN_DECLS
5112
5113INLINE_DECL double gsl_pow_2(const double x);
5114INLINE_DECL double gsl_pow_3(const double x);
5115INLINE_DECL double gsl_pow_4(const double x);
5116INLINE_DECL double gsl_pow_5(const double x);
5117INLINE_DECL double gsl_pow_6(const double x);
5118INLINE_DECL double gsl_pow_7(const double x);
5119INLINE_DECL double gsl_pow_8(const double x);
5120INLINE_DECL double gsl_pow_9(const double x);
5121
5122#ifdef HAVE_INLINE
5123INLINE_FUN double gsl_pow_2(const double x) { return x*x; }
5124INLINE_FUN double gsl_pow_3(const double x) { return x*x*x; }
5125INLINE_FUN double gsl_pow_4(const double x) { double x2 = x*x; return x2*x2; }
5126INLINE_FUN double gsl_pow_5(const double x) { double x2 = x*x; return x2*x2*x; }
5127INLINE_FUN double gsl_pow_6(const double x) { double x2 = x*x; return x2*x2*x2; }
5128INLINE_FUN double gsl_pow_7(const double x) { double x3 = x*x*x; return x3*x3*x; }
5129INLINE_FUN double gsl_pow_8(const double x) { double x2 = x*x; double x4 = x2*x2; return x4*x4; }
5130INLINE_FUN double gsl_pow_9(const double x) { double x3 = x*x*x; return x3*x3*x3; }
5131#endif
5132
5133double gsl_pow_int(double x, int n);
5134double gsl_pow_uint(double x, unsigned int n);
5135
5136__END_DECLS
5137
5138#endif /* __GSL_POW_INT_H__ */
5139
5140/* end inlined header: gsl/gsl_pow_int.h */
5141/* begin inlined header: gsl/gsl_minmax.h */
5142/* gsl_minmax.h
5143 *
5144 * Copyright (C) 2008 Gerard Jungman, Brian Gough
5145 *
5146 * This program is free software; you can redistribute it and/or modify
5147 * it under the terms of the GNU General Public License as published by
5148 * the Free Software Foundation; either version 3 of the License, or (at
5149 * your option) any later version.
5150 *
5151 * This program is distributed in the hope that it will be useful, but
5152 * WITHOUT ANY WARRANTY; without even the implied warranty of
5153 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5154 * General Public License for more details.
5155 *
5156 * You should have received a copy of the GNU General Public License
5157 * along with this program; if not, write to the Free Software
5158 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
5159 */
5160
5161#ifndef __GSL_MINMAX_H__
5162#define __GSL_MINMAX_H__
5163/* begin inlined header: gsl/gsl_inline.h */
5164/* gsl_inline.h
5165 *
5166 * Copyright (C) 2008, 2009 Brian Gough
5167 *
5168 * This program is free software; you can redistribute it and/or modify
5169 * it under the terms of the GNU General Public License as published by
5170 * the Free Software Foundation; either version 3 of the License, or (at
5171 * your option) any later version.
5172 *
5173 * This program is distributed in the hope that it will be useful, but
5174 * WITHOUT ANY WARRANTY; without even the implied warranty of
5175 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5176 * General Public License for more details.
5177 *
5178 * You should have received a copy of the GNU General Public License
5179 * along with this program; if not, write to the Free Software
5180 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
5181 */
5182
5183#ifndef __GSL_INLINE_H__
5184#define __GSL_INLINE_H__
5185
5186/* In recent versiions of GCC, the inline keyword has two different
5187 forms: GNU and C99.
5188
5189 In GNU mode we can use 'extern inline' to make inline functions
5190 work like macros. The function is only inlined--it is never output
5191 as a definition in an object file.
5192
5193 In the new C99 mode 'extern inline' has a different meaning--it
5194 causes the definition of the function to be output in each object
5195 file where it is used. This will result in multiple-definition
5196 errors on linking. The 'inline' keyword on its own (without
5197 extern) has the same behavior as the original GNU 'extern inline'.
5198
5199 The C99 style is the default with -std=c99 in GCC 4.3.
5200
5201 This header file allows either form of inline to be used by
5202 redefining the macros INLINE_DECL and INLINE_FUN. These are used
5203 in the public header files as
5204
5205 INLINE_DECL double gsl_foo (double x);
5206 #ifdef HAVE_INLINE
5207 INLINE_FUN double gsl_foo (double x) { return x+1.0; } ;
5208 #endif
5209
5210*/
5211
5212#ifdef HAVE_INLINE
5213# if defined(__GNUC_STDC_INLINE__) || defined(GSL_C99_INLINE) || defined(HAVE_C99_INLINE)
5214# define INLINE_DECL inline /* use C99 inline */
5215# define INLINE_FUN inline
5216# else
5217# define INLINE_DECL /* use GNU extern inline */
5218# define INLINE_FUN extern inline
5219# endif
5220#else
5221# define INLINE_DECL /* */
5222#endif
5223
5224/* Range checking conditions in headers do not require any run-time
5225 tests of the global variable gsl_check_range. They are enabled or
5226 disabled in user code at compile time with GSL_RANGE_CHECK macro.
5227 See also build.h. */
5228#define GSL_RANGE_COND(x) (x)
5229
5230#endif /* __GSL_INLINE_H__ */
5231
5232/* end inlined header: gsl/gsl_inline.h */
5233
5234__BEGIN_DECLS
5235
5236/* Define MAX and MIN macros/functions if they don't exist. */
5237
5238/* plain old macros for general use */
5239#define GSL_MAX(a,b) ((a) > (b) ? (a) : (b))
5240#define GSL_MIN(a,b) ((a) < (b) ? (a) : (b))
5241
5242/* function versions of the above, in case they are needed */
5243double gsl_max (double a, double b);
5244double gsl_min (double a, double b);
5245
5246/* inline-friendly strongly typed versions */
5247#ifdef HAVE_INLINE
5248
5249INLINE_FUN int GSL_MAX_INT (int a, int b);
5250INLINE_FUN int GSL_MIN_INT (int a, int b);
5251INLINE_FUN double GSL_MAX_DBL (double a, double b);
5252INLINE_FUN double GSL_MIN_DBL (double a, double b);
5253INLINE_FUN long double GSL_MAX_LDBL (long double a, long double b);
5254INLINE_FUN long double GSL_MIN_LDBL (long double a, long double b);
5255
5256INLINE_FUN int
5257GSL_MAX_INT (int a, int b)
5258{
5259 return GSL_MAX (a, b);
5260}
5261
5262INLINE_FUN int
5263GSL_MIN_INT (int a, int b)
5264{
5265 return GSL_MIN (a, b);
5266}
5267
5268INLINE_FUN double
5269GSL_MAX_DBL (double a, double b)
5270{
5271 return GSL_MAX (a, b);
5272}
5273
5274INLINE_FUN double
5275GSL_MIN_DBL (double a, double b)
5276{
5277 return GSL_MIN (a, b);
5278}
5279
5280INLINE_FUN long double
5281GSL_MAX_LDBL (long double a, long double b)
5282{
5283 return GSL_MAX (a, b);
5284}
5285
5286INLINE_FUN long double
5287GSL_MIN_LDBL (long double a, long double b)
5288{
5289 return GSL_MIN (a, b);
5290}
5291#else
5292#define GSL_MAX_INT(a,b) GSL_MAX(a,b)
5293#define GSL_MIN_INT(a,b) GSL_MIN(a,b)
5294#define GSL_MAX_DBL(a,b) GSL_MAX(a,b)
5295#define GSL_MIN_DBL(a,b) GSL_MIN(a,b)
5296#define GSL_MAX_LDBL(a,b) GSL_MAX(a,b)
5297#define GSL_MIN_LDBL(a,b) GSL_MIN(a,b)
5298#endif /* HAVE_INLINE */
5299
5300__END_DECLS
5301
5302#endif /* __GSL_POW_INT_H__ */
5303
5304/* end inlined header: gsl/gsl_minmax.h */
5305#ifndef M_E
5306#define M_E 2.71828182845904523536028747135 /* e */
5307#endif
5308
5309#ifndef M_LOG2E
5310#define M_LOG2E 1.44269504088896340735992468100 /* log_2 (e) */
5311#endif
5312
5313#ifndef M_LOG10E
5314#define M_LOG10E 0.43429448190325182765112891892 /* log_10 (e) */
5315#endif
5316
5317#ifndef M_SQRT2
5318#define M_SQRT2 1.41421356237309504880168872421 /* sqrt(2) */
5319#endif
5320
5321#ifndef M_SQRT1_2
5322#define M_SQRT1_2 0.70710678118654752440084436210 /* sqrt(1/2) */
5323#endif
5324
5325
5326#ifndef M_SQRT3
5327#define M_SQRT3 1.73205080756887729352744634151 /* sqrt(3) */
5328#endif
5329
5330#ifndef M_PI
5331#define M_PI 3.14159265358979323846264338328 /* pi */
5332#endif
5333
5334#ifndef M_PI_2
5335#define M_PI_2 1.57079632679489661923132169164 /* pi/2 */
5336#endif
5337
5338#ifndef M_PI_4
5339#define M_PI_4 0.78539816339744830961566084582 /* pi/4 */
5340#endif
5341
5342#ifndef M_SQRTPI
5343#define M_SQRTPI 1.77245385090551602729816748334 /* sqrt(pi) */
5344#endif
5345
5346#ifndef M_2_SQRTPI
5347#define M_2_SQRTPI 1.12837916709551257389615890312 /* 2/sqrt(pi) */
5348#endif
5349
5350#ifndef M_1_PI
5351#define M_1_PI 0.31830988618379067153776752675 /* 1/pi */
5352#endif
5353
5354#ifndef M_2_PI
5355#define M_2_PI 0.63661977236758134307553505349 /* 2/pi */
5356#endif
5357
5358#ifndef M_LN10
5359#define M_LN10 2.30258509299404568401799145468 /* ln(10) */
5360#endif
5361
5362#ifndef M_LN2
5363#define M_LN2 0.69314718055994530941723212146 /* ln(2) */
5364#endif
5365
5366#ifndef M_LNPI
5367#define M_LNPI 1.14472988584940017414342735135 /* ln(pi) */
5368#endif
5369
5370#ifndef M_EULER
5371#define M_EULER 0.57721566490153286060651209008 /* Euler constant */
5372#endif
5373
5374__BEGIN_DECLS
5375
5376/* other needlessly compulsive abstractions */
5377
5378#define GSL_IS_ODD(n) ((n) & 1)
5379#define GSL_IS_EVEN(n) (!(GSL_IS_ODD(n)))
5380#define GSL_SIGN(x) ((x) >= 0.0 ? 1 : -1)
5381
5382/* Return nonzero if x is a real number, i.e. non NaN or infinite. */
5383#define GSL_IS_REAL(x) (gsl_finite(x))
5384
5385/* Definition of an arbitrary function with parameters */
5386
5388{
5389 double (* function) (double x, void * params);
5390 void * params;
5391};
5392
5393typedef struct gsl_function_struct gsl_function ;
5394
5395#define GSL_FN_EVAL(F,x) (*((F)->function))(x,(F)->params)
5396
5397/* Definition of an arbitrary function returning two values, r1, r2 */
5398
5400{
5401 double (* f) (double x, void * params);
5402 double (* df) (double x, void * params);
5403 void (* fdf) (double x, void * params, double * f, double * df);
5404 void * params;
5405};
5406
5407typedef struct gsl_function_fdf_struct gsl_function_fdf ;
5408
5409#define GSL_FN_FDF_EVAL_F(FDF,x) (*((FDF)->f))(x,(FDF)->params)
5410#define GSL_FN_FDF_EVAL_DF(FDF,x) (*((FDF)->df))(x,(FDF)->params)
5411#define GSL_FN_FDF_EVAL_F_DF(FDF,x,y,dy) (*((FDF)->fdf))(x,(FDF)->params,(y),(dy))
5412
5413
5414/* Definition of an arbitrary vector-valued function with parameters */
5415
5417{
5418 int (* function) (double x, double y[], void * params);
5419 void * params;
5420};
5421
5422typedef struct gsl_function_vec_struct gsl_function_vec ;
5423
5424#define GSL_FN_VEC_EVAL(F,x,y) (*((F)->function))(x,y,(F)->params)
5425
5426__END_DECLS
5427
5428#endif /* __GSL_MATH_H__ */
5429
5430/* end inlined header: gsl/gsl_math.h */
5431/* begin inlined header: gsl/gsl_errno.h */
5432/* err/gsl_errno.h
5433 *
5434 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, Brian Gough
5435 *
5436 * This program is free software; you can redistribute it and/or modify
5437 * it under the terms of the GNU General Public License as published by
5438 * the Free Software Foundation; either version 3 of the License, or (at
5439 * your option) any later version.
5440 *
5441 * This program is distributed in the hope that it will be useful, but
5442 * WITHOUT ANY WARRANTY; without even the implied warranty of
5443 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5444 * General Public License for more details.
5445 *
5446 * You should have received a copy of the GNU General Public License
5447 * along with this program; if not, write to the Free Software
5448 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
5449 */
5450
5451#ifndef __GSL_ERRNO_H__
5452#define __GSL_ERRNO_H__
5453
5454#include <stdio.h>
5455#include <errno.h>
5456/* begin inlined header: gsl/gsl_types.h */
5457/* gsl_types.h
5458 *
5459 * Copyright (C) 2001, 2007 Brian Gough
5460 *
5461 * This program is free software; you can redistribute it and/or modify
5462 * it under the terms of the GNU General Public License as published by
5463 * the Free Software Foundation; either version 3 of the License, or (at
5464 * your option) any later version.
5465 *
5466 * This program is distributed in the hope that it will be useful, but
5467 * WITHOUT ANY WARRANTY; without even the implied warranty of
5468 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5469 * General Public License for more details.
5470 *
5471 * You should have received a copy of the GNU General Public License
5472 * along with this program; if not, write to the Free Software
5473 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
5474 */
5475
5476#ifndef __GSL_TYPES_H__
5477#define __GSL_TYPES_H__
5478
5479#ifndef GSL_VAR
5480
5481#ifdef WIN32
5482# ifdef GSL_DLL
5483# ifdef DLL_EXPORT
5484# define GSL_VAR extern __declspec(dllexport)
5485# else
5486# define GSL_VAR extern __declspec(dllimport)
5487# endif
5488# else
5489# define GSL_VAR extern
5490# endif
5491#else
5492# define GSL_VAR extern
5493#endif
5494
5495#endif
5496
5497#endif /* __GSL_TYPES_H__ */
5498
5499/* end inlined header: gsl/gsl_types.h */
5500
5501__BEGIN_DECLS
5502
5503enum {
5504 GSL_SUCCESS = 0,
5505 GSL_FAILURE = -1,
5506 GSL_CONTINUE = -2, /* iteration has not converged */
5507 GSL_EDOM = 1, /* input domain error, e.g sqrt(-1) */
5508 GSL_ERANGE = 2, /* output range error, e.g. exp(1e100) */
5509 GSL_EFAULT = 3, /* invalid pointer */
5510 GSL_EINVAL = 4, /* invalid argument supplied by user */
5511 GSL_EFAILED = 5, /* generic failure */
5512 GSL_EFACTOR = 6, /* factorization failed */
5513 GSL_ESANITY = 7, /* sanity check failed - shouldn't happen */
5514 GSL_ENOMEM = 8, /* malloc failed */
5515 GSL_EBADFUNC = 9, /* problem with user-supplied function */
5516 GSL_ERUNAWAY = 10, /* iterative process is out of control */
5517 GSL_EMAXITER = 11, /* exceeded max number of iterations */
5518 GSL_EZERODIV = 12, /* tried to divide by zero */
5519 GSL_EBADTOL = 13, /* user specified an invalid tolerance */
5520 GSL_ETOL = 14, /* failed to reach the specified tolerance */
5521 GSL_EUNDRFLW = 15, /* underflow */
5522 GSL_EOVRFLW = 16, /* overflow */
5523 GSL_ELOSS = 17, /* loss of accuracy */
5524 GSL_EROUND = 18, /* failed because of roundoff error */
5525 GSL_EBADLEN = 19, /* matrix, vector lengths are not conformant */
5526 GSL_ENOTSQR = 20, /* matrix not square */
5527 GSL_ESING = 21, /* apparent singularity detected */
5528 GSL_EDIVERGE = 22, /* integral or series is divergent */
5529 GSL_EUNSUP = 23, /* requested feature is not supported by the hardware */
5530 GSL_EUNIMPL = 24, /* requested feature not (yet) implemented */
5531 GSL_ECACHE = 25, /* cache limit exceeded */
5532 GSL_ETABLE = 26, /* table limit exceeded */
5533 GSL_ENOPROG = 27, /* iteration is not making progress towards solution */
5534 GSL_ENOPROGJ = 28, /* jacobian evaluations are not improving the solution */
5535 GSL_ETOLF = 29, /* cannot reach the specified tolerance in F */
5536 GSL_ETOLX = 30, /* cannot reach the specified tolerance in X */
5537 GSL_ETOLG = 31, /* cannot reach the specified tolerance in gradient */
5538 GSL_EOF = 32 /* end of file */
5539} ;
5540
5541void gsl_error (const char * reason, const char * file, int line,
5542 int gsl_errno);
5543
5544void gsl_stream_printf (const char *label, const char *file,
5545 int line, const char *reason);
5546
5547typedef void gsl_error_handler_t (const char * reason, const char * file,
5548 int line, int gsl_errno);
5549
5550gsl_error_handler_t *
5551gsl_set_error_handler (gsl_error_handler_t * new_handler);
5552
5553/* GSL_ERROR: call the error handler, and return the error code */
5554
5555#define GSL_ERROR(reason, gsl_errno) \
5556 do { \
5557 gsl_error (reason, __FILE__, __LINE__, gsl_errno) ; \
5558 return gsl_errno ; \
5559 } while (0)
5560
5561/* GSL_ERROR_VAL: call the error handler, and return the given value */
5562
5563#define GSL_ERROR_VAL(reason, gsl_errno, value) \
5564 do { \
5565 gsl_error (reason, __FILE__, __LINE__, gsl_errno) ; \
5566 return value ; \
5567 } while (0)
5568
5569/* GSL_ERROR_VOID: call the error handler, and then return
5570 (for void functions which still need to generate an error) */
5571
5572#define GSL_ERROR_VOID(reason, gsl_errno) \
5573 do { \
5574 gsl_error (reason, __FILE__, __LINE__, gsl_errno) ; \
5575 return ; \
5576 } while (0)
5577
5578/* GSL_ERROR_NULL suitable for out-of-memory conditions */
5579
5580#define GSL_ERROR_NULL(reason, gsl_errno) GSL_ERROR_VAL(reason, gsl_errno, 0)
5581
5582/* Sometimes you have several status results returned from
5583 * function calls and you want to combine them in some sensible
5584 * way. You cannot produce a "total" status condition, but you can
5585 * pick one from a set of conditions based on an implied hierarchy.
5586 *
5587 * In other words:
5588 * you have: status_a, status_b, ...
5589 * you want: status = (status_a if it is bad, or status_b if it is bad,...)
5590 *
5591 * In this example you consider status_a to be more important and
5592 * it is checked first, followed by the others in the order specified.
5593 *
5594 * Here are some dumb macros to do this.
5595 */
5596#define GSL_ERROR_SELECT_2(a,b) ((a) != GSL_SUCCESS ? (a) : ((b) != GSL_SUCCESS ? (b) : GSL_SUCCESS))
5597#define GSL_ERROR_SELECT_3(a,b,c) ((a) != GSL_SUCCESS ? (a) : GSL_ERROR_SELECT_2(b,c))
5598#define GSL_ERROR_SELECT_4(a,b,c,d) ((a) != GSL_SUCCESS ? (a) : GSL_ERROR_SELECT_3(b,c,d))
5599#define GSL_ERROR_SELECT_5(a,b,c,d,e) ((a) != GSL_SUCCESS ? (a) : GSL_ERROR_SELECT_4(b,c,d,e))
5600
5601#define GSL_STATUS_UPDATE(sp, s) do { if ((s) != GSL_SUCCESS) *(sp) = (s);} while(0)
5602
5603__END_DECLS
5604
5605#endif /* __GSL_ERRNO_H__ */
5606
5607/* end inlined header: gsl/gsl_errno.h */
5608/* begin inlined header: gsl/gsl_sf_log.h */
5609/* specfunc/gsl_sf_log.h
5610 *
5611 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2004 Gerard Jungman
5612 *
5613 * This program is free software; you can redistribute it and/or modify
5614 * it under the terms of the GNU General Public License as published by
5615 * the Free Software Foundation; either version 3 of the License, or (at
5616 * your option) any later version.
5617 *
5618 * This program is distributed in the hope that it will be useful, but
5619 * WITHOUT ANY WARRANTY; without even the implied warranty of
5620 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5621 * General Public License for more details.
5622 *
5623 * You should have received a copy of the GNU General Public License
5624 * along with this program; if not, write to the Free Software
5625 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
5626 */
5627
5628/* Author: G. Jungman */
5629
5630#ifndef __GSL_SF_LOG_H__
5631#define __GSL_SF_LOG_H__
5632/* begin inlined header: gsl/gsl_sf_result.h */
5633/* specfunc/gsl_sf_result.h
5634 *
5635 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
5636 *
5637 * This program is free software; you can redistribute it and/or modify
5638 * it under the terms of the GNU General Public License as published by
5639 * the Free Software Foundation; either version 3 of the License, or (at
5640 * your option) any later version.
5641 *
5642 * This program is distributed in the hope that it will be useful, but
5643 * WITHOUT ANY WARRANTY; without even the implied warranty of
5644 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5645 * General Public License for more details.
5646 *
5647 * You should have received a copy of the GNU General Public License
5648 * along with this program; if not, write to the Free Software
5649 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
5650 */
5651
5652/* Author: G. Jungman */
5653
5654#ifndef __GSL_SF_RESULT_H__
5655#define __GSL_SF_RESULT_H__
5656
5657__BEGIN_DECLS
5658
5660 double val;
5661 double err;
5662};
5663typedef struct gsl_sf_result_struct gsl_sf_result;
5664
5665#define GSL_SF_RESULT_SET(r,v,e) do { (r)->val=(v); (r)->err=(e); } while(0)
5666
5667
5669 double val;
5670 double err;
5671 int e10;
5672};
5673typedef struct gsl_sf_result_e10_struct gsl_sf_result_e10;
5674
5675
5676int gsl_sf_result_smash_e(const gsl_sf_result_e10 * re, gsl_sf_result * r);
5677
5678
5679__END_DECLS
5680
5681#endif /* __GSL_SF_RESULT_H__ */
5682
5683/* end inlined header: gsl/gsl_sf_result.h */
5684
5685__BEGIN_DECLS
5686
5687
5688/* Provide a logarithm function with GSL semantics.
5689 *
5690 * exceptions: GSL_EDOM
5691 */
5692int gsl_sf_log_e(const double x, gsl_sf_result * result);
5693double gsl_sf_log(const double x);
5694
5695
5696/* Log(|x|)
5697 *
5698 * exceptions: GSL_EDOM
5699 */
5700int gsl_sf_log_abs_e(const double x, gsl_sf_result * result);
5701double gsl_sf_log_abs(const double x);
5702
5703
5704/* Complex Logarithm
5705 * exp(lnr + I theta) = zr + I zi
5706 * Returns argument in [-pi,pi].
5707 *
5708 * exceptions: GSL_EDOM
5709 */
5710int gsl_sf_complex_log_e(const double zr, const double zi, gsl_sf_result * lnr, gsl_sf_result * theta);
5711
5712
5713/* Log(1 + x)
5714 *
5715 * exceptions: GSL_EDOM
5716 */
5717int gsl_sf_log_1plusx_e(const double x, gsl_sf_result * result);
5718double gsl_sf_log_1plusx(const double x);
5719
5720
5721/* Log(1 + x) - x
5722 *
5723 * exceptions: GSL_EDOM
5724 */
5725int gsl_sf_log_1plusx_mx_e(const double x, gsl_sf_result * result);
5726double gsl_sf_log_1plusx_mx(const double x);
5727
5728__END_DECLS
5729
5730#endif /* __GSL_SF_LOG_H__ */
5731
5732/* end inlined header: gsl/gsl_sf_log.h */
5733/* inlined: error.h */
5734
5735/* inlined: chebyshev.h */
5736/* begin inlined source: specfunc/cheb_eval.c */
5737
5738#ifndef MARLEY_BUILTIN_GSL_CHEB_EVAL_C
5739#define MARLEY_BUILTIN_GSL_CHEB_EVAL_C
5740
5741static inline int
5742cheb_eval_e(const cheb_series * cs,
5743 const double x,
5744 gsl_sf_result * result)
5745{
5746 int j;
5747 double d = 0.0;
5748 double dd = 0.0;
5749
5750 double y = (2.0*x - cs->a - cs->b) / (cs->b - cs->a);
5751 double y2 = 2.0 * y;
5752
5753 double e = 0.0;
5754
5755 for(j = cs->order; j>=1; j--) {
5756 double temp = d;
5757 d = y2*d - dd + cs->c[j];
5758 e += fabs(y2*temp) + fabs(dd) + fabs(cs->c[j]);
5759 dd = temp;
5760 }
5761
5762 {
5763 double temp = d;
5764 d = y*d - dd + 0.5 * cs->c[0];
5765 e += fabs(y*temp) + fabs(dd) + 0.5 * fabs(cs->c[0]);
5766 }
5767
5768 result->val = d;
5769 result->err = GSL_DBL_EPSILON * e + fabs(cs->c[cs->order]);
5770
5771 return GSL_SUCCESS;
5772}
5773
5774#endif /* MARLEY_BUILTIN_GSL_CHEB_EVAL_C */
5775/* end inlined source: specfunc/cheb_eval.c */
5776
5777/*-*-*-*-*-*-*-*-*-*-*-* Private Section *-*-*-*-*-*-*-*-*-*-*-*/
5778
5779/* Chebyshev expansion for log(1 + x(t))/x(t)
5780 *
5781 * x(t) = (4t-1)/(2(4-t))
5782 * t(x) = (8x+1)/(2(x+2))
5783 * -1/2 < x < 1/2
5784 * -1 < t < 1
5785 */
5786static double lopx_data[21] = {
5787 2.16647910664395270521272590407,
5788 -0.28565398551049742084877469679,
5789 0.01517767255690553732382488171,
5790 -0.00200215904941415466274422081,
5791 0.00019211375164056698287947962,
5792 -0.00002553258886105542567601400,
5793 2.9004512660400621301999384544e-06,
5794 -3.8873813517057343800270917900e-07,
5795 4.7743678729400456026672697926e-08,
5796 -6.4501969776090319441714445454e-09,
5797 8.2751976628812389601561347296e-10,
5798 -1.1260499376492049411710290413e-10,
5799 1.4844576692270934446023686322e-11,
5800 -2.0328515972462118942821556033e-12,
5801 2.7291231220549214896095654769e-13,
5802 -3.7581977830387938294437434651e-14,
5803 5.1107345870861673561462339876e-15,
5804 -7.0722150011433276578323272272e-16,
5805 9.7089758328248469219003866867e-17,
5806 -1.3492637457521938883731579510e-17,
5807 1.8657327910677296608121390705e-18
5808};
5809static cheb_series lopx_cs = {
5810 lopx_data,
5811 20,
5812 -1, 1,
5813 10
5814};
5815
5816/* Chebyshev expansion for (log(1 + x(t)) - x(t))/x(t)^2
5817 *
5818 * x(t) = (4t-1)/(2(4-t))
5819 * t(x) = (8x+1)/(2(x+2))
5820 * -1/2 < x < 1/2
5821 * -1 < t < 1
5822 */
5823static double lopxmx_data[20] = {
5824 -1.12100231323744103373737274541,
5825 0.19553462773379386241549597019,
5826 -0.01467470453808083971825344956,
5827 0.00166678250474365477643629067,
5828 -0.00018543356147700369785746902,
5829 0.00002280154021771635036301071,
5830 -2.8031253116633521699214134172e-06,
5831 3.5936568872522162983669541401e-07,
5832 -4.6241857041062060284381167925e-08,
5833 6.0822637459403991012451054971e-09,
5834 -8.0339824424815790302621320732e-10,
5835 1.0751718277499375044851551587e-10,
5836 -1.4445310914224613448759230882e-11,
5837 1.9573912180610336168921438426e-12,
5838 -2.6614436796793061741564104510e-13,
5839 3.6402634315269586532158344584e-14,
5840 -4.9937495922755006545809120531e-15,
5841 6.8802890218846809524646902703e-16,
5842 -9.5034129794804273611403251480e-17,
5843 1.3170135013050997157326965813e-17
5844};
5845static cheb_series lopxmx_cs = {
5846 lopxmx_data,
5847 19,
5848 -1, 1,
5849 9
5850};
5851
5852
5853/*-*-*-*-*-*-*-*-*-*-*-* Functions with Error Codes *-*-*-*-*-*-*-*-*-*-*-*/
5854
5855int
5856gsl_sf_log_e(const double x, gsl_sf_result * result)
5857{
5858 /* CHECK_POINTER(result) */
5859
5860 if(x <= 0.0) {
5861 DOMAIN_ERROR(result);
5862 }
5863 else {
5864 result->val = log(x);
5865 result->err = 2.0 * GSL_DBL_EPSILON * fabs(result->val);
5866 return GSL_SUCCESS;
5867 }
5868}
5869
5870
5871int
5872gsl_sf_log_abs_e(const double x, gsl_sf_result * result)
5873{
5874 /* CHECK_POINTER(result) */
5875
5876 if(x == 0.0) {
5877 DOMAIN_ERROR(result);
5878 }
5879 else {
5880 result->val = log(fabs(x));
5881 result->err = 2.0 * GSL_DBL_EPSILON * fabs(result->val);
5882 return GSL_SUCCESS;
5883 }
5884}
5885
5886int
5887gsl_sf_complex_log_e(const double zr, const double zi, gsl_sf_result * lnr, gsl_sf_result * theta)
5888{
5889 /* CHECK_POINTER(lnr) */
5890 /* CHECK_POINTER(theta) */
5891
5892 if(zr != 0.0 || zi != 0.0) {
5893 const double ax = fabs(zr);
5894 const double ay = fabs(zi);
5895 const double min = GSL_MIN(ax, ay);
5896 const double max = GSL_MAX(ax, ay);
5897 lnr->val = log(max) + 0.5 * log(1.0 + (min/max)*(min/max));
5898 lnr->err = 2.0 * GSL_DBL_EPSILON * fabs(lnr->val);
5899 theta->val = atan2(zi, zr);
5900 theta->err = GSL_DBL_EPSILON * fabs(lnr->val);
5901 return GSL_SUCCESS;
5902 }
5903 else {
5904 DOMAIN_ERROR_2(lnr, theta);
5905 }
5906}
5907
5908
5909int
5910gsl_sf_log_1plusx_e(const double x, gsl_sf_result * result)
5911{
5912 /* CHECK_POINTER(result) */
5913
5914 if(x <= -1.0) {
5915 DOMAIN_ERROR(result);
5916 }
5917 else if(fabs(x) < GSL_ROOT6_DBL_EPSILON) {
5918 const double c1 = -0.5;
5919 const double c2 = 1.0/3.0;
5920 const double c3 = -1.0/4.0;
5921 const double c4 = 1.0/5.0;
5922 const double c5 = -1.0/6.0;
5923 const double c6 = 1.0/7.0;
5924 const double c7 = -1.0/8.0;
5925 const double c8 = 1.0/9.0;
5926 const double c9 = -1.0/10.0;
5927 const double t = c5 + x*(c6 + x*(c7 + x*(c8 + x*c9)));
5928 result->val = x * (1.0 + x*(c1 + x*(c2 + x*(c3 + x*(c4 + x*t)))));
5929 result->err = GSL_DBL_EPSILON * fabs(result->val);
5930 return GSL_SUCCESS;
5931 }
5932 else if(fabs(x) < 0.5) {
5933 double t = 0.5*(8.0*x + 1.0)/(x+2.0);
5934 gsl_sf_result c;
5935 cheb_eval_e(&lopx_cs, t, &c);
5936 result->val = x * c.val;
5937 result->err = fabs(x * c.err);
5938 return GSL_SUCCESS;
5939 }
5940 else {
5941 result->val = log(1.0 + x);
5942 result->err = GSL_DBL_EPSILON * fabs(result->val);
5943 return GSL_SUCCESS;
5944 }
5945}
5946
5947
5948int
5949gsl_sf_log_1plusx_mx_e(const double x, gsl_sf_result * result)
5950{
5951 /* CHECK_POINTER(result) */
5952
5953 if(x <= -1.0) {
5954 DOMAIN_ERROR(result);
5955 }
5956 else if(fabs(x) < GSL_ROOT5_DBL_EPSILON) {
5957 const double c1 = -0.5;
5958 const double c2 = 1.0/3.0;
5959 const double c3 = -1.0/4.0;
5960 const double c4 = 1.0/5.0;
5961 const double c5 = -1.0/6.0;
5962 const double c6 = 1.0/7.0;
5963 const double c7 = -1.0/8.0;
5964 const double c8 = 1.0/9.0;
5965 const double c9 = -1.0/10.0;
5966 const double t = c5 + x*(c6 + x*(c7 + x*(c8 + x*c9)));
5967 result->val = x*x * (c1 + x*(c2 + x*(c3 + x*(c4 + x*t))));
5968 result->err = GSL_DBL_EPSILON * fabs(result->val);
5969 return GSL_SUCCESS;
5970 }
5971 else if(fabs(x) < 0.5) {
5972 double t = 0.5*(8.0*x + 1.0)/(x+2.0);
5973 gsl_sf_result c;
5974 cheb_eval_e(&lopxmx_cs, t, &c);
5975 result->val = x*x * c.val;
5976 result->err = x*x * c.err;
5977 return GSL_SUCCESS;
5978 }
5979 else {
5980 const double lterm = log(1.0 + x);
5981 result->val = lterm - x;
5982 result->err = GSL_DBL_EPSILON * (fabs(lterm) + fabs(x));
5983 return GSL_SUCCESS;
5984 }
5985}
5986
5987
5988
5989/*-*-*-*-*-*-*-*-*-* Functions w/ Natural Prototypes *-*-*-*-*-*-*-*-*-*-*/
5990
5991/* inlined: eval.h */
5992
5993double gsl_sf_log(const double x)
5994{
5995 EVAL_RESULT(gsl_sf_log_e(x, &result));
5996}
5997
5998double gsl_sf_log_abs(const double x)
5999{
6000 EVAL_RESULT(gsl_sf_log_abs_e(x, &result));
6001}
6002
6003double gsl_sf_log_1plusx(const double x)
6004{
6005 EVAL_RESULT(gsl_sf_log_1plusx_e(x, &result));
6006}
6007
6008double gsl_sf_log_1plusx_mx(const double x)
6009{
6010 EVAL_RESULT(gsl_sf_log_1plusx_mx_e(x, &result));
6011}
6012/* end inlined source: specfunc/log.c */
6013/* begin inlined source: specfunc/trig.c */
6014/* specfunc/trig.c
6015 *
6016 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
6017 *
6018 * This program is free software; you can redistribute it and/or modify
6019 * it under the terms of the GNU General Public License as published by
6020 * the Free Software Foundation; either version 3 of the License, or (at
6021 * your option) any later version.
6022 *
6023 * This program is distributed in the hope that it will be useful, but
6024 * WITHOUT ANY WARRANTY; without even the implied warranty of
6025 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
6026 * General Public License for more details.
6027 *
6028 * You should have received a copy of the GNU General Public License
6029 * along with this program; if not, write to the Free Software
6030 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
6031 */
6032
6033/* Author: G. Jungman */
6034/* begin inlined header: config.h */
6035#ifndef MARLEY_BUILTIN_GSL_CONFIG_WRAPPER_H
6036#define MARLEY_BUILTIN_GSL_CONFIG_WRAPPER_H
6037/* begin inlined header: gsl_config.h */
6038#ifndef MARLEY_BUILTIN_GSL_CONFIG_H
6039#define MARLEY_BUILTIN_GSL_CONFIG_H
6040
6041#define HAVE_INLINE 1
6042#define HAVE_DECL_ISFINITE 1
6043#define HAVE_DECL_ISNAN 1
6044#define HAVE_DECL_ISINF 1
6045#define GSL_COERCE_DBL(x) (x)
6046
6047#define GSL_DISABLE_DEPRECATED 0
6048#define PACKAGE_VERSION "2.8"
6049#define VERSION "2.8"
6050
6051#endif
6052
6053/* end inlined header: gsl_config.h */
6054#endif
6055
6056/* end inlined header: config.h */
6057/* begin inlined header: gsl/gsl_math.h */
6058/* gsl_math.h
6059 *
6060 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2004, 2007 Gerard Jungman, Brian Gough
6061 *
6062 * This program is free software; you can redistribute it and/or modify
6063 * it under the terms of the GNU General Public License as published by
6064 * the Free Software Foundation; either version 3 of the License, or (at
6065 * your option) any later version.
6066 *
6067 * This program is distributed in the hope that it will be useful, but
6068 * WITHOUT ANY WARRANTY; without even the implied warranty of
6069 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
6070 * General Public License for more details.
6071 *
6072 * You should have received a copy of the GNU General Public License
6073 * along with this program; if not, write to the Free Software
6074 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
6075 */
6076
6077#ifndef __GSL_MATH_H__
6078#define __GSL_MATH_H__
6079#include <math.h>
6080/* begin inlined header: gsl/gsl_sys.h */
6081/* sys/gsl_sys.h
6082 *
6083 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, Brian Gough
6084 *
6085 * This program is free software; you can redistribute it and/or modify
6086 * it under the terms of the GNU General Public License as published by
6087 * the Free Software Foundation; either version 3 of the License, or (at
6088 * your option) any later version.
6089 *
6090 * This program is distributed in the hope that it will be useful, but
6091 * WITHOUT ANY WARRANTY; without even the implied warranty of
6092 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
6093 * General Public License for more details.
6094 *
6095 * You should have received a copy of the GNU General Public License
6096 * along with this program; if not, write to the Free Software
6097 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
6098 */
6099
6100#ifndef __GSL_SYS_H__
6101#define __GSL_SYS_H__
6102
6103__BEGIN_DECLS
6104
6105double gsl_log1p (const double x);
6106double gsl_expm1 (const double x);
6107double gsl_hypot (const double x, const double y);
6108double gsl_hypot3 (const double x, const double y, const double z);
6109double gsl_acosh (const double x);
6110double gsl_asinh (const double x);
6111double gsl_atanh (const double x);
6112
6113int gsl_isnan (const double x);
6114int gsl_isinf (const double x);
6115int gsl_finite (const double x);
6116
6117double gsl_nan (void);
6118double gsl_posinf (void);
6119double gsl_neginf (void);
6120double gsl_fdiv (const double x, const double y);
6121
6122double gsl_coerce_double (const double x);
6123float gsl_coerce_float (const float x);
6124long double gsl_coerce_long_double (const long double x);
6125
6126double gsl_ldexp(const double x, const int e);
6127double gsl_frexp(const double x, int * e);
6128
6129int gsl_fcmp (const double x1, const double x2, const double epsilon);
6130
6131__END_DECLS
6132
6133#endif /* __GSL_SYS_H__ */
6134
6135/* end inlined header: gsl/gsl_sys.h */
6136/* begin inlined header: gsl/gsl_inline.h */
6137/* gsl_inline.h
6138 *
6139 * Copyright (C) 2008, 2009 Brian Gough
6140 *
6141 * This program is free software; you can redistribute it and/or modify
6142 * it under the terms of the GNU General Public License as published by
6143 * the Free Software Foundation; either version 3 of the License, or (at
6144 * your option) any later version.
6145 *
6146 * This program is distributed in the hope that it will be useful, but
6147 * WITHOUT ANY WARRANTY; without even the implied warranty of
6148 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
6149 * General Public License for more details.
6150 *
6151 * You should have received a copy of the GNU General Public License
6152 * along with this program; if not, write to the Free Software
6153 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
6154 */
6155
6156#ifndef __GSL_INLINE_H__
6157#define __GSL_INLINE_H__
6158
6159/* In recent versiions of GCC, the inline keyword has two different
6160 forms: GNU and C99.
6161
6162 In GNU mode we can use 'extern inline' to make inline functions
6163 work like macros. The function is only inlined--it is never output
6164 as a definition in an object file.
6165
6166 In the new C99 mode 'extern inline' has a different meaning--it
6167 causes the definition of the function to be output in each object
6168 file where it is used. This will result in multiple-definition
6169 errors on linking. The 'inline' keyword on its own (without
6170 extern) has the same behavior as the original GNU 'extern inline'.
6171
6172 The C99 style is the default with -std=c99 in GCC 4.3.
6173
6174 This header file allows either form of inline to be used by
6175 redefining the macros INLINE_DECL and INLINE_FUN. These are used
6176 in the public header files as
6177
6178 INLINE_DECL double gsl_foo (double x);
6179 #ifdef HAVE_INLINE
6180 INLINE_FUN double gsl_foo (double x) { return x+1.0; } ;
6181 #endif
6182
6183*/
6184
6185#ifdef HAVE_INLINE
6186# if defined(__GNUC_STDC_INLINE__) || defined(GSL_C99_INLINE) || defined(HAVE_C99_INLINE)
6187# define INLINE_DECL inline /* use C99 inline */
6188# define INLINE_FUN inline
6189# else
6190# define INLINE_DECL /* use GNU extern inline */
6191# define INLINE_FUN extern inline
6192# endif
6193#else
6194# define INLINE_DECL /* */
6195#endif
6196
6197/* Range checking conditions in headers do not require any run-time
6198 tests of the global variable gsl_check_range. They are enabled or
6199 disabled in user code at compile time with GSL_RANGE_CHECK macro.
6200 See also build.h. */
6201#define GSL_RANGE_COND(x) (x)
6202
6203#endif /* __GSL_INLINE_H__ */
6204
6205/* end inlined header: gsl/gsl_inline.h */
6206/* begin inlined header: gsl/gsl_machine.h */
6207/* Author: B. Gough and G. Jungman */
6208#ifndef __GSL_MACHINE_H__
6209#define __GSL_MACHINE_H__
6210
6211#include <limits.h>
6212#include <float.h>
6213
6214/* magic constants; mostly for the benefit of the implementation */
6215
6216/* -*-MACHINE CONSTANTS-*-
6217 *
6218 * PLATFORM: Whiz-O-Matic 9000
6219 * FP_PLATFORM: IEEE-Virtual
6220 * HOSTNAME: nnn.lanl.gov
6221 * DATE: Fri Nov 20 17:53:26 MST 1998
6222 */
6223#define GSL_DBL_EPSILON 2.2204460492503131e-16
6224#define GSL_SQRT_DBL_EPSILON 1.4901161193847656e-08
6225#define GSL_ROOT3_DBL_EPSILON 6.0554544523933429e-06
6226#define GSL_ROOT4_DBL_EPSILON 1.2207031250000000e-04
6227#define GSL_ROOT5_DBL_EPSILON 7.4009597974140505e-04
6228#define GSL_ROOT6_DBL_EPSILON 2.4607833005759251e-03
6229#define GSL_LOG_DBL_EPSILON (-3.6043653389117154e+01)
6230
6231#define GSL_DBL_MIN 2.2250738585072014e-308
6232#define GSL_SQRT_DBL_MIN 1.4916681462400413e-154
6233#define GSL_ROOT3_DBL_MIN 2.8126442852362996e-103
6234#define GSL_ROOT4_DBL_MIN 1.2213386697554620e-77
6235#define GSL_ROOT5_DBL_MIN 2.9476022969691763e-62
6236#define GSL_ROOT6_DBL_MIN 5.3034368905798218e-52
6237#define GSL_LOG_DBL_MIN (-7.0839641853226408e+02)
6238
6239#define GSL_DBL_MAX 1.7976931348623157e+308
6240#define GSL_SQRT_DBL_MAX 1.3407807929942596e+154
6241#define GSL_ROOT3_DBL_MAX 5.6438030941222897e+102
6242#define GSL_ROOT4_DBL_MAX 1.1579208923731620e+77
6243#define GSL_ROOT5_DBL_MAX 4.4765466227572707e+61
6244#define GSL_ROOT6_DBL_MAX 2.3756689782295612e+51
6245#define GSL_LOG_DBL_MAX 7.0978271289338397e+02
6246
6247#define GSL_FLT_EPSILON 1.1920928955078125e-07
6248#define GSL_SQRT_FLT_EPSILON 3.4526698300124393e-04
6249#define GSL_ROOT3_FLT_EPSILON 4.9215666011518501e-03
6250#define GSL_ROOT4_FLT_EPSILON 1.8581361171917516e-02
6251#define GSL_ROOT5_FLT_EPSILON 4.1234622211652937e-02
6252#define GSL_ROOT6_FLT_EPSILON 7.0153878019335827e-02
6253#define GSL_LOG_FLT_EPSILON (-1.5942385152878742e+01)
6254
6255#define GSL_FLT_MIN 1.1754943508222875e-38
6256#define GSL_SQRT_FLT_MIN 1.0842021724855044e-19
6257#define GSL_ROOT3_FLT_MIN 2.2737367544323241e-13
6258#define GSL_ROOT4_FLT_MIN 3.2927225399135965e-10
6259#define GSL_ROOT5_FLT_MIN 2.5944428542140822e-08
6260#define GSL_ROOT6_FLT_MIN 4.7683715820312542e-07
6261#define GSL_LOG_FLT_MIN (-8.7336544750553102e+01)
6262
6263#define GSL_FLT_MAX 3.4028234663852886e+38
6264#define GSL_SQRT_FLT_MAX 1.8446743523953730e+19
6265#define GSL_ROOT3_FLT_MAX 6.9814635196223242e+12
6266#define GSL_ROOT4_FLT_MAX 4.2949672319999986e+09
6267#define GSL_ROOT5_FLT_MAX 5.0859007855960041e+07
6268#define GSL_ROOT6_FLT_MAX 2.6422459233807749e+06
6269#define GSL_LOG_FLT_MAX 8.8722839052068352e+01
6270
6271#define GSL_SFLT_EPSILON 4.8828125000000000e-04
6272#define GSL_SQRT_SFLT_EPSILON 2.2097086912079612e-02
6273#define GSL_ROOT3_SFLT_EPSILON 7.8745065618429588e-02
6274#define GSL_ROOT4_SFLT_EPSILON 1.4865088937534013e-01
6275#define GSL_ROOT5_SFLT_EPSILON 2.1763764082403100e-01
6276#define GSL_ROOT6_SFLT_EPSILON 2.8061551207734325e-01
6277#define GSL_LOG_SFLT_EPSILON (-7.6246189861593985e+00)
6278
6279/* !MACHINE CONSTANTS! */
6280
6281
6282/* a little internal backwards compatibility */
6283#define GSL_MACH_EPS GSL_DBL_EPSILON
6284
6285
6286
6287/* Here are the constants related to or derived from
6288 * machine constants. These are not to be confused with
6289 * the constants that define various precision levels
6290 * for the precision/error system.
6291 *
6292 * This information is determined at configure time
6293 * and is platform dependent. Edit at your own risk.
6294 *
6295 * PLATFORM: WHIZ-O-MATIC
6296 * CONFIG-DATE: Thu Nov 19 19:27:18 MST 1998
6297 * CONFIG-HOST: nnn.lanl.gov
6298 */
6299
6300/* machine precision constants */
6301/* #define GSL_MACH_EPS 1.0e-15 */
6302#define GSL_SQRT_MACH_EPS 3.2e-08
6303#define GSL_ROOT3_MACH_EPS 1.0e-05
6304#define GSL_ROOT4_MACH_EPS 0.000178
6305#define GSL_ROOT5_MACH_EPS 0.00100
6306#define GSL_ROOT6_MACH_EPS 0.00316
6307#define GSL_LOG_MACH_EPS (-34.54)
6308
6309
6310#endif /* __GSL_MACHINE_H__ */
6311
6312/* end inlined header: gsl/gsl_machine.h */
6313/* begin inlined header: gsl/gsl_precision.h */
6314/* gsl_precision.h
6315 *
6316 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
6317 *
6318 * This program is free software; you can redistribute it and/or modify
6319 * it under the terms of the GNU General Public License as published by
6320 * the Free Software Foundation; either version 3 of the License, or (at
6321 * your option) any later version.
6322 *
6323 * This program is distributed in the hope that it will be useful, but
6324 * WITHOUT ANY WARRANTY; without even the implied warranty of
6325 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
6326 * General Public License for more details.
6327 *
6328 * You should have received a copy of the GNU General Public License
6329 * along with this program; if not, write to the Free Software
6330 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
6331 */
6332
6333/* Author: B. Gough and G. Jungman */
6334
6335#ifndef __GSL_PRECISION_H__
6336#define __GSL_PRECISION_H__
6337/* begin inlined header: gsl/gsl_types.h */
6338/* gsl_types.h
6339 *
6340 * Copyright (C) 2001, 2007 Brian Gough
6341 *
6342 * This program is free software; you can redistribute it and/or modify
6343 * it under the terms of the GNU General Public License as published by
6344 * the Free Software Foundation; either version 3 of the License, or (at
6345 * your option) any later version.
6346 *
6347 * This program is distributed in the hope that it will be useful, but
6348 * WITHOUT ANY WARRANTY; without even the implied warranty of
6349 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
6350 * General Public License for more details.
6351 *
6352 * You should have received a copy of the GNU General Public License
6353 * along with this program; if not, write to the Free Software
6354 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
6355 */
6356
6357#ifndef __GSL_TYPES_H__
6358#define __GSL_TYPES_H__
6359
6360#ifndef GSL_VAR
6361
6362#ifdef WIN32
6363# ifdef GSL_DLL
6364# ifdef DLL_EXPORT
6365# define GSL_VAR extern __declspec(dllexport)
6366# else
6367# define GSL_VAR extern __declspec(dllimport)
6368# endif
6369# else
6370# define GSL_VAR extern
6371# endif
6372#else
6373# define GSL_VAR extern
6374#endif
6375
6376#endif
6377
6378#endif /* __GSL_TYPES_H__ */
6379
6380/* end inlined header: gsl/gsl_types.h */
6381
6382__BEGIN_DECLS
6383
6384
6385/* A type for the precision indicator.
6386 * This is mainly for pedagogy.
6387 */
6388typedef unsigned int gsl_prec_t;
6389
6390
6391/* The number of precision types.
6392 * Remember that precision-mode
6393 * can index an array.
6394 */
6395#define _GSL_PREC_T_NUM 3
6396
6397
6398/* Arrays containing derived
6399 * precision constants for the
6400 * different precision levels.
6401 */
6402GSL_VAR const double gsl_prec_eps[];
6403GSL_VAR const double gsl_prec_sqrt_eps[];
6404GSL_VAR const double gsl_prec_root3_eps[];
6405GSL_VAR const double gsl_prec_root4_eps[];
6406GSL_VAR const double gsl_prec_root5_eps[];
6407GSL_VAR const double gsl_prec_root6_eps[];
6408
6409
6410__END_DECLS
6411
6412#endif /* __GSL_PRECISION_H__ */
6413
6414/* end inlined header: gsl/gsl_precision.h */
6415/* begin inlined header: gsl/gsl_nan.h */
6416/* gsl_nan.h
6417 *
6418 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, Brian Gough
6419 *
6420 * This program is free software; you can redistribute it and/or modify
6421 * it under the terms of the GNU General Public License as published by
6422 * the Free Software Foundation; either version 3 of the License, or (at
6423 * your option) any later version.
6424 *
6425 * This program is distributed in the hope that it will be useful, but
6426 * WITHOUT ANY WARRANTY; without even the implied warranty of
6427 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
6428 * General Public License for more details.
6429 *
6430 * You should have received a copy of the GNU General Public License
6431 * along with this program; if not, write to the Free Software
6432 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
6433 */
6434
6435#ifndef __GSL_NAN_H__
6436#define __GSL_NAN_H__
6437
6438#ifdef INFINITY
6439# define GSL_POSINF INFINITY
6440# define GSL_NEGINF (-INFINITY)
6441#elif defined(HUGE_VAL)
6442# define GSL_POSINF HUGE_VAL
6443# define GSL_NEGINF (-HUGE_VAL)
6444#else
6445# define GSL_POSINF (gsl_posinf())
6446# define GSL_NEGINF (gsl_neginf())
6447#endif
6448
6449#ifdef NAN
6450# define GSL_NAN NAN
6451#elif defined(INFINITY)
6452# define GSL_NAN (INFINITY/INFINITY)
6453#else
6454# define GSL_NAN (gsl_nan())
6455#endif
6456
6457#define GSL_POSZERO (+0.0)
6458#define GSL_NEGZERO (-0.0)
6459
6460#endif /* __GSL_NAN_H__ */
6461
6462/* end inlined header: gsl/gsl_nan.h */
6463/* begin inlined header: gsl/gsl_pow_int.h */
6464/* gsl_pow_int.h
6465 *
6466 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2004, 2007 Gerard Jungman, Brian Gough
6467 *
6468 * This program is free software; you can redistribute it and/or modify
6469 * it under the terms of the GNU General Public License as published by
6470 * the Free Software Foundation; either version 3 of the License, or (at
6471 * your option) any later version.
6472 *
6473 * This program is distributed in the hope that it will be useful, but
6474 * WITHOUT ANY WARRANTY; without even the implied warranty of
6475 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
6476 * General Public License for more details.
6477 *
6478 * You should have received a copy of the GNU General Public License
6479 * along with this program; if not, write to the Free Software
6480 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
6481 */
6482
6483#ifndef __GSL_POW_INT_H__
6484#define __GSL_POW_INT_H__
6485/* begin inlined header: gsl/gsl_inline.h */
6486/* gsl_inline.h
6487 *
6488 * Copyright (C) 2008, 2009 Brian Gough
6489 *
6490 * This program is free software; you can redistribute it and/or modify
6491 * it under the terms of the GNU General Public License as published by
6492 * the Free Software Foundation; either version 3 of the License, or (at
6493 * your option) any later version.
6494 *
6495 * This program is distributed in the hope that it will be useful, but
6496 * WITHOUT ANY WARRANTY; without even the implied warranty of
6497 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
6498 * General Public License for more details.
6499 *
6500 * You should have received a copy of the GNU General Public License
6501 * along with this program; if not, write to the Free Software
6502 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
6503 */
6504
6505#ifndef __GSL_INLINE_H__
6506#define __GSL_INLINE_H__
6507
6508/* In recent versiions of GCC, the inline keyword has two different
6509 forms: GNU and C99.
6510
6511 In GNU mode we can use 'extern inline' to make inline functions
6512 work like macros. The function is only inlined--it is never output
6513 as a definition in an object file.
6514
6515 In the new C99 mode 'extern inline' has a different meaning--it
6516 causes the definition of the function to be output in each object
6517 file where it is used. This will result in multiple-definition
6518 errors on linking. The 'inline' keyword on its own (without
6519 extern) has the same behavior as the original GNU 'extern inline'.
6520
6521 The C99 style is the default with -std=c99 in GCC 4.3.
6522
6523 This header file allows either form of inline to be used by
6524 redefining the macros INLINE_DECL and INLINE_FUN. These are used
6525 in the public header files as
6526
6527 INLINE_DECL double gsl_foo (double x);
6528 #ifdef HAVE_INLINE
6529 INLINE_FUN double gsl_foo (double x) { return x+1.0; } ;
6530 #endif
6531
6532*/
6533
6534#ifdef HAVE_INLINE
6535# if defined(__GNUC_STDC_INLINE__) || defined(GSL_C99_INLINE) || defined(HAVE_C99_INLINE)
6536# define INLINE_DECL inline /* use C99 inline */
6537# define INLINE_FUN inline
6538# else
6539# define INLINE_DECL /* use GNU extern inline */
6540# define INLINE_FUN extern inline
6541# endif
6542#else
6543# define INLINE_DECL /* */
6544#endif
6545
6546/* Range checking conditions in headers do not require any run-time
6547 tests of the global variable gsl_check_range. They are enabled or
6548 disabled in user code at compile time with GSL_RANGE_CHECK macro.
6549 See also build.h. */
6550#define GSL_RANGE_COND(x) (x)
6551
6552#endif /* __GSL_INLINE_H__ */
6553
6554/* end inlined header: gsl/gsl_inline.h */
6555
6556__BEGIN_DECLS
6557
6558INLINE_DECL double gsl_pow_2(const double x);
6559INLINE_DECL double gsl_pow_3(const double x);
6560INLINE_DECL double gsl_pow_4(const double x);
6561INLINE_DECL double gsl_pow_5(const double x);
6562INLINE_DECL double gsl_pow_6(const double x);
6563INLINE_DECL double gsl_pow_7(const double x);
6564INLINE_DECL double gsl_pow_8(const double x);
6565INLINE_DECL double gsl_pow_9(const double x);
6566
6567#ifdef HAVE_INLINE
6568INLINE_FUN double gsl_pow_2(const double x) { return x*x; }
6569INLINE_FUN double gsl_pow_3(const double x) { return x*x*x; }
6570INLINE_FUN double gsl_pow_4(const double x) { double x2 = x*x; return x2*x2; }
6571INLINE_FUN double gsl_pow_5(const double x) { double x2 = x*x; return x2*x2*x; }
6572INLINE_FUN double gsl_pow_6(const double x) { double x2 = x*x; return x2*x2*x2; }
6573INLINE_FUN double gsl_pow_7(const double x) { double x3 = x*x*x; return x3*x3*x; }
6574INLINE_FUN double gsl_pow_8(const double x) { double x2 = x*x; double x4 = x2*x2; return x4*x4; }
6575INLINE_FUN double gsl_pow_9(const double x) { double x3 = x*x*x; return x3*x3*x3; }
6576#endif
6577
6578double gsl_pow_int(double x, int n);
6579double gsl_pow_uint(double x, unsigned int n);
6580
6581__END_DECLS
6582
6583#endif /* __GSL_POW_INT_H__ */
6584
6585/* end inlined header: gsl/gsl_pow_int.h */
6586/* begin inlined header: gsl/gsl_minmax.h */
6587/* gsl_minmax.h
6588 *
6589 * Copyright (C) 2008 Gerard Jungman, Brian Gough
6590 *
6591 * This program is free software; you can redistribute it and/or modify
6592 * it under the terms of the GNU General Public License as published by
6593 * the Free Software Foundation; either version 3 of the License, or (at
6594 * your option) any later version.
6595 *
6596 * This program is distributed in the hope that it will be useful, but
6597 * WITHOUT ANY WARRANTY; without even the implied warranty of
6598 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
6599 * General Public License for more details.
6600 *
6601 * You should have received a copy of the GNU General Public License
6602 * along with this program; if not, write to the Free Software
6603 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
6604 */
6605
6606#ifndef __GSL_MINMAX_H__
6607#define __GSL_MINMAX_H__
6608/* begin inlined header: gsl/gsl_inline.h */
6609/* gsl_inline.h
6610 *
6611 * Copyright (C) 2008, 2009 Brian Gough
6612 *
6613 * This program is free software; you can redistribute it and/or modify
6614 * it under the terms of the GNU General Public License as published by
6615 * the Free Software Foundation; either version 3 of the License, or (at
6616 * your option) any later version.
6617 *
6618 * This program is distributed in the hope that it will be useful, but
6619 * WITHOUT ANY WARRANTY; without even the implied warranty of
6620 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
6621 * General Public License for more details.
6622 *
6623 * You should have received a copy of the GNU General Public License
6624 * along with this program; if not, write to the Free Software
6625 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
6626 */
6627
6628#ifndef __GSL_INLINE_H__
6629#define __GSL_INLINE_H__
6630
6631/* In recent versiions of GCC, the inline keyword has two different
6632 forms: GNU and C99.
6633
6634 In GNU mode we can use 'extern inline' to make inline functions
6635 work like macros. The function is only inlined--it is never output
6636 as a definition in an object file.
6637
6638 In the new C99 mode 'extern inline' has a different meaning--it
6639 causes the definition of the function to be output in each object
6640 file where it is used. This will result in multiple-definition
6641 errors on linking. The 'inline' keyword on its own (without
6642 extern) has the same behavior as the original GNU 'extern inline'.
6643
6644 The C99 style is the default with -std=c99 in GCC 4.3.
6645
6646 This header file allows either form of inline to be used by
6647 redefining the macros INLINE_DECL and INLINE_FUN. These are used
6648 in the public header files as
6649
6650 INLINE_DECL double gsl_foo (double x);
6651 #ifdef HAVE_INLINE
6652 INLINE_FUN double gsl_foo (double x) { return x+1.0; } ;
6653 #endif
6654
6655*/
6656
6657#ifdef HAVE_INLINE
6658# if defined(__GNUC_STDC_INLINE__) || defined(GSL_C99_INLINE) || defined(HAVE_C99_INLINE)
6659# define INLINE_DECL inline /* use C99 inline */
6660# define INLINE_FUN inline
6661# else
6662# define INLINE_DECL /* use GNU extern inline */
6663# define INLINE_FUN extern inline
6664# endif
6665#else
6666# define INLINE_DECL /* */
6667#endif
6668
6669/* Range checking conditions in headers do not require any run-time
6670 tests of the global variable gsl_check_range. They are enabled or
6671 disabled in user code at compile time with GSL_RANGE_CHECK macro.
6672 See also build.h. */
6673#define GSL_RANGE_COND(x) (x)
6674
6675#endif /* __GSL_INLINE_H__ */
6676
6677/* end inlined header: gsl/gsl_inline.h */
6678
6679__BEGIN_DECLS
6680
6681/* Define MAX and MIN macros/functions if they don't exist. */
6682
6683/* plain old macros for general use */
6684#define GSL_MAX(a,b) ((a) > (b) ? (a) : (b))
6685#define GSL_MIN(a,b) ((a) < (b) ? (a) : (b))
6686
6687/* function versions of the above, in case they are needed */
6688double gsl_max (double a, double b);
6689double gsl_min (double a, double b);
6690
6691/* inline-friendly strongly typed versions */
6692#ifdef HAVE_INLINE
6693
6694INLINE_FUN int GSL_MAX_INT (int a, int b);
6695INLINE_FUN int GSL_MIN_INT (int a, int b);
6696INLINE_FUN double GSL_MAX_DBL (double a, double b);
6697INLINE_FUN double GSL_MIN_DBL (double a, double b);
6698INLINE_FUN long double GSL_MAX_LDBL (long double a, long double b);
6699INLINE_FUN long double GSL_MIN_LDBL (long double a, long double b);
6700
6701INLINE_FUN int
6702GSL_MAX_INT (int a, int b)
6703{
6704 return GSL_MAX (a, b);
6705}
6706
6707INLINE_FUN int
6708GSL_MIN_INT (int a, int b)
6709{
6710 return GSL_MIN (a, b);
6711}
6712
6713INLINE_FUN double
6714GSL_MAX_DBL (double a, double b)
6715{
6716 return GSL_MAX (a, b);
6717}
6718
6719INLINE_FUN double
6720GSL_MIN_DBL (double a, double b)
6721{
6722 return GSL_MIN (a, b);
6723}
6724
6725INLINE_FUN long double
6726GSL_MAX_LDBL (long double a, long double b)
6727{
6728 return GSL_MAX (a, b);
6729}
6730
6731INLINE_FUN long double
6732GSL_MIN_LDBL (long double a, long double b)
6733{
6734 return GSL_MIN (a, b);
6735}
6736#else
6737#define GSL_MAX_INT(a,b) GSL_MAX(a,b)
6738#define GSL_MIN_INT(a,b) GSL_MIN(a,b)
6739#define GSL_MAX_DBL(a,b) GSL_MAX(a,b)
6740#define GSL_MIN_DBL(a,b) GSL_MIN(a,b)
6741#define GSL_MAX_LDBL(a,b) GSL_MAX(a,b)
6742#define GSL_MIN_LDBL(a,b) GSL_MIN(a,b)
6743#endif /* HAVE_INLINE */
6744
6745__END_DECLS
6746
6747#endif /* __GSL_POW_INT_H__ */
6748
6749/* end inlined header: gsl/gsl_minmax.h */
6750#ifndef M_E
6751#define M_E 2.71828182845904523536028747135 /* e */
6752#endif
6753
6754#ifndef M_LOG2E
6755#define M_LOG2E 1.44269504088896340735992468100 /* log_2 (e) */
6756#endif
6757
6758#ifndef M_LOG10E
6759#define M_LOG10E 0.43429448190325182765112891892 /* log_10 (e) */
6760#endif
6761
6762#ifndef M_SQRT2
6763#define M_SQRT2 1.41421356237309504880168872421 /* sqrt(2) */
6764#endif
6765
6766#ifndef M_SQRT1_2
6767#define M_SQRT1_2 0.70710678118654752440084436210 /* sqrt(1/2) */
6768#endif
6769
6770
6771#ifndef M_SQRT3
6772#define M_SQRT3 1.73205080756887729352744634151 /* sqrt(3) */
6773#endif
6774
6775#ifndef M_PI
6776#define M_PI 3.14159265358979323846264338328 /* pi */
6777#endif
6778
6779#ifndef M_PI_2
6780#define M_PI_2 1.57079632679489661923132169164 /* pi/2 */
6781#endif
6782
6783#ifndef M_PI_4
6784#define M_PI_4 0.78539816339744830961566084582 /* pi/4 */
6785#endif
6786
6787#ifndef M_SQRTPI
6788#define M_SQRTPI 1.77245385090551602729816748334 /* sqrt(pi) */
6789#endif
6790
6791#ifndef M_2_SQRTPI
6792#define M_2_SQRTPI 1.12837916709551257389615890312 /* 2/sqrt(pi) */
6793#endif
6794
6795#ifndef M_1_PI
6796#define M_1_PI 0.31830988618379067153776752675 /* 1/pi */
6797#endif
6798
6799#ifndef M_2_PI
6800#define M_2_PI 0.63661977236758134307553505349 /* 2/pi */
6801#endif
6802
6803#ifndef M_LN10
6804#define M_LN10 2.30258509299404568401799145468 /* ln(10) */
6805#endif
6806
6807#ifndef M_LN2
6808#define M_LN2 0.69314718055994530941723212146 /* ln(2) */
6809#endif
6810
6811#ifndef M_LNPI
6812#define M_LNPI 1.14472988584940017414342735135 /* ln(pi) */
6813#endif
6814
6815#ifndef M_EULER
6816#define M_EULER 0.57721566490153286060651209008 /* Euler constant */
6817#endif
6818
6819__BEGIN_DECLS
6820
6821/* other needlessly compulsive abstractions */
6822
6823#define GSL_IS_ODD(n) ((n) & 1)
6824#define GSL_IS_EVEN(n) (!(GSL_IS_ODD(n)))
6825#define GSL_SIGN(x) ((x) >= 0.0 ? 1 : -1)
6826
6827/* Return nonzero if x is a real number, i.e. non NaN or infinite. */
6828#define GSL_IS_REAL(x) (gsl_finite(x))
6829
6830/* Definition of an arbitrary function with parameters */
6831
6833{
6834 double (* function) (double x, void * params);
6835 void * params;
6836};
6837
6838typedef struct gsl_function_struct gsl_function ;
6839
6840#define GSL_FN_EVAL(F,x) (*((F)->function))(x,(F)->params)
6841
6842/* Definition of an arbitrary function returning two values, r1, r2 */
6843
6845{
6846 double (* f) (double x, void * params);
6847 double (* df) (double x, void * params);
6848 void (* fdf) (double x, void * params, double * f, double * df);
6849 void * params;
6850};
6851
6852typedef struct gsl_function_fdf_struct gsl_function_fdf ;
6853
6854#define GSL_FN_FDF_EVAL_F(FDF,x) (*((FDF)->f))(x,(FDF)->params)
6855#define GSL_FN_FDF_EVAL_DF(FDF,x) (*((FDF)->df))(x,(FDF)->params)
6856#define GSL_FN_FDF_EVAL_F_DF(FDF,x,y,dy) (*((FDF)->fdf))(x,(FDF)->params,(y),(dy))
6857
6858
6859/* Definition of an arbitrary vector-valued function with parameters */
6860
6862{
6863 int (* function) (double x, double y[], void * params);
6864 void * params;
6865};
6866
6867typedef struct gsl_function_vec_struct gsl_function_vec ;
6868
6869#define GSL_FN_VEC_EVAL(F,x,y) (*((F)->function))(x,y,(F)->params)
6870
6871__END_DECLS
6872
6873#endif /* __GSL_MATH_H__ */
6874
6875/* end inlined header: gsl/gsl_math.h */
6876/* begin inlined header: gsl/gsl_errno.h */
6877/* err/gsl_errno.h
6878 *
6879 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, Brian Gough
6880 *
6881 * This program is free software; you can redistribute it and/or modify
6882 * it under the terms of the GNU General Public License as published by
6883 * the Free Software Foundation; either version 3 of the License, or (at
6884 * your option) any later version.
6885 *
6886 * This program is distributed in the hope that it will be useful, but
6887 * WITHOUT ANY WARRANTY; without even the implied warranty of
6888 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
6889 * General Public License for more details.
6890 *
6891 * You should have received a copy of the GNU General Public License
6892 * along with this program; if not, write to the Free Software
6893 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
6894 */
6895
6896#ifndef __GSL_ERRNO_H__
6897#define __GSL_ERRNO_H__
6898
6899#include <stdio.h>
6900#include <errno.h>
6901/* begin inlined header: gsl/gsl_types.h */
6902/* gsl_types.h
6903 *
6904 * Copyright (C) 2001, 2007 Brian Gough
6905 *
6906 * This program is free software; you can redistribute it and/or modify
6907 * it under the terms of the GNU General Public License as published by
6908 * the Free Software Foundation; either version 3 of the License, or (at
6909 * your option) any later version.
6910 *
6911 * This program is distributed in the hope that it will be useful, but
6912 * WITHOUT ANY WARRANTY; without even the implied warranty of
6913 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
6914 * General Public License for more details.
6915 *
6916 * You should have received a copy of the GNU General Public License
6917 * along with this program; if not, write to the Free Software
6918 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
6919 */
6920
6921#ifndef __GSL_TYPES_H__
6922#define __GSL_TYPES_H__
6923
6924#ifndef GSL_VAR
6925
6926#ifdef WIN32
6927# ifdef GSL_DLL
6928# ifdef DLL_EXPORT
6929# define GSL_VAR extern __declspec(dllexport)
6930# else
6931# define GSL_VAR extern __declspec(dllimport)
6932# endif
6933# else
6934# define GSL_VAR extern
6935# endif
6936#else
6937# define GSL_VAR extern
6938#endif
6939
6940#endif
6941
6942#endif /* __GSL_TYPES_H__ */
6943
6944/* end inlined header: gsl/gsl_types.h */
6945__BEGIN_DECLS
6946
6947enum {
6948 GSL_SUCCESS = 0,
6949 GSL_FAILURE = -1,
6950 GSL_CONTINUE = -2, /* iteration has not converged */
6951 GSL_EDOM = 1, /* input domain error, e.g sqrt(-1) */
6952 GSL_ERANGE = 2, /* output range error, e.g. exp(1e100) */
6953 GSL_EFAULT = 3, /* invalid pointer */
6954 GSL_EINVAL = 4, /* invalid argument supplied by user */
6955 GSL_EFAILED = 5, /* generic failure */
6956 GSL_EFACTOR = 6, /* factorization failed */
6957 GSL_ESANITY = 7, /* sanity check failed - shouldn't happen */
6958 GSL_ENOMEM = 8, /* malloc failed */
6959 GSL_EBADFUNC = 9, /* problem with user-supplied function */
6960 GSL_ERUNAWAY = 10, /* iterative process is out of control */
6961 GSL_EMAXITER = 11, /* exceeded max number of iterations */
6962 GSL_EZERODIV = 12, /* tried to divide by zero */
6963 GSL_EBADTOL = 13, /* user specified an invalid tolerance */
6964 GSL_ETOL = 14, /* failed to reach the specified tolerance */
6965 GSL_EUNDRFLW = 15, /* underflow */
6966 GSL_EOVRFLW = 16, /* overflow */
6967 GSL_ELOSS = 17, /* loss of accuracy */
6968 GSL_EROUND = 18, /* failed because of roundoff error */
6969 GSL_EBADLEN = 19, /* matrix, vector lengths are not conformant */
6970 GSL_ENOTSQR = 20, /* matrix not square */
6971 GSL_ESING = 21, /* apparent singularity detected */
6972 GSL_EDIVERGE = 22, /* integral or series is divergent */
6973 GSL_EUNSUP = 23, /* requested feature is not supported by the hardware */
6974 GSL_EUNIMPL = 24, /* requested feature not (yet) implemented */
6975 GSL_ECACHE = 25, /* cache limit exceeded */
6976 GSL_ETABLE = 26, /* table limit exceeded */
6977 GSL_ENOPROG = 27, /* iteration is not making progress towards solution */
6978 GSL_ENOPROGJ = 28, /* jacobian evaluations are not improving the solution */
6979 GSL_ETOLF = 29, /* cannot reach the specified tolerance in F */
6980 GSL_ETOLX = 30, /* cannot reach the specified tolerance in X */
6981 GSL_ETOLG = 31, /* cannot reach the specified tolerance in gradient */
6982 GSL_EOF = 32 /* end of file */
6983} ;
6984
6985void gsl_error (const char * reason, const char * file, int line,
6986 int gsl_errno);
6987
6988void gsl_stream_printf (const char *label, const char *file,
6989 int line, const char *reason);
6990
6991typedef void gsl_error_handler_t (const char * reason, const char * file,
6992 int line, int gsl_errno);
6993
6994gsl_error_handler_t *
6995gsl_set_error_handler (gsl_error_handler_t * new_handler);
6996
6997/* GSL_ERROR: call the error handler, and return the error code */
6998
6999#define GSL_ERROR(reason, gsl_errno) \
7000 do { \
7001 gsl_error (reason, __FILE__, __LINE__, gsl_errno) ; \
7002 return gsl_errno ; \
7003 } while (0)
7004
7005/* GSL_ERROR_VAL: call the error handler, and return the given value */
7006
7007#define GSL_ERROR_VAL(reason, gsl_errno, value) \
7008 do { \
7009 gsl_error (reason, __FILE__, __LINE__, gsl_errno) ; \
7010 return value ; \
7011 } while (0)
7012
7013/* GSL_ERROR_VOID: call the error handler, and then return
7014 (for void functions which still need to generate an error) */
7015
7016#define GSL_ERROR_VOID(reason, gsl_errno) \
7017 do { \
7018 gsl_error (reason, __FILE__, __LINE__, gsl_errno) ; \
7019 return ; \
7020 } while (0)
7021
7022/* GSL_ERROR_NULL suitable for out-of-memory conditions */
7023
7024#define GSL_ERROR_NULL(reason, gsl_errno) GSL_ERROR_VAL(reason, gsl_errno, 0)
7025
7026/* Sometimes you have several status results returned from
7027 * function calls and you want to combine them in some sensible
7028 * way. You cannot produce a "total" status condition, but you can
7029 * pick one from a set of conditions based on an implied hierarchy.
7030 *
7031 * In other words:
7032 * you have: status_a, status_b, ...
7033 * you want: status = (status_a if it is bad, or status_b if it is bad,...)
7034 *
7035 * In this example you consider status_a to be more important and
7036 * it is checked first, followed by the others in the order specified.
7037 *
7038 * Here are some dumb macros to do this.
7039 */
7040#define GSL_ERROR_SELECT_2(a,b) ((a) != GSL_SUCCESS ? (a) : ((b) != GSL_SUCCESS ? (b) : GSL_SUCCESS))
7041#define GSL_ERROR_SELECT_3(a,b,c) ((a) != GSL_SUCCESS ? (a) : GSL_ERROR_SELECT_2(b,c))
7042#define GSL_ERROR_SELECT_4(a,b,c,d) ((a) != GSL_SUCCESS ? (a) : GSL_ERROR_SELECT_3(b,c,d))
7043#define GSL_ERROR_SELECT_5(a,b,c,d,e) ((a) != GSL_SUCCESS ? (a) : GSL_ERROR_SELECT_4(b,c,d,e))
7044
7045#define GSL_STATUS_UPDATE(sp, s) do { if ((s) != GSL_SUCCESS) *(sp) = (s);} while(0)
7046
7047__END_DECLS
7048
7049#endif /* __GSL_ERRNO_H__ */
7050
7051/* end inlined header: gsl/gsl_errno.h */
7052/* begin inlined header: gsl/gsl_sf_log.h */
7053/* specfunc/gsl_sf_log.h
7054 *
7055 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2004 Gerard Jungman
7056 *
7057 * This program is free software; you can redistribute it and/or modify
7058 * it under the terms of the GNU General Public License as published by
7059 * the Free Software Foundation; either version 3 of the License, or (at
7060 * your option) any later version.
7061 *
7062 * This program is distributed in the hope that it will be useful, but
7063 * WITHOUT ANY WARRANTY; without even the implied warranty of
7064 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
7065 * General Public License for more details.
7066 *
7067 * You should have received a copy of the GNU General Public License
7068 * along with this program; if not, write to the Free Software
7069 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
7070 */
7071
7072/* Author: G. Jungman */
7073
7074#ifndef __GSL_SF_LOG_H__
7075#define __GSL_SF_LOG_H__
7076/* begin inlined header: gsl/gsl_sf_result.h */
7077/* specfunc/gsl_sf_result.h
7078 *
7079 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
7080 *
7081 * This program is free software; you can redistribute it and/or modify
7082 * it under the terms of the GNU General Public License as published by
7083 * the Free Software Foundation; either version 3 of the License, or (at
7084 * your option) any later version.
7085 *
7086 * This program is distributed in the hope that it will be useful, but
7087 * WITHOUT ANY WARRANTY; without even the implied warranty of
7088 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
7089 * General Public License for more details.
7090 *
7091 * You should have received a copy of the GNU General Public License
7092 * along with this program; if not, write to the Free Software
7093 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
7094 */
7095
7096/* Author: G. Jungman */
7097
7098#ifndef __GSL_SF_RESULT_H__
7099#define __GSL_SF_RESULT_H__
7100
7101__BEGIN_DECLS
7102
7103struct gsl_sf_result_struct {
7104 double val;
7105 double err;
7106};
7107typedef struct gsl_sf_result_struct gsl_sf_result;
7108
7109#define GSL_SF_RESULT_SET(r,v,e) do { (r)->val=(v); (r)->err=(e); } while(0)
7110
7111
7113 double val;
7114 double err;
7115 int e10;
7116};
7117typedef struct gsl_sf_result_e10_struct gsl_sf_result_e10;
7118
7119
7120int gsl_sf_result_smash_e(const gsl_sf_result_e10 * re, gsl_sf_result * r);
7121
7122
7123__END_DECLS
7124
7125#endif /* __GSL_SF_RESULT_H__ */
7126
7127/* end inlined header: gsl/gsl_sf_result.h */
7128
7129
7130__BEGIN_DECLS
7131
7132
7133/* Provide a logarithm function with GSL semantics.
7134 *
7135 * exceptions: GSL_EDOM
7136 */
7137int gsl_sf_log_e(const double x, gsl_sf_result * result);
7138double gsl_sf_log(const double x);
7139
7140
7141/* Log(|x|)
7142 *
7143 * exceptions: GSL_EDOM
7144 */
7145int gsl_sf_log_abs_e(const double x, gsl_sf_result * result);
7146double gsl_sf_log_abs(const double x);
7147
7148
7149/* Complex Logarithm
7150 * exp(lnr + I theta) = zr + I zi
7151 * Returns argument in [-pi,pi].
7152 *
7153 * exceptions: GSL_EDOM
7154 */
7155int gsl_sf_complex_log_e(const double zr, const double zi, gsl_sf_result * lnr, gsl_sf_result * theta);
7156
7157
7158/* Log(1 + x)
7159 *
7160 * exceptions: GSL_EDOM
7161 */
7162int gsl_sf_log_1plusx_e(const double x, gsl_sf_result * result);
7163double gsl_sf_log_1plusx(const double x);
7164
7165
7166/* Log(1 + x) - x
7167 *
7168 * exceptions: GSL_EDOM
7169 */
7170int gsl_sf_log_1plusx_mx_e(const double x, gsl_sf_result * result);
7171double gsl_sf_log_1plusx_mx(const double x);
7172
7173__END_DECLS
7174
7175#endif /* __GSL_SF_LOG_H__ */
7176
7177/* end inlined header: gsl/gsl_sf_log.h */
7178/* begin inlined header: gsl/gsl_sf_trig.h */
7179/* specfunc/gsl_sf_trig.h
7180 *
7181 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
7182 *
7183 * This program is free software; you can redistribute it and/or modify
7184 * it under the terms of the GNU General Public License as published by
7185 * the Free Software Foundation; either version 3 of the License, or (at
7186 * your option) any later version.
7187 *
7188 * This program is distributed in the hope that it will be useful, but
7189 * WITHOUT ANY WARRANTY; without even the implied warranty of
7190 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
7191 * General Public License for more details.
7192 *
7193 * You should have received a copy of the GNU General Public License
7194 * along with this program; if not, write to the Free Software
7195 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
7196 */
7197
7198/* Author: G. Jungman */
7199
7200#ifndef __GSL_SF_TRIG_H__
7201#define __GSL_SF_TRIG_H__
7202/* begin inlined header: gsl/gsl_sf_result.h */
7203/* specfunc/gsl_sf_result.h
7204 *
7205 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
7206 *
7207 * This program is free software; you can redistribute it and/or modify
7208 * it under the terms of the GNU General Public License as published by
7209 * the Free Software Foundation; either version 3 of the License, or (at
7210 * your option) any later version.
7211 *
7212 * This program is distributed in the hope that it will be useful, but
7213 * WITHOUT ANY WARRANTY; without even the implied warranty of
7214 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
7215 * General Public License for more details.
7216 *
7217 * You should have received a copy of the GNU General Public License
7218 * along with this program; if not, write to the Free Software
7219 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
7220 */
7221
7222/* Author: G. Jungman */
7223
7224#ifndef __GSL_SF_RESULT_H__
7225#define __GSL_SF_RESULT_H__
7226
7227
7228
7229__BEGIN_DECLS
7230
7231struct gsl_sf_result_struct {
7232 double val;
7233 double err;
7234};
7235typedef struct gsl_sf_result_struct gsl_sf_result;
7236
7237#define GSL_SF_RESULT_SET(r,v,e) do { (r)->val=(v); (r)->err=(e); } while(0)
7238
7239
7241 double val;
7242 double err;
7243 int e10;
7244};
7245typedef struct gsl_sf_result_e10_struct gsl_sf_result_e10;
7246
7247
7248int gsl_sf_result_smash_e(const gsl_sf_result_e10 * re, gsl_sf_result * r);
7249
7250
7251__END_DECLS
7252
7253#endif /* __GSL_SF_RESULT_H__ */
7254
7255/* end inlined header: gsl/gsl_sf_result.h */
7256
7257
7258__BEGIN_DECLS
7259
7260
7261/* Sin(x) with GSL semantics. This is actually important
7262 * because we want to control the error estimate, and trying
7263 * to guess the error for the standard library implementation
7264 * every time it is used would be a little goofy.
7265 */
7266int gsl_sf_sin_e(double x, gsl_sf_result * result);
7267double gsl_sf_sin(const double x);
7268
7269
7270/* Cos(x) with GSL semantics.
7271 */
7272int gsl_sf_cos_e(double x, gsl_sf_result * result);
7273double gsl_sf_cos(const double x);
7274
7275
7276/* Hypot(x,y) with GSL semantics.
7277 */
7278int gsl_sf_hypot_e(const double x, const double y, gsl_sf_result * result);
7279double gsl_sf_hypot(const double x, const double y);
7280
7281
7282/* Sin(z) for complex z
7283 *
7284 * exceptions: GSL_EOVRFLW
7285 */
7286int gsl_sf_complex_sin_e(const double zr, const double zi, gsl_sf_result * szr, gsl_sf_result * szi);
7287
7288
7289/* Cos(z) for complex z
7290 *
7291 * exceptions: GSL_EOVRFLW
7292 */
7293int gsl_sf_complex_cos_e(const double zr, const double zi, gsl_sf_result * czr, gsl_sf_result * czi);
7294
7295
7296/* Log(Sin(z)) for complex z
7297 *
7298 * exceptions: GSL_EDOM, GSL_ELOSS
7299 */
7300int gsl_sf_complex_logsin_e(const double zr, const double zi, gsl_sf_result * lszr, gsl_sf_result * lszi);
7301
7302
7303/* Sinc(x) = sin(pi x) / (pi x)
7304 *
7305 * exceptions: none
7306 */
7307int gsl_sf_sinc_e(double x, gsl_sf_result * result);
7308double gsl_sf_sinc(const double x);
7309
7310
7311/* Log(Sinh(x)), x > 0
7312 *
7313 * exceptions: GSL_EDOM
7314 */
7315int gsl_sf_lnsinh_e(const double x, gsl_sf_result * result);
7316double gsl_sf_lnsinh(const double x);
7317
7318
7319/* Log(Cosh(x))
7320 *
7321 * exceptions: none
7322 */
7323int gsl_sf_lncosh_e(const double x, gsl_sf_result * result);
7324double gsl_sf_lncosh(const double x);
7325
7326
7327/* Convert polar to rectlinear coordinates.
7328 *
7329 * exceptions: GSL_ELOSS
7330 */
7331int gsl_sf_polar_to_rect(const double r, const double theta, gsl_sf_result * x, gsl_sf_result * y);
7332
7333/* Convert rectilinear to polar coordinates.
7334 * return argument in range [-pi, pi]
7335 *
7336 * exceptions: GSL_EDOM
7337 */
7338int gsl_sf_rect_to_polar(const double x, const double y, gsl_sf_result * r, gsl_sf_result * theta);
7339
7340/* Sin(x) for quantity with an associated error.
7341 */
7342int gsl_sf_sin_err_e(const double x, const double dx, gsl_sf_result * result);
7343
7344
7345/* Cos(x) for quantity with an associated error.
7346 */
7347int gsl_sf_cos_err_e(const double x, const double dx, gsl_sf_result * result);
7348
7349
7350/* Force an angle to lie in the range (-pi,pi].
7351 *
7352 * exceptions: GSL_ELOSS
7353 */
7354int gsl_sf_angle_restrict_symm_e(double * theta);
7355double gsl_sf_angle_restrict_symm(const double theta);
7356
7357
7358/* Force an angle to lie in the range [0, 2pi)
7359 *
7360 * exceptions: GSL_ELOSS
7361 */
7362int gsl_sf_angle_restrict_pos_e(double * theta);
7363double gsl_sf_angle_restrict_pos(const double theta);
7364
7365
7366int gsl_sf_angle_restrict_symm_err_e(const double theta, gsl_sf_result * result);
7367
7368int gsl_sf_angle_restrict_pos_err_e(const double theta, gsl_sf_result * result);
7369
7370
7371__END_DECLS
7372
7373#endif /* __GSL_SF_TRIG_H__ */
7374
7375/* end inlined header: gsl/gsl_sf_trig.h */
7376/* inlined: error.h */
7377
7378/* inlined: chebyshev.h */
7379/* inlined once already: specfunc/cheb_eval.c */
7380
7381/* sinh(x) series
7382 * double-precision for |x| < 1.0
7383 */
7384inline
7385static
7386int
7387sinh_series(const double x, double * result)
7388{
7389 const double y = x*x;
7390 const double c0 = 1.0/6.0;
7391 const double c1 = 1.0/120.0;
7392 const double c2 = 1.0/5040.0;
7393 const double c3 = 1.0/362880.0;
7394 const double c4 = 1.0/39916800.0;
7395 const double c5 = 1.0/6227020800.0;
7396 const double c6 = 1.0/1307674368000.0;
7397 const double c7 = 1.0/355687428096000.0;
7398 *result = x*(1.0 + y*(c0+y*(c1+y*(c2+y*(c3+y*(c4+y*(c5+y*(c6+y*c7))))))));
7399 return GSL_SUCCESS;
7400}
7401
7402
7403/* cosh(x)-1 series
7404 * double-precision for |x| < 1.0
7405 */
7406inline
7407static
7408int
7409cosh_m1_series(const double x, double * result)
7410{
7411 const double y = x*x;
7412 const double c0 = 0.5;
7413 const double c1 = 1.0/24.0;
7414 const double c2 = 1.0/720.0;
7415 const double c3 = 1.0/40320.0;
7416 const double c4 = 1.0/3628800.0;
7417 const double c5 = 1.0/479001600.0;
7418 const double c6 = 1.0/87178291200.0;
7419 const double c7 = 1.0/20922789888000.0;
7420 const double c8 = 1.0/6402373705728000.0;
7421 *result = y*(c0+y*(c1+y*(c2+y*(c3+y*(c4+y*(c5+y*(c6+y*(c7+y*c8))))))));
7422 return GSL_SUCCESS;
7423}
7424
7425
7426/* Chebyshev expansion for f(t) = sinc((t+1)/2), -1 < t < 1
7427 */
7428static double sinc_data[17] = {
7429 1.133648177811747875422,
7430 -0.532677564732557348781,
7431 -0.068293048346633177859,
7432 0.033403684226353715020,
7433 0.001485679893925747818,
7434 -0.000734421305768455295,
7435 -0.000016837282388837229,
7436 0.000008359950146618018,
7437 0.000000117382095601192,
7438 -0.000000058413665922724,
7439 -0.000000000554763755743,
7440 0.000000000276434190426,
7441 0.000000000001895374892,
7442 -0.000000000000945237101,
7443 -0.000000000000004900690,
7444 0.000000000000002445383,
7445 0.000000000000000009925
7446};
7447static cheb_series sinc_cs = {
7448 sinc_data,
7449 16,
7450 -1, 1,
7451 10
7452};
7453
7454
7455/* Chebyshev expansion for f(t) = g((t+1)Pi/8), -1<t<1
7456 * g(x) = (sin(x)/x - 1)/(x*x)
7457 */
7458static double sin_data[12] = {
7459 -0.3295190160663511504173,
7460 0.0025374284671667991990,
7461 0.0006261928782647355874,
7462 -4.6495547521854042157541e-06,
7463 -5.6917531549379706526677e-07,
7464 3.7283335140973803627866e-09,
7465 3.0267376484747473727186e-10,
7466 -1.7400875016436622322022e-12,
7467 -1.0554678305790849834462e-13,
7468 5.3701981409132410797062e-16,
7469 2.5984137983099020336115e-17,
7470 -1.1821555255364833468288e-19
7471};
7472static cheb_series sin_cs = {
7473 sin_data,
7474 11,
7475 -1, 1,
7476 11
7477};
7478
7479/* Chebyshev expansion for f(t) = g((t+1)Pi/8), -1<t<1
7480 * g(x) = (2(cos(x) - 1)/(x^2) + 1) / x^2
7481 */
7482static double cos_data[11] = {
7483 0.165391825637921473505668118136,
7484 -0.00084852883845000173671196530195,
7485 -0.000210086507222940730213625768083,
7486 1.16582269619760204299639757584e-6,
7487 1.43319375856259870334412701165e-7,
7488 -7.4770883429007141617951330184e-10,
7489 -6.0969994944584252706997438007e-11,
7490 2.90748249201909353949854872638e-13,
7491 1.77126739876261435667156490461e-14,
7492 -7.6896421502815579078577263149e-17,
7493 -3.7363121133079412079201377318e-18
7494};
7495static cheb_series cos_cs = {
7496 cos_data,
7497 10,
7498 -1, 1,
7499 10
7500};
7501
7502
7503/*-*-*-*-*-*-*-*-*-*-*-* Functions with Error Codes *-*-*-*-*-*-*-*-*-*-*-*/
7504
7505/* I would have prefered just using the library sin() function.
7506 * But after some experimentation I decided that there was
7507 * no good way to understand the error; library sin() is just a black box.
7508 * So we have to roll our own.
7509 */
7510int
7511gsl_sf_sin_e(double x, gsl_sf_result * result)
7512{
7513 /* CHECK_POINTER(result) */
7514
7515 {
7516 const double P1 = 7.85398125648498535156e-1;
7517 const double P2 = 3.77489470793079817668e-8;
7518 const double P3 = 2.69515142907905952645e-15;
7519
7520 const double sgn_x = GSL_SIGN(x);
7521 const double abs_x = fabs(x);
7522
7523 if(abs_x < GSL_ROOT4_DBL_EPSILON) {
7524 const double x2 = x*x;
7525 result->val = x * (1.0 - x2/6.0);
7526 result->err = fabs(x*x2*x2 / 100.0);
7527 return GSL_SUCCESS;
7528 }
7529 else {
7530 double sgn_result = sgn_x;
7531 double y = floor(abs_x/(0.25*M_PI));
7532 int octant = y - ldexp(floor(ldexp(y,-3)),3);
7533 int stat_cs;
7534 double z;
7535
7536 if(GSL_IS_ODD(octant)) {
7537 octant += 1;
7538 octant &= 07;
7539 y += 1.0;
7540 }
7541
7542 if(octant > 3) {
7543 octant -= 4;
7544 sgn_result = -sgn_result;
7545 }
7546
7547 z = ((abs_x - y * P1) - y * P2) - y * P3;
7548
7549 if(octant == 0) {
7550 gsl_sf_result sin_cs_result;
7551 const double t = 8.0*fabs(z)/M_PI - 1.0;
7552 stat_cs = cheb_eval_e(&sin_cs, t, &sin_cs_result);
7553 result->val = z * (1.0 + z*z * sin_cs_result.val);
7554 }
7555 else { /* octant == 2 */
7556 gsl_sf_result cos_cs_result;
7557 const double t = 8.0*fabs(z)/M_PI - 1.0;
7558 stat_cs = cheb_eval_e(&cos_cs, t, &cos_cs_result);
7559 result->val = 1.0 - 0.5*z*z * (1.0 - z*z * cos_cs_result.val);
7560 }
7561
7562 result->val *= sgn_result;
7563
7564 if(abs_x > 1.0/GSL_DBL_EPSILON) {
7565 result->err = fabs(result->val);
7566 }
7567 else if(abs_x > 100.0/GSL_SQRT_DBL_EPSILON) {
7568 result->err = 2.0 * abs_x * GSL_DBL_EPSILON * fabs(result->val);
7569 }
7570 else if(abs_x > 0.1/GSL_SQRT_DBL_EPSILON) {
7571 result->err = 2.0 * GSL_SQRT_DBL_EPSILON * fabs(result->val);
7572 }
7573 else {
7574 result->err = 2.0 * GSL_DBL_EPSILON * fabs(result->val);
7575 }
7576
7577 return stat_cs;
7578 }
7579 }
7580}
7581
7582
7583int
7584gsl_sf_cos_e(double x, gsl_sf_result * result)
7585{
7586 /* CHECK_POINTER(result) */
7587
7588 {
7589 const double P1 = 7.85398125648498535156e-1;
7590 const double P2 = 3.77489470793079817668e-8;
7591 const double P3 = 2.69515142907905952645e-15;
7592
7593 const double abs_x = fabs(x);
7594
7595 if(abs_x < GSL_ROOT4_DBL_EPSILON) {
7596 const double x2 = x*x;
7597 result->val = 1.0 - 0.5*x2;
7598 result->err = fabs(x2*x2/12.0);
7599 return GSL_SUCCESS;
7600 }
7601 else {
7602 double sgn_result = 1.0;
7603 double y = floor(abs_x/(0.25*M_PI));
7604 int octant = y - ldexp(floor(ldexp(y,-3)),3);
7605 int stat_cs;
7606 double z;
7607
7608 if(GSL_IS_ODD(octant)) {
7609 octant += 1;
7610 octant &= 07;
7611 y += 1.0;
7612 }
7613
7614 if(octant > 3) {
7615 octant -= 4;
7616 sgn_result = -sgn_result;
7617 }
7618
7619 if(octant > 1) {
7620 sgn_result = -sgn_result;
7621 }
7622
7623 z = ((abs_x - y * P1) - y * P2) - y * P3;
7624
7625 if(octant == 0) {
7626 gsl_sf_result cos_cs_result;
7627 const double t = 8.0*fabs(z)/M_PI - 1.0;
7628 stat_cs = cheb_eval_e(&cos_cs, t, &cos_cs_result);
7629 result->val = 1.0 - 0.5*z*z * (1.0 - z*z * cos_cs_result.val);
7630 }
7631 else { /* octant == 2 */
7632 gsl_sf_result sin_cs_result;
7633 const double t = 8.0*fabs(z)/M_PI - 1.0;
7634 stat_cs = cheb_eval_e(&sin_cs, t, &sin_cs_result);
7635 result->val = z * (1.0 + z*z * sin_cs_result.val);
7636 }
7637
7638 result->val *= sgn_result;
7639
7640 if(abs_x > 1.0/GSL_DBL_EPSILON) {
7641 result->err = fabs(result->val);
7642 }
7643 else if(abs_x > 100.0/GSL_SQRT_DBL_EPSILON) {
7644 result->err = 2.0 * abs_x * GSL_DBL_EPSILON * fabs(result->val);
7645 }
7646 else if(abs_x > 0.1/GSL_SQRT_DBL_EPSILON) {
7647 result->err = 2.0 * GSL_SQRT_DBL_EPSILON * fabs(result->val);
7648 }
7649 else {
7650 result->err = 2.0 * GSL_DBL_EPSILON * fabs(result->val);
7651 }
7652
7653 return stat_cs;
7654 }
7655 }
7656}
7657
7658
7659int
7660gsl_sf_hypot_e(const double x, const double y, gsl_sf_result * result)
7661{
7662 /* CHECK_POINTER(result) */
7663
7664 if(x == 0.0 && y == 0.0) {
7665 result->val = 0.0;
7666 result->err = 0.0;
7667 return GSL_SUCCESS;
7668 }
7669 else {
7670 const double a = fabs(x);
7671 const double b = fabs(y);
7672 const double min = GSL_MIN_DBL(a,b);
7673 const double max = GSL_MAX_DBL(a,b);
7674 const double rat = min/max;
7675 const double root_term = sqrt(1.0 + rat*rat);
7676
7677 if(max < GSL_DBL_MAX/root_term) {
7678 result->val = max * root_term;
7679 result->err = 2.0 * GSL_DBL_EPSILON * fabs(result->val);
7680 return GSL_SUCCESS;
7681 }
7682 else {
7683 OVERFLOW_ERROR(result);
7684 }
7685 }
7686}
7687
7688
7689int
7690gsl_sf_complex_sin_e(const double zr, const double zi,
7691 gsl_sf_result * szr, gsl_sf_result * szi)
7692{
7693 /* CHECK_POINTER(szr) */
7694 /* CHECK_POINTER(szi) */
7695
7696 if(fabs(zi) < 1.0) {
7697 double ch_m1, sh;
7698 sinh_series(zi, &sh);
7699 cosh_m1_series(zi, &ch_m1);
7700 szr->val = sin(zr)*(ch_m1 + 1.0);
7701 szi->val = cos(zr)*sh;
7702 szr->err = 2.0 * GSL_DBL_EPSILON * fabs(szr->val);
7703 szi->err = 2.0 * GSL_DBL_EPSILON * fabs(szi->val);
7704 return GSL_SUCCESS;
7705 }
7706 else if(fabs(zi) < GSL_LOG_DBL_MAX) {
7707 double ex = exp(zi);
7708 double ch = 0.5*(ex+1.0/ex);
7709 double sh = 0.5*(ex-1.0/ex);
7710 szr->val = sin(zr)*ch;
7711 szi->val = cos(zr)*sh;
7712 szr->err = 2.0 * GSL_DBL_EPSILON * fabs(szr->val);
7713 szi->err = 2.0 * GSL_DBL_EPSILON * fabs(szi->val);
7714 return GSL_SUCCESS;
7715 }
7716 else {
7717 OVERFLOW_ERROR_2(szr, szi);
7718 }
7719}
7720
7721
7722int
7723gsl_sf_complex_cos_e(const double zr, const double zi,
7724 gsl_sf_result * czr, gsl_sf_result * czi)
7725{
7726 /* CHECK_POINTER(czr) */
7727 /* CHECK_POINTER(czi) */
7728
7729 if(fabs(zi) < 1.0) {
7730 double ch_m1, sh;
7731 sinh_series(zi, &sh);
7732 cosh_m1_series(zi, &ch_m1);
7733 czr->val = cos(zr)*(ch_m1 + 1.0);
7734 czi->val = -sin(zr)*sh;
7735 czr->err = 2.0 * GSL_DBL_EPSILON * fabs(czr->val);
7736 czi->err = 2.0 * GSL_DBL_EPSILON * fabs(czi->val);
7737 return GSL_SUCCESS;
7738 }
7739 else if(fabs(zi) < GSL_LOG_DBL_MAX) {
7740 double ex = exp(zi);
7741 double ch = 0.5*(ex+1.0/ex);
7742 double sh = 0.5*(ex-1.0/ex);
7743 czr->val = cos(zr)*ch;
7744 czi->val = -sin(zr)*sh;
7745 czr->err = 2.0 * GSL_DBL_EPSILON * fabs(czr->val);
7746 czi->err = 2.0 * GSL_DBL_EPSILON * fabs(czi->val);
7747 return GSL_SUCCESS;
7748 }
7749 else {
7750 OVERFLOW_ERROR_2(czr,czi);
7751 }
7752}
7753
7754
7755int
7756gsl_sf_complex_logsin_e(const double zr, const double zi,
7757 gsl_sf_result * lszr, gsl_sf_result * lszi)
7758{
7759 /* CHECK_POINTER(lszr) */
7760 /* CHECK_POINTER(lszi) */
7761
7762 if(zi > 60.0) {
7763 lszr->val = -M_LN2 + zi;
7764 lszi->val = 0.5*M_PI - zr;
7765 lszr->err = 2.0 * GSL_DBL_EPSILON * fabs(lszr->val);
7766 lszi->err = 2.0 * GSL_DBL_EPSILON * fabs(lszi->val);
7767 }
7768 else if(zi < -60.0) {
7769 lszr->val = -M_LN2 - zi;
7770 lszi->val = -0.5*M_PI + zr;
7771 lszr->err = 2.0 * GSL_DBL_EPSILON * fabs(lszr->val);
7772 lszi->err = 2.0 * GSL_DBL_EPSILON * fabs(lszi->val);
7773 }
7774 else {
7775 gsl_sf_result sin_r, sin_i;
7776 int status;
7777 gsl_sf_complex_sin_e(zr, zi, &sin_r, &sin_i); /* ok by construction */
7778 status = gsl_sf_complex_log_e(sin_r.val, sin_i.val, lszr, lszi);
7779 if(status == GSL_EDOM) {
7780 DOMAIN_ERROR_2(lszr, lszi);
7781 }
7782 }
7783 return gsl_sf_angle_restrict_symm_e(&(lszi->val));
7784}
7785
7786
7787int
7788gsl_sf_lnsinh_e(const double x, gsl_sf_result * result)
7789{
7790 /* CHECK_POINTER(result) */
7791
7792 if(x <= 0.0) {
7793 DOMAIN_ERROR(result);
7794 }
7795 else if(fabs(x) < 1.0) {
7796 double eps;
7797 sinh_series(x, &eps);
7798 result->val = log(eps);
7799 result->err = 2.0 * GSL_DBL_EPSILON * fabs(result->val);
7800 return GSL_SUCCESS;
7801 }
7802 else if(x < -0.5*GSL_LOG_DBL_EPSILON) {
7803 result->val = x + log(0.5*(1.0 - exp(-2.0*x)));
7804 result->err = 2.0 * GSL_DBL_EPSILON * fabs(result->val);
7805 return GSL_SUCCESS;
7806 }
7807 else {
7808 result->val = -M_LN2 + x;
7809 result->err = 2.0 * GSL_DBL_EPSILON * fabs(result->val);
7810 return GSL_SUCCESS;
7811 }
7812}
7813
7814
7815int gsl_sf_lncosh_e(const double x, gsl_sf_result * result)
7816{
7817 /* CHECK_POINTER(result) */
7818
7819 if(fabs(x) < 1.0) {
7820 double eps;
7821 cosh_m1_series(x, &eps);
7822 return gsl_sf_log_1plusx_e(eps, result);
7823 }
7824 else if(fabs(x) < -0.5*GSL_LOG_DBL_EPSILON) {
7825 result->val = fabs(x) + log(0.5*(1.0 + exp(-2.0*fabs(x))));
7826 result->err = 2.0 * GSL_DBL_EPSILON * fabs(result->val);
7827 return GSL_SUCCESS;
7828 }
7829 else {
7830 result->val = -M_LN2 + fabs(x);
7831 result->err = 2.0 * GSL_DBL_EPSILON * fabs(result->val);
7832 return GSL_SUCCESS;
7833 }
7834}
7835
7836
7837/*
7838inline int gsl_sf_sincos_e(const double theta, double * s, double * c)
7839{
7840 double tan_half = tan(0.5 * theta);
7841 double den = 1. + tan_half*tan_half;
7842 double cos_theta = (1.0 - tan_half*tan_half) / den;
7843 double sin_theta = 2.0 * tan_half / den;
7844}
7845*/
7846
7847int
7848gsl_sf_polar_to_rect(const double r, const double theta,
7849 gsl_sf_result * x, gsl_sf_result * y)
7850{
7851 double t = theta;
7852 int status = gsl_sf_angle_restrict_symm_e(&t);
7853 double c = cos(t);
7854 double s = sin(t);
7855 x->val = r * cos(t);
7856 y->val = r * sin(t);
7857 x->err = r * fabs(s * GSL_DBL_EPSILON * t);
7858 x->err += 2.0 * GSL_DBL_EPSILON * fabs(x->val);
7859 y->err = r * fabs(c * GSL_DBL_EPSILON * t);
7860 y->err += 2.0 * GSL_DBL_EPSILON * fabs(y->val);
7861 return status;
7862}
7863
7864
7865int
7866gsl_sf_rect_to_polar(const double x, const double y,
7867 gsl_sf_result * r, gsl_sf_result * theta)
7868{
7869 int stat_h = gsl_sf_hypot_e(x, y, r);
7870 if(r->val > 0.0) {
7871 theta->val = atan2(y, x);
7872 theta->err = 2.0 * GSL_DBL_EPSILON * fabs(theta->val);
7873 return stat_h;
7874 }
7875 else {
7876 DOMAIN_ERROR(theta);
7877 }
7878}
7879
7880
7881int gsl_sf_angle_restrict_symm_err_e(const double theta, gsl_sf_result * result)
7882{
7883 /* synthetic extended precision constants */
7884 const double P1 = 4 * 7.8539812564849853515625e-01;
7885 const double P2 = 4 * 3.7748947079307981766760e-08;
7886 const double P3 = 4 * 2.6951514290790594840552e-15;
7887 const double TwoPi = 2*(P1 + P2 + P3);
7888
7889 const double y = GSL_SIGN(theta) * 2 * floor(fabs(theta)/TwoPi);
7890 double r = ((theta - y*P1) - y*P2) - y*P3;
7891
7892 if(r > M_PI) { r = (((r-2*P1)-2*P2)-2*P3); } /* r-TwoPi */
7893 else if (r < -M_PI) r = (((r+2*P1)+2*P2)+2*P3); /* r+TwoPi */
7894
7895 result->val = r;
7896
7897 if(fabs(theta) > 0.0625/GSL_DBL_EPSILON) {
7898 result->val = GSL_NAN;
7899 result->err = GSL_NAN;
7900 GSL_ERROR ("error", GSL_ELOSS);
7901 }
7902 else if(fabs(theta) > 0.0625/GSL_SQRT_DBL_EPSILON) {
7903 result->err = 2.0 * GSL_DBL_EPSILON * fabs(result->val - theta);
7904 return GSL_SUCCESS;
7905 }
7906 else {
7907 double delta = fabs(result->val - theta);
7908 result->err = 2.0 * GSL_DBL_EPSILON * ((delta < M_PI) ? delta : M_PI);
7909 return GSL_SUCCESS;
7910 }
7911}
7912
7913
7914int gsl_sf_angle_restrict_pos_err_e(const double theta, gsl_sf_result * result)
7915{
7916 /* synthetic extended precision constants */
7917 const double P1 = 4 * 7.85398125648498535156e-01;
7918 const double P2 = 4 * 3.77489470793079817668e-08;
7919 const double P3 = 4 * 2.69515142907905952645e-15;
7920 const double TwoPi = 2*(P1 + P2 + P3);
7921
7922 const double y = 2*floor(theta/TwoPi);
7923
7924 double r = ((theta - y*P1) - y*P2) - y*P3;
7925
7926 if(r > TwoPi) {r = (((r-2*P1)-2*P2)-2*P3); } /* r-TwoPi */
7927 else if (r < 0) { /* may happen due to FP rounding */
7928 r = (((r+2*P1)+2*P2)+2*P3); /* r+TwoPi */
7929 }
7930
7931 result->val = r;
7932
7933 if(fabs(theta) > 0.0625/GSL_DBL_EPSILON) {
7934 result->val = GSL_NAN;
7935 result->err = fabs(result->val);
7936 GSL_ERROR ("error", GSL_ELOSS);
7937 }
7938 else if(fabs(theta) > 0.0625/GSL_SQRT_DBL_EPSILON) {
7939 result->err = GSL_DBL_EPSILON * fabs(result->val - theta);
7940 return GSL_SUCCESS;
7941 }
7942 else {
7943 double delta = fabs(result->val - theta);
7944 result->err = 2.0 * GSL_DBL_EPSILON * ((delta < M_PI) ? delta : M_PI);
7945 return GSL_SUCCESS;
7946 }
7947}
7948
7949
7950int gsl_sf_angle_restrict_symm_e(double * theta)
7951{
7952 gsl_sf_result r;
7953 int stat = gsl_sf_angle_restrict_symm_err_e(*theta, &r);
7954 *theta = r.val;
7955 return stat;
7956}
7957
7958
7959int gsl_sf_angle_restrict_pos_e(double * theta)
7960{
7961 gsl_sf_result r;
7962 int stat = gsl_sf_angle_restrict_pos_err_e(*theta, &r);
7963 *theta = r.val;
7964 return stat;
7965}
7966
7967
7968int gsl_sf_sin_err_e(const double x, const double dx, gsl_sf_result * result)
7969{
7970 int stat_s = gsl_sf_sin_e(x, result);
7971 result->err += fabs(cos(x) * dx);
7972 result->err += GSL_DBL_EPSILON * fabs(result->val);
7973 return stat_s;
7974}
7975
7976
7977int gsl_sf_cos_err_e(const double x, const double dx, gsl_sf_result * result)
7978{
7979 int stat_c = gsl_sf_cos_e(x, result);
7980 result->err += fabs(sin(x) * dx);
7981 result->err += GSL_DBL_EPSILON * fabs(result->val);
7982 return stat_c;
7983}
7984
7985
7986#if 0
7987int
7988gsl_sf_sin_pi_x_e(const double x, gsl_sf_result * result)
7989{
7990 /* CHECK_POINTER(result) */
7991
7992 if(-100.0 < x && x < 100.0) {
7993 result->val = sin(M_PI * x) / (M_PI * x);
7994 result->err = 2.0 * GSL_DBL_EPSILON * fabs(result->val);
7995 return GSL_SUCCESS;
7996 }
7997 else {
7998 const double N = floor(x + 0.5);
7999 const double f = x - N;
8000
8001 if(N < INT_MAX && N > INT_MIN) {
8002 /* Make it an integer if we can. Saves another
8003 * call to floor().
8004 */
8005 const int intN = (int)N;
8006 const double sign = ( GSL_IS_ODD(intN) ? -1.0 : 1.0 );
8007 result->val = sign * sin(M_PI * f);
8008 result->err = GSL_DBL_EPSILON * fabs(result->val);
8009 }
8010 else if(N > 2.0/GSL_DBL_EPSILON || N < -2.0/GSL_DBL_EPSILON) {
8011 /* All integer-valued floating point numbers
8012 * bigger than 2/eps=2^53 are actually even.
8013 */
8014 result->val = 0.0;
8015 result->err = 0.0;
8016 }
8017 else {
8018 const double resN = N - 2.0*floor(0.5*N); /* 0 for even N, 1 for odd N */
8019 const double sign = ( fabs(resN) > 0.5 ? -1.0 : 1.0 );
8020 result->val = sign * sin(M_PI*f);
8021 result->err = GSL_DBL_EPSILON * fabs(result->val);
8022 }
8023
8024 return GSL_SUCCESS;
8025 }
8026}
8027#endif
8028
8029
8030int gsl_sf_sinc_e(double x, gsl_sf_result * result)
8031{
8032 /* CHECK_POINTER(result) */
8033
8034 {
8035 const double ax = fabs(x);
8036
8037 if(ax < 0.8) {
8038 /* Do not go to the limit of the fit since
8039 * there is a zero there and the Chebyshev
8040 * accuracy will go to zero.
8041 */
8042 return cheb_eval_e(&sinc_cs, 2.0*ax-1.0, result);
8043 }
8044 else if(ax < 100.0) {
8045 /* Small arguments are no problem.
8046 * We trust the library sin() to
8047 * roughly machine precision.
8048 */
8049 result->val = sin(M_PI * ax)/(M_PI * ax);
8050 result->err = 2.0 * GSL_DBL_EPSILON * fabs(result->val);
8051 return GSL_SUCCESS;
8052 }
8053 else {
8054 /* Large arguments must be handled separately.
8055 */
8056 const double r = M_PI*ax;
8057 gsl_sf_result s;
8058 int stat_s = gsl_sf_sin_e(r, &s);
8059 result->val = s.val/r;
8060 result->err = s.err/r + 2.0 * GSL_DBL_EPSILON * fabs(result->val);
8061 return stat_s;
8062 }
8063 }
8064}
8065
8066
8067
8068/*-*-*-*-*-*-*-*-*-* Functions w/ Natural Prototypes *-*-*-*-*-*-*-*-*-*-*/
8069
8070/* inlined: eval.h */
8071
8072double gsl_sf_sin(const double x)
8073{
8074 EVAL_RESULT(gsl_sf_sin_e(x, &result));
8075}
8076
8077double gsl_sf_cos(const double x)
8078{
8079 EVAL_RESULT(gsl_sf_cos_e(x, &result));
8080}
8081
8082double gsl_sf_hypot(const double x, const double y)
8083{
8084 EVAL_RESULT(gsl_sf_hypot_e(x, y, &result));
8085}
8086
8087double gsl_sf_lnsinh(const double x)
8088{
8089 EVAL_RESULT(gsl_sf_lnsinh_e(x, &result));
8090}
8091
8092double gsl_sf_lncosh(const double x)
8093{
8094 EVAL_RESULT(gsl_sf_lncosh_e(x, &result));
8095}
8096
8097double gsl_sf_angle_restrict_symm(const double theta)
8098{
8099 double result = theta;
8100 EVAL_DOUBLE(gsl_sf_angle_restrict_symm_e(&result));
8101}
8102
8103double gsl_sf_angle_restrict_pos(const double theta)
8104{
8105 double result = theta;
8106 EVAL_DOUBLE(gsl_sf_angle_restrict_pos_e(&result));
8107}
8108
8109#if 0
8110double gsl_sf_sin_pi_x(const double x)
8111{
8112 EVAL_RESULT(gsl_sf_sin_pi_x_e(x, &result));
8113}
8114#endif
8115
8116double gsl_sf_sinc(const double x)
8117{
8118 EVAL_RESULT(gsl_sf_sinc_e(x, &result));
8119}
8120/* end inlined source: specfunc/trig.c */
8121/* begin inlined source: specfunc/exp.c */
8122/* specfunc/exp.c
8123 *
8124 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
8125 *
8126 * This program is free software; you can redistribute it and/or modify
8127 * it under the terms of the GNU General Public License as published by
8128 * the Free Software Foundation; either version 3 of the License, or (at
8129 * your option) any later version.
8130 *
8131 * This program is distributed in the hope that it will be useful, but
8132 * WITHOUT ANY WARRANTY; without even the implied warranty of
8133 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
8134 * General Public License for more details.
8135 *
8136 * You should have received a copy of the GNU General Public License
8137 * along with this program; if not, write to the Free Software
8138 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
8139 */
8140
8141/* Author: G. Jungman */
8142/* begin inlined header: config.h */
8143#ifndef MARLEY_BUILTIN_GSL_CONFIG_WRAPPER_H
8144#define MARLEY_BUILTIN_GSL_CONFIG_WRAPPER_H
8145/* begin inlined header: gsl_config.h */
8146#ifndef MARLEY_BUILTIN_GSL_CONFIG_H
8147#define MARLEY_BUILTIN_GSL_CONFIG_H
8148
8149#define HAVE_INLINE 1
8150#define HAVE_DECL_ISFINITE 1
8151#define HAVE_DECL_ISNAN 1
8152#define HAVE_DECL_ISINF 1
8153#define GSL_COERCE_DBL(x) (x)
8154
8155#define GSL_DISABLE_DEPRECATED 0
8156#define PACKAGE_VERSION "2.8"
8157#define VERSION "2.8"
8158
8159#endif
8160
8161/* end inlined header: gsl_config.h */
8162#endif
8163
8164/* end inlined header: config.h */
8165#include <stdlib.h>
8166/* begin inlined header: gsl/gsl_math.h */
8167/* gsl_math.h
8168 *
8169 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2004, 2007 Gerard Jungman, Brian Gough
8170 *
8171 * This program is free software; you can redistribute it and/or modify
8172 * it under the terms of the GNU General Public License as published by
8173 * the Free Software Foundation; either version 3 of the License, or (at
8174 * your option) any later version.
8175 *
8176 * This program is distributed in the hope that it will be useful, but
8177 * WITHOUT ANY WARRANTY; without even the implied warranty of
8178 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
8179 * General Public License for more details.
8180 *
8181 * You should have received a copy of the GNU General Public License
8182 * along with this program; if not, write to the Free Software
8183 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
8184 */
8185
8186#ifndef __GSL_MATH_H__
8187#define __GSL_MATH_H__
8188#include <math.h>
8189/* begin inlined header: gsl/gsl_sys.h */
8190/* sys/gsl_sys.h
8191 *
8192 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, Brian Gough
8193 *
8194 * This program is free software; you can redistribute it and/or modify
8195 * it under the terms of the GNU General Public License as published by
8196 * the Free Software Foundation; either version 3 of the License, or (at
8197 * your option) any later version.
8198 *
8199 * This program is distributed in the hope that it will be useful, but
8200 * WITHOUT ANY WARRANTY; without even the implied warranty of
8201 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
8202 * General Public License for more details.
8203 *
8204 * You should have received a copy of the GNU General Public License
8205 * along with this program; if not, write to the Free Software
8206 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
8207 */
8208
8209#ifndef __GSL_SYS_H__
8210#define __GSL_SYS_H__
8211
8212
8213
8214__BEGIN_DECLS
8215
8216double gsl_log1p (const double x);
8217double gsl_expm1 (const double x);
8218double gsl_hypot (const double x, const double y);
8219double gsl_hypot3 (const double x, const double y, const double z);
8220double gsl_acosh (const double x);
8221double gsl_asinh (const double x);
8222double gsl_atanh (const double x);
8223
8224int gsl_isnan (const double x);
8225int gsl_isinf (const double x);
8226int gsl_finite (const double x);
8227
8228double gsl_nan (void);
8229double gsl_posinf (void);
8230double gsl_neginf (void);
8231double gsl_fdiv (const double x, const double y);
8232
8233double gsl_coerce_double (const double x);
8234float gsl_coerce_float (const float x);
8235long double gsl_coerce_long_double (const long double x);
8236
8237double gsl_ldexp(const double x, const int e);
8238double gsl_frexp(const double x, int * e);
8239
8240int gsl_fcmp (const double x1, const double x2, const double epsilon);
8241
8242__END_DECLS
8243
8244#endif /* __GSL_SYS_H__ */
8245
8246/* end inlined header: gsl/gsl_sys.h */
8247/* begin inlined header: gsl/gsl_inline.h */
8248/* gsl_inline.h
8249 *
8250 * Copyright (C) 2008, 2009 Brian Gough
8251 *
8252 * This program is free software; you can redistribute it and/or modify
8253 * it under the terms of the GNU General Public License as published by
8254 * the Free Software Foundation; either version 3 of the License, or (at
8255 * your option) any later version.
8256 *
8257 * This program is distributed in the hope that it will be useful, but
8258 * WITHOUT ANY WARRANTY; without even the implied warranty of
8259 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
8260 * General Public License for more details.
8261 *
8262 * You should have received a copy of the GNU General Public License
8263 * along with this program; if not, write to the Free Software
8264 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
8265 */
8266
8267#ifndef __GSL_INLINE_H__
8268#define __GSL_INLINE_H__
8269
8270/* In recent versiions of GCC, the inline keyword has two different
8271 forms: GNU and C99.
8272
8273 In GNU mode we can use 'extern inline' to make inline functions
8274 work like macros. The function is only inlined--it is never output
8275 as a definition in an object file.
8276
8277 In the new C99 mode 'extern inline' has a different meaning--it
8278 causes the definition of the function to be output in each object
8279 file where it is used. This will result in multiple-definition
8280 errors on linking. The 'inline' keyword on its own (without
8281 extern) has the same behavior as the original GNU 'extern inline'.
8282
8283 The C99 style is the default with -std=c99 in GCC 4.3.
8284
8285 This header file allows either form of inline to be used by
8286 redefining the macros INLINE_DECL and INLINE_FUN. These are used
8287 in the public header files as
8288
8289 INLINE_DECL double gsl_foo (double x);
8290 #ifdef HAVE_INLINE
8291 INLINE_FUN double gsl_foo (double x) { return x+1.0; } ;
8292 #endif
8293
8294*/
8295
8296#ifdef HAVE_INLINE
8297# if defined(__GNUC_STDC_INLINE__) || defined(GSL_C99_INLINE) || defined(HAVE_C99_INLINE)
8298# define INLINE_DECL inline /* use C99 inline */
8299# define INLINE_FUN inline
8300# else
8301# define INLINE_DECL /* use GNU extern inline */
8302# define INLINE_FUN extern inline
8303# endif
8304#else
8305# define INLINE_DECL /* */
8306#endif
8307
8308/* Range checking conditions in headers do not require any run-time
8309 tests of the global variable gsl_check_range. They are enabled or
8310 disabled in user code at compile time with GSL_RANGE_CHECK macro.
8311 See also build.h. */
8312#define GSL_RANGE_COND(x) (x)
8313
8314#endif /* __GSL_INLINE_H__ */
8315
8316/* end inlined header: gsl/gsl_inline.h */
8317/* begin inlined header: gsl/gsl_machine.h */
8318/* Author: B. Gough and G. Jungman */
8319#ifndef __GSL_MACHINE_H__
8320#define __GSL_MACHINE_H__
8321
8322#include <limits.h>
8323#include <float.h>
8324
8325/* magic constants; mostly for the benefit of the implementation */
8326
8327/* -*-MACHINE CONSTANTS-*-
8328 *
8329 * PLATFORM: Whiz-O-Matic 9000
8330 * FP_PLATFORM: IEEE-Virtual
8331 * HOSTNAME: nnn.lanl.gov
8332 * DATE: Fri Nov 20 17:53:26 MST 1998
8333 */
8334#define GSL_DBL_EPSILON 2.2204460492503131e-16
8335#define GSL_SQRT_DBL_EPSILON 1.4901161193847656e-08
8336#define GSL_ROOT3_DBL_EPSILON 6.0554544523933429e-06
8337#define GSL_ROOT4_DBL_EPSILON 1.2207031250000000e-04
8338#define GSL_ROOT5_DBL_EPSILON 7.4009597974140505e-04
8339#define GSL_ROOT6_DBL_EPSILON 2.4607833005759251e-03
8340#define GSL_LOG_DBL_EPSILON (-3.6043653389117154e+01)
8341
8342#define GSL_DBL_MIN 2.2250738585072014e-308
8343#define GSL_SQRT_DBL_MIN 1.4916681462400413e-154
8344#define GSL_ROOT3_DBL_MIN 2.8126442852362996e-103
8345#define GSL_ROOT4_DBL_MIN 1.2213386697554620e-77
8346#define GSL_ROOT5_DBL_MIN 2.9476022969691763e-62
8347#define GSL_ROOT6_DBL_MIN 5.3034368905798218e-52
8348#define GSL_LOG_DBL_MIN (-7.0839641853226408e+02)
8349
8350#define GSL_DBL_MAX 1.7976931348623157e+308
8351#define GSL_SQRT_DBL_MAX 1.3407807929942596e+154
8352#define GSL_ROOT3_DBL_MAX 5.6438030941222897e+102
8353#define GSL_ROOT4_DBL_MAX 1.1579208923731620e+77
8354#define GSL_ROOT5_DBL_MAX 4.4765466227572707e+61
8355#define GSL_ROOT6_DBL_MAX 2.3756689782295612e+51
8356#define GSL_LOG_DBL_MAX 7.0978271289338397e+02
8357
8358#define GSL_FLT_EPSILON 1.1920928955078125e-07
8359#define GSL_SQRT_FLT_EPSILON 3.4526698300124393e-04
8360#define GSL_ROOT3_FLT_EPSILON 4.9215666011518501e-03
8361#define GSL_ROOT4_FLT_EPSILON 1.8581361171917516e-02
8362#define GSL_ROOT5_FLT_EPSILON 4.1234622211652937e-02
8363#define GSL_ROOT6_FLT_EPSILON 7.0153878019335827e-02
8364#define GSL_LOG_FLT_EPSILON (-1.5942385152878742e+01)
8365
8366#define GSL_FLT_MIN 1.1754943508222875e-38
8367#define GSL_SQRT_FLT_MIN 1.0842021724855044e-19
8368#define GSL_ROOT3_FLT_MIN 2.2737367544323241e-13
8369#define GSL_ROOT4_FLT_MIN 3.2927225399135965e-10
8370#define GSL_ROOT5_FLT_MIN 2.5944428542140822e-08
8371#define GSL_ROOT6_FLT_MIN 4.7683715820312542e-07
8372#define GSL_LOG_FLT_MIN (-8.7336544750553102e+01)
8373
8374#define GSL_FLT_MAX 3.4028234663852886e+38
8375#define GSL_SQRT_FLT_MAX 1.8446743523953730e+19
8376#define GSL_ROOT3_FLT_MAX 6.9814635196223242e+12
8377#define GSL_ROOT4_FLT_MAX 4.2949672319999986e+09
8378#define GSL_ROOT5_FLT_MAX 5.0859007855960041e+07
8379#define GSL_ROOT6_FLT_MAX 2.6422459233807749e+06
8380#define GSL_LOG_FLT_MAX 8.8722839052068352e+01
8381
8382#define GSL_SFLT_EPSILON 4.8828125000000000e-04
8383#define GSL_SQRT_SFLT_EPSILON 2.2097086912079612e-02
8384#define GSL_ROOT3_SFLT_EPSILON 7.8745065618429588e-02
8385#define GSL_ROOT4_SFLT_EPSILON 1.4865088937534013e-01
8386#define GSL_ROOT5_SFLT_EPSILON 2.1763764082403100e-01
8387#define GSL_ROOT6_SFLT_EPSILON 2.8061551207734325e-01
8388#define GSL_LOG_SFLT_EPSILON (-7.6246189861593985e+00)
8389
8390/* !MACHINE CONSTANTS! */
8391
8392
8393/* a little internal backwards compatibility */
8394#define GSL_MACH_EPS GSL_DBL_EPSILON
8395
8396
8397
8398/* Here are the constants related to or derived from
8399 * machine constants. These are not to be confused with
8400 * the constants that define various precision levels
8401 * for the precision/error system.
8402 *
8403 * This information is determined at configure time
8404 * and is platform dependent. Edit at your own risk.
8405 *
8406 * PLATFORM: WHIZ-O-MATIC
8407 * CONFIG-DATE: Thu Nov 19 19:27:18 MST 1998
8408 * CONFIG-HOST: nnn.lanl.gov
8409 */
8410
8411/* machine precision constants */
8412/* #define GSL_MACH_EPS 1.0e-15 */
8413#define GSL_SQRT_MACH_EPS 3.2e-08
8414#define GSL_ROOT3_MACH_EPS 1.0e-05
8415#define GSL_ROOT4_MACH_EPS 0.000178
8416#define GSL_ROOT5_MACH_EPS 0.00100
8417#define GSL_ROOT6_MACH_EPS 0.00316
8418#define GSL_LOG_MACH_EPS (-34.54)
8419
8420
8421#endif /* __GSL_MACHINE_H__ */
8422
8423/* end inlined header: gsl/gsl_machine.h */
8424/* begin inlined header: gsl/gsl_precision.h */
8425/* gsl_precision.h
8426 *
8427 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
8428 *
8429 * This program is free software; you can redistribute it and/or modify
8430 * it under the terms of the GNU General Public License as published by
8431 * the Free Software Foundation; either version 3 of the License, or (at
8432 * your option) any later version.
8433 *
8434 * This program is distributed in the hope that it will be useful, but
8435 * WITHOUT ANY WARRANTY; without even the implied warranty of
8436 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
8437 * General Public License for more details.
8438 *
8439 * You should have received a copy of the GNU General Public License
8440 * along with this program; if not, write to the Free Software
8441 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
8442 */
8443
8444/* Author: B. Gough and G. Jungman */
8445
8446#ifndef __GSL_PRECISION_H__
8447#define __GSL_PRECISION_H__
8448/* begin inlined header: gsl/gsl_types.h */
8449/* gsl_types.h
8450 *
8451 * Copyright (C) 2001, 2007 Brian Gough
8452 *
8453 * This program is free software; you can redistribute it and/or modify
8454 * it under the terms of the GNU General Public License as published by
8455 * the Free Software Foundation; either version 3 of the License, or (at
8456 * your option) any later version.
8457 *
8458 * This program is distributed in the hope that it will be useful, but
8459 * WITHOUT ANY WARRANTY; without even the implied warranty of
8460 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
8461 * General Public License for more details.
8462 *
8463 * You should have received a copy of the GNU General Public License
8464 * along with this program; if not, write to the Free Software
8465 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
8466 */
8467
8468#ifndef __GSL_TYPES_H__
8469#define __GSL_TYPES_H__
8470
8471#ifndef GSL_VAR
8472
8473#ifdef WIN32
8474# ifdef GSL_DLL
8475# ifdef DLL_EXPORT
8476# define GSL_VAR extern __declspec(dllexport)
8477# else
8478# define GSL_VAR extern __declspec(dllimport)
8479# endif
8480# else
8481# define GSL_VAR extern
8482# endif
8483#else
8484# define GSL_VAR extern
8485#endif
8486
8487#endif
8488
8489#endif /* __GSL_TYPES_H__ */
8490
8491/* end inlined header: gsl/gsl_types.h */
8492
8493
8494__BEGIN_DECLS
8495
8496
8497/* A type for the precision indicator.
8498 * This is mainly for pedagogy.
8499 */
8500typedef unsigned int gsl_prec_t;
8501
8502
8503/* The number of precision types.
8504 * Remember that precision-mode
8505 * can index an array.
8506 */
8507#define _GSL_PREC_T_NUM 3
8508
8509
8510/* Arrays containing derived
8511 * precision constants for the
8512 * different precision levels.
8513 */
8514GSL_VAR const double gsl_prec_eps[];
8515GSL_VAR const double gsl_prec_sqrt_eps[];
8516GSL_VAR const double gsl_prec_root3_eps[];
8517GSL_VAR const double gsl_prec_root4_eps[];
8518GSL_VAR const double gsl_prec_root5_eps[];
8519GSL_VAR const double gsl_prec_root6_eps[];
8520
8521
8522__END_DECLS
8523
8524#endif /* __GSL_PRECISION_H__ */
8525
8526/* end inlined header: gsl/gsl_precision.h */
8527/* begin inlined header: gsl/gsl_nan.h */
8528/* gsl_nan.h
8529 *
8530 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, Brian Gough
8531 *
8532 * This program is free software; you can redistribute it and/or modify
8533 * it under the terms of the GNU General Public License as published by
8534 * the Free Software Foundation; either version 3 of the License, or (at
8535 * your option) any later version.
8536 *
8537 * This program is distributed in the hope that it will be useful, but
8538 * WITHOUT ANY WARRANTY; without even the implied warranty of
8539 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
8540 * General Public License for more details.
8541 *
8542 * You should have received a copy of the GNU General Public License
8543 * along with this program; if not, write to the Free Software
8544 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
8545 */
8546
8547#ifndef __GSL_NAN_H__
8548#define __GSL_NAN_H__
8549
8550#ifdef INFINITY
8551# define GSL_POSINF INFINITY
8552# define GSL_NEGINF (-INFINITY)
8553#elif defined(HUGE_VAL)
8554# define GSL_POSINF HUGE_VAL
8555# define GSL_NEGINF (-HUGE_VAL)
8556#else
8557# define GSL_POSINF (gsl_posinf())
8558# define GSL_NEGINF (gsl_neginf())
8559#endif
8560
8561#ifdef NAN
8562# define GSL_NAN NAN
8563#elif defined(INFINITY)
8564# define GSL_NAN (INFINITY/INFINITY)
8565#else
8566# define GSL_NAN (gsl_nan())
8567#endif
8568
8569#define GSL_POSZERO (+0.0)
8570#define GSL_NEGZERO (-0.0)
8571
8572#endif /* __GSL_NAN_H__ */
8573
8574/* end inlined header: gsl/gsl_nan.h */
8575/* begin inlined header: gsl/gsl_pow_int.h */
8576/* gsl_pow_int.h
8577 *
8578 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2004, 2007 Gerard Jungman, Brian Gough
8579 *
8580 * This program is free software; you can redistribute it and/or modify
8581 * it under the terms of the GNU General Public License as published by
8582 * the Free Software Foundation; either version 3 of the License, or (at
8583 * your option) any later version.
8584 *
8585 * This program is distributed in the hope that it will be useful, but
8586 * WITHOUT ANY WARRANTY; without even the implied warranty of
8587 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
8588 * General Public License for more details.
8589 *
8590 * You should have received a copy of the GNU General Public License
8591 * along with this program; if not, write to the Free Software
8592 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
8593 */
8594
8595#ifndef __GSL_POW_INT_H__
8596#define __GSL_POW_INT_H__
8597/* begin inlined header: gsl/gsl_inline.h */
8598/* gsl_inline.h
8599 *
8600 * Copyright (C) 2008, 2009 Brian Gough
8601 *
8602 * This program is free software; you can redistribute it and/or modify
8603 * it under the terms of the GNU General Public License as published by
8604 * the Free Software Foundation; either version 3 of the License, or (at
8605 * your option) any later version.
8606 *
8607 * This program is distributed in the hope that it will be useful, but
8608 * WITHOUT ANY WARRANTY; without even the implied warranty of
8609 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
8610 * General Public License for more details.
8611 *
8612 * You should have received a copy of the GNU General Public License
8613 * along with this program; if not, write to the Free Software
8614 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
8615 */
8616
8617#ifndef __GSL_INLINE_H__
8618#define __GSL_INLINE_H__
8619
8620/* In recent versiions of GCC, the inline keyword has two different
8621 forms: GNU and C99.
8622
8623 In GNU mode we can use 'extern inline' to make inline functions
8624 work like macros. The function is only inlined--it is never output
8625 as a definition in an object file.
8626
8627 In the new C99 mode 'extern inline' has a different meaning--it
8628 causes the definition of the function to be output in each object
8629 file where it is used. This will result in multiple-definition
8630 errors on linking. The 'inline' keyword on its own (without
8631 extern) has the same behavior as the original GNU 'extern inline'.
8632
8633 The C99 style is the default with -std=c99 in GCC 4.3.
8634
8635 This header file allows either form of inline to be used by
8636 redefining the macros INLINE_DECL and INLINE_FUN. These are used
8637 in the public header files as
8638
8639 INLINE_DECL double gsl_foo (double x);
8640 #ifdef HAVE_INLINE
8641 INLINE_FUN double gsl_foo (double x) { return x+1.0; } ;
8642 #endif
8643
8644*/
8645
8646#ifdef HAVE_INLINE
8647# if defined(__GNUC_STDC_INLINE__) || defined(GSL_C99_INLINE) || defined(HAVE_C99_INLINE)
8648# define INLINE_DECL inline /* use C99 inline */
8649# define INLINE_FUN inline
8650# else
8651# define INLINE_DECL /* use GNU extern inline */
8652# define INLINE_FUN extern inline
8653# endif
8654#else
8655# define INLINE_DECL /* */
8656#endif
8657
8658/* Range checking conditions in headers do not require any run-time
8659 tests of the global variable gsl_check_range. They are enabled or
8660 disabled in user code at compile time with GSL_RANGE_CHECK macro.
8661 See also build.h. */
8662#define GSL_RANGE_COND(x) (x)
8663
8664#endif /* __GSL_INLINE_H__ */
8665
8666/* end inlined header: gsl/gsl_inline.h */
8667
8668
8669__BEGIN_DECLS
8670
8671INLINE_DECL double gsl_pow_2(const double x);
8672INLINE_DECL double gsl_pow_3(const double x);
8673INLINE_DECL double gsl_pow_4(const double x);
8674INLINE_DECL double gsl_pow_5(const double x);
8675INLINE_DECL double gsl_pow_6(const double x);
8676INLINE_DECL double gsl_pow_7(const double x);
8677INLINE_DECL double gsl_pow_8(const double x);
8678INLINE_DECL double gsl_pow_9(const double x);
8679
8680#ifdef HAVE_INLINE
8681INLINE_FUN double gsl_pow_2(const double x) { return x*x; }
8682INLINE_FUN double gsl_pow_3(const double x) { return x*x*x; }
8683INLINE_FUN double gsl_pow_4(const double x) { double x2 = x*x; return x2*x2; }
8684INLINE_FUN double gsl_pow_5(const double x) { double x2 = x*x; return x2*x2*x; }
8685INLINE_FUN double gsl_pow_6(const double x) { double x2 = x*x; return x2*x2*x2; }
8686INLINE_FUN double gsl_pow_7(const double x) { double x3 = x*x*x; return x3*x3*x; }
8687INLINE_FUN double gsl_pow_8(const double x) { double x2 = x*x; double x4 = x2*x2; return x4*x4; }
8688INLINE_FUN double gsl_pow_9(const double x) { double x3 = x*x*x; return x3*x3*x3; }
8689#endif
8690
8691double gsl_pow_int(double x, int n);
8692double gsl_pow_uint(double x, unsigned int n);
8693
8694__END_DECLS
8695
8696#endif /* __GSL_POW_INT_H__ */
8697
8698/* end inlined header: gsl/gsl_pow_int.h */
8699/* begin inlined header: gsl/gsl_minmax.h */
8700/* gsl_minmax.h
8701 *
8702 * Copyright (C) 2008 Gerard Jungman, Brian Gough
8703 *
8704 * This program is free software; you can redistribute it and/or modify
8705 * it under the terms of the GNU General Public License as published by
8706 * the Free Software Foundation; either version 3 of the License, or (at
8707 * your option) any later version.
8708 *
8709 * This program is distributed in the hope that it will be useful, but
8710 * WITHOUT ANY WARRANTY; without even the implied warranty of
8711 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
8712 * General Public License for more details.
8713 *
8714 * You should have received a copy of the GNU General Public License
8715 * along with this program; if not, write to the Free Software
8716 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
8717 */
8718
8719#ifndef __GSL_MINMAX_H__
8720#define __GSL_MINMAX_H__
8721/* begin inlined header: gsl/gsl_inline.h */
8722/* gsl_inline.h
8723 *
8724 * Copyright (C) 2008, 2009 Brian Gough
8725 *
8726 * This program is free software; you can redistribute it and/or modify
8727 * it under the terms of the GNU General Public License as published by
8728 * the Free Software Foundation; either version 3 of the License, or (at
8729 * your option) any later version.
8730 *
8731 * This program is distributed in the hope that it will be useful, but
8732 * WITHOUT ANY WARRANTY; without even the implied warranty of
8733 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
8734 * General Public License for more details.
8735 *
8736 * You should have received a copy of the GNU General Public License
8737 * along with this program; if not, write to the Free Software
8738 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
8739 */
8740
8741#ifndef __GSL_INLINE_H__
8742#define __GSL_INLINE_H__
8743
8744/* In recent versiions of GCC, the inline keyword has two different
8745 forms: GNU and C99.
8746
8747 In GNU mode we can use 'extern inline' to make inline functions
8748 work like macros. The function is only inlined--it is never output
8749 as a definition in an object file.
8750
8751 In the new C99 mode 'extern inline' has a different meaning--it
8752 causes the definition of the function to be output in each object
8753 file where it is used. This will result in multiple-definition
8754 errors on linking. The 'inline' keyword on its own (without
8755 extern) has the same behavior as the original GNU 'extern inline'.
8756
8757 The C99 style is the default with -std=c99 in GCC 4.3.
8758
8759 This header file allows either form of inline to be used by
8760 redefining the macros INLINE_DECL and INLINE_FUN. These are used
8761 in the public header files as
8762
8763 INLINE_DECL double gsl_foo (double x);
8764 #ifdef HAVE_INLINE
8765 INLINE_FUN double gsl_foo (double x) { return x+1.0; } ;
8766 #endif
8767
8768*/
8769
8770#ifdef HAVE_INLINE
8771# if defined(__GNUC_STDC_INLINE__) || defined(GSL_C99_INLINE) || defined(HAVE_C99_INLINE)
8772# define INLINE_DECL inline /* use C99 inline */
8773# define INLINE_FUN inline
8774# else
8775# define INLINE_DECL /* use GNU extern inline */
8776# define INLINE_FUN extern inline
8777# endif
8778#else
8779# define INLINE_DECL /* */
8780#endif
8781
8782/* Range checking conditions in headers do not require any run-time
8783 tests of the global variable gsl_check_range. They are enabled or
8784 disabled in user code at compile time with GSL_RANGE_CHECK macro.
8785 See also build.h. */
8786#define GSL_RANGE_COND(x) (x)
8787
8788#endif /* __GSL_INLINE_H__ */
8789
8790/* end inlined header: gsl/gsl_inline.h */
8791
8792
8793__BEGIN_DECLS
8794
8795/* Define MAX and MIN macros/functions if they don't exist. */
8796
8797/* plain old macros for general use */
8798#define GSL_MAX(a,b) ((a) > (b) ? (a) : (b))
8799#define GSL_MIN(a,b) ((a) < (b) ? (a) : (b))
8800
8801/* function versions of the above, in case they are needed */
8802double gsl_max (double a, double b);
8803double gsl_min (double a, double b);
8804
8805/* inline-friendly strongly typed versions */
8806#ifdef HAVE_INLINE
8807
8808INLINE_FUN int GSL_MAX_INT (int a, int b);
8809INLINE_FUN int GSL_MIN_INT (int a, int b);
8810INLINE_FUN double GSL_MAX_DBL (double a, double b);
8811INLINE_FUN double GSL_MIN_DBL (double a, double b);
8812INLINE_FUN long double GSL_MAX_LDBL (long double a, long double b);
8813INLINE_FUN long double GSL_MIN_LDBL (long double a, long double b);
8814
8815INLINE_FUN int
8816GSL_MAX_INT (int a, int b)
8817{
8818 return GSL_MAX (a, b);
8819}
8820
8821INLINE_FUN int
8822GSL_MIN_INT (int a, int b)
8823{
8824 return GSL_MIN (a, b);
8825}
8826
8827INLINE_FUN double
8828GSL_MAX_DBL (double a, double b)
8829{
8830 return GSL_MAX (a, b);
8831}
8832
8833INLINE_FUN double
8834GSL_MIN_DBL (double a, double b)
8835{
8836 return GSL_MIN (a, b);
8837}
8838
8839INLINE_FUN long double
8840GSL_MAX_LDBL (long double a, long double b)
8841{
8842 return GSL_MAX (a, b);
8843}
8844
8845INLINE_FUN long double
8846GSL_MIN_LDBL (long double a, long double b)
8847{
8848 return GSL_MIN (a, b);
8849}
8850#else
8851#define GSL_MAX_INT(a,b) GSL_MAX(a,b)
8852#define GSL_MIN_INT(a,b) GSL_MIN(a,b)
8853#define GSL_MAX_DBL(a,b) GSL_MAX(a,b)
8854#define GSL_MIN_DBL(a,b) GSL_MIN(a,b)
8855#define GSL_MAX_LDBL(a,b) GSL_MAX(a,b)
8856#define GSL_MIN_LDBL(a,b) GSL_MIN(a,b)
8857#endif /* HAVE_INLINE */
8858
8859__END_DECLS
8860
8861#endif /* __GSL_POW_INT_H__ */
8862
8863/* end inlined header: gsl/gsl_minmax.h */
8864#ifndef M_E
8865#define M_E 2.71828182845904523536028747135 /* e */
8866#endif
8867
8868#ifndef M_LOG2E
8869#define M_LOG2E 1.44269504088896340735992468100 /* log_2 (e) */
8870#endif
8871
8872#ifndef M_LOG10E
8873#define M_LOG10E 0.43429448190325182765112891892 /* log_10 (e) */
8874#endif
8875
8876#ifndef M_SQRT2
8877#define M_SQRT2 1.41421356237309504880168872421 /* sqrt(2) */
8878#endif
8879
8880#ifndef M_SQRT1_2
8881#define M_SQRT1_2 0.70710678118654752440084436210 /* sqrt(1/2) */
8882#endif
8883
8884
8885#ifndef M_SQRT3
8886#define M_SQRT3 1.73205080756887729352744634151 /* sqrt(3) */
8887#endif
8888
8889#ifndef M_PI
8890#define M_PI 3.14159265358979323846264338328 /* pi */
8891#endif
8892
8893#ifndef M_PI_2
8894#define M_PI_2 1.57079632679489661923132169164 /* pi/2 */
8895#endif
8896
8897#ifndef M_PI_4
8898#define M_PI_4 0.78539816339744830961566084582 /* pi/4 */
8899#endif
8900
8901#ifndef M_SQRTPI
8902#define M_SQRTPI 1.77245385090551602729816748334 /* sqrt(pi) */
8903#endif
8904
8905#ifndef M_2_SQRTPI
8906#define M_2_SQRTPI 1.12837916709551257389615890312 /* 2/sqrt(pi) */
8907#endif
8908
8909#ifndef M_1_PI
8910#define M_1_PI 0.31830988618379067153776752675 /* 1/pi */
8911#endif
8912
8913#ifndef M_2_PI
8914#define M_2_PI 0.63661977236758134307553505349 /* 2/pi */
8915#endif
8916
8917#ifndef M_LN10
8918#define M_LN10 2.30258509299404568401799145468 /* ln(10) */
8919#endif
8920
8921#ifndef M_LN2
8922#define M_LN2 0.69314718055994530941723212146 /* ln(2) */
8923#endif
8924
8925#ifndef M_LNPI
8926#define M_LNPI 1.14472988584940017414342735135 /* ln(pi) */
8927#endif
8928
8929#ifndef M_EULER
8930#define M_EULER 0.57721566490153286060651209008 /* Euler constant */
8931#endif
8932
8933
8934
8935__BEGIN_DECLS
8936
8937/* other needlessly compulsive abstractions */
8938
8939#define GSL_IS_ODD(n) ((n) & 1)
8940#define GSL_IS_EVEN(n) (!(GSL_IS_ODD(n)))
8941#define GSL_SIGN(x) ((x) >= 0.0 ? 1 : -1)
8942
8943/* Return nonzero if x is a real number, i.e. non NaN or infinite. */
8944#define GSL_IS_REAL(x) (gsl_finite(x))
8945
8946/* Definition of an arbitrary function with parameters */
8947
8949{
8950 double (* function) (double x, void * params);
8951 void * params;
8952};
8953
8954typedef struct gsl_function_struct gsl_function ;
8955
8956#define GSL_FN_EVAL(F,x) (*((F)->function))(x,(F)->params)
8957
8958/* Definition of an arbitrary function returning two values, r1, r2 */
8959
8961{
8962 double (* f) (double x, void * params);
8963 double (* df) (double x, void * params);
8964 void (* fdf) (double x, void * params, double * f, double * df);
8965 void * params;
8966};
8967
8968typedef struct gsl_function_fdf_struct gsl_function_fdf ;
8969
8970#define GSL_FN_FDF_EVAL_F(FDF,x) (*((FDF)->f))(x,(FDF)->params)
8971#define GSL_FN_FDF_EVAL_DF(FDF,x) (*((FDF)->df))(x,(FDF)->params)
8972#define GSL_FN_FDF_EVAL_F_DF(FDF,x,y,dy) (*((FDF)->fdf))(x,(FDF)->params,(y),(dy))
8973
8974
8975/* Definition of an arbitrary vector-valued function with parameters */
8976
8978{
8979 int (* function) (double x, double y[], void * params);
8980 void * params;
8981};
8982
8983typedef struct gsl_function_vec_struct gsl_function_vec ;
8984
8985#define GSL_FN_VEC_EVAL(F,x,y) (*((F)->function))(x,y,(F)->params)
8986
8987__END_DECLS
8988
8989#endif /* __GSL_MATH_H__ */
8990
8991/* end inlined header: gsl/gsl_math.h */
8992/* begin inlined header: gsl/gsl_errno.h */
8993/* err/gsl_errno.h
8994 *
8995 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, Brian Gough
8996 *
8997 * This program is free software; you can redistribute it and/or modify
8998 * it under the terms of the GNU General Public License as published by
8999 * the Free Software Foundation; either version 3 of the License, or (at
9000 * your option) any later version.
9001 *
9002 * This program is distributed in the hope that it will be useful, but
9003 * WITHOUT ANY WARRANTY; without even the implied warranty of
9004 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9005 * General Public License for more details.
9006 *
9007 * You should have received a copy of the GNU General Public License
9008 * along with this program; if not, write to the Free Software
9009 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
9010 */
9011
9012#ifndef __GSL_ERRNO_H__
9013#define __GSL_ERRNO_H__
9014
9015#include <stdio.h>
9016#include <errno.h>
9017/* begin inlined header: gsl/gsl_types.h */
9018/* gsl_types.h
9019 *
9020 * Copyright (C) 2001, 2007 Brian Gough
9021 *
9022 * This program is free software; you can redistribute it and/or modify
9023 * it under the terms of the GNU General Public License as published by
9024 * the Free Software Foundation; either version 3 of the License, or (at
9025 * your option) any later version.
9026 *
9027 * This program is distributed in the hope that it will be useful, but
9028 * WITHOUT ANY WARRANTY; without even the implied warranty of
9029 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9030 * General Public License for more details.
9031 *
9032 * You should have received a copy of the GNU General Public License
9033 * along with this program; if not, write to the Free Software
9034 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
9035 */
9036
9037#ifndef __GSL_TYPES_H__
9038#define __GSL_TYPES_H__
9039
9040#ifndef GSL_VAR
9041
9042#ifdef WIN32
9043# ifdef GSL_DLL
9044# ifdef DLL_EXPORT
9045# define GSL_VAR extern __declspec(dllexport)
9046# else
9047# define GSL_VAR extern __declspec(dllimport)
9048# endif
9049# else
9050# define GSL_VAR extern
9051# endif
9052#else
9053# define GSL_VAR extern
9054#endif
9055
9056#endif
9057
9058#endif /* __GSL_TYPES_H__ */
9059
9060/* end inlined header: gsl/gsl_types.h */
9061
9062
9063__BEGIN_DECLS
9064
9065enum {
9066 GSL_SUCCESS = 0,
9067 GSL_FAILURE = -1,
9068 GSL_CONTINUE = -2, /* iteration has not converged */
9069 GSL_EDOM = 1, /* input domain error, e.g sqrt(-1) */
9070 GSL_ERANGE = 2, /* output range error, e.g. exp(1e100) */
9071 GSL_EFAULT = 3, /* invalid pointer */
9072 GSL_EINVAL = 4, /* invalid argument supplied by user */
9073 GSL_EFAILED = 5, /* generic failure */
9074 GSL_EFACTOR = 6, /* factorization failed */
9075 GSL_ESANITY = 7, /* sanity check failed - shouldn't happen */
9076 GSL_ENOMEM = 8, /* malloc failed */
9077 GSL_EBADFUNC = 9, /* problem with user-supplied function */
9078 GSL_ERUNAWAY = 10, /* iterative process is out of control */
9079 GSL_EMAXITER = 11, /* exceeded max number of iterations */
9080 GSL_EZERODIV = 12, /* tried to divide by zero */
9081 GSL_EBADTOL = 13, /* user specified an invalid tolerance */
9082 GSL_ETOL = 14, /* failed to reach the specified tolerance */
9083 GSL_EUNDRFLW = 15, /* underflow */
9084 GSL_EOVRFLW = 16, /* overflow */
9085 GSL_ELOSS = 17, /* loss of accuracy */
9086 GSL_EROUND = 18, /* failed because of roundoff error */
9087 GSL_EBADLEN = 19, /* matrix, vector lengths are not conformant */
9088 GSL_ENOTSQR = 20, /* matrix not square */
9089 GSL_ESING = 21, /* apparent singularity detected */
9090 GSL_EDIVERGE = 22, /* integral or series is divergent */
9091 GSL_EUNSUP = 23, /* requested feature is not supported by the hardware */
9092 GSL_EUNIMPL = 24, /* requested feature not (yet) implemented */
9093 GSL_ECACHE = 25, /* cache limit exceeded */
9094 GSL_ETABLE = 26, /* table limit exceeded */
9095 GSL_ENOPROG = 27, /* iteration is not making progress towards solution */
9096 GSL_ENOPROGJ = 28, /* jacobian evaluations are not improving the solution */
9097 GSL_ETOLF = 29, /* cannot reach the specified tolerance in F */
9098 GSL_ETOLX = 30, /* cannot reach the specified tolerance in X */
9099 GSL_ETOLG = 31, /* cannot reach the specified tolerance in gradient */
9100 GSL_EOF = 32 /* end of file */
9101} ;
9102
9103void gsl_error (const char * reason, const char * file, int line,
9104 int gsl_errno);
9105
9106void gsl_stream_printf (const char *label, const char *file,
9107 int line, const char *reason);
9108
9109typedef void gsl_error_handler_t (const char * reason, const char * file,
9110 int line, int gsl_errno);
9111
9112gsl_error_handler_t *
9113gsl_set_error_handler (gsl_error_handler_t * new_handler);
9114
9115/* GSL_ERROR: call the error handler, and return the error code */
9116
9117#define GSL_ERROR(reason, gsl_errno) \
9118 do { \
9119 gsl_error (reason, __FILE__, __LINE__, gsl_errno) ; \
9120 return gsl_errno ; \
9121 } while (0)
9122
9123/* GSL_ERROR_VAL: call the error handler, and return the given value */
9124
9125#define GSL_ERROR_VAL(reason, gsl_errno, value) \
9126 do { \
9127 gsl_error (reason, __FILE__, __LINE__, gsl_errno) ; \
9128 return value ; \
9129 } while (0)
9130
9131/* GSL_ERROR_VOID: call the error handler, and then return
9132 (for void functions which still need to generate an error) */
9133
9134#define GSL_ERROR_VOID(reason, gsl_errno) \
9135 do { \
9136 gsl_error (reason, __FILE__, __LINE__, gsl_errno) ; \
9137 return ; \
9138 } while (0)
9139
9140/* GSL_ERROR_NULL suitable for out-of-memory conditions */
9141
9142#define GSL_ERROR_NULL(reason, gsl_errno) GSL_ERROR_VAL(reason, gsl_errno, 0)
9143
9144/* Sometimes you have several status results returned from
9145 * function calls and you want to combine them in some sensible
9146 * way. You cannot produce a "total" status condition, but you can
9147 * pick one from a set of conditions based on an implied hierarchy.
9148 *
9149 * In other words:
9150 * you have: status_a, status_b, ...
9151 * you want: status = (status_a if it is bad, or status_b if it is bad,...)
9152 *
9153 * In this example you consider status_a to be more important and
9154 * it is checked first, followed by the others in the order specified.
9155 *
9156 * Here are some dumb macros to do this.
9157 */
9158#define GSL_ERROR_SELECT_2(a,b) ((a) != GSL_SUCCESS ? (a) : ((b) != GSL_SUCCESS ? (b) : GSL_SUCCESS))
9159#define GSL_ERROR_SELECT_3(a,b,c) ((a) != GSL_SUCCESS ? (a) : GSL_ERROR_SELECT_2(b,c))
9160#define GSL_ERROR_SELECT_4(a,b,c,d) ((a) != GSL_SUCCESS ? (a) : GSL_ERROR_SELECT_3(b,c,d))
9161#define GSL_ERROR_SELECT_5(a,b,c,d,e) ((a) != GSL_SUCCESS ? (a) : GSL_ERROR_SELECT_4(b,c,d,e))
9162
9163#define GSL_STATUS_UPDATE(sp, s) do { if ((s) != GSL_SUCCESS) *(sp) = (s);} while(0)
9164
9165__END_DECLS
9166
9167#endif /* __GSL_ERRNO_H__ */
9168
9169/* end inlined header: gsl/gsl_errno.h */
9170/* begin inlined header: gsl/gsl_sf_gamma.h */
9171/* specfunc/gsl_sf_gamma.h
9172 *
9173 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
9174 *
9175 * This program is free software; you can redistribute it and/or modify
9176 * it under the terms of the GNU General Public License as published by
9177 * the Free Software Foundation; either version 3 of the License, or (at
9178 * your option) any later version.
9179 *
9180 * This program is distributed in the hope that it will be useful, but
9181 * WITHOUT ANY WARRANTY; without even the implied warranty of
9182 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9183 * General Public License for more details.
9184 *
9185 * You should have received a copy of the GNU General Public License
9186 * along with this program; if not, write to the Free Software
9187 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
9188 */
9189
9190/* Author: G. Jungman */
9191
9192#ifndef __GSL_SF_GAMMA_H__
9193#define __GSL_SF_GAMMA_H__
9194/* begin inlined header: gsl/gsl_sf_result.h */
9195/* specfunc/gsl_sf_result.h
9196 *
9197 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
9198 *
9199 * This program is free software; you can redistribute it and/or modify
9200 * it under the terms of the GNU General Public License as published by
9201 * the Free Software Foundation; either version 3 of the License, or (at
9202 * your option) any later version.
9203 *
9204 * This program is distributed in the hope that it will be useful, but
9205 * WITHOUT ANY WARRANTY; without even the implied warranty of
9206 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9207 * General Public License for more details.
9208 *
9209 * You should have received a copy of the GNU General Public License
9210 * along with this program; if not, write to the Free Software
9211 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
9212 */
9213
9214/* Author: G. Jungman */
9215
9216#ifndef __GSL_SF_RESULT_H__
9217#define __GSL_SF_RESULT_H__
9218
9219
9220
9221__BEGIN_DECLS
9222
9223struct gsl_sf_result_struct {
9224 double val;
9225 double err;
9226};
9227typedef struct gsl_sf_result_struct gsl_sf_result;
9228
9229#define GSL_SF_RESULT_SET(r,v,e) do { (r)->val=(v); (r)->err=(e); } while(0)
9230
9231
9233 double val;
9234 double err;
9235 int e10;
9236};
9237typedef struct gsl_sf_result_e10_struct gsl_sf_result_e10;
9238
9239
9240int gsl_sf_result_smash_e(const gsl_sf_result_e10 * re, gsl_sf_result * r);
9241
9242
9243__END_DECLS
9244
9245#endif /* __GSL_SF_RESULT_H__ */
9246
9247/* end inlined header: gsl/gsl_sf_result.h */
9248
9249
9250__BEGIN_DECLS
9251
9252
9253/* Log[Gamma(x)], x not a negative integer
9254 * Uses real Lanczos method.
9255 * Returns the real part of Log[Gamma[x]] when x < 0,
9256 * i.e. Log[|Gamma[x]|].
9257 *
9258 * exceptions: GSL_EDOM, GSL_EROUND
9259 */
9260int gsl_sf_lngamma_e(double x, gsl_sf_result * result);
9261double gsl_sf_lngamma(const double x);
9262
9263
9264/* Log[Gamma(x)], x not a negative integer
9265 * Uses real Lanczos method. Determines
9266 * the sign of Gamma[x] as well as Log[|Gamma[x]|] for x < 0.
9267 * So Gamma[x] = sgn * Exp[result_lg].
9268 *
9269 * exceptions: GSL_EDOM, GSL_EROUND
9270 */
9271int gsl_sf_lngamma_sgn_e(double x, gsl_sf_result * result_lg, double *sgn);
9272
9273
9274/* Gamma(x), x not a negative integer
9275 * Uses real Lanczos method.
9276 *
9277 * exceptions: GSL_EDOM, GSL_EOVRFLW, GSL_EROUND
9278 */
9279int gsl_sf_gamma_e(const double x, gsl_sf_result * result);
9280double gsl_sf_gamma(const double x);
9281
9282
9283/* Regulated Gamma Function, x > 0
9284 * Gamma^*(x) = Gamma(x)/(Sqrt[2Pi] x^(x-1/2) exp(-x))
9285 * = (1 + 1/(12x) + ...), x->Inf
9286 * A useful suggestion of Temme.
9287 *
9288 * exceptions: GSL_EDOM
9289 */
9290int gsl_sf_gammastar_e(const double x, gsl_sf_result * result);
9291double gsl_sf_gammastar(const double x);
9292
9293
9294/* 1/Gamma(x)
9295 * Uses real Lanczos method.
9296 *
9297 * exceptions: GSL_EUNDRFLW, GSL_EROUND
9298 */
9299int gsl_sf_gammainv_e(const double x, gsl_sf_result * result);
9300double gsl_sf_gammainv(const double x);
9301
9302
9303/* Log[Gamma(z)] for z complex, z not a negative integer
9304 * Uses complex Lanczos method. Note that the phase part (arg)
9305 * is not well-determined when |z| is very large, due
9306 * to inevitable roundoff in restricting to (-Pi,Pi].
9307 * This will raise the GSL_ELOSS exception when it occurs.
9308 * The absolute value part (lnr), however, never suffers.
9309 *
9310 * Calculates:
9311 * lnr = log|Gamma(z)|
9312 * arg = arg(Gamma(z)) in (-Pi, Pi]
9313 *
9314 * exceptions: GSL_EDOM, GSL_ELOSS
9315 */
9316int gsl_sf_lngamma_complex_e(double zr, double zi, gsl_sf_result * lnr, gsl_sf_result * arg);
9317
9318
9319/* x^n / n!
9320 *
9321 * x >= 0.0, n >= 0
9322 * exceptions: GSL_EDOM, GSL_EOVRFLW, GSL_EUNDRFLW
9323 */
9324int gsl_sf_taylorcoeff_e(const int n, const double x, gsl_sf_result * result);
9325double gsl_sf_taylorcoeff(const int n, const double x);
9326
9327
9328/* n!
9329 *
9330 * exceptions: GSL_EDOM, GSL_EOVRFLW
9331 */
9332int gsl_sf_fact_e(const unsigned int n, gsl_sf_result * result);
9333double gsl_sf_fact(const unsigned int n);
9334
9335
9336/* n!! = n(n-2)(n-4) ...
9337 *
9338 * exceptions: GSL_EDOM, GSL_EOVRFLW
9339 */
9340int gsl_sf_doublefact_e(const unsigned int n, gsl_sf_result * result);
9341double gsl_sf_doublefact(const unsigned int n);
9342
9343
9344/* log(n!)
9345 * Faster than ln(Gamma(n+1)) for n < 170; defers for larger n.
9346 *
9347 * exceptions: none
9348 */
9349int gsl_sf_lnfact_e(const unsigned int n, gsl_sf_result * result);
9350double gsl_sf_lnfact(const unsigned int n);
9351
9352
9353/* log(n!!)
9354 *
9355 * exceptions: none
9356 */
9357int gsl_sf_lndoublefact_e(const unsigned int n, gsl_sf_result * result);
9358double gsl_sf_lndoublefact(const unsigned int n);
9359
9360
9361/* log(n choose m)
9362 *
9363 * exceptions: GSL_EDOM
9364 */
9365int gsl_sf_lnchoose_e(unsigned int n, unsigned int m, gsl_sf_result * result);
9366double gsl_sf_lnchoose(unsigned int n, unsigned int m);
9367
9368
9369/* n choose m
9370 *
9371 * exceptions: GSL_EDOM, GSL_EOVRFLW
9372 */
9373int gsl_sf_choose_e(unsigned int n, unsigned int m, gsl_sf_result * result);
9374double gsl_sf_choose(unsigned int n, unsigned int m);
9375
9376
9377/* Logarithm of Pochhammer (Apell) symbol
9378 * log( (a)_x )
9379 * where (a)_x := Gamma[a + x]/Gamma[a]
9380 *
9381 * a > 0, a+x > 0
9382 *
9383 * exceptions: GSL_EDOM
9384 */
9385int gsl_sf_lnpoch_e(const double a, const double x, gsl_sf_result * result);
9386double gsl_sf_lnpoch(const double a, const double x);
9387
9388
9389/* Logarithm of Pochhammer (Apell) symbol, with sign information.
9390 * result = log( |(a)_x| )
9391 * sgn = sgn( (a)_x )
9392 * where (a)_x := Gamma[a + x]/Gamma[a]
9393 *
9394 * a != neg integer, a+x != neg integer
9395 *
9396 * exceptions: GSL_EDOM
9397 */
9398int gsl_sf_lnpoch_sgn_e(const double a, const double x, gsl_sf_result * result, double * sgn);
9399
9400
9401/* Pochhammer (Apell) symbol
9402 * (a)_x := Gamma[a + x]/Gamma[x]
9403 *
9404 * a != neg integer, a+x != neg integer
9405 *
9406 * exceptions: GSL_EDOM, GSL_EOVRFLW
9407 */
9408int gsl_sf_poch_e(const double a, const double x, gsl_sf_result * result);
9409double gsl_sf_poch(const double a, const double x);
9410
9411
9412/* Relative Pochhammer (Apell) symbol
9413 * ((a,x) - 1)/x
9414 * where (a,x) = (a)_x := Gamma[a + x]/Gamma[a]
9415 *
9416 * exceptions: GSL_EDOM
9417 */
9418int gsl_sf_pochrel_e(const double a, const double x, gsl_sf_result * result);
9419double gsl_sf_pochrel(const double a, const double x);
9420
9421
9422/* Normalized Incomplete Gamma Function
9423 *
9424 * Q(a,x) = 1/Gamma(a) Integral[ t^(a-1) e^(-t), {t,x,Infinity} ]
9425 *
9426 * a >= 0, x >= 0
9427 * Q(a,0) := 1
9428 * Q(0,x) := 0, x != 0
9429 *
9430 * exceptions: GSL_EDOM
9431 */
9432int gsl_sf_gamma_inc_Q_e(const double a, const double x, gsl_sf_result * result);
9433double gsl_sf_gamma_inc_Q(const double a, const double x);
9434
9435
9436/* Complementary Normalized Incomplete Gamma Function
9437 *
9438 * P(a,x) = 1/Gamma(a) Integral[ t^(a-1) e^(-t), {t,0,x} ]
9439 *
9440 * a > 0, x >= 0
9441 *
9442 * exceptions: GSL_EDOM
9443 */
9444int gsl_sf_gamma_inc_P_e(const double a, const double x, gsl_sf_result * result);
9445double gsl_sf_gamma_inc_P(const double a, const double x);
9446
9447
9448/* Non-normalized Incomplete Gamma Function
9449 *
9450 * Gamma(a,x) := Integral[ t^(a-1) e^(-t), {t,x,Infinity} ]
9451 *
9452 * x >= 0.0
9453 * Gamma(a, 0) := Gamma(a)
9454 *
9455 * exceptions: GSL_EDOM
9456 */
9457int gsl_sf_gamma_inc_e(const double a, const double x, gsl_sf_result * result);
9458double gsl_sf_gamma_inc(const double a, const double x);
9459
9460
9461/* Logarithm of Beta Function
9462 * Log[B(a,b)]
9463 *
9464 * a > 0, b > 0
9465 * exceptions: GSL_EDOM
9466 */
9467int gsl_sf_lnbeta_e(const double a, const double b, gsl_sf_result * result);
9468double gsl_sf_lnbeta(const double a, const double b);
9469
9470int gsl_sf_lnbeta_sgn_e(const double x, const double y, gsl_sf_result * result, double * sgn);
9471
9472
9473/* Beta Function
9474 * B(a,b)
9475 *
9476 * a > 0, b > 0
9477 * exceptions: GSL_EDOM, GSL_EOVRFLW, GSL_EUNDRFLW
9478 */
9479int gsl_sf_beta_e(const double a, const double b, gsl_sf_result * result);
9480double gsl_sf_beta(const double a, const double b);
9481
9482
9483/* Normalized Incomplete Beta Function
9484 * B_x(a,b)/B(a,b)
9485 *
9486 * a > 0, b > 0, 0 <= x <= 1
9487 * exceptions: GSL_EDOM, GSL_EUNDRFLW
9488 */
9489int gsl_sf_beta_inc_e(const double a, const double b, const double x, gsl_sf_result * result);
9490double gsl_sf_beta_inc(const double a, const double b, const double x);
9491
9492
9493/* The maximum x such that gamma(x) is not
9494 * considered an overflow.
9495 */
9496#define GSL_SF_GAMMA_XMAX 171.0
9497
9498/* The maximum n such that gsl_sf_fact(n) does not give an overflow. */
9499#define GSL_SF_FACT_NMAX 170
9500
9501/* The maximum n such that gsl_sf_doublefact(n) does not give an overflow. */
9502#define GSL_SF_DOUBLEFACT_NMAX 297
9503
9504__END_DECLS
9505
9506#endif /* __GSL_SF_GAMMA_H__ */
9507
9508/* end inlined header: gsl/gsl_sf_gamma.h */
9509/* begin inlined header: gsl/gsl_sf_exp.h */
9510/* specfunc/gsl_sf_exp.h
9511 *
9512 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2004 Gerard Jungman
9513 *
9514 * This program is free software; you can redistribute it and/or modify
9515 * it under the terms of the GNU General Public License as published by
9516 * the Free Software Foundation; either version 3 of the License, or (at
9517 * your option) any later version.
9518 *
9519 * This program is distributed in the hope that it will be useful, but
9520 * WITHOUT ANY WARRANTY; without even the implied warranty of
9521 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9522 * General Public License for more details.
9523 *
9524 * You should have received a copy of the GNU General Public License
9525 * along with this program; if not, write to the Free Software
9526 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
9527 */
9528
9529/* Author: G. Jungman */
9530
9531#ifndef __GSL_SF_EXP_H__
9532#define __GSL_SF_EXP_H__
9533/* begin inlined header: gsl/gsl_sf_result.h */
9534/* specfunc/gsl_sf_result.h
9535 *
9536 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
9537 *
9538 * This program is free software; you can redistribute it and/or modify
9539 * it under the terms of the GNU General Public License as published by
9540 * the Free Software Foundation; either version 3 of the License, or (at
9541 * your option) any later version.
9542 *
9543 * This program is distributed in the hope that it will be useful, but
9544 * WITHOUT ANY WARRANTY; without even the implied warranty of
9545 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9546 * General Public License for more details.
9547 *
9548 * You should have received a copy of the GNU General Public License
9549 * along with this program; if not, write to the Free Software
9550 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
9551 */
9552
9553/* Author: G. Jungman */
9554
9555#ifndef __GSL_SF_RESULT_H__
9556#define __GSL_SF_RESULT_H__
9557
9558
9559
9560__BEGIN_DECLS
9561
9562struct gsl_sf_result_struct {
9563 double val;
9564 double err;
9565};
9566typedef struct gsl_sf_result_struct gsl_sf_result;
9567
9568#define GSL_SF_RESULT_SET(r,v,e) do { (r)->val=(v); (r)->err=(e); } while(0)
9569
9570
9572 double val;
9573 double err;
9574 int e10;
9575};
9576typedef struct gsl_sf_result_e10_struct gsl_sf_result_e10;
9577
9578
9579int gsl_sf_result_smash_e(const gsl_sf_result_e10 * re, gsl_sf_result * r);
9580
9581
9582__END_DECLS
9583
9584#endif /* __GSL_SF_RESULT_H__ */
9585
9586/* end inlined header: gsl/gsl_sf_result.h */
9587/* begin inlined header: gsl/gsl_precision.h */
9588/* gsl_precision.h
9589 *
9590 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
9591 *
9592 * This program is free software; you can redistribute it and/or modify
9593 * it under the terms of the GNU General Public License as published by
9594 * the Free Software Foundation; either version 3 of the License, or (at
9595 * your option) any later version.
9596 *
9597 * This program is distributed in the hope that it will be useful, but
9598 * WITHOUT ANY WARRANTY; without even the implied warranty of
9599 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9600 * General Public License for more details.
9601 *
9602 * You should have received a copy of the GNU General Public License
9603 * along with this program; if not, write to the Free Software
9604 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
9605 */
9606
9607/* Author: B. Gough and G. Jungman */
9608
9609#ifndef __GSL_PRECISION_H__
9610#define __GSL_PRECISION_H__
9611/* begin inlined header: gsl/gsl_types.h */
9612/* gsl_types.h
9613 *
9614 * Copyright (C) 2001, 2007 Brian Gough
9615 *
9616 * This program is free software; you can redistribute it and/or modify
9617 * it under the terms of the GNU General Public License as published by
9618 * the Free Software Foundation; either version 3 of the License, or (at
9619 * your option) any later version.
9620 *
9621 * This program is distributed in the hope that it will be useful, but
9622 * WITHOUT ANY WARRANTY; without even the implied warranty of
9623 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9624 * General Public License for more details.
9625 *
9626 * You should have received a copy of the GNU General Public License
9627 * along with this program; if not, write to the Free Software
9628 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
9629 */
9630
9631#ifndef __GSL_TYPES_H__
9632#define __GSL_TYPES_H__
9633
9634#ifndef GSL_VAR
9635
9636#ifdef WIN32
9637# ifdef GSL_DLL
9638# ifdef DLL_EXPORT
9639# define GSL_VAR extern __declspec(dllexport)
9640# else
9641# define GSL_VAR extern __declspec(dllimport)
9642# endif
9643# else
9644# define GSL_VAR extern
9645# endif
9646#else
9647# define GSL_VAR extern
9648#endif
9649
9650#endif
9651
9652#endif /* __GSL_TYPES_H__ */
9653
9654/* end inlined header: gsl/gsl_types.h */
9655
9656
9657__BEGIN_DECLS
9658
9659
9660/* A type for the precision indicator.
9661 * This is mainly for pedagogy.
9662 */
9663typedef unsigned int gsl_prec_t;
9664
9665
9666/* The number of precision types.
9667 * Remember that precision-mode
9668 * can index an array.
9669 */
9670#define _GSL_PREC_T_NUM 3
9671
9672
9673/* Arrays containing derived
9674 * precision constants for the
9675 * different precision levels.
9676 */
9677GSL_VAR const double gsl_prec_eps[];
9678GSL_VAR const double gsl_prec_sqrt_eps[];
9679GSL_VAR const double gsl_prec_root3_eps[];
9680GSL_VAR const double gsl_prec_root4_eps[];
9681GSL_VAR const double gsl_prec_root5_eps[];
9682GSL_VAR const double gsl_prec_root6_eps[];
9683
9684
9685__END_DECLS
9686
9687#endif /* __GSL_PRECISION_H__ */
9688
9689/* end inlined header: gsl/gsl_precision.h */
9690
9691
9692__BEGIN_DECLS
9693
9694/* Provide an exp() function with GSL semantics,
9695 * i.e. with proper error checking, etc.
9696 *
9697 * exceptions: GSL_EOVRFLW, GSL_EUNDRFLW
9698 */
9699int gsl_sf_exp_e(const double x, gsl_sf_result * result);
9700double gsl_sf_exp(const double x);
9701
9702
9703/* Exp(x)
9704 *
9705 * exceptions: GSL_EOVRFLW, GSL_EUNDRFLW
9706 */
9707int gsl_sf_exp_e10_e(const double x, gsl_sf_result_e10 * result);
9708
9709
9710/* Exponentiate and multiply by a given factor: y * Exp(x)
9711 *
9712 * exceptions: GSL_EOVRFLW, GSL_EUNDRFLW
9713 */
9714int gsl_sf_exp_mult_e(const double x, const double y, gsl_sf_result * result);
9715double gsl_sf_exp_mult(const double x, const double y);
9716
9717
9718/* Exponentiate and multiply by a given factor: y * Exp(x)
9719 *
9720 * exceptions: GSL_EOVRFLW, GSL_EUNDRFLW
9721 */
9722int gsl_sf_exp_mult_e10_e(const double x, const double y, gsl_sf_result_e10 * result);
9723
9724
9725/* exp(x)-1
9726 *
9727 * exceptions: GSL_EOVRFLW
9728 */
9729int gsl_sf_expm1_e(const double x, gsl_sf_result * result);
9730double gsl_sf_expm1(const double x);
9731
9732
9733/* (exp(x)-1)/x = 1 + x/2 + x^2/(2*3) + x^3/(2*3*4) + ...
9734 *
9735 * exceptions: GSL_EOVRFLW
9736 */
9737int gsl_sf_exprel_e(const double x, gsl_sf_result * result);
9738double gsl_sf_exprel(const double x);
9739
9740
9741/* 2(exp(x)-1-x)/x^2 = 1 + x/3 + x^2/(3*4) + x^3/(3*4*5) + ...
9742 *
9743 * exceptions: GSL_EOVRFLW
9744 */
9745int gsl_sf_exprel_2_e(double x, gsl_sf_result * result);
9746double gsl_sf_exprel_2(const double x);
9747
9748
9749/* Similarly for the N-th generalization of
9750 * the above. The so-called N-relative exponential
9751 *
9752 * exprel_N(x) = N!/x^N (exp(x) - Sum[x^k/k!, {k,0,N-1}])
9753 * = 1 + x/(N+1) + x^2/((N+1)(N+2)) + ...
9754 * = 1F1(1,1+N,x)
9755 */
9756int gsl_sf_exprel_n_e(const int n, const double x, gsl_sf_result * result);
9757double gsl_sf_exprel_n(const int n, const double x);
9758
9759int gsl_sf_exprel_n_CF_e(const double n, const double x, gsl_sf_result * result);
9760
9761
9762/* Exponentiate a quantity with an associated error.
9763 */
9764int gsl_sf_exp_err_e(const double x, const double dx, gsl_sf_result * result);
9765
9766/* Exponentiate a quantity with an associated error.
9767 */
9768int gsl_sf_exp_err_e10_e(const double x, const double dx, gsl_sf_result_e10 * result);
9769
9770
9771/* Exponentiate and multiply by a given factor: y * Exp(x),
9772 * for quantities with associated errors.
9773 *
9774 * exceptions: GSL_EOVRFLW, GSL_EUNDRFLW
9775 */
9776int gsl_sf_exp_mult_err_e(const double x, const double dx, const double y, const double dy, gsl_sf_result * result);
9777
9778
9779/* Exponentiate and multiply by a given factor: y * Exp(x),
9780 * for quantities with associated errors.
9781 *
9782 * exceptions: GSL_EOVRFLW, GSL_EUNDRFLW
9783 */
9784int gsl_sf_exp_mult_err_e10_e(const double x, const double dx, const double y, const double dy, gsl_sf_result_e10 * result);
9785
9786__END_DECLS
9787
9788#endif /* __GSL_SF_EXP_H__ */
9789
9790/* end inlined header: gsl/gsl_sf_exp.h */
9791/* inlined: error.h */
9792
9793/* Evaluate the continued fraction for exprel.
9794 * [Abramowitz+Stegun, 4.2.41]
9795 */
9796static
9797int
9798exprel_n_CF(const double N, const double x, gsl_sf_result * result)
9799{
9800 const double RECUR_BIG = GSL_SQRT_DBL_MAX;
9801 const int maxiter = 5000;
9802 int n = 1;
9803 double Anm2 = 1.0;
9804 double Bnm2 = 0.0;
9805 double Anm1 = 0.0;
9806 double Bnm1 = 1.0;
9807 double a1 = 1.0;
9808 double b1 = 1.0;
9809 double a2 = -x;
9810 double b2 = N+1;
9811 double an, bn;
9812
9813 double fn;
9814
9815 double An = b1*Anm1 + a1*Anm2; /* A1 */
9816 double Bn = b1*Bnm1 + a1*Bnm2; /* B1 */
9817
9818 /* One explicit step, before we get to the main pattern. */
9819 n++;
9820 Anm2 = Anm1;
9821 Bnm2 = Bnm1;
9822 Anm1 = An;
9823 Bnm1 = Bn;
9824 An = b2*Anm1 + a2*Anm2; /* A2 */
9825 Bn = b2*Bnm1 + a2*Bnm2; /* B2 */
9826
9827 fn = An/Bn;
9828
9829 while(n < maxiter) {
9830 double old_fn;
9831 double del;
9832 n++;
9833 Anm2 = Anm1;
9834 Bnm2 = Bnm1;
9835 Anm1 = An;
9836 Bnm1 = Bn;
9837 an = ( GSL_IS_ODD(n) ? ((n-1)/2)*x : -(N+(n/2)-1)*x );
9838 bn = N + n - 1;
9839 An = bn*Anm1 + an*Anm2;
9840 Bn = bn*Bnm1 + an*Bnm2;
9841
9842 if(fabs(An) > RECUR_BIG || fabs(Bn) > RECUR_BIG) {
9843 An /= RECUR_BIG;
9844 Bn /= RECUR_BIG;
9845 Anm1 /= RECUR_BIG;
9846 Bnm1 /= RECUR_BIG;
9847 Anm2 /= RECUR_BIG;
9848 Bnm2 /= RECUR_BIG;
9849 }
9850
9851 old_fn = fn;
9852 fn = An/Bn;
9853 del = old_fn/fn;
9854
9855 if(fabs(del - 1.0) < 2.0*GSL_DBL_EPSILON) break;
9856 }
9857
9858 result->val = fn;
9859 result->err = 4.0*(n+1.0)*GSL_DBL_EPSILON*fabs(fn);
9860
9861 if(n == maxiter)
9862 GSL_ERROR ("error", GSL_EMAXITER);
9863 else
9864 return GSL_SUCCESS;
9865}
9866
9867
9868/*-*-*-*-*-*-*-*-*-*-*-* Functions with Error Codes *-*-*-*-*-*-*-*-*-*-*-*/
9869
9870int gsl_sf_exp_e(const double x, gsl_sf_result * result)
9871{
9872 if(x > GSL_LOG_DBL_MAX) {
9873 OVERFLOW_ERROR(result);
9874 }
9875 else if(x < GSL_LOG_DBL_MIN) {
9876 UNDERFLOW_ERROR(result);
9877 }
9878 else {
9879 result->val = exp(x);
9880 result->err = 2.0 * GSL_DBL_EPSILON * fabs(result->val);
9881 return GSL_SUCCESS;
9882 }
9883}
9884
9885int gsl_sf_exp_e10_e(const double x, gsl_sf_result_e10 * result)
9886{
9887 if(x > INT_MAX-1) {
9888 OVERFLOW_ERROR_E10(result);
9889 }
9890 else if(x < INT_MIN+1) {
9891 UNDERFLOW_ERROR_E10(result);
9892 }
9893 else {
9894 const int N = (x > GSL_LOG_DBL_MAX || x < GSL_LOG_DBL_MIN) ? (int) floor(x/M_LN10) : 0;
9895 result->val = exp(x-N*M_LN10);
9896 result->err = 2.0 * (fabs(x)+1.0) * GSL_DBL_EPSILON * fabs(result->val);
9897 result->e10 = N;
9898 return GSL_SUCCESS;
9899 }
9900}
9901
9902
9903int gsl_sf_exp_mult_e(const double x, const double y, gsl_sf_result * result)
9904{
9905 const double ay = fabs(y);
9906
9907 if(y == 0.0) {
9908 result->val = 0.0;
9909 result->err = 0.0;
9910 return GSL_SUCCESS;
9911 }
9912 else if( ( x < 0.5*GSL_LOG_DBL_MAX && x > 0.5*GSL_LOG_DBL_MIN)
9913 && (ay < 0.8*GSL_SQRT_DBL_MAX && ay > 1.2*GSL_SQRT_DBL_MIN)
9914 ) {
9915 const double ex = exp(x);
9916 result->val = y * ex;
9917 result->err = (2.0 + fabs(x)) * GSL_DBL_EPSILON * fabs(result->val);
9918 return GSL_SUCCESS;
9919 }
9920 else {
9921 const double ly = log(ay);
9922 const double lnr = x + ly;
9923
9924 if(lnr > GSL_LOG_DBL_MAX - 0.01) {
9925 OVERFLOW_ERROR(result);
9926 }
9927 else if(lnr < GSL_LOG_DBL_MIN + 0.01) {
9928 UNDERFLOW_ERROR(result);
9929 }
9930 else {
9931 const double sy = GSL_SIGN(y);
9932 const double M = floor(x);
9933 const double N = floor(ly);
9934 const double a = x - M;
9935 const double b = ly - N;
9936 const double berr = 2.0 * GSL_DBL_EPSILON * (fabs(ly) + fabs(N));
9937 result->val = sy * exp(M+N) * exp(a+b);
9938 result->err = berr * fabs(result->val);
9939 result->err += 2.0 * GSL_DBL_EPSILON * (M + N + 1.0) * fabs(result->val);
9940 return GSL_SUCCESS;
9941 }
9942 }
9943}
9944
9945
9946int gsl_sf_exp_mult_e10_e(const double x, const double y, gsl_sf_result_e10 * result)
9947{
9948 const double ay = fabs(y);
9949
9950 if(y == 0.0) {
9951 result->val = 0.0;
9952 result->err = 0.0;
9953 result->e10 = 0;
9954 return GSL_SUCCESS;
9955 }
9956 else if( ( x < 0.5*GSL_LOG_DBL_MAX && x > 0.5*GSL_LOG_DBL_MIN)
9957 && (ay < 0.8*GSL_SQRT_DBL_MAX && ay > 1.2*GSL_SQRT_DBL_MIN)
9958 ) {
9959 const double ex = exp(x);
9960 result->val = y * ex;
9961 result->err = (2.0 + fabs(x)) * GSL_DBL_EPSILON * fabs(result->val);
9962 result->e10 = 0;
9963 return GSL_SUCCESS;
9964 }
9965 else {
9966 const double ly = log(ay);
9967 const double l10_val = (x + ly)/M_LN10;
9968
9969 if(l10_val > INT_MAX-1) {
9970 OVERFLOW_ERROR_E10(result);
9971 }
9972 else if(l10_val < INT_MIN+1) {
9973 UNDERFLOW_ERROR_E10(result);
9974 }
9975 else {
9976 const double sy = GSL_SIGN(y);
9977 const int N = (int) floor(l10_val);
9978 const double arg_val = (l10_val - N) * M_LN10;
9979 const double arg_err = 2.0 * GSL_DBL_EPSILON * (fabs(x) + fabs(ly) + M_LN10*abs(N));
9980
9981 result->val = sy * exp(arg_val);
9982 result->err = arg_err * fabs(result->val);
9983 result->err += 2.0 * GSL_DBL_EPSILON * fabs(result->val);
9984 result->e10 = N;
9985
9986 return GSL_SUCCESS;
9987 }
9988 }
9989}
9990
9991
9992int gsl_sf_exp_mult_err_e(const double x, const double dx,
9993 const double y, const double dy,
9994 gsl_sf_result * result)
9995{
9996 const double ay = fabs(y);
9997
9998 if(y == 0.0) {
9999 result->val = 0.0;
10000 result->err = fabs(dy * exp(x));
10001 return GSL_SUCCESS;
10002 }
10003 else if( ( x < 0.5*GSL_LOG_DBL_MAX && x > 0.5*GSL_LOG_DBL_MIN)
10004 && (ay < 0.8*GSL_SQRT_DBL_MAX && ay > 1.2*GSL_SQRT_DBL_MIN)
10005 ) {
10006 double ex = exp(x);
10007 result->val = y * ex;
10008 result->err = ex * (fabs(dy) + fabs(y*dx));
10009 result->err += 2.0 * GSL_DBL_EPSILON * fabs(result->val);
10010 return GSL_SUCCESS;
10011 }
10012 else {
10013 const double ly = log(ay);
10014 const double lnr = x + ly;
10015
10016 if(lnr > GSL_LOG_DBL_MAX - 0.01) {
10017 OVERFLOW_ERROR(result);
10018 }
10019 else if(lnr < GSL_LOG_DBL_MIN + 0.01) {
10020 UNDERFLOW_ERROR(result);
10021 }
10022 else {
10023 const double sy = GSL_SIGN(y);
10024 const double M = floor(x);
10025 const double N = floor(ly);
10026 const double a = x - M;
10027 const double b = ly - N;
10028 const double eMN = exp(M+N);
10029 const double eab = exp(a+b);
10030 result->val = sy * eMN * eab;
10031 result->err = eMN * eab * 2.0*GSL_DBL_EPSILON;
10032 result->err += eMN * eab * fabs(dy/y);
10033 result->err += eMN * eab * fabs(dx);
10034 return GSL_SUCCESS;
10035 }
10036 }
10037}
10038
10039
10040int gsl_sf_exp_mult_err_e10_e(const double x, const double dx,
10041 const double y, const double dy,
10042 gsl_sf_result_e10 * result)
10043{
10044 const double ay = fabs(y);
10045
10046 if(y == 0.0) {
10047 result->val = 0.0;
10048 result->err = fabs(dy * exp(x));
10049 result->e10 = 0;
10050 return GSL_SUCCESS;
10051 }
10052 else if( ( x < 0.5*GSL_LOG_DBL_MAX && x > 0.5*GSL_LOG_DBL_MIN)
10053 && (ay < 0.8*GSL_SQRT_DBL_MAX && ay > 1.2*GSL_SQRT_DBL_MIN)
10054 ) {
10055 const double ex = exp(x);
10056 result->val = y * ex;
10057 result->err = ex * (fabs(dy) + fabs(y*dx));
10058 result->err += 2.0 * GSL_DBL_EPSILON * fabs(result->val);
10059 result->e10 = 0;
10060 return GSL_SUCCESS;
10061 }
10062 else {
10063 const double ly = log(ay);
10064 const double l10_val = (x + ly)/M_LN10;
10065
10066 if(l10_val > INT_MAX-1) {
10067 OVERFLOW_ERROR_E10(result);
10068 }
10069 else if(l10_val < INT_MIN+1) {
10070 UNDERFLOW_ERROR_E10(result);
10071 }
10072 else {
10073 const double sy = GSL_SIGN(y);
10074 const int N = (int) floor(l10_val);
10075 const double arg_val = (l10_val - N) * M_LN10;
10076 const double arg_err = dy/fabs(y) + dx + 2.0*GSL_DBL_EPSILON*fabs(arg_val);
10077
10078 result->val = sy * exp(arg_val);
10079 result->err = arg_err * fabs(result->val);
10080 result->err += 2.0 * GSL_DBL_EPSILON * fabs(result->val);
10081 result->e10 = N;
10082
10083 return GSL_SUCCESS;
10084 }
10085 }
10086}
10087
10088
10089int gsl_sf_expm1_e(const double x, gsl_sf_result * result)
10090{
10091 const double cut = 0.002;
10092
10093 if(x < GSL_LOG_DBL_MIN) {
10094 result->val = -1.0;
10095 result->err = GSL_DBL_EPSILON;
10096 return GSL_SUCCESS;
10097 }
10098 else if(x < -cut) {
10099 result->val = exp(x) - 1.0;
10100 result->err = 2.0 * GSL_DBL_EPSILON * fabs(result->val);
10101 return GSL_SUCCESS;
10102 }
10103 else if(x < cut) {
10104 result->val = x * (1.0 + 0.5*x*(1.0 + x/3.0*(1.0 + 0.25*x*(1.0 + 0.2*x))));
10105 result->err = 2.0 * GSL_DBL_EPSILON * fabs(result->val);
10106 return GSL_SUCCESS;
10107 }
10108 else if(x < GSL_LOG_DBL_MAX) {
10109 result->val = exp(x) - 1.0;
10110 result->err = 2.0 * GSL_DBL_EPSILON * fabs(result->val);
10111 return GSL_SUCCESS;
10112 }
10113 else {
10114 OVERFLOW_ERROR(result);
10115 }
10116}
10117
10118
10119int gsl_sf_exprel_e(const double x, gsl_sf_result * result)
10120{
10121 const double cut = 0.002;
10122
10123 if(x < GSL_LOG_DBL_MIN) {
10124 result->val = -1.0/x;
10125 result->err = GSL_DBL_EPSILON * fabs(result->val);
10126 return GSL_SUCCESS;
10127 }
10128 else if(x < -cut) {
10129 result->val = (exp(x) - 1.0)/x;
10130 result->err = 2.0 * GSL_DBL_EPSILON * fabs(result->val);
10131 return GSL_SUCCESS;
10132 }
10133 else if(x < cut) {
10134 result->val = (1.0 + 0.5*x*(1.0 + x/3.0*(1.0 + 0.25*x*(1.0 + 0.2*x))));
10135 result->err = 2.0 * GSL_DBL_EPSILON * fabs(result->val);
10136 return GSL_SUCCESS;
10137 }
10138 else if(x < GSL_LOG_DBL_MAX) {
10139 result->val = (exp(x) - 1.0)/x;
10140 result->err = 2.0 * GSL_DBL_EPSILON * fabs(result->val);
10141 return GSL_SUCCESS;
10142 }
10143 else {
10144 OVERFLOW_ERROR(result);
10145 }
10146}
10147
10148
10149int gsl_sf_exprel_2_e(double x, gsl_sf_result * result)
10150{
10151 const double cut = 0.002;
10152
10153 if(x < GSL_LOG_DBL_MIN) {
10154 result->val = -2.0/x*(1.0 + 1.0/x);
10155 result->err = 2.0 * GSL_DBL_EPSILON * fabs(result->val);
10156 return GSL_SUCCESS;
10157 }
10158 else if(x < -cut) {
10159 result->val = 2.0*(exp(x) - 1.0 - x)/(x*x);
10160 result->err = 2.0 * GSL_DBL_EPSILON * fabs(result->val);
10161 return GSL_SUCCESS;
10162 }
10163 else if(x < cut) {
10164 result->val = (1.0 + 1.0/3.0*x*(1.0 + 0.25*x*(1.0 + 0.2*x*(1.0 + 1.0/6.0*x))));
10165 result->err = 2.0 * GSL_DBL_EPSILON * fabs(result->val);
10166 return GSL_SUCCESS;
10167 }
10168 else if(x < GSL_LOG_DBL_MAX) {
10169 result->val = 2.0*(exp(x) - 1.0 - x)/(x*x);
10170 result->err = 2.0 * GSL_DBL_EPSILON * fabs(result->val);
10171 return GSL_SUCCESS;
10172 }
10173 else {
10174 OVERFLOW_ERROR(result);
10175 }
10176}
10177
10178
10179int
10180gsl_sf_exprel_n_CF_e(const double N, const double x, gsl_sf_result * result)
10181{
10182 return exprel_n_CF(N, x, result);
10183}
10184
10185int
10186gsl_sf_exprel_n_e(const int N, const double x, gsl_sf_result * result)
10187{
10188 if(N < 0) {
10189 DOMAIN_ERROR(result);
10190 }
10191 else if(x == 0.0) {
10192 result->val = 1.0;
10193 result->err = 0.0;
10194 return GSL_SUCCESS;
10195 }
10196 else if(fabs(x) < GSL_ROOT3_DBL_EPSILON * N) {
10197 result->val = 1.0 + x/(N+1) * (1.0 + x/(N+2));
10198 result->err = 2.0 * GSL_DBL_EPSILON;
10199 return GSL_SUCCESS;
10200 }
10201 else if(N == 0) {
10202 return gsl_sf_exp_e(x, result);
10203 }
10204 else if(N == 1) {
10205 return gsl_sf_exprel_e(x, result);
10206 }
10207 else if(N == 2) {
10208 return gsl_sf_exprel_2_e(x, result);
10209 }
10210 else {
10211 if(x > N && (-x + N*(1.0 + log(x/N)) < GSL_LOG_DBL_EPSILON)) {
10212 /* x is much larger than n.
10213 * Ignore polynomial part, so
10214 * exprel_N(x) ~= e^x N!/x^N
10215 */
10216 gsl_sf_result lnf_N;
10217 double lnr_val;
10218 double lnr_err;
10219 double lnterm;
10220 gsl_sf_lnfact_e(N, &lnf_N);
10221 lnterm = N*log(x);
10222 lnr_val = x + lnf_N.val - lnterm;
10223 lnr_err = GSL_DBL_EPSILON * (fabs(x) + fabs(lnf_N.val) + fabs(lnterm));
10224 lnr_err += lnf_N.err;
10225 return gsl_sf_exp_err_e(lnr_val, lnr_err, result);
10226 }
10227 else if(x > N) {
10228 /* Write the identity
10229 * exprel_n(x) = e^x n! / x^n (1 - Gamma[n,x]/Gamma[n])
10230 * then use the asymptotic expansion
10231 * Gamma[n,x] ~ x^(n-1) e^(-x) (1 + (n-1)/x + (n-1)(n-2)/x^2 + ...)
10232 */
10233 double ln_x = log(x);
10234 gsl_sf_result lnf_N;
10235 double lg_N;
10236 double lnpre_val;
10237 double lnpre_err;
10238 gsl_sf_lnfact_e(N, &lnf_N); /* log(N!) */
10239 lg_N = lnf_N.val - log(N); /* log(Gamma(N)) */
10240 lnpre_val = x + lnf_N.val - N*ln_x;
10241 lnpre_err = GSL_DBL_EPSILON * (fabs(x) + fabs(lnf_N.val) + fabs(N*ln_x));
10242 lnpre_err += lnf_N.err;
10243 if(lnpre_val < GSL_LOG_DBL_MAX - 5.0) {
10244 int stat_eG;
10245 gsl_sf_result bigG_ratio;
10246 gsl_sf_result pre;
10247 int stat_ex = gsl_sf_exp_err_e(lnpre_val, lnpre_err, &pre);
10248 double ln_bigG_ratio_pre = -x + (N-1)*ln_x - lg_N;
10249 double bigGsum = 1.0;
10250 double term = 1.0;
10251 int k;
10252 for(k=1; k<N; k++) {
10253 term *= (N-k)/x;
10254 bigGsum += term;
10255 }
10256 stat_eG = gsl_sf_exp_mult_e(ln_bigG_ratio_pre, bigGsum, &bigG_ratio);
10257 if(stat_eG == GSL_SUCCESS) {
10258 result->val = pre.val * (1.0 - bigG_ratio.val);
10259 result->err = pre.val * (2.0*GSL_DBL_EPSILON + bigG_ratio.err);
10260 result->err += pre.err * fabs(1.0 - bigG_ratio.val);
10261 result->err += 2.0 * GSL_DBL_EPSILON * fabs(result->val);
10262 return stat_ex;
10263 }
10264 else {
10265 result->val = 0.0;
10266 result->err = 0.0;
10267 return stat_eG;
10268 }
10269 }
10270 else {
10271 OVERFLOW_ERROR(result);
10272 }
10273 }
10274 else if(x > -10.0*N) {
10275 return exprel_n_CF(N, x, result);
10276 }
10277 else {
10278 /* x -> -Inf asymptotic:
10279 * exprel_n(x) ~ e^x n!/x^n - n/x (1 + (n-1)/x + (n-1)(n-2)/x + ...)
10280 * ~ - n/x (1 + (n-1)/x + (n-1)(n-2)/x + ...)
10281 */
10282 double sum = 1.0;
10283 double term = 1.0;
10284 int k;
10285 for(k=1; k<N; k++) {
10286 term *= (N-k)/x;
10287 sum += term;
10288 }
10289 result->val = -N/x * sum;
10290 result->err = 2.0 * GSL_DBL_EPSILON * fabs(result->val);
10291 return GSL_SUCCESS;
10292 }
10293 }
10294}
10295
10296
10297int
10298gsl_sf_exp_err_e(const double x, const double dx, gsl_sf_result * result)
10299{
10300 const double adx = fabs(dx);
10301
10302 /* CHECK_POINTER(result) */
10303
10304 if(x + adx > GSL_LOG_DBL_MAX) {
10305 OVERFLOW_ERROR(result);
10306 }
10307 else if(x - adx < GSL_LOG_DBL_MIN) {
10308 UNDERFLOW_ERROR(result);
10309 }
10310 else {
10311 const double ex = exp(x);
10312 const double edx = exp(adx);
10313 result->val = ex;
10314 result->err = ex * GSL_MAX_DBL(GSL_DBL_EPSILON, edx - 1.0/edx);
10315 result->err += 2.0 * GSL_DBL_EPSILON * fabs(result->val);
10316 return GSL_SUCCESS;
10317 }
10318}
10319
10320
10321int
10322gsl_sf_exp_err_e10_e(const double x, const double dx, gsl_sf_result_e10 * result)
10323{
10324 const double adx = fabs(dx);
10325
10326 /* CHECK_POINTER(result) */
10327
10328 if(x + adx > INT_MAX - 1) {
10329 OVERFLOW_ERROR_E10(result);
10330 }
10331 else if(x - adx < INT_MIN + 1) {
10332 UNDERFLOW_ERROR_E10(result);
10333 }
10334 else {
10335 const int N = (int)floor(x/M_LN10);
10336 const double ex = exp(x-N*M_LN10);
10337 result->val = ex;
10338 result->err = ex * (2.0 * GSL_DBL_EPSILON * (fabs(x) + 1.0) + adx);
10339 result->e10 = N;
10340 return GSL_SUCCESS;
10341 }
10342}
10343
10344
10345/*-*-*-*-*-*-*-*-*-* Functions w/ Natural Prototypes *-*-*-*-*-*-*-*-*-*-*/
10346
10347/* inlined: eval.h */
10348
10349double gsl_sf_exp(const double x)
10350{
10351 EVAL_RESULT(gsl_sf_exp_e(x, &result));
10352}
10353
10354double gsl_sf_exp_mult(const double x, const double y)
10355{
10356 EVAL_RESULT(gsl_sf_exp_mult_e(x, y, &result));
10357}
10358
10359double gsl_sf_expm1(const double x)
10360{
10361 EVAL_RESULT(gsl_sf_expm1_e(x, &result));
10362}
10363
10364double gsl_sf_exprel(const double x)
10365{
10366 EVAL_RESULT(gsl_sf_exprel_e(x, &result));
10367}
10368
10369double gsl_sf_exprel_2(const double x)
10370{
10371 EVAL_RESULT(gsl_sf_exprel_2_e(x, &result));
10372}
10373
10374double gsl_sf_exprel_n(const int n, const double x)
10375{
10376 EVAL_RESULT(gsl_sf_exprel_n_e(n, x, &result));
10377}
10378/* end inlined source: specfunc/exp.c */
10379/* begin inlined source: specfunc/gamma.c */
10380/* specfunc/gamma.c
10381 *
10382 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
10383 *
10384 * This program is free software; you can redistribute it and/or modify
10385 * it under the terms of the GNU General Public License as published by
10386 * the Free Software Foundation; either version 3 of the License, or (at
10387 * your option) any later version.
10388 *
10389 * This program is distributed in the hope that it will be useful, but
10390 * WITHOUT ANY WARRANTY; without even the implied warranty of
10391 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10392 * General Public License for more details.
10393 *
10394 * You should have received a copy of the GNU General Public License
10395 * along with this program; if not, write to the Free Software
10396 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
10397 */
10398
10399/* Author: G. Jungman */
10400/* begin inlined header: config.h */
10401#ifndef MARLEY_BUILTIN_GSL_CONFIG_WRAPPER_H
10402#define MARLEY_BUILTIN_GSL_CONFIG_WRAPPER_H
10403/* begin inlined header: gsl_config.h */
10404#ifndef MARLEY_BUILTIN_GSL_CONFIG_H
10405#define MARLEY_BUILTIN_GSL_CONFIG_H
10406
10407#define HAVE_INLINE 1
10408#define HAVE_DECL_ISFINITE 1
10409#define HAVE_DECL_ISNAN 1
10410#define HAVE_DECL_ISINF 1
10411#define GSL_COERCE_DBL(x) (x)
10412
10413#define GSL_DISABLE_DEPRECATED 0
10414#define PACKAGE_VERSION "2.8"
10415#define VERSION "2.8"
10416
10417#endif
10418
10419/* end inlined header: gsl_config.h */
10420#endif
10421
10422/* end inlined header: config.h */
10423/* begin inlined header: gsl/gsl_math.h */
10424/* gsl_math.h
10425 *
10426 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2004, 2007 Gerard Jungman, Brian Gough
10427 *
10428 * This program is free software; you can redistribute it and/or modify
10429 * it under the terms of the GNU General Public License as published by
10430 * the Free Software Foundation; either version 3 of the License, or (at
10431 * your option) any later version.
10432 *
10433 * This program is distributed in the hope that it will be useful, but
10434 * WITHOUT ANY WARRANTY; without even the implied warranty of
10435 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10436 * General Public License for more details.
10437 *
10438 * You should have received a copy of the GNU General Public License
10439 * along with this program; if not, write to the Free Software
10440 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
10441 */
10442
10443#ifndef __GSL_MATH_H__
10444#define __GSL_MATH_H__
10445#include <math.h>
10446/* begin inlined header: gsl/gsl_sys.h */
10447/* sys/gsl_sys.h
10448 *
10449 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, Brian Gough
10450 *
10451 * This program is free software; you can redistribute it and/or modify
10452 * it under the terms of the GNU General Public License as published by
10453 * the Free Software Foundation; either version 3 of the License, or (at
10454 * your option) any later version.
10455 *
10456 * This program is distributed in the hope that it will be useful, but
10457 * WITHOUT ANY WARRANTY; without even the implied warranty of
10458 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10459 * General Public License for more details.
10460 *
10461 * You should have received a copy of the GNU General Public License
10462 * along with this program; if not, write to the Free Software
10463 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
10464 */
10465
10466#ifndef __GSL_SYS_H__
10467#define __GSL_SYS_H__
10468
10469
10470
10471__BEGIN_DECLS
10472
10473double gsl_log1p (const double x);
10474double gsl_expm1 (const double x);
10475double gsl_hypot (const double x, const double y);
10476double gsl_hypot3 (const double x, const double y, const double z);
10477double gsl_acosh (const double x);
10478double gsl_asinh (const double x);
10479double gsl_atanh (const double x);
10480
10481int gsl_isnan (const double x);
10482int gsl_isinf (const double x);
10483int gsl_finite (const double x);
10484
10485double gsl_nan (void);
10486double gsl_posinf (void);
10487double gsl_neginf (void);
10488double gsl_fdiv (const double x, const double y);
10489
10490double gsl_coerce_double (const double x);
10491float gsl_coerce_float (const float x);
10492long double gsl_coerce_long_double (const long double x);
10493
10494double gsl_ldexp(const double x, const int e);
10495double gsl_frexp(const double x, int * e);
10496
10497int gsl_fcmp (const double x1, const double x2, const double epsilon);
10498
10499__END_DECLS
10500
10501#endif /* __GSL_SYS_H__ */
10502
10503/* end inlined header: gsl/gsl_sys.h */
10504/* begin inlined header: gsl/gsl_inline.h */
10505/* gsl_inline.h
10506 *
10507 * Copyright (C) 2008, 2009 Brian Gough
10508 *
10509 * This program is free software; you can redistribute it and/or modify
10510 * it under the terms of the GNU General Public License as published by
10511 * the Free Software Foundation; either version 3 of the License, or (at
10512 * your option) any later version.
10513 *
10514 * This program is distributed in the hope that it will be useful, but
10515 * WITHOUT ANY WARRANTY; without even the implied warranty of
10516 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10517 * General Public License for more details.
10518 *
10519 * You should have received a copy of the GNU General Public License
10520 * along with this program; if not, write to the Free Software
10521 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
10522 */
10523
10524#ifndef __GSL_INLINE_H__
10525#define __GSL_INLINE_H__
10526
10527/* In recent versiions of GCC, the inline keyword has two different
10528 forms: GNU and C99.
10529
10530 In GNU mode we can use 'extern inline' to make inline functions
10531 work like macros. The function is only inlined--it is never output
10532 as a definition in an object file.
10533
10534 In the new C99 mode 'extern inline' has a different meaning--it
10535 causes the definition of the function to be output in each object
10536 file where it is used. This will result in multiple-definition
10537 errors on linking. The 'inline' keyword on its own (without
10538 extern) has the same behavior as the original GNU 'extern inline'.
10539
10540 The C99 style is the default with -std=c99 in GCC 4.3.
10541
10542 This header file allows either form of inline to be used by
10543 redefining the macros INLINE_DECL and INLINE_FUN. These are used
10544 in the public header files as
10545
10546 INLINE_DECL double gsl_foo (double x);
10547 #ifdef HAVE_INLINE
10548 INLINE_FUN double gsl_foo (double x) { return x+1.0; } ;
10549 #endif
10550
10551*/
10552
10553#ifdef HAVE_INLINE
10554# if defined(__GNUC_STDC_INLINE__) || defined(GSL_C99_INLINE) || defined(HAVE_C99_INLINE)
10555# define INLINE_DECL inline /* use C99 inline */
10556# define INLINE_FUN inline
10557# else
10558# define INLINE_DECL /* use GNU extern inline */
10559# define INLINE_FUN extern inline
10560# endif
10561#else
10562# define INLINE_DECL /* */
10563#endif
10564
10565/* Range checking conditions in headers do not require any run-time
10566 tests of the global variable gsl_check_range. They are enabled or
10567 disabled in user code at compile time with GSL_RANGE_CHECK macro.
10568 See also build.h. */
10569#define GSL_RANGE_COND(x) (x)
10570
10571#endif /* __GSL_INLINE_H__ */
10572
10573/* end inlined header: gsl/gsl_inline.h */
10574/* begin inlined header: gsl/gsl_machine.h */
10575/* Author: B. Gough and G. Jungman */
10576#ifndef __GSL_MACHINE_H__
10577#define __GSL_MACHINE_H__
10578
10579#include <limits.h>
10580#include <float.h>
10581
10582/* magic constants; mostly for the benefit of the implementation */
10583
10584/* -*-MACHINE CONSTANTS-*-
10585 *
10586 * PLATFORM: Whiz-O-Matic 9000
10587 * FP_PLATFORM: IEEE-Virtual
10588 * HOSTNAME: nnn.lanl.gov
10589 * DATE: Fri Nov 20 17:53:26 MST 1998
10590 */
10591#define GSL_DBL_EPSILON 2.2204460492503131e-16
10592#define GSL_SQRT_DBL_EPSILON 1.4901161193847656e-08
10593#define GSL_ROOT3_DBL_EPSILON 6.0554544523933429e-06
10594#define GSL_ROOT4_DBL_EPSILON 1.2207031250000000e-04
10595#define GSL_ROOT5_DBL_EPSILON 7.4009597974140505e-04
10596#define GSL_ROOT6_DBL_EPSILON 2.4607833005759251e-03
10597#define GSL_LOG_DBL_EPSILON (-3.6043653389117154e+01)
10598
10599#define GSL_DBL_MIN 2.2250738585072014e-308
10600#define GSL_SQRT_DBL_MIN 1.4916681462400413e-154
10601#define GSL_ROOT3_DBL_MIN 2.8126442852362996e-103
10602#define GSL_ROOT4_DBL_MIN 1.2213386697554620e-77
10603#define GSL_ROOT5_DBL_MIN 2.9476022969691763e-62
10604#define GSL_ROOT6_DBL_MIN 5.3034368905798218e-52
10605#define GSL_LOG_DBL_MIN (-7.0839641853226408e+02)
10606
10607#define GSL_DBL_MAX 1.7976931348623157e+308
10608#define GSL_SQRT_DBL_MAX 1.3407807929942596e+154
10609#define GSL_ROOT3_DBL_MAX 5.6438030941222897e+102
10610#define GSL_ROOT4_DBL_MAX 1.1579208923731620e+77
10611#define GSL_ROOT5_DBL_MAX 4.4765466227572707e+61
10612#define GSL_ROOT6_DBL_MAX 2.3756689782295612e+51
10613#define GSL_LOG_DBL_MAX 7.0978271289338397e+02
10614
10615#define GSL_FLT_EPSILON 1.1920928955078125e-07
10616#define GSL_SQRT_FLT_EPSILON 3.4526698300124393e-04
10617#define GSL_ROOT3_FLT_EPSILON 4.9215666011518501e-03
10618#define GSL_ROOT4_FLT_EPSILON 1.8581361171917516e-02
10619#define GSL_ROOT5_FLT_EPSILON 4.1234622211652937e-02
10620#define GSL_ROOT6_FLT_EPSILON 7.0153878019335827e-02
10621#define GSL_LOG_FLT_EPSILON (-1.5942385152878742e+01)
10622
10623#define GSL_FLT_MIN 1.1754943508222875e-38
10624#define GSL_SQRT_FLT_MIN 1.0842021724855044e-19
10625#define GSL_ROOT3_FLT_MIN 2.2737367544323241e-13
10626#define GSL_ROOT4_FLT_MIN 3.2927225399135965e-10
10627#define GSL_ROOT5_FLT_MIN 2.5944428542140822e-08
10628#define GSL_ROOT6_FLT_MIN 4.7683715820312542e-07
10629#define GSL_LOG_FLT_MIN (-8.7336544750553102e+01)
10630
10631#define GSL_FLT_MAX 3.4028234663852886e+38
10632#define GSL_SQRT_FLT_MAX 1.8446743523953730e+19
10633#define GSL_ROOT3_FLT_MAX 6.9814635196223242e+12
10634#define GSL_ROOT4_FLT_MAX 4.2949672319999986e+09
10635#define GSL_ROOT5_FLT_MAX 5.0859007855960041e+07
10636#define GSL_ROOT6_FLT_MAX 2.6422459233807749e+06
10637#define GSL_LOG_FLT_MAX 8.8722839052068352e+01
10638
10639#define GSL_SFLT_EPSILON 4.8828125000000000e-04
10640#define GSL_SQRT_SFLT_EPSILON 2.2097086912079612e-02
10641#define GSL_ROOT3_SFLT_EPSILON 7.8745065618429588e-02
10642#define GSL_ROOT4_SFLT_EPSILON 1.4865088937534013e-01
10643#define GSL_ROOT5_SFLT_EPSILON 2.1763764082403100e-01
10644#define GSL_ROOT6_SFLT_EPSILON 2.8061551207734325e-01
10645#define GSL_LOG_SFLT_EPSILON (-7.6246189861593985e+00)
10646
10647/* !MACHINE CONSTANTS! */
10648
10649
10650/* a little internal backwards compatibility */
10651#define GSL_MACH_EPS GSL_DBL_EPSILON
10652
10653
10654
10655/* Here are the constants related to or derived from
10656 * machine constants. These are not to be confused with
10657 * the constants that define various precision levels
10658 * for the precision/error system.
10659 *
10660 * This information is determined at configure time
10661 * and is platform dependent. Edit at your own risk.
10662 *
10663 * PLATFORM: WHIZ-O-MATIC
10664 * CONFIG-DATE: Thu Nov 19 19:27:18 MST 1998
10665 * CONFIG-HOST: nnn.lanl.gov
10666 */
10667
10668/* machine precision constants */
10669/* #define GSL_MACH_EPS 1.0e-15 */
10670#define GSL_SQRT_MACH_EPS 3.2e-08
10671#define GSL_ROOT3_MACH_EPS 1.0e-05
10672#define GSL_ROOT4_MACH_EPS 0.000178
10673#define GSL_ROOT5_MACH_EPS 0.00100
10674#define GSL_ROOT6_MACH_EPS 0.00316
10675#define GSL_LOG_MACH_EPS (-34.54)
10676
10677
10678#endif /* __GSL_MACHINE_H__ */
10679
10680/* end inlined header: gsl/gsl_machine.h */
10681/* begin inlined header: gsl/gsl_precision.h */
10682/* gsl_precision.h
10683 *
10684 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
10685 *
10686 * This program is free software; you can redistribute it and/or modify
10687 * it under the terms of the GNU General Public License as published by
10688 * the Free Software Foundation; either version 3 of the License, or (at
10689 * your option) any later version.
10690 *
10691 * This program is distributed in the hope that it will be useful, but
10692 * WITHOUT ANY WARRANTY; without even the implied warranty of
10693 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10694 * General Public License for more details.
10695 *
10696 * You should have received a copy of the GNU General Public License
10697 * along with this program; if not, write to the Free Software
10698 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
10699 */
10700
10701/* Author: B. Gough and G. Jungman */
10702
10703#ifndef __GSL_PRECISION_H__
10704#define __GSL_PRECISION_H__
10705/* begin inlined header: gsl/gsl_types.h */
10706/* gsl_types.h
10707 *
10708 * Copyright (C) 2001, 2007 Brian Gough
10709 *
10710 * This program is free software; you can redistribute it and/or modify
10711 * it under the terms of the GNU General Public License as published by
10712 * the Free Software Foundation; either version 3 of the License, or (at
10713 * your option) any later version.
10714 *
10715 * This program is distributed in the hope that it will be useful, but
10716 * WITHOUT ANY WARRANTY; without even the implied warranty of
10717 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10718 * General Public License for more details.
10719 *
10720 * You should have received a copy of the GNU General Public License
10721 * along with this program; if not, write to the Free Software
10722 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
10723 */
10724
10725#ifndef __GSL_TYPES_H__
10726#define __GSL_TYPES_H__
10727
10728#ifndef GSL_VAR
10729
10730#ifdef WIN32
10731# ifdef GSL_DLL
10732# ifdef DLL_EXPORT
10733# define GSL_VAR extern __declspec(dllexport)
10734# else
10735# define GSL_VAR extern __declspec(dllimport)
10736# endif
10737# else
10738# define GSL_VAR extern
10739# endif
10740#else
10741# define GSL_VAR extern
10742#endif
10743
10744#endif
10745
10746#endif /* __GSL_TYPES_H__ */
10747
10748/* end inlined header: gsl/gsl_types.h */
10749
10750
10751__BEGIN_DECLS
10752
10753
10754/* A type for the precision indicator.
10755 * This is mainly for pedagogy.
10756 */
10757typedef unsigned int gsl_prec_t;
10758
10759
10760/* The number of precision types.
10761 * Remember that precision-mode
10762 * can index an array.
10763 */
10764#define _GSL_PREC_T_NUM 3
10765
10766
10767/* Arrays containing derived
10768 * precision constants for the
10769 * different precision levels.
10770 */
10771GSL_VAR const double gsl_prec_eps[];
10772GSL_VAR const double gsl_prec_sqrt_eps[];
10773GSL_VAR const double gsl_prec_root3_eps[];
10774GSL_VAR const double gsl_prec_root4_eps[];
10775GSL_VAR const double gsl_prec_root5_eps[];
10776GSL_VAR const double gsl_prec_root6_eps[];
10777
10778
10779__END_DECLS
10780
10781#endif /* __GSL_PRECISION_H__ */
10782
10783/* end inlined header: gsl/gsl_precision.h */
10784/* begin inlined header: gsl/gsl_nan.h */
10785/* gsl_nan.h
10786 *
10787 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, Brian Gough
10788 *
10789 * This program is free software; you can redistribute it and/or modify
10790 * it under the terms of the GNU General Public License as published by
10791 * the Free Software Foundation; either version 3 of the License, or (at
10792 * your option) any later version.
10793 *
10794 * This program is distributed in the hope that it will be useful, but
10795 * WITHOUT ANY WARRANTY; without even the implied warranty of
10796 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10797 * General Public License for more details.
10798 *
10799 * You should have received a copy of the GNU General Public License
10800 * along with this program; if not, write to the Free Software
10801 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
10802 */
10803
10804#ifndef __GSL_NAN_H__
10805#define __GSL_NAN_H__
10806
10807#ifdef INFINITY
10808# define GSL_POSINF INFINITY
10809# define GSL_NEGINF (-INFINITY)
10810#elif defined(HUGE_VAL)
10811# define GSL_POSINF HUGE_VAL
10812# define GSL_NEGINF (-HUGE_VAL)
10813#else
10814# define GSL_POSINF (gsl_posinf())
10815# define GSL_NEGINF (gsl_neginf())
10816#endif
10817
10818#ifdef NAN
10819# define GSL_NAN NAN
10820#elif defined(INFINITY)
10821# define GSL_NAN (INFINITY/INFINITY)
10822#else
10823# define GSL_NAN (gsl_nan())
10824#endif
10825
10826#define GSL_POSZERO (+0.0)
10827#define GSL_NEGZERO (-0.0)
10828
10829#endif /* __GSL_NAN_H__ */
10830
10831/* end inlined header: gsl/gsl_nan.h */
10832/* begin inlined header: gsl/gsl_pow_int.h */
10833/* gsl_pow_int.h
10834 *
10835 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2004, 2007 Gerard Jungman, Brian Gough
10836 *
10837 * This program is free software; you can redistribute it and/or modify
10838 * it under the terms of the GNU General Public License as published by
10839 * the Free Software Foundation; either version 3 of the License, or (at
10840 * your option) any later version.
10841 *
10842 * This program is distributed in the hope that it will be useful, but
10843 * WITHOUT ANY WARRANTY; without even the implied warranty of
10844 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10845 * General Public License for more details.
10846 *
10847 * You should have received a copy of the GNU General Public License
10848 * along with this program; if not, write to the Free Software
10849 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
10850 */
10851
10852#ifndef __GSL_POW_INT_H__
10853#define __GSL_POW_INT_H__
10854/* begin inlined header: gsl/gsl_inline.h */
10855/* gsl_inline.h
10856 *
10857 * Copyright (C) 2008, 2009 Brian Gough
10858 *
10859 * This program is free software; you can redistribute it and/or modify
10860 * it under the terms of the GNU General Public License as published by
10861 * the Free Software Foundation; either version 3 of the License, or (at
10862 * your option) any later version.
10863 *
10864 * This program is distributed in the hope that it will be useful, but
10865 * WITHOUT ANY WARRANTY; without even the implied warranty of
10866 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10867 * General Public License for more details.
10868 *
10869 * You should have received a copy of the GNU General Public License
10870 * along with this program; if not, write to the Free Software
10871 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
10872 */
10873
10874#ifndef __GSL_INLINE_H__
10875#define __GSL_INLINE_H__
10876
10877/* In recent versiions of GCC, the inline keyword has two different
10878 forms: GNU and C99.
10879
10880 In GNU mode we can use 'extern inline' to make inline functions
10881 work like macros. The function is only inlined--it is never output
10882 as a definition in an object file.
10883
10884 In the new C99 mode 'extern inline' has a different meaning--it
10885 causes the definition of the function to be output in each object
10886 file where it is used. This will result in multiple-definition
10887 errors on linking. The 'inline' keyword on its own (without
10888 extern) has the same behavior as the original GNU 'extern inline'.
10889
10890 The C99 style is the default with -std=c99 in GCC 4.3.
10891
10892 This header file allows either form of inline to be used by
10893 redefining the macros INLINE_DECL and INLINE_FUN. These are used
10894 in the public header files as
10895
10896 INLINE_DECL double gsl_foo (double x);
10897 #ifdef HAVE_INLINE
10898 INLINE_FUN double gsl_foo (double x) { return x+1.0; } ;
10899 #endif
10900
10901*/
10902
10903#ifdef HAVE_INLINE
10904# if defined(__GNUC_STDC_INLINE__) || defined(GSL_C99_INLINE) || defined(HAVE_C99_INLINE)
10905# define INLINE_DECL inline /* use C99 inline */
10906# define INLINE_FUN inline
10907# else
10908# define INLINE_DECL /* use GNU extern inline */
10909# define INLINE_FUN extern inline
10910# endif
10911#else
10912# define INLINE_DECL /* */
10913#endif
10914
10915/* Range checking conditions in headers do not require any run-time
10916 tests of the global variable gsl_check_range. They are enabled or
10917 disabled in user code at compile time with GSL_RANGE_CHECK macro.
10918 See also build.h. */
10919#define GSL_RANGE_COND(x) (x)
10920
10921#endif /* __GSL_INLINE_H__ */
10922
10923/* end inlined header: gsl/gsl_inline.h */
10924
10925
10926__BEGIN_DECLS
10927
10928INLINE_DECL double gsl_pow_2(const double x);
10929INLINE_DECL double gsl_pow_3(const double x);
10930INLINE_DECL double gsl_pow_4(const double x);
10931INLINE_DECL double gsl_pow_5(const double x);
10932INLINE_DECL double gsl_pow_6(const double x);
10933INLINE_DECL double gsl_pow_7(const double x);
10934INLINE_DECL double gsl_pow_8(const double x);
10935INLINE_DECL double gsl_pow_9(const double x);
10936
10937#ifdef HAVE_INLINE
10938INLINE_FUN double gsl_pow_2(const double x) { return x*x; }
10939INLINE_FUN double gsl_pow_3(const double x) { return x*x*x; }
10940INLINE_FUN double gsl_pow_4(const double x) { double x2 = x*x; return x2*x2; }
10941INLINE_FUN double gsl_pow_5(const double x) { double x2 = x*x; return x2*x2*x; }
10942INLINE_FUN double gsl_pow_6(const double x) { double x2 = x*x; return x2*x2*x2; }
10943INLINE_FUN double gsl_pow_7(const double x) { double x3 = x*x*x; return x3*x3*x; }
10944INLINE_FUN double gsl_pow_8(const double x) { double x2 = x*x; double x4 = x2*x2; return x4*x4; }
10945INLINE_FUN double gsl_pow_9(const double x) { double x3 = x*x*x; return x3*x3*x3; }
10946#endif
10947
10948double gsl_pow_int(double x, int n);
10949double gsl_pow_uint(double x, unsigned int n);
10950
10951__END_DECLS
10952
10953#endif /* __GSL_POW_INT_H__ */
10954
10955/* end inlined header: gsl/gsl_pow_int.h */
10956/* begin inlined header: gsl/gsl_minmax.h */
10957/* gsl_minmax.h
10958 *
10959 * Copyright (C) 2008 Gerard Jungman, Brian Gough
10960 *
10961 * This program is free software; you can redistribute it and/or modify
10962 * it under the terms of the GNU General Public License as published by
10963 * the Free Software Foundation; either version 3 of the License, or (at
10964 * your option) any later version.
10965 *
10966 * This program is distributed in the hope that it will be useful, but
10967 * WITHOUT ANY WARRANTY; without even the implied warranty of
10968 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10969 * General Public License for more details.
10970 *
10971 * You should have received a copy of the GNU General Public License
10972 * along with this program; if not, write to the Free Software
10973 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
10974 */
10975
10976#ifndef __GSL_MINMAX_H__
10977#define __GSL_MINMAX_H__
10978/* begin inlined header: gsl/gsl_inline.h */
10979/* gsl_inline.h
10980 *
10981 * Copyright (C) 2008, 2009 Brian Gough
10982 *
10983 * This program is free software; you can redistribute it and/or modify
10984 * it under the terms of the GNU General Public License as published by
10985 * the Free Software Foundation; either version 3 of the License, or (at
10986 * your option) any later version.
10987 *
10988 * This program is distributed in the hope that it will be useful, but
10989 * WITHOUT ANY WARRANTY; without even the implied warranty of
10990 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10991 * General Public License for more details.
10992 *
10993 * You should have received a copy of the GNU General Public License
10994 * along with this program; if not, write to the Free Software
10995 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
10996 */
10997
10998#ifndef __GSL_INLINE_H__
10999#define __GSL_INLINE_H__
11000
11001/* In recent versiions of GCC, the inline keyword has two different
11002 forms: GNU and C99.
11003
11004 In GNU mode we can use 'extern inline' to make inline functions
11005 work like macros. The function is only inlined--it is never output
11006 as a definition in an object file.
11007
11008 In the new C99 mode 'extern inline' has a different meaning--it
11009 causes the definition of the function to be output in each object
11010 file where it is used. This will result in multiple-definition
11011 errors on linking. The 'inline' keyword on its own (without
11012 extern) has the same behavior as the original GNU 'extern inline'.
11013
11014 The C99 style is the default with -std=c99 in GCC 4.3.
11015
11016 This header file allows either form of inline to be used by
11017 redefining the macros INLINE_DECL and INLINE_FUN. These are used
11018 in the public header files as
11019
11020 INLINE_DECL double gsl_foo (double x);
11021 #ifdef HAVE_INLINE
11022 INLINE_FUN double gsl_foo (double x) { return x+1.0; } ;
11023 #endif
11024
11025*/
11026
11027#ifdef HAVE_INLINE
11028# if defined(__GNUC_STDC_INLINE__) || defined(GSL_C99_INLINE) || defined(HAVE_C99_INLINE)
11029# define INLINE_DECL inline /* use C99 inline */
11030# define INLINE_FUN inline
11031# else
11032# define INLINE_DECL /* use GNU extern inline */
11033# define INLINE_FUN extern inline
11034# endif
11035#else
11036# define INLINE_DECL /* */
11037#endif
11038
11039/* Range checking conditions in headers do not require any run-time
11040 tests of the global variable gsl_check_range. They are enabled or
11041 disabled in user code at compile time with GSL_RANGE_CHECK macro.
11042 See also build.h. */
11043#define GSL_RANGE_COND(x) (x)
11044
11045#endif /* __GSL_INLINE_H__ */
11046
11047/* end inlined header: gsl/gsl_inline.h */
11048
11049
11050__BEGIN_DECLS
11051
11052/* Define MAX and MIN macros/functions if they don't exist. */
11053
11054/* plain old macros for general use */
11055#define GSL_MAX(a,b) ((a) > (b) ? (a) : (b))
11056#define GSL_MIN(a,b) ((a) < (b) ? (a) : (b))
11057
11058/* function versions of the above, in case they are needed */
11059double gsl_max (double a, double b);
11060double gsl_min (double a, double b);
11061
11062/* inline-friendly strongly typed versions */
11063#ifdef HAVE_INLINE
11064
11065INLINE_FUN int GSL_MAX_INT (int a, int b);
11066INLINE_FUN int GSL_MIN_INT (int a, int b);
11067INLINE_FUN double GSL_MAX_DBL (double a, double b);
11068INLINE_FUN double GSL_MIN_DBL (double a, double b);
11069INLINE_FUN long double GSL_MAX_LDBL (long double a, long double b);
11070INLINE_FUN long double GSL_MIN_LDBL (long double a, long double b);
11071
11072INLINE_FUN int
11073GSL_MAX_INT (int a, int b)
11074{
11075 return GSL_MAX (a, b);
11076}
11077
11078INLINE_FUN int
11079GSL_MIN_INT (int a, int b)
11080{
11081 return GSL_MIN (a, b);
11082}
11083
11084INLINE_FUN double
11085GSL_MAX_DBL (double a, double b)
11086{
11087 return GSL_MAX (a, b);
11088}
11089
11090INLINE_FUN double
11091GSL_MIN_DBL (double a, double b)
11092{
11093 return GSL_MIN (a, b);
11094}
11095
11096INLINE_FUN long double
11097GSL_MAX_LDBL (long double a, long double b)
11098{
11099 return GSL_MAX (a, b);
11100}
11101
11102INLINE_FUN long double
11103GSL_MIN_LDBL (long double a, long double b)
11104{
11105 return GSL_MIN (a, b);
11106}
11107#else
11108#define GSL_MAX_INT(a,b) GSL_MAX(a,b)
11109#define GSL_MIN_INT(a,b) GSL_MIN(a,b)
11110#define GSL_MAX_DBL(a,b) GSL_MAX(a,b)
11111#define GSL_MIN_DBL(a,b) GSL_MIN(a,b)
11112#define GSL_MAX_LDBL(a,b) GSL_MAX(a,b)
11113#define GSL_MIN_LDBL(a,b) GSL_MIN(a,b)
11114#endif /* HAVE_INLINE */
11115
11116__END_DECLS
11117
11118#endif /* __GSL_POW_INT_H__ */
11119
11120/* end inlined header: gsl/gsl_minmax.h */
11121#ifndef M_E
11122#define M_E 2.71828182845904523536028747135 /* e */
11123#endif
11124
11125#ifndef M_LOG2E
11126#define M_LOG2E 1.44269504088896340735992468100 /* log_2 (e) */
11127#endif
11128
11129#ifndef M_LOG10E
11130#define M_LOG10E 0.43429448190325182765112891892 /* log_10 (e) */
11131#endif
11132
11133#ifndef M_SQRT2
11134#define M_SQRT2 1.41421356237309504880168872421 /* sqrt(2) */
11135#endif
11136
11137#ifndef M_SQRT1_2
11138#define M_SQRT1_2 0.70710678118654752440084436210 /* sqrt(1/2) */
11139#endif
11140
11141
11142#ifndef M_SQRT3
11143#define M_SQRT3 1.73205080756887729352744634151 /* sqrt(3) */
11144#endif
11145
11146#ifndef M_PI
11147#define M_PI 3.14159265358979323846264338328 /* pi */
11148#endif
11149
11150#ifndef M_PI_2
11151#define M_PI_2 1.57079632679489661923132169164 /* pi/2 */
11152#endif
11153
11154#ifndef M_PI_4
11155#define M_PI_4 0.78539816339744830961566084582 /* pi/4 */
11156#endif
11157
11158#ifndef M_SQRTPI
11159#define M_SQRTPI 1.77245385090551602729816748334 /* sqrt(pi) */
11160#endif
11161
11162#ifndef M_2_SQRTPI
11163#define M_2_SQRTPI 1.12837916709551257389615890312 /* 2/sqrt(pi) */
11164#endif
11165
11166#ifndef M_1_PI
11167#define M_1_PI 0.31830988618379067153776752675 /* 1/pi */
11168#endif
11169
11170#ifndef M_2_PI
11171#define M_2_PI 0.63661977236758134307553505349 /* 2/pi */
11172#endif
11173
11174#ifndef M_LN10
11175#define M_LN10 2.30258509299404568401799145468 /* ln(10) */
11176#endif
11177
11178#ifndef M_LN2
11179#define M_LN2 0.69314718055994530941723212146 /* ln(2) */
11180#endif
11181
11182#ifndef M_LNPI
11183#define M_LNPI 1.14472988584940017414342735135 /* ln(pi) */
11184#endif
11185
11186#ifndef M_EULER
11187#define M_EULER 0.57721566490153286060651209008 /* Euler constant */
11188#endif
11189
11190
11191
11192__BEGIN_DECLS
11193
11194/* other needlessly compulsive abstractions */
11195
11196#define GSL_IS_ODD(n) ((n) & 1)
11197#define GSL_IS_EVEN(n) (!(GSL_IS_ODD(n)))
11198#define GSL_SIGN(x) ((x) >= 0.0 ? 1 : -1)
11199
11200/* Return nonzero if x is a real number, i.e. non NaN or infinite. */
11201#define GSL_IS_REAL(x) (gsl_finite(x))
11202
11203/* Definition of an arbitrary function with parameters */
11204
11206{
11207 double (* function) (double x, void * params);
11208 void * params;
11209};
11210
11211typedef struct gsl_function_struct gsl_function ;
11212
11213#define GSL_FN_EVAL(F,x) (*((F)->function))(x,(F)->params)
11214
11215/* Definition of an arbitrary function returning two values, r1, r2 */
11216
11218{
11219 double (* f) (double x, void * params);
11220 double (* df) (double x, void * params);
11221 void (* fdf) (double x, void * params, double * f, double * df);
11222 void * params;
11223};
11224
11225typedef struct gsl_function_fdf_struct gsl_function_fdf ;
11226
11227#define GSL_FN_FDF_EVAL_F(FDF,x) (*((FDF)->f))(x,(FDF)->params)
11228#define GSL_FN_FDF_EVAL_DF(FDF,x) (*((FDF)->df))(x,(FDF)->params)
11229#define GSL_FN_FDF_EVAL_F_DF(FDF,x,y,dy) (*((FDF)->fdf))(x,(FDF)->params,(y),(dy))
11230
11231
11232/* Definition of an arbitrary vector-valued function with parameters */
11233
11235{
11236 int (* function) (double x, double y[], void * params);
11237 void * params;
11238};
11239
11240typedef struct gsl_function_vec_struct gsl_function_vec ;
11241
11242#define GSL_FN_VEC_EVAL(F,x,y) (*((F)->function))(x,y,(F)->params)
11243
11244__END_DECLS
11245
11246#endif /* __GSL_MATH_H__ */
11247
11248/* end inlined header: gsl/gsl_math.h */
11249/* begin inlined header: gsl/gsl_errno.h */
11250/* err/gsl_errno.h
11251 *
11252 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, Brian Gough
11253 *
11254 * This program is free software; you can redistribute it and/or modify
11255 * it under the terms of the GNU General Public License as published by
11256 * the Free Software Foundation; either version 3 of the License, or (at
11257 * your option) any later version.
11258 *
11259 * This program is distributed in the hope that it will be useful, but
11260 * WITHOUT ANY WARRANTY; without even the implied warranty of
11261 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11262 * General Public License for more details.
11263 *
11264 * You should have received a copy of the GNU General Public License
11265 * along with this program; if not, write to the Free Software
11266 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
11267 */
11268
11269#ifndef __GSL_ERRNO_H__
11270#define __GSL_ERRNO_H__
11271
11272#include <stdio.h>
11273#include <errno.h>
11274/* begin inlined header: gsl/gsl_types.h */
11275/* gsl_types.h
11276 *
11277 * Copyright (C) 2001, 2007 Brian Gough
11278 *
11279 * This program is free software; you can redistribute it and/or modify
11280 * it under the terms of the GNU General Public License as published by
11281 * the Free Software Foundation; either version 3 of the License, or (at
11282 * your option) any later version.
11283 *
11284 * This program is distributed in the hope that it will be useful, but
11285 * WITHOUT ANY WARRANTY; without even the implied warranty of
11286 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11287 * General Public License for more details.
11288 *
11289 * You should have received a copy of the GNU General Public License
11290 * along with this program; if not, write to the Free Software
11291 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
11292 */
11293
11294#ifndef __GSL_TYPES_H__
11295#define __GSL_TYPES_H__
11296
11297#ifndef GSL_VAR
11298
11299#ifdef WIN32
11300# ifdef GSL_DLL
11301# ifdef DLL_EXPORT
11302# define GSL_VAR extern __declspec(dllexport)
11303# else
11304# define GSL_VAR extern __declspec(dllimport)
11305# endif
11306# else
11307# define GSL_VAR extern
11308# endif
11309#else
11310# define GSL_VAR extern
11311#endif
11312
11313#endif
11314
11315#endif /* __GSL_TYPES_H__ */
11316
11317/* end inlined header: gsl/gsl_types.h */
11318
11319
11320__BEGIN_DECLS
11321
11322enum {
11323 GSL_SUCCESS = 0,
11324 GSL_FAILURE = -1,
11325 GSL_CONTINUE = -2, /* iteration has not converged */
11326 GSL_EDOM = 1, /* input domain error, e.g sqrt(-1) */
11327 GSL_ERANGE = 2, /* output range error, e.g. exp(1e100) */
11328 GSL_EFAULT = 3, /* invalid pointer */
11329 GSL_EINVAL = 4, /* invalid argument supplied by user */
11330 GSL_EFAILED = 5, /* generic failure */
11331 GSL_EFACTOR = 6, /* factorization failed */
11332 GSL_ESANITY = 7, /* sanity check failed - shouldn't happen */
11333 GSL_ENOMEM = 8, /* malloc failed */
11334 GSL_EBADFUNC = 9, /* problem with user-supplied function */
11335 GSL_ERUNAWAY = 10, /* iterative process is out of control */
11336 GSL_EMAXITER = 11, /* exceeded max number of iterations */
11337 GSL_EZERODIV = 12, /* tried to divide by zero */
11338 GSL_EBADTOL = 13, /* user specified an invalid tolerance */
11339 GSL_ETOL = 14, /* failed to reach the specified tolerance */
11340 GSL_EUNDRFLW = 15, /* underflow */
11341 GSL_EOVRFLW = 16, /* overflow */
11342 GSL_ELOSS = 17, /* loss of accuracy */
11343 GSL_EROUND = 18, /* failed because of roundoff error */
11344 GSL_EBADLEN = 19, /* matrix, vector lengths are not conformant */
11345 GSL_ENOTSQR = 20, /* matrix not square */
11346 GSL_ESING = 21, /* apparent singularity detected */
11347 GSL_EDIVERGE = 22, /* integral or series is divergent */
11348 GSL_EUNSUP = 23, /* requested feature is not supported by the hardware */
11349 GSL_EUNIMPL = 24, /* requested feature not (yet) implemented */
11350 GSL_ECACHE = 25, /* cache limit exceeded */
11351 GSL_ETABLE = 26, /* table limit exceeded */
11352 GSL_ENOPROG = 27, /* iteration is not making progress towards solution */
11353 GSL_ENOPROGJ = 28, /* jacobian evaluations are not improving the solution */
11354 GSL_ETOLF = 29, /* cannot reach the specified tolerance in F */
11355 GSL_ETOLX = 30, /* cannot reach the specified tolerance in X */
11356 GSL_ETOLG = 31, /* cannot reach the specified tolerance in gradient */
11357 GSL_EOF = 32 /* end of file */
11358} ;
11359
11360void gsl_error (const char * reason, const char * file, int line,
11361 int gsl_errno);
11362
11363void gsl_stream_printf (const char *label, const char *file,
11364 int line, const char *reason);
11365
11366typedef void gsl_error_handler_t (const char * reason, const char * file,
11367 int line, int gsl_errno);
11368
11369gsl_error_handler_t *
11370gsl_set_error_handler (gsl_error_handler_t * new_handler);
11371
11372/* GSL_ERROR: call the error handler, and return the error code */
11373
11374#define GSL_ERROR(reason, gsl_errno) \
11375 do { \
11376 gsl_error (reason, __FILE__, __LINE__, gsl_errno) ; \
11377 return gsl_errno ; \
11378 } while (0)
11379
11380/* GSL_ERROR_VAL: call the error handler, and return the given value */
11381
11382#define GSL_ERROR_VAL(reason, gsl_errno, value) \
11383 do { \
11384 gsl_error (reason, __FILE__, __LINE__, gsl_errno) ; \
11385 return value ; \
11386 } while (0)
11387
11388/* GSL_ERROR_VOID: call the error handler, and then return
11389 (for void functions which still need to generate an error) */
11390
11391#define GSL_ERROR_VOID(reason, gsl_errno) \
11392 do { \
11393 gsl_error (reason, __FILE__, __LINE__, gsl_errno) ; \
11394 return ; \
11395 } while (0)
11396
11397/* GSL_ERROR_NULL suitable for out-of-memory conditions */
11398
11399#define GSL_ERROR_NULL(reason, gsl_errno) GSL_ERROR_VAL(reason, gsl_errno, 0)
11400
11401/* Sometimes you have several status results returned from
11402 * function calls and you want to combine them in some sensible
11403 * way. You cannot produce a "total" status condition, but you can
11404 * pick one from a set of conditions based on an implied hierarchy.
11405 *
11406 * In other words:
11407 * you have: status_a, status_b, ...
11408 * you want: status = (status_a if it is bad, or status_b if it is bad,...)
11409 *
11410 * In this example you consider status_a to be more important and
11411 * it is checked first, followed by the others in the order specified.
11412 *
11413 * Here are some dumb macros to do this.
11414 */
11415#define GSL_ERROR_SELECT_2(a,b) ((a) != GSL_SUCCESS ? (a) : ((b) != GSL_SUCCESS ? (b) : GSL_SUCCESS))
11416#define GSL_ERROR_SELECT_3(a,b,c) ((a) != GSL_SUCCESS ? (a) : GSL_ERROR_SELECT_2(b,c))
11417#define GSL_ERROR_SELECT_4(a,b,c,d) ((a) != GSL_SUCCESS ? (a) : GSL_ERROR_SELECT_3(b,c,d))
11418#define GSL_ERROR_SELECT_5(a,b,c,d,e) ((a) != GSL_SUCCESS ? (a) : GSL_ERROR_SELECT_4(b,c,d,e))
11419
11420#define GSL_STATUS_UPDATE(sp, s) do { if ((s) != GSL_SUCCESS) *(sp) = (s);} while(0)
11421
11422__END_DECLS
11423
11424#endif /* __GSL_ERRNO_H__ */
11425
11426/* end inlined header: gsl/gsl_errno.h */
11427/* begin inlined header: gsl/gsl_sf_exp.h */
11428/* specfunc/gsl_sf_exp.h
11429 *
11430 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2004 Gerard Jungman
11431 *
11432 * This program is free software; you can redistribute it and/or modify
11433 * it under the terms of the GNU General Public License as published by
11434 * the Free Software Foundation; either version 3 of the License, or (at
11435 * your option) any later version.
11436 *
11437 * This program is distributed in the hope that it will be useful, but
11438 * WITHOUT ANY WARRANTY; without even the implied warranty of
11439 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11440 * General Public License for more details.
11441 *
11442 * You should have received a copy of the GNU General Public License
11443 * along with this program; if not, write to the Free Software
11444 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
11445 */
11446
11447/* Author: G. Jungman */
11448
11449#ifndef __GSL_SF_EXP_H__
11450#define __GSL_SF_EXP_H__
11451/* begin inlined header: gsl/gsl_sf_result.h */
11452/* specfunc/gsl_sf_result.h
11453 *
11454 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
11455 *
11456 * This program is free software; you can redistribute it and/or modify
11457 * it under the terms of the GNU General Public License as published by
11458 * the Free Software Foundation; either version 3 of the License, or (at
11459 * your option) any later version.
11460 *
11461 * This program is distributed in the hope that it will be useful, but
11462 * WITHOUT ANY WARRANTY; without even the implied warranty of
11463 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11464 * General Public License for more details.
11465 *
11466 * You should have received a copy of the GNU General Public License
11467 * along with this program; if not, write to the Free Software
11468 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
11469 */
11470
11471/* Author: G. Jungman */
11472
11473#ifndef __GSL_SF_RESULT_H__
11474#define __GSL_SF_RESULT_H__
11475
11476
11477
11478__BEGIN_DECLS
11479
11480struct gsl_sf_result_struct {
11481 double val;
11482 double err;
11483};
11484typedef struct gsl_sf_result_struct gsl_sf_result;
11485
11486#define GSL_SF_RESULT_SET(r,v,e) do { (r)->val=(v); (r)->err=(e); } while(0)
11487
11488
11490 double val;
11491 double err;
11492 int e10;
11493};
11494typedef struct gsl_sf_result_e10_struct gsl_sf_result_e10;
11495
11496
11497int gsl_sf_result_smash_e(const gsl_sf_result_e10 * re, gsl_sf_result * r);
11498
11499
11500__END_DECLS
11501
11502#endif /* __GSL_SF_RESULT_H__ */
11503
11504/* end inlined header: gsl/gsl_sf_result.h */
11505/* begin inlined header: gsl/gsl_precision.h */
11506/* gsl_precision.h
11507 *
11508 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
11509 *
11510 * This program is free software; you can redistribute it and/or modify
11511 * it under the terms of the GNU General Public License as published by
11512 * the Free Software Foundation; either version 3 of the License, or (at
11513 * your option) any later version.
11514 *
11515 * This program is distributed in the hope that it will be useful, but
11516 * WITHOUT ANY WARRANTY; without even the implied warranty of
11517 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11518 * General Public License for more details.
11519 *
11520 * You should have received a copy of the GNU General Public License
11521 * along with this program; if not, write to the Free Software
11522 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
11523 */
11524
11525/* Author: B. Gough and G. Jungman */
11526
11527#ifndef __GSL_PRECISION_H__
11528#define __GSL_PRECISION_H__
11529/* begin inlined header: gsl/gsl_types.h */
11530/* gsl_types.h
11531 *
11532 * Copyright (C) 2001, 2007 Brian Gough
11533 *
11534 * This program is free software; you can redistribute it and/or modify
11535 * it under the terms of the GNU General Public License as published by
11536 * the Free Software Foundation; either version 3 of the License, or (at
11537 * your option) any later version.
11538 *
11539 * This program is distributed in the hope that it will be useful, but
11540 * WITHOUT ANY WARRANTY; without even the implied warranty of
11541 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11542 * General Public License for more details.
11543 *
11544 * You should have received a copy of the GNU General Public License
11545 * along with this program; if not, write to the Free Software
11546 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
11547 */
11548
11549#ifndef __GSL_TYPES_H__
11550#define __GSL_TYPES_H__
11551
11552#ifndef GSL_VAR
11553
11554#ifdef WIN32
11555# ifdef GSL_DLL
11556# ifdef DLL_EXPORT
11557# define GSL_VAR extern __declspec(dllexport)
11558# else
11559# define GSL_VAR extern __declspec(dllimport)
11560# endif
11561# else
11562# define GSL_VAR extern
11563# endif
11564#else
11565# define GSL_VAR extern
11566#endif
11567
11568#endif
11569
11570#endif /* __GSL_TYPES_H__ */
11571
11572/* end inlined header: gsl/gsl_types.h */
11573
11574
11575__BEGIN_DECLS
11576
11577
11578/* A type for the precision indicator.
11579 * This is mainly for pedagogy.
11580 */
11581typedef unsigned int gsl_prec_t;
11582
11583
11584/* The number of precision types.
11585 * Remember that precision-mode
11586 * can index an array.
11587 */
11588#define _GSL_PREC_T_NUM 3
11589
11590
11591/* Arrays containing derived
11592 * precision constants for the
11593 * different precision levels.
11594 */
11595GSL_VAR const double gsl_prec_eps[];
11596GSL_VAR const double gsl_prec_sqrt_eps[];
11597GSL_VAR const double gsl_prec_root3_eps[];
11598GSL_VAR const double gsl_prec_root4_eps[];
11599GSL_VAR const double gsl_prec_root5_eps[];
11600GSL_VAR const double gsl_prec_root6_eps[];
11601
11602
11603__END_DECLS
11604
11605#endif /* __GSL_PRECISION_H__ */
11606
11607/* end inlined header: gsl/gsl_precision.h */
11608
11609
11610__BEGIN_DECLS
11611
11612/* Provide an exp() function with GSL semantics,
11613 * i.e. with proper error checking, etc.
11614 *
11615 * exceptions: GSL_EOVRFLW, GSL_EUNDRFLW
11616 */
11617int gsl_sf_exp_e(const double x, gsl_sf_result * result);
11618double gsl_sf_exp(const double x);
11619
11620
11621/* Exp(x)
11622 *
11623 * exceptions: GSL_EOVRFLW, GSL_EUNDRFLW
11624 */
11625int gsl_sf_exp_e10_e(const double x, gsl_sf_result_e10 * result);
11626
11627
11628/* Exponentiate and multiply by a given factor: y * Exp(x)
11629 *
11630 * exceptions: GSL_EOVRFLW, GSL_EUNDRFLW
11631 */
11632int gsl_sf_exp_mult_e(const double x, const double y, gsl_sf_result * result);
11633double gsl_sf_exp_mult(const double x, const double y);
11634
11635
11636/* Exponentiate and multiply by a given factor: y * Exp(x)
11637 *
11638 * exceptions: GSL_EOVRFLW, GSL_EUNDRFLW
11639 */
11640int gsl_sf_exp_mult_e10_e(const double x, const double y, gsl_sf_result_e10 * result);
11641
11642
11643/* exp(x)-1
11644 *
11645 * exceptions: GSL_EOVRFLW
11646 */
11647int gsl_sf_expm1_e(const double x, gsl_sf_result * result);
11648double gsl_sf_expm1(const double x);
11649
11650
11651/* (exp(x)-1)/x = 1 + x/2 + x^2/(2*3) + x^3/(2*3*4) + ...
11652 *
11653 * exceptions: GSL_EOVRFLW
11654 */
11655int gsl_sf_exprel_e(const double x, gsl_sf_result * result);
11656double gsl_sf_exprel(const double x);
11657
11658
11659/* 2(exp(x)-1-x)/x^2 = 1 + x/3 + x^2/(3*4) + x^3/(3*4*5) + ...
11660 *
11661 * exceptions: GSL_EOVRFLW
11662 */
11663int gsl_sf_exprel_2_e(double x, gsl_sf_result * result);
11664double gsl_sf_exprel_2(const double x);
11665
11666
11667/* Similarly for the N-th generalization of
11668 * the above. The so-called N-relative exponential
11669 *
11670 * exprel_N(x) = N!/x^N (exp(x) - Sum[x^k/k!, {k,0,N-1}])
11671 * = 1 + x/(N+1) + x^2/((N+1)(N+2)) + ...
11672 * = 1F1(1,1+N,x)
11673 */
11674int gsl_sf_exprel_n_e(const int n, const double x, gsl_sf_result * result);
11675double gsl_sf_exprel_n(const int n, const double x);
11676
11677int gsl_sf_exprel_n_CF_e(const double n, const double x, gsl_sf_result * result);
11678
11679
11680/* Exponentiate a quantity with an associated error.
11681 */
11682int gsl_sf_exp_err_e(const double x, const double dx, gsl_sf_result * result);
11683
11684/* Exponentiate a quantity with an associated error.
11685 */
11686int gsl_sf_exp_err_e10_e(const double x, const double dx, gsl_sf_result_e10 * result);
11687
11688
11689/* Exponentiate and multiply by a given factor: y * Exp(x),
11690 * for quantities with associated errors.
11691 *
11692 * exceptions: GSL_EOVRFLW, GSL_EUNDRFLW
11693 */
11694int gsl_sf_exp_mult_err_e(const double x, const double dx, const double y, const double dy, gsl_sf_result * result);
11695
11696
11697/* Exponentiate and multiply by a given factor: y * Exp(x),
11698 * for quantities with associated errors.
11699 *
11700 * exceptions: GSL_EOVRFLW, GSL_EUNDRFLW
11701 */
11702int gsl_sf_exp_mult_err_e10_e(const double x, const double dx, const double y, const double dy, gsl_sf_result_e10 * result);
11703
11704__END_DECLS
11705
11706#endif /* __GSL_SF_EXP_H__ */
11707
11708/* end inlined header: gsl/gsl_sf_exp.h */
11709/* begin inlined header: gsl/gsl_sf_log.h */
11710/* specfunc/gsl_sf_log.h
11711 *
11712 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2004 Gerard Jungman
11713 *
11714 * This program is free software; you can redistribute it and/or modify
11715 * it under the terms of the GNU General Public License as published by
11716 * the Free Software Foundation; either version 3 of the License, or (at
11717 * your option) any later version.
11718 *
11719 * This program is distributed in the hope that it will be useful, but
11720 * WITHOUT ANY WARRANTY; without even the implied warranty of
11721 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11722 * General Public License for more details.
11723 *
11724 * You should have received a copy of the GNU General Public License
11725 * along with this program; if not, write to the Free Software
11726 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
11727 */
11728
11729/* Author: G. Jungman */
11730
11731#ifndef __GSL_SF_LOG_H__
11732#define __GSL_SF_LOG_H__
11733/* begin inlined header: gsl/gsl_sf_result.h */
11734/* specfunc/gsl_sf_result.h
11735 *
11736 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
11737 *
11738 * This program is free software; you can redistribute it and/or modify
11739 * it under the terms of the GNU General Public License as published by
11740 * the Free Software Foundation; either version 3 of the License, or (at
11741 * your option) any later version.
11742 *
11743 * This program is distributed in the hope that it will be useful, but
11744 * WITHOUT ANY WARRANTY; without even the implied warranty of
11745 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11746 * General Public License for more details.
11747 *
11748 * You should have received a copy of the GNU General Public License
11749 * along with this program; if not, write to the Free Software
11750 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
11751 */
11752
11753/* Author: G. Jungman */
11754
11755#ifndef __GSL_SF_RESULT_H__
11756#define __GSL_SF_RESULT_H__
11757
11758
11759
11760__BEGIN_DECLS
11761
11762struct gsl_sf_result_struct {
11763 double val;
11764 double err;
11765};
11766typedef struct gsl_sf_result_struct gsl_sf_result;
11767
11768#define GSL_SF_RESULT_SET(r,v,e) do { (r)->val=(v); (r)->err=(e); } while(0)
11769
11770
11772 double val;
11773 double err;
11774 int e10;
11775};
11776typedef struct gsl_sf_result_e10_struct gsl_sf_result_e10;
11777
11778
11779int gsl_sf_result_smash_e(const gsl_sf_result_e10 * re, gsl_sf_result * r);
11780
11781
11782__END_DECLS
11783
11784#endif /* __GSL_SF_RESULT_H__ */
11785
11786/* end inlined header: gsl/gsl_sf_result.h */
11787
11788
11789__BEGIN_DECLS
11790
11791
11792/* Provide a logarithm function with GSL semantics.
11793 *
11794 * exceptions: GSL_EDOM
11795 */
11796int gsl_sf_log_e(const double x, gsl_sf_result * result);
11797double gsl_sf_log(const double x);
11798
11799
11800/* Log(|x|)
11801 *
11802 * exceptions: GSL_EDOM
11803 */
11804int gsl_sf_log_abs_e(const double x, gsl_sf_result * result);
11805double gsl_sf_log_abs(const double x);
11806
11807
11808/* Complex Logarithm
11809 * exp(lnr + I theta) = zr + I zi
11810 * Returns argument in [-pi,pi].
11811 *
11812 * exceptions: GSL_EDOM
11813 */
11814int gsl_sf_complex_log_e(const double zr, const double zi, gsl_sf_result * lnr, gsl_sf_result * theta);
11815
11816
11817/* Log(1 + x)
11818 *
11819 * exceptions: GSL_EDOM
11820 */
11821int gsl_sf_log_1plusx_e(const double x, gsl_sf_result * result);
11822double gsl_sf_log_1plusx(const double x);
11823
11824
11825/* Log(1 + x) - x
11826 *
11827 * exceptions: GSL_EDOM
11828 */
11829int gsl_sf_log_1plusx_mx_e(const double x, gsl_sf_result * result);
11830double gsl_sf_log_1plusx_mx(const double x);
11831
11832__END_DECLS
11833
11834#endif /* __GSL_SF_LOG_H__ */
11835
11836/* end inlined header: gsl/gsl_sf_log.h */
11837/* begin inlined header: gsl/gsl_sf_psi.h */
11838/* specfunc/gsl_sf_psi.h
11839 *
11840 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2004 Gerard Jungman
11841 *
11842 * This program is free software; you can redistribute it and/or modify
11843 * it under the terms of the GNU General Public License as published by
11844 * the Free Software Foundation; either version 3 of the License, or (at
11845 * your option) any later version.
11846 *
11847 * This program is distributed in the hope that it will be useful, but
11848 * WITHOUT ANY WARRANTY; without even the implied warranty of
11849 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11850 * General Public License for more details.
11851 *
11852 * You should have received a copy of the GNU General Public License
11853 * along with this program; if not, write to the Free Software
11854 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
11855 */
11856
11857/* Author: G. Jungman */
11858
11859#ifndef __GSL_SF_PSI_H__
11860#define __GSL_SF_PSI_H__
11861/* begin inlined header: gsl/gsl_sf_result.h */
11862/* specfunc/gsl_sf_result.h
11863 *
11864 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
11865 *
11866 * This program is free software; you can redistribute it and/or modify
11867 * it under the terms of the GNU General Public License as published by
11868 * the Free Software Foundation; either version 3 of the License, or (at
11869 * your option) any later version.
11870 *
11871 * This program is distributed in the hope that it will be useful, but
11872 * WITHOUT ANY WARRANTY; without even the implied warranty of
11873 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11874 * General Public License for more details.
11875 *
11876 * You should have received a copy of the GNU General Public License
11877 * along with this program; if not, write to the Free Software
11878 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
11879 */
11880
11881/* Author: G. Jungman */
11882
11883#ifndef __GSL_SF_RESULT_H__
11884#define __GSL_SF_RESULT_H__
11885
11886
11887
11888__BEGIN_DECLS
11889
11890struct gsl_sf_result_struct {
11891 double val;
11892 double err;
11893};
11894typedef struct gsl_sf_result_struct gsl_sf_result;
11895
11896#define GSL_SF_RESULT_SET(r,v,e) do { (r)->val=(v); (r)->err=(e); } while(0)
11897
11898
11900 double val;
11901 double err;
11902 int e10;
11903};
11904typedef struct gsl_sf_result_e10_struct gsl_sf_result_e10;
11905
11906
11907int gsl_sf_result_smash_e(const gsl_sf_result_e10 * re, gsl_sf_result * r);
11908
11909
11910__END_DECLS
11911
11912#endif /* __GSL_SF_RESULT_H__ */
11913
11914/* end inlined header: gsl/gsl_sf_result.h */
11915
11916
11917__BEGIN_DECLS
11918
11919
11920/* Poly-Gamma Functions
11921 *
11922 * psi(m,x) := (d/dx)^m psi(0,x) = (d/dx)^{m+1} log(gamma(x))
11923 */
11924
11925
11926/* Di-Gamma Function psi(n) = psi(0,n)
11927 *
11928 * n > 0
11929 * exceptions: GSL_EDOM
11930 */
11931int gsl_sf_psi_int_e(const int n, gsl_sf_result * result);
11932double gsl_sf_psi_int(const int n);
11933
11934
11935/* Di-Gamma Function psi(x) = psi(0, x)
11936 *
11937 * x != 0.0, -1.0, -2.0, ...
11938 * exceptions: GSL_EDOM, GSL_ELOSS
11939 */
11940int gsl_sf_psi_e(const double x, gsl_sf_result * result);
11941double gsl_sf_psi(const double x);
11942
11943
11944/* Di-Gamma Function Re[psi(1 + I y)]
11945 *
11946 * exceptions: none
11947 */
11948int gsl_sf_psi_1piy_e(const double y, gsl_sf_result * result);
11949double gsl_sf_psi_1piy(const double y);
11950
11951
11952/* Di-Gamma Function psi(z) for general complex argument z = x + iy
11953 *
11954 * exceptions: GSL_EDOM
11955 */
11956int gsl_sf_complex_psi_e(
11957 const double x,
11958 const double y,
11959 gsl_sf_result * result_re,
11960 gsl_sf_result * result_im
11961 );
11962
11963
11964/* Tri-Gamma Function psi^(1)(n)
11965 *
11966 * n > 0
11967 * exceptions: GSL_EDOM
11968 */
11969int gsl_sf_psi_1_int_e(const int n, gsl_sf_result * result);
11970double gsl_sf_psi_1_int(const int n);
11971
11972
11973/* Tri-Gamma Function psi^(1)(x)
11974 *
11975 * x != 0.0, -1.0, -2.0, ...
11976 * exceptions: GSL_EDOM, GSL_ELOSS
11977 */
11978int gsl_sf_psi_1_e(const double x, gsl_sf_result * result);
11979double gsl_sf_psi_1(const double x);
11980
11981
11982/* Poly-Gamma Function psi^(n)(x)
11983 *
11984 * n >= 0, x > 0.0
11985 * exceptions: GSL_EDOM
11986 */
11987int gsl_sf_psi_n_e(const int n, const double x, gsl_sf_result * result);
11988double gsl_sf_psi_n(const int n, const double x);
11989
11990
11991__END_DECLS
11992
11993#endif /* __GSL_SF_PSI_H__ */
11994
11995/* end inlined header: gsl/gsl_sf_psi.h */
11996/* begin inlined header: gsl/gsl_sf_trig.h */
11997/* specfunc/gsl_sf_trig.h
11998 *
11999 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
12000 *
12001 * This program is free software; you can redistribute it and/or modify
12002 * it under the terms of the GNU General Public License as published by
12003 * the Free Software Foundation; either version 3 of the License, or (at
12004 * your option) any later version.
12005 *
12006 * This program is distributed in the hope that it will be useful, but
12007 * WITHOUT ANY WARRANTY; without even the implied warranty of
12008 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12009 * General Public License for more details.
12010 *
12011 * You should have received a copy of the GNU General Public License
12012 * along with this program; if not, write to the Free Software
12013 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
12014 */
12015
12016/* Author: G. Jungman */
12017
12018#ifndef __GSL_SF_TRIG_H__
12019#define __GSL_SF_TRIG_H__
12020/* begin inlined header: gsl/gsl_sf_result.h */
12021/* specfunc/gsl_sf_result.h
12022 *
12023 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
12024 *
12025 * This program is free software; you can redistribute it and/or modify
12026 * it under the terms of the GNU General Public License as published by
12027 * the Free Software Foundation; either version 3 of the License, or (at
12028 * your option) any later version.
12029 *
12030 * This program is distributed in the hope that it will be useful, but
12031 * WITHOUT ANY WARRANTY; without even the implied warranty of
12032 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12033 * General Public License for more details.
12034 *
12035 * You should have received a copy of the GNU General Public License
12036 * along with this program; if not, write to the Free Software
12037 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
12038 */
12039
12040/* Author: G. Jungman */
12041
12042#ifndef __GSL_SF_RESULT_H__
12043#define __GSL_SF_RESULT_H__
12044
12045
12046
12047__BEGIN_DECLS
12048
12049struct gsl_sf_result_struct {
12050 double val;
12051 double err;
12052};
12053typedef struct gsl_sf_result_struct gsl_sf_result;
12054
12055#define GSL_SF_RESULT_SET(r,v,e) do { (r)->val=(v); (r)->err=(e); } while(0)
12056
12057
12059 double val;
12060 double err;
12061 int e10;
12062};
12063typedef struct gsl_sf_result_e10_struct gsl_sf_result_e10;
12064
12065
12066int gsl_sf_result_smash_e(const gsl_sf_result_e10 * re, gsl_sf_result * r);
12067
12068
12069__END_DECLS
12070
12071#endif /* __GSL_SF_RESULT_H__ */
12072
12073/* end inlined header: gsl/gsl_sf_result.h */
12074
12075
12076__BEGIN_DECLS
12077
12078
12079/* Sin(x) with GSL semantics. This is actually important
12080 * because we want to control the error estimate, and trying
12081 * to guess the error for the standard library implementation
12082 * every time it is used would be a little goofy.
12083 */
12084int gsl_sf_sin_e(double x, gsl_sf_result * result);
12085double gsl_sf_sin(const double x);
12086
12087
12088/* Cos(x) with GSL semantics.
12089 */
12090int gsl_sf_cos_e(double x, gsl_sf_result * result);
12091double gsl_sf_cos(const double x);
12092
12093
12094/* Hypot(x,y) with GSL semantics.
12095 */
12096int gsl_sf_hypot_e(const double x, const double y, gsl_sf_result * result);
12097double gsl_sf_hypot(const double x, const double y);
12098
12099
12100/* Sin(z) for complex z
12101 *
12102 * exceptions: GSL_EOVRFLW
12103 */
12104int gsl_sf_complex_sin_e(const double zr, const double zi, gsl_sf_result * szr, gsl_sf_result * szi);
12105
12106
12107/* Cos(z) for complex z
12108 *
12109 * exceptions: GSL_EOVRFLW
12110 */
12111int gsl_sf_complex_cos_e(const double zr, const double zi, gsl_sf_result * czr, gsl_sf_result * czi);
12112
12113
12114/* Log(Sin(z)) for complex z
12115 *
12116 * exceptions: GSL_EDOM, GSL_ELOSS
12117 */
12118int gsl_sf_complex_logsin_e(const double zr, const double zi, gsl_sf_result * lszr, gsl_sf_result * lszi);
12119
12120
12121/* Sinc(x) = sin(pi x) / (pi x)
12122 *
12123 * exceptions: none
12124 */
12125int gsl_sf_sinc_e(double x, gsl_sf_result * result);
12126double gsl_sf_sinc(const double x);
12127
12128
12129/* Log(Sinh(x)), x > 0
12130 *
12131 * exceptions: GSL_EDOM
12132 */
12133int gsl_sf_lnsinh_e(const double x, gsl_sf_result * result);
12134double gsl_sf_lnsinh(const double x);
12135
12136
12137/* Log(Cosh(x))
12138 *
12139 * exceptions: none
12140 */
12141int gsl_sf_lncosh_e(const double x, gsl_sf_result * result);
12142double gsl_sf_lncosh(const double x);
12143
12144
12145/* Convert polar to rectlinear coordinates.
12146 *
12147 * exceptions: GSL_ELOSS
12148 */
12149int gsl_sf_polar_to_rect(const double r, const double theta, gsl_sf_result * x, gsl_sf_result * y);
12150
12151/* Convert rectilinear to polar coordinates.
12152 * return argument in range [-pi, pi]
12153 *
12154 * exceptions: GSL_EDOM
12155 */
12156int gsl_sf_rect_to_polar(const double x, const double y, gsl_sf_result * r, gsl_sf_result * theta);
12157
12158/* Sin(x) for quantity with an associated error.
12159 */
12160int gsl_sf_sin_err_e(const double x, const double dx, gsl_sf_result * result);
12161
12162
12163/* Cos(x) for quantity with an associated error.
12164 */
12165int gsl_sf_cos_err_e(const double x, const double dx, gsl_sf_result * result);
12166
12167
12168/* Force an angle to lie in the range (-pi,pi].
12169 *
12170 * exceptions: GSL_ELOSS
12171 */
12172int gsl_sf_angle_restrict_symm_e(double * theta);
12173double gsl_sf_angle_restrict_symm(const double theta);
12174
12175
12176/* Force an angle to lie in the range [0, 2pi)
12177 *
12178 * exceptions: GSL_ELOSS
12179 */
12180int gsl_sf_angle_restrict_pos_e(double * theta);
12181double gsl_sf_angle_restrict_pos(const double theta);
12182
12183
12184int gsl_sf_angle_restrict_symm_err_e(const double theta, gsl_sf_result * result);
12185
12186int gsl_sf_angle_restrict_pos_err_e(const double theta, gsl_sf_result * result);
12187
12188
12189__END_DECLS
12190
12191#endif /* __GSL_SF_TRIG_H__ */
12192
12193/* end inlined header: gsl/gsl_sf_trig.h */
12194/* begin inlined header: gsl/gsl_sf_gamma.h */
12195/* specfunc/gsl_sf_gamma.h
12196 *
12197 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
12198 *
12199 * This program is free software; you can redistribute it and/or modify
12200 * it under the terms of the GNU General Public License as published by
12201 * the Free Software Foundation; either version 3 of the License, or (at
12202 * your option) any later version.
12203 *
12204 * This program is distributed in the hope that it will be useful, but
12205 * WITHOUT ANY WARRANTY; without even the implied warranty of
12206 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12207 * General Public License for more details.
12208 *
12209 * You should have received a copy of the GNU General Public License
12210 * along with this program; if not, write to the Free Software
12211 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
12212 */
12213
12214/* Author: G. Jungman */
12215
12216#ifndef __GSL_SF_GAMMA_H__
12217#define __GSL_SF_GAMMA_H__
12218/* begin inlined header: gsl/gsl_sf_result.h */
12219/* specfunc/gsl_sf_result.h
12220 *
12221 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
12222 *
12223 * This program is free software; you can redistribute it and/or modify
12224 * it under the terms of the GNU General Public License as published by
12225 * the Free Software Foundation; either version 3 of the License, or (at
12226 * your option) any later version.
12227 *
12228 * This program is distributed in the hope that it will be useful, but
12229 * WITHOUT ANY WARRANTY; without even the implied warranty of
12230 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12231 * General Public License for more details.
12232 *
12233 * You should have received a copy of the GNU General Public License
12234 * along with this program; if not, write to the Free Software
12235 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
12236 */
12237
12238/* Author: G. Jungman */
12239
12240#ifndef __GSL_SF_RESULT_H__
12241#define __GSL_SF_RESULT_H__
12242
12243
12244
12245__BEGIN_DECLS
12246
12247struct gsl_sf_result_struct {
12248 double val;
12249 double err;
12250};
12251typedef struct gsl_sf_result_struct gsl_sf_result;
12252
12253#define GSL_SF_RESULT_SET(r,v,e) do { (r)->val=(v); (r)->err=(e); } while(0)
12254
12255
12257 double val;
12258 double err;
12259 int e10;
12260};
12261typedef struct gsl_sf_result_e10_struct gsl_sf_result_e10;
12262
12263
12264int gsl_sf_result_smash_e(const gsl_sf_result_e10 * re, gsl_sf_result * r);
12265
12266
12267__END_DECLS
12268
12269#endif /* __GSL_SF_RESULT_H__ */
12270
12271/* end inlined header: gsl/gsl_sf_result.h */
12272
12273
12274__BEGIN_DECLS
12275
12276
12277/* Log[Gamma(x)], x not a negative integer
12278 * Uses real Lanczos method.
12279 * Returns the real part of Log[Gamma[x]] when x < 0,
12280 * i.e. Log[|Gamma[x]|].
12281 *
12282 * exceptions: GSL_EDOM, GSL_EROUND
12283 */
12284int gsl_sf_lngamma_e(double x, gsl_sf_result * result);
12285double gsl_sf_lngamma(const double x);
12286
12287
12288/* Log[Gamma(x)], x not a negative integer
12289 * Uses real Lanczos method. Determines
12290 * the sign of Gamma[x] as well as Log[|Gamma[x]|] for x < 0.
12291 * So Gamma[x] = sgn * Exp[result_lg].
12292 *
12293 * exceptions: GSL_EDOM, GSL_EROUND
12294 */
12295int gsl_sf_lngamma_sgn_e(double x, gsl_sf_result * result_lg, double *sgn);
12296
12297
12298/* Gamma(x), x not a negative integer
12299 * Uses real Lanczos method.
12300 *
12301 * exceptions: GSL_EDOM, GSL_EOVRFLW, GSL_EROUND
12302 */
12303int gsl_sf_gamma_e(const double x, gsl_sf_result * result);
12304double gsl_sf_gamma(const double x);
12305
12306
12307/* Regulated Gamma Function, x > 0
12308 * Gamma^*(x) = Gamma(x)/(Sqrt[2Pi] x^(x-1/2) exp(-x))
12309 * = (1 + 1/(12x) + ...), x->Inf
12310 * A useful suggestion of Temme.
12311 *
12312 * exceptions: GSL_EDOM
12313 */
12314int gsl_sf_gammastar_e(const double x, gsl_sf_result * result);
12315double gsl_sf_gammastar(const double x);
12316
12317
12318/* 1/Gamma(x)
12319 * Uses real Lanczos method.
12320 *
12321 * exceptions: GSL_EUNDRFLW, GSL_EROUND
12322 */
12323int gsl_sf_gammainv_e(const double x, gsl_sf_result * result);
12324double gsl_sf_gammainv(const double x);
12325
12326
12327/* Log[Gamma(z)] for z complex, z not a negative integer
12328 * Uses complex Lanczos method. Note that the phase part (arg)
12329 * is not well-determined when |z| is very large, due
12330 * to inevitable roundoff in restricting to (-Pi,Pi].
12331 * This will raise the GSL_ELOSS exception when it occurs.
12332 * The absolute value part (lnr), however, never suffers.
12333 *
12334 * Calculates:
12335 * lnr = log|Gamma(z)|
12336 * arg = arg(Gamma(z)) in (-Pi, Pi]
12337 *
12338 * exceptions: GSL_EDOM, GSL_ELOSS
12339 */
12340int gsl_sf_lngamma_complex_e(double zr, double zi, gsl_sf_result * lnr, gsl_sf_result * arg);
12341
12342
12343/* x^n / n!
12344 *
12345 * x >= 0.0, n >= 0
12346 * exceptions: GSL_EDOM, GSL_EOVRFLW, GSL_EUNDRFLW
12347 */
12348int gsl_sf_taylorcoeff_e(const int n, const double x, gsl_sf_result * result);
12349double gsl_sf_taylorcoeff(const int n, const double x);
12350
12351
12352/* n!
12353 *
12354 * exceptions: GSL_EDOM, GSL_EOVRFLW
12355 */
12356int gsl_sf_fact_e(const unsigned int n, gsl_sf_result * result);
12357double gsl_sf_fact(const unsigned int n);
12358
12359
12360/* n!! = n(n-2)(n-4) ...
12361 *
12362 * exceptions: GSL_EDOM, GSL_EOVRFLW
12363 */
12364int gsl_sf_doublefact_e(const unsigned int n, gsl_sf_result * result);
12365double gsl_sf_doublefact(const unsigned int n);
12366
12367
12368/* log(n!)
12369 * Faster than ln(Gamma(n+1)) for n < 170; defers for larger n.
12370 *
12371 * exceptions: none
12372 */
12373int gsl_sf_lnfact_e(const unsigned int n, gsl_sf_result * result);
12374double gsl_sf_lnfact(const unsigned int n);
12375
12376
12377/* log(n!!)
12378 *
12379 * exceptions: none
12380 */
12381int gsl_sf_lndoublefact_e(const unsigned int n, gsl_sf_result * result);
12382double gsl_sf_lndoublefact(const unsigned int n);
12383
12384
12385/* log(n choose m)
12386 *
12387 * exceptions: GSL_EDOM
12388 */
12389int gsl_sf_lnchoose_e(unsigned int n, unsigned int m, gsl_sf_result * result);
12390double gsl_sf_lnchoose(unsigned int n, unsigned int m);
12391
12392
12393/* n choose m
12394 *
12395 * exceptions: GSL_EDOM, GSL_EOVRFLW
12396 */
12397int gsl_sf_choose_e(unsigned int n, unsigned int m, gsl_sf_result * result);
12398double gsl_sf_choose(unsigned int n, unsigned int m);
12399
12400
12401/* Logarithm of Pochhammer (Apell) symbol
12402 * log( (a)_x )
12403 * where (a)_x := Gamma[a + x]/Gamma[a]
12404 *
12405 * a > 0, a+x > 0
12406 *
12407 * exceptions: GSL_EDOM
12408 */
12409int gsl_sf_lnpoch_e(const double a, const double x, gsl_sf_result * result);
12410double gsl_sf_lnpoch(const double a, const double x);
12411
12412
12413/* Logarithm of Pochhammer (Apell) symbol, with sign information.
12414 * result = log( |(a)_x| )
12415 * sgn = sgn( (a)_x )
12416 * where (a)_x := Gamma[a + x]/Gamma[a]
12417 *
12418 * a != neg integer, a+x != neg integer
12419 *
12420 * exceptions: GSL_EDOM
12421 */
12422int gsl_sf_lnpoch_sgn_e(const double a, const double x, gsl_sf_result * result, double * sgn);
12423
12424
12425/* Pochhammer (Apell) symbol
12426 * (a)_x := Gamma[a + x]/Gamma[x]
12427 *
12428 * a != neg integer, a+x != neg integer
12429 *
12430 * exceptions: GSL_EDOM, GSL_EOVRFLW
12431 */
12432int gsl_sf_poch_e(const double a, const double x, gsl_sf_result * result);
12433double gsl_sf_poch(const double a, const double x);
12434
12435
12436/* Relative Pochhammer (Apell) symbol
12437 * ((a,x) - 1)/x
12438 * where (a,x) = (a)_x := Gamma[a + x]/Gamma[a]
12439 *
12440 * exceptions: GSL_EDOM
12441 */
12442int gsl_sf_pochrel_e(const double a, const double x, gsl_sf_result * result);
12443double gsl_sf_pochrel(const double a, const double x);
12444
12445
12446/* Normalized Incomplete Gamma Function
12447 *
12448 * Q(a,x) = 1/Gamma(a) Integral[ t^(a-1) e^(-t), {t,x,Infinity} ]
12449 *
12450 * a >= 0, x >= 0
12451 * Q(a,0) := 1
12452 * Q(0,x) := 0, x != 0
12453 *
12454 * exceptions: GSL_EDOM
12455 */
12456int gsl_sf_gamma_inc_Q_e(const double a, const double x, gsl_sf_result * result);
12457double gsl_sf_gamma_inc_Q(const double a, const double x);
12458
12459
12460/* Complementary Normalized Incomplete Gamma Function
12461 *
12462 * P(a,x) = 1/Gamma(a) Integral[ t^(a-1) e^(-t), {t,0,x} ]
12463 *
12464 * a > 0, x >= 0
12465 *
12466 * exceptions: GSL_EDOM
12467 */
12468int gsl_sf_gamma_inc_P_e(const double a, const double x, gsl_sf_result * result);
12469double gsl_sf_gamma_inc_P(const double a, const double x);
12470
12471
12472/* Non-normalized Incomplete Gamma Function
12473 *
12474 * Gamma(a,x) := Integral[ t^(a-1) e^(-t), {t,x,Infinity} ]
12475 *
12476 * x >= 0.0
12477 * Gamma(a, 0) := Gamma(a)
12478 *
12479 * exceptions: GSL_EDOM
12480 */
12481int gsl_sf_gamma_inc_e(const double a, const double x, gsl_sf_result * result);
12482double gsl_sf_gamma_inc(const double a, const double x);
12483
12484
12485/* Logarithm of Beta Function
12486 * Log[B(a,b)]
12487 *
12488 * a > 0, b > 0
12489 * exceptions: GSL_EDOM
12490 */
12491int gsl_sf_lnbeta_e(const double a, const double b, gsl_sf_result * result);
12492double gsl_sf_lnbeta(const double a, const double b);
12493
12494int gsl_sf_lnbeta_sgn_e(const double x, const double y, gsl_sf_result * result, double * sgn);
12495
12496
12497/* Beta Function
12498 * B(a,b)
12499 *
12500 * a > 0, b > 0
12501 * exceptions: GSL_EDOM, GSL_EOVRFLW, GSL_EUNDRFLW
12502 */
12503int gsl_sf_beta_e(const double a, const double b, gsl_sf_result * result);
12504double gsl_sf_beta(const double a, const double b);
12505
12506
12507/* Normalized Incomplete Beta Function
12508 * B_x(a,b)/B(a,b)
12509 *
12510 * a > 0, b > 0, 0 <= x <= 1
12511 * exceptions: GSL_EDOM, GSL_EUNDRFLW
12512 */
12513int gsl_sf_beta_inc_e(const double a, const double b, const double x, gsl_sf_result * result);
12514double gsl_sf_beta_inc(const double a, const double b, const double x);
12515
12516
12517/* The maximum x such that gamma(x) is not
12518 * considered an overflow.
12519 */
12520#define GSL_SF_GAMMA_XMAX 171.0
12521
12522/* The maximum n such that gsl_sf_fact(n) does not give an overflow. */
12523#define GSL_SF_FACT_NMAX 170
12524
12525/* The maximum n such that gsl_sf_doublefact(n) does not give an overflow. */
12526#define GSL_SF_DOUBLEFACT_NMAX 297
12527
12528__END_DECLS
12529
12530#endif /* __GSL_SF_GAMMA_H__ */
12531
12532/* end inlined header: gsl/gsl_sf_gamma.h */
12533/* inlined: error.h */
12534/* inlined: check.h */
12535
12536/* inlined: chebyshev.h */
12537/* inlined once already: specfunc/cheb_eval.c */
12538
12539#define LogRootTwoPi_ 0.9189385332046727418
12540
12541
12542/*-*-*-*-*-*-*-*-*-*-*-* Private Section *-*-*-*-*-*-*-*-*-*-*-*/
12543
12544static struct {int n; double f; long i; } fact_table[GSL_SF_FACT_NMAX + 1] = {
12545 { 0, 1.0, 1L },
12546 { 1, 1.0, 1L },
12547 { 2, 2.0, 2L },
12548 { 3, 6.0, 6L },
12549 { 4, 24.0, 24L },
12550 { 5, 120.0, 120L },
12551 { 6, 720.0, 720L },
12552 { 7, 5040.0, 5040L },
12553 { 8, 40320.0, 40320L },
12554
12555 { 9, 362880.0, 362880L },
12556 { 10, 3628800.0, 3628800L },
12557 { 11, 39916800.0, 39916800L },
12558 { 12, 479001600.0, 479001600L },
12559
12560 { 13, 6227020800.0, 0 },
12561 { 14, 87178291200.0, 0 },
12562 { 15, 1307674368000.0, 0 },
12563 { 16, 20922789888000.0, 0 },
12564 { 17, 355687428096000.0, 0 },
12565 { 18, 6402373705728000.0, 0 },
12566 { 19, 121645100408832000.0, 0 },
12567 { 20, 2432902008176640000.0, 0 },
12568 { 21, 51090942171709440000.0, 0 },
12569 { 22, 1124000727777607680000.0, 0 },
12570 { 23, 25852016738884976640000.0, 0 },
12571 { 24, 620448401733239439360000.0, 0 },
12572 { 25, 15511210043330985984000000.0, 0 },
12573 { 26, 403291461126605635584000000.0, 0 },
12574 { 27, 10888869450418352160768000000.0, 0 },
12575 { 28, 304888344611713860501504000000.0, 0 },
12576 { 29, 8841761993739701954543616000000.0, 0 },
12577 { 30, 265252859812191058636308480000000.0, 0 },
12578 { 31, 8222838654177922817725562880000000.0, 0 },
12579 { 32, 263130836933693530167218012160000000.0, 0 },
12580 { 33, 8683317618811886495518194401280000000.0, 0 },
12581 { 34, 2.95232799039604140847618609644e38, 0 },
12582 { 35, 1.03331479663861449296666513375e40, 0 },
12583 { 36, 3.71993326789901217467999448151e41, 0 },
12584 { 37, 1.37637530912263450463159795816e43, 0 },
12585 { 38, 5.23022617466601111760007224100e44, 0 },
12586 { 39, 2.03978820811974433586402817399e46, 0 },
12587 { 40, 8.15915283247897734345611269600e47, 0 },
12588 { 41, 3.34525266131638071081700620534e49, 0 },
12589 { 42, 1.40500611775287989854314260624e51, 0 },
12590 { 43, 6.04152630633738356373551320685e52, 0 },
12591 { 44, 2.65827157478844876804362581101e54, 0 },
12592 { 45, 1.19622220865480194561963161496e56, 0 },
12593 { 46, 5.50262215981208894985030542880e57, 0 },
12594 { 47, 2.58623241511168180642964355154e59, 0 },
12595 { 48, 1.24139155925360726708622890474e61, 0 },
12596 { 49, 6.08281864034267560872252163321e62, 0 },
12597 { 50, 3.04140932017133780436126081661e64, 0 },
12598 { 51, 1.55111875328738228022424301647e66, 0 },
12599 { 52, 8.06581751709438785716606368564e67, 0 },
12600 { 53, 4.27488328406002556429801375339e69, 0 },
12601 { 54, 2.30843697339241380472092742683e71, 0 },
12602 { 55, 1.26964033536582759259651008476e73, 0 },
12603 { 56, 7.10998587804863451854045647464e74, 0 },
12604 { 57, 4.05269195048772167556806019054e76, 0 },
12605 { 58, 2.35056133128287857182947491052e78, 0 },
12606 { 59, 1.38683118545689835737939019720e80, 0 },
12607 { 60, 8.32098711274139014427634118320e81, 0 },
12608 { 61, 5.07580213877224798800856812177e83, 0 },
12609 { 62, 3.14699732603879375256531223550e85, 0 },
12610 { 63, 1.982608315404440064116146708360e87, 0 },
12611 { 64, 1.268869321858841641034333893350e89, 0 },
12612 { 65, 8.247650592082470666723170306800e90, 0 },
12613 { 66, 5.443449390774430640037292402480e92, 0 },
12614 { 67, 3.647111091818868528824985909660e94, 0 },
12615 { 68, 2.480035542436830599600990418570e96, 0 },
12616 { 69, 1.711224524281413113724683388810e98, 0 },
12617 { 70, 1.197857166996989179607278372170e100, 0 },
12618 { 71, 8.504785885678623175211676442400e101, 0 },
12619 { 72, 6.123445837688608686152407038530e103, 0 },
12620 { 73, 4.470115461512684340891257138130e105, 0 },
12621 { 74, 3.307885441519386412259530282210e107, 0 },
12622 { 75, 2.480914081139539809194647711660e109, 0 },
12623 { 76, 1.885494701666050254987932260860e111, 0 },
12624 { 77, 1.451830920282858696340707840860e113, 0 },
12625 { 78, 1.132428117820629783145752115870e115, 0 },
12626 { 79, 8.946182130782975286851441715400e116, 0 },
12627 { 80, 7.156945704626380229481153372320e118, 0 },
12628 { 81, 5.797126020747367985879734231580e120, 0 },
12629 { 82, 4.753643337012841748421382069890e122, 0 },
12630 { 83, 3.945523969720658651189747118010e124, 0 },
12631 { 84, 3.314240134565353266999387579130e126, 0 },
12632 { 85, 2.817104114380550276949479442260e128, 0 },
12633 { 86, 2.422709538367273238176552320340e130, 0 },
12634 { 87, 2.107757298379527717213600518700e132, 0 },
12635 { 88, 1.854826422573984391147968456460e134, 0 },
12636 { 89, 1.650795516090846108121691926250e136, 0 },
12637 { 90, 1.485715964481761497309522733620e138, 0 },
12638 { 91, 1.352001527678402962551665687590e140, 0 },
12639 { 92, 1.243841405464130725547532432590e142, 0 },
12640 { 93, 1.156772507081641574759205162310e144, 0 },
12641 { 94, 1.087366156656743080273652852570e146, 0 },
12642 { 95, 1.032997848823905926259970209940e148, 0 },
12643 { 96, 9.916779348709496892095714015400e149, 0 },
12644 { 97, 9.619275968248211985332842594960e151, 0 },
12645 { 98, 9.426890448883247745626185743100e153, 0 },
12646 { 99, 9.332621544394415268169923885600e155, 0 },
12647 { 100, 9.33262154439441526816992388563e157, 0 },
12648 { 101, 9.42594775983835942085162312450e159, 0 },
12649 { 102, 9.61446671503512660926865558700e161, 0 },
12650 { 103, 9.90290071648618040754671525458e163, 0 },
12651 { 104, 1.02990167451456276238485838648e166, 0 },
12652 { 105, 1.08139675824029090050410130580e168, 0 },
12653 { 106, 1.146280563734708354534347384148e170, 0 },
12654 { 107, 1.226520203196137939351751701040e172, 0 },
12655 { 108, 1.324641819451828974499891837120e174, 0 },
12656 { 109, 1.443859583202493582204882102460e176, 0 },
12657 { 110, 1.588245541522742940425370312710e178, 0 },
12658 { 111, 1.762952551090244663872161047110e180, 0 },
12659 { 112, 1.974506857221074023536820372760e182, 0 },
12660 { 113, 2.231192748659813646596607021220e184, 0 },
12661 { 114, 2.543559733472187557120132004190e186, 0 },
12662 { 115, 2.925093693493015690688151804820e188, 0 },
12663 { 116, 3.393108684451898201198256093590e190, 0 },
12664 { 117, 3.96993716080872089540195962950e192, 0 },
12665 { 118, 4.68452584975429065657431236281e194, 0 },
12666 { 119, 5.57458576120760588132343171174e196, 0 },
12667 { 120, 6.68950291344912705758811805409e198, 0 },
12668 { 121, 8.09429852527344373968162284545e200, 0 },
12669 { 122, 9.87504420083360136241157987140e202, 0 },
12670 { 123, 1.21463043670253296757662432419e205, 0 },
12671 { 124, 1.50614174151114087979501416199e207, 0 },
12672 { 125, 1.88267717688892609974376770249e209, 0 },
12673 { 126, 2.37217324288004688567714730514e211, 0 },
12674 { 127, 3.01266001845765954480997707753e213, 0 },
12675 { 128, 3.85620482362580421735677065923e215, 0 },
12676 { 129, 4.97450422247728744039023415041e217, 0 },
12677 { 130, 6.46685548922047367250730439554e219, 0 },
12678 { 131, 8.47158069087882051098456875820e221, 0 },
12679 { 132, 1.11824865119600430744996307608e224, 0 },
12680 { 133, 1.48727070609068572890845089118e226, 0 },
12681 { 134, 1.99294274616151887673732419418e228, 0 },
12682 { 135, 2.69047270731805048359538766215e230, 0 },
12683 { 136, 3.65904288195254865768972722052e232, 0 },
12684 { 137, 5.01288874827499166103492629211e234, 0 },
12685 { 138, 6.91778647261948849222819828311e236, 0 },
12686 { 139, 9.61572319694108900419719561353e238, 0 },
12687 { 140, 1.34620124757175246058760738589e241, 0 },
12688 { 141, 1.89814375907617096942852641411e243, 0 },
12689 { 142, 2.69536413788816277658850750804e245, 0 },
12690 { 143, 3.85437071718007277052156573649e247, 0 },
12691 { 144, 5.55029383273930478955105466055e249, 0 },
12692 { 145, 8.04792605747199194484902925780e251, 0 },
12693 { 146, 1.17499720439091082394795827164e254, 0 },
12694 { 147, 1.72724589045463891120349865931e256, 0 },
12695 { 148, 2.55632391787286558858117801578e258, 0 },
12696 { 149, 3.80892263763056972698595524351e260, 0 },
12697 { 150, 5.71338395644585459047893286526e262, 0 },
12698 { 151, 8.62720977423324043162318862650e264, 0 },
12699 { 152, 1.31133588568345254560672467123e267, 0 },
12700 { 153, 2.00634390509568239477828874699e269, 0 },
12701 { 154, 3.08976961384735088795856467036e271, 0 },
12702 { 155, 4.78914290146339387633577523906e273, 0 },
12703 { 156, 7.47106292628289444708380937294e275, 0 },
12704 { 157, 1.17295687942641442819215807155e278, 0 },
12705 { 158, 1.85327186949373479654360975305e280, 0 },
12706 { 159, 2.94670227249503832650433950735e282, 0 },
12707 { 160, 4.71472363599206132240694321176e284, 0 },
12708 { 161, 7.59070505394721872907517857094e286, 0 },
12709 { 162, 1.22969421873944943411017892849e289, 0 },
12710 { 163, 2.00440157654530257759959165344e291, 0 },
12711 { 164, 3.28721858553429622726333031164e293, 0 },
12712 { 165, 5.42391066613158877498449501421e295, 0 },
12713 { 166, 9.00369170577843736647426172359e297, 0 },
12714 { 167, 1.50361651486499904020120170784e300, 0 },
12715 { 168, 2.52607574497319838753801886917e302, 0 },
12716 { 169, 4.26906800900470527493925188890e304, 0 },
12717 { 170, 7.25741561530799896739672821113e306, 0 },
12718
12719 /*
12720 { 171, 1.24101807021766782342484052410e309, 0 },
12721 { 172, 2.13455108077438865629072570146e311, 0 },
12722 { 173, 3.69277336973969237538295546352e313, 0 },
12723 { 174, 6.42542566334706473316634250653e315, 0 },
12724 { 175, 1.12444949108573632830410993864e318, 0 },
12725 { 176, 1.97903110431089593781523349201e320, 0 },
12726 { 177, 3.50288505463028580993296328086e322, 0 },
12727 { 178, 6.23513539724190874168067463993e324, 0 },
12728 { 179, 1.11608923610630166476084076055e327, 0 },
12729 { 180, 2.00896062499134299656951336898e329, 0 },
12730 { 181, 3.63621873123433082379081919786e331, 0 },
12731 { 182, 6.61791809084648209929929094011e333, 0 },
12732 { 183, 1.21107901062490622417177024204e336, 0 },
12733 { 184, 2.22838537954982745247605724535e338, 0 },
12734 { 185, 4.12251295216718078708070590390e340, 0 },
12735 { 186, 7.66787409103095626397011298130e342, 0 },
12736 { 187, 1.43389245502278882136241112750e345, 0 },
12737 { 188, 2.69571781544284298416133291969e347, 0 },
12738 { 189, 5.09490667118697324006491921822e349, 0 },
12739 { 190, 9.68032267525524915612334651460e351, 0 },
12740 { 191, 1.84894163097375258881955918429e354, 0 },
12741 { 192, 3.54996793146960497053355363384e356, 0 },
12742 { 193, 6.85143810773633759312975851330e358, 0 },
12743 { 194, 1.32917899290084949306717315158e361, 0 },
12744 { 195, 2.59189903615665651148098764559e363, 0 },
12745 { 196, 5.08012211086704676250273578535e365, 0 },
12746 { 197, 1.00078405584080821221303894971e368, 0 },
12747 { 198, 1.98155243056480026018181712043e370, 0 },
12748 { 199, 3.94328933682395251776181606966e372, 0 },
12749 { 200, 7.88657867364790503552363213932e374, 0 }
12750 */
12751};
12752
12753static struct {int n; double f; long i; } doub_fact_table[GSL_SF_DOUBLEFACT_NMAX + 1] = {
12754 { 0, 1.000000000000000000000000000, 1L },
12755 { 1, 1.000000000000000000000000000, 1L },
12756 { 2, 2.000000000000000000000000000, 2L },
12757 { 3, 3.000000000000000000000000000, 3L },
12758 { 4, 8.000000000000000000000000000, 8L },
12759 { 5, 15.00000000000000000000000000, 15L },
12760 { 6, 48.00000000000000000000000000, 48L },
12761 { 7, 105.0000000000000000000000000, 105L },
12762 { 8, 384.0000000000000000000000000, 384L },
12763 { 9, 945.0000000000000000000000000, 945L },
12764 { 10, 3840.000000000000000000000000, 3840L },
12765 { 11, 10395.00000000000000000000000, 10395L },
12766 { 12, 46080.00000000000000000000000, 46080L },
12767 { 13, 135135.0000000000000000000000, 135135L },
12768 { 14, 645120.00000000000000000000000, 645120L },
12769 { 15, 2.02702500000000000000000000000e6, 2027025L },
12770 { 16, 1.03219200000000000000000000000e7, 10321920L },
12771 { 17, 3.4459425000000000000000000000e7, 34459425L },
12772 { 18, 1.85794560000000000000000000000e8, 185794560L },
12773 { 19, 6.5472907500000000000000000000e8, 0 },
12774 { 20, 3.7158912000000000000000000000e9, 0 },
12775 { 21, 1.37493105750000000000000000000e10, 0 },
12776 { 22, 8.1749606400000000000000000000e10, 0 },
12777 { 23, 3.1623414322500000000000000000e11, 0 },
12778 { 24, 1.96199055360000000000000000000e12, 0 },
12779 { 25, 7.9058535806250000000000000000e12, 0 },
12780 { 26, 5.1011754393600000000000000000e13, 0 },
12781 { 27, 2.13458046676875000000000000000e14, 0 },
12782 { 28, 1.42832912302080000000000000000e15, 0 },
12783 { 29, 6.1902833536293750000000000000e15, 0 },
12784 { 30, 4.2849873690624000000000000000e16, 0 },
12785 { 31, 1.91898783962510625000000000000e17, 0 },
12786 { 32, 1.37119595809996800000000000000e18, 0 },
12787 { 33, 6.3326598707628506250000000000e18, 0 },
12788 { 34, 4.6620662575398912000000000000e19, 0 },
12789 { 35, 2.21643095476699771875000000000e20, 0 },
12790 { 36, 1.67834385271436083200000000000e21, 0 },
12791 { 37, 8.2007945326378915593750000000e21, 0 },
12792 { 38, 6.3777066403145711616000000000e22, 0 },
12793 { 39, 3.1983098677287777081562500000e23, 0 },
12794 { 40, 2.55108265612582846464000000000e24, 0 },
12795 { 41, 1.31130704576879886034406250000e25, 0 },
12796 { 42, 1.07145471557284795514880000000e26, 0 },
12797 { 43, 5.6386202968058350994794687500e26, 0 },
12798 { 44, 4.7144007485205310026547200000e27, 0 },
12799 { 45, 2.53737913356262579476576093750e28, 0 },
12800 { 46, 2.16862434431944426122117120000e29, 0 },
12801 { 47, 1.19256819277443412353990764062e30, 0 },
12802 { 48, 1.04093968527333324538616217600e31, 0 },
12803 { 49, 5.8435841445947272053455474391e31, 0 },
12804 { 50, 5.2046984263666662269308108800e32, 0 },
12805 { 51, 2.98022791374331087472622919392e33, 0 },
12806 { 52, 2.70644318171066643800402165760e34, 0 },
12807 { 53, 1.57952079428395476360490147278e35, 0 },
12808 { 54, 1.46147931812375987652217169510e36, 0 },
12809 { 55, 8.6873643685617511998269581003e36, 0 },
12810 { 56, 8.1842841814930553085241614926e37, 0 },
12811 { 57, 4.9517976900801981839013661172e38, 0 },
12812 { 58, 4.7468848252659720789440136657e39, 0 },
12813 { 59, 2.92156063714731692850180600912e40, 0 },
12814 { 60, 2.84813089515958324736640819942e41, 0 },
12815 { 61, 1.78215198865986332638610166557e42, 0 },
12816 { 62, 1.76584115499894161336717308364e43, 0 },
12817 { 63, 1.12275575285571389562324404931e44, 0 },
12818 { 64, 1.13013833919932263255499077353e45, 0 },
12819 { 65, 7.2979123935621403215510863205e45, 0 },
12820 { 66, 7.4589130387155293748629391053e46, 0 },
12821 { 67, 4.8896013036866340154392278347e47, 0 },
12822 { 68, 5.0720608663265599749067985916e48, 0 },
12823 { 69, 3.3738248995437774706530672060e49, 0 },
12824 { 70, 3.5504426064285919824347590141e50, 0 },
12825 { 71, 2.39541567867608200416367771623e51, 0 },
12826 { 72, 2.55631867662858622735302649017e52, 0 },
12827 { 73, 1.74865344543353986303948473285e53, 0 },
12828 { 74, 1.89167582070515380824123960272e54, 0 },
12829 { 75, 1.31149008407515489727961354964e55, 0 },
12830 { 76, 1.43767362373591689426334209807e56, 0 },
12831 { 77, 1.00984736473786927090530243322e57, 0 },
12832 { 78, 1.12138542651401517752540683649e58, 0 },
12833 { 79, 7.9777941814291672401518892225e58, 0 },
12834 { 80, 8.9710834121121214202032546920e59, 0 },
12835 { 81, 6.4620132869576254645230302702e60, 0 },
12836 { 82, 7.3562883979319395645666688474e61, 0 },
12837 { 83, 5.3634710281748291355541151243e62, 0 },
12838 { 84, 6.1792822542628292342360018318e63, 0 },
12839 { 85, 4.5589503739486047652209978556e64, 0 },
12840 { 86, 5.3141827386660331414429615754e65, 0 },
12841 { 87, 3.9662868253352861457422681344e66, 0 },
12842 { 88, 4.6764808100261091644698061863e67, 0 },
12843 { 89, 3.5299952745484046697106186396e68, 0 },
12844 { 90, 4.2088327290234982480228255677e69, 0 },
12845 { 91, 3.2122956998390482494366629620e70, 0 },
12846 { 92, 3.8721261107016183881809995223e71, 0 },
12847 { 93, 2.98743500085031487197609655470e72, 0 },
12848 { 94, 3.6397985440595212848901395509e73, 0 },
12849 { 95, 2.83806325080779912837729172696e74, 0 },
12850 { 96, 3.4942066022971404334945339689e75, 0 },
12851 { 97, 2.75292135328356515452597297515e76, 0 },
12852 { 98, 3.4243224702511976248246432895e77, 0 },
12853 { 99, 2.72539213975072950298071324540e78, 0 },
12854 { 100, 3.4243224702511976248246432895e79, 0 },
12855 { 101, 2.75264606114823679801052037785e80, 0 },
12856 { 102, 3.4928089196562215773211361553e81, 0 },
12857 { 103, 2.83522544298268390195083598919e82, 0 },
12858 { 104, 3.6325212764424704404139816015e83, 0 },
12859 { 105, 2.97698671513181809704837778865e84, 0 },
12860 { 106, 3.8504725530290186668388204976e85, 0 },
12861 { 107, 3.1853757851910453638417642339e86, 0 },
12862 { 108, 4.1585103572713401601859261374e87, 0 },
12863 { 109, 3.4720596058582394465875230149e88, 0 },
12864 { 110, 4.5743613929984741762045187512e89, 0 },
12865 { 111, 3.8539861625026457857121505465e90, 0 },
12866 { 112, 5.1232847601582910773490610013e91, 0 },
12867 { 113, 4.3550043636279897378547301176e92, 0 },
12868 { 114, 5.8405446265804518281779295415e93, 0 },
12869 { 115, 5.0082550181721881985329396352e94, 0 },
12870 { 116, 6.7750317668333241206863982681e95, 0 },
12871 { 117, 5.8596583712614601922835393732e96, 0 },
12872 { 118, 7.9945374848633224624099499564e97, 0 },
12873 { 119, 6.9729934618011376288174118541e98, 0 },
12874 { 120, 9.5934449818359869548919399477e99, 0 },
12875 { 121, 8.4373220887793765308690683435e100, 0 },
12876 { 122, 1.17040028778399040849681667362e102, 0 },
12877 { 123, 1.03779061691986331329689540625e103, 0 },
12878 { 124, 1.45129635685214810653605267528e104, 0 },
12879 { 125, 1.29723827114982914162111925781e105, 0 },
12880 { 126, 1.82863340963370661423542637086e106, 0 },
12881 { 127, 1.64749260436028300985882145742e107, 0 },
12882 { 128, 2.34065076433114446622134575470e108, 0 },
12883 { 129, 2.12526545962476508271787968008e109, 0 },
12884 { 130, 3.04284599363048780608774948111e110, 0 },
12885 { 131, 2.78409775210844225836042238090e111, 0 },
12886 { 132, 4.0165567115922439040358293151e112, 0 },
12887 { 133, 3.7028500103042282036193617666e113, 0 },
12888 { 134, 5.3821859935336068314080112822e114, 0 },
12889 { 135, 4.9988475139107080748861383849e115, 0 },
12890 { 136, 7.3197729512057052907148953438e116, 0 },
12891 { 137, 6.8484210940576700625940095873e117, 0 },
12892 { 138, 1.01012866726638733011865555744e119, 0 },
12893 { 139, 9.5193053207401613870056733264e119, 0 },
12894 { 140, 1.41418013417294226216611778042e121, 0 },
12895 { 141, 1.34222205022436275556779993902e122, 0 },
12896 { 142, 2.00813579052557801227588724819e123, 0 },
12897 { 143, 1.91937753182083874046195391280e124, 0 },
12898 { 144, 2.89171553835683233767727763739e125, 0 },
12899 { 145, 2.78309742114021617366983317355e126, 0 },
12900 { 146, 4.2219046860009752130088253506e127, 0 },
12901 { 147, 4.0911532090761177752946547651e128, 0 },
12902 { 148, 6.2484189352814433152530615189e129, 0 },
12903 { 149, 6.0958182815234154851890356000e130, 0 },
12904 { 150, 9.3726284029221649728795922783e131, 0 },
12905 { 151, 9.2046856051003573826354437561e132, 0 },
12906 { 152, 1.42463951724416907587769802630e134, 0 },
12907 { 153, 1.40831689758035467954322289468e135, 0 },
12908 { 154, 2.19394485655602037685165496051e136, 0 },
12909 { 155, 2.18289119124954975329199548675e137, 0 },
12910 { 156, 3.4225539762273917878885817384e138, 0 },
12911 { 157, 3.4271391702617931126684329142e139, 0 },
12912 { 158, 5.4076352824392790248639591467e140, 0 },
12913 { 159, 5.4491512807162510491428083336e141, 0 },
12914 { 160, 8.6522164519028464397823346347e142, 0 },
12915 { 161, 8.7731335619531641891199214170e143, 0 },
12916 { 162, 1.40165906520826112324473821082e145, 0 },
12917 { 163, 1.43002077059836576282654719098e146, 0 },
12918 { 164, 2.29872086694154824212137066574e147, 0 },
12919 { 165, 2.35953427148730350866380286512e148, 0 },
12920 { 166, 3.8158766391229700819214753051e149, 0 },
12921 { 167, 3.9404222333837968594685507847e150, 0 },
12922 { 168, 6.4106727537265897376280785126e151, 0 },
12923 { 169, 6.6593135744186166925018508262e152, 0 },
12924 { 170, 1.08981436813352025539677334714e154, 0 },
12925 { 171, 1.13874262122558345441781649128e155, 0 },
12926 { 172, 1.87448071318965483928245015709e156, 0 },
12927 { 173, 1.97002473472025937614282252992e157, 0 },
12928 { 174, 3.2615964409499994203514632733e158, 0 },
12929 { 175, 3.4475432857604539082499394274e159, 0 },
12930 { 176, 5.7404097360719989798185753611e160, 0 },
12931 { 177, 6.1021516157960034176023927864e161, 0 },
12932 { 178, 1.02179293302081581840770641427e163, 0 },
12933 { 179, 1.09228513922748461175082830877e164, 0 },
12934 { 180, 1.83922727943746847313387154568e165, 0 },
12935 { 181, 1.97703610200174714726899923887e166, 0 },
12936 { 182, 3.3473936485761926211036462131e167, 0 },
12937 { 183, 3.6179760666631972795022686071e168, 0 },
12938 { 184, 6.1592043133801944228307090322e169, 0 },
12939 { 185, 6.6932557233269149670791969232e170, 0 },
12940 { 186, 1.14561200228871616264651187999e172, 0 },
12941 { 187, 1.25163882026213309884380982464e173, 0 },
12942 { 188, 2.15375056430278638577544233437e174, 0 },
12943 { 189, 2.36559737029543155681480056857e175, 0 },
12944 { 190, 4.0921260721752941329733404353e176, 0 },
12945 { 191, 4.5182909772642742735162690860e177, 0 },
12946 { 192, 7.8568820585765647353088136358e178, 0 },
12947 { 193, 8.7203015861200493478863993359e179, 0 },
12948 { 194, 1.52423511936385355864990984535e181, 0 },
12949 { 195, 1.70045880929340962283784787050e182, 0 },
12950 { 196, 2.98750083395315297495382329688e183, 0 },
12951 { 197, 3.3499038543080169569905603049e184, 0 },
12952 { 198, 5.9152516512272428904085701278e185, 0 },
12953 { 199, 6.6663086700729537444112150067e186, 0 },
12954 { 200, 1.18305033024544857808171402556e188, 0 },
12955 { 201, 1.33992804268466370262665421635e189, 0 },
12956 { 202, 2.38976166709580612772506233164e190, 0 },
12957 { 203, 2.72005392664986731633210805920e191, 0 },
12958 { 204, 4.8751138008754445005591271565e192, 0 },
12959 { 205, 5.5761105496322279984808215214e193, 0 },
12960 { 206, 1.00427344298034156711518019425e195, 0 },
12961 { 207, 1.15425488377387119568553005492e196, 0 },
12962 { 208, 2.08888876139911045959957480403e197, 0 },
12963 { 209, 2.41239270708739079898275781478e198, 0 },
12964 { 210, 4.3866663989381319651591070885e199, 0 },
12965 { 211, 5.0901486119543945858536189892e200, 0 },
12966 { 212, 9.2997327657488397661373070276e201, 0 },
12967 { 213, 1.08420165434628604678682084470e203, 0 },
12968 { 214, 1.99014281187025170995338370390e204, 0 },
12969 { 215, 2.33103355684451500059166481610e205, 0 },
12970 { 216, 4.2987084736397436934993088004e206, 0 },
12971 { 217, 5.0583428183525975512839126509e207, 0 },
12972 { 218, 9.3711844725346412518284931849e208, 0 },
12973 { 219, 1.10777707721921886373117687056e210, 0 },
12974 { 220, 2.06166058395762107540226850068e211, 0 },
12975 { 221, 2.44818734065447368884590088393e212, 0 },
12976 { 222, 4.5768864963859187873930360715e213, 0 },
12977 { 223, 5.4594577696594763261263589712e214, 0 },
12978 { 224, 1.02522257519044580837604008002e216, 0 },
12979 { 225, 1.22837799817338217337843076851e217, 0 },
12980 { 226, 2.31700301993040752692985058084e218, 0 },
12981 { 227, 2.78841805585357753356903784452e219, 0 },
12982 { 228, 5.2827668854413291614000593243e220, 0 },
12983 { 229, 6.3854773479046925518730966640e221, 0 },
12984 { 230, 1.21503638365150570712201364459e223, 0 },
12985 { 231, 1.47504526736598397948268532937e224, 0 },
12986 { 232, 2.81888441007149324052307165546e225, 0 },
12987 { 233, 3.4368554729627426721946568174e226, 0 },
12988 { 234, 6.5961895195672941828239876738e227, 0 },
12989 { 235, 8.0766103614624452796574435210e228, 0 },
12990 { 236, 1.55670072661788142714646109101e230, 0 },
12991 { 237, 1.91415665566659953127881411447e231, 0 },
12992 { 238, 3.7049477293505577966085773966e232, 0 },
12993 { 239, 4.5748344070431728797563657336e233, 0 },
12994 { 240, 8.8918745504413387118605857518e234, 0 },
12995 { 241, 1.10253509209740466402128414180e236, 0 },
12996 { 242, 2.15183364120680396827026175195e237, 0 },
12997 { 243, 2.67916027379669333357172046456e238, 0 },
12998 { 244, 5.2504740845446016825794386748e239, 0 },
12999 { 245, 6.5639426708018986672507151382e240, 0 },
13000 { 246, 1.29161662479797201391454191399e242, 0 },
13001 { 247, 1.62129383968806897081092663913e243, 0 },
13002 { 248, 3.2032092294989705945080639467e244, 0 },
13003 { 249, 4.0370216608232917373192073314e245, 0 },
13004 { 250, 8.0080230737474264862701598667e246, 0 },
13005 { 251, 1.01329243686664622606712104019e248, 0 },
13006 { 252, 2.01802181458435147454008028642e249, 0 },
13007 { 253, 2.56362986527261495194981623168e250, 0 },
13008 { 254, 5.1257754090442527453318039275e251, 0 },
13009 { 255, 6.5372561564451681274720313908e252, 0 },
13010 { 256, 1.31219850471532870280494180544e254, 0 },
13011 { 257, 1.68007483220640820876031206743e255, 0 },
13012 { 258, 3.3854721421655480532367498580e256, 0 },
13013 { 259, 4.3513938154145972606892082546e257, 0 },
13014 { 260, 8.8022275696304249384155496309e258, 0 },
13015 { 261, 1.13571378582320988503988335446e260, 0 },
13016 { 262, 2.30618362324317133386487400329e261, 0 },
13017 { 263, 2.98692725671504199765489322224e262, 0 },
13018 { 264, 6.0883247653619723214032673687e263, 0 },
13019 { 265, 7.9153572302948612937854670389e264, 0 },
13020 { 266, 1.61949438758628463749326912007e266, 0 },
13021 { 267, 2.11340038048872796544071969939e267, 0 },
13022 { 268, 4.3402449587312428284819612418e268, 0 },
13023 { 269, 5.6850470235146782270355359914e269, 0 },
13024 { 270, 1.17186613885743556369012953528e271, 0 },
13025 { 271, 1.54064774337247779952663025366e272, 0 },
13026 { 272, 3.1874758976922247332371523360e273, 0 },
13027 { 273, 4.2059683394068643927077005925e274, 0 },
13028 { 274, 8.7336839596766957690697974006e275, 0 },
13029 { 275, 1.15664129333688770799461766294e277, 0 },
13030 { 276, 2.41049677287076803226326408256e278, 0 },
13031 { 277, 3.2038963825431789511450909263e279, 0 },
13032 { 278, 6.7011810285807351296918741495e280, 0 },
13033 { 279, 8.9388709072954692736948036845e281, 0 },
13034 { 280, 1.87633068800260583631372476186e283, 0 },
13035 { 281, 2.51182272495002686590823983534e284, 0 },
13036 { 282, 5.2912525401673484584047038284e285, 0 },
13037 { 283, 7.1084583116085760305203187340e286, 0 },
13038 { 284, 1.50271572140752696218693588728e288, 0 },
13039 { 285, 2.02591061880844416869829083919e289, 0 },
13040 { 286, 4.2977669632255271118546366376e290, 0 },
13041 { 287, 5.8143634759802347641640947085e291, 0 },
13042 { 288, 1.23775688540895180821413535163e293, 0 },
13043 { 289, 1.68035104455828784684342337075e294, 0 },
13044 { 290, 3.5894949676859602438209925197e295, 0 },
13045 { 291, 4.8898215396646176343143620089e296, 0 },
13046 { 292, 1.04813253056430039119572981576e298, 0 },
13047 { 293, 1.43271771112173296685410806860e299, 0 },
13048 { 294, 3.08150963985904315011544565835e300, 0 },
13049 { 295, 4.2265172478091122522196188024e301, 0 },
13050 { 296, 9.1212685339827677243417191487e302, 0 },
13051 { 297, 1.25527562259930633890922678431e304, 0 },
13052 /*
13053 { 298, 2.71813802312686478185383230631e305, 0 },
13054 { 299, 3.7532741115719259533385880851e306, 0 },
13055 { 300, 8.1544140693805943455614969189e307, }
13056 */
13057};
13058
13059
13060/* Chebyshev coefficients for Gamma*(3/4(t+1)+1/2), -1<t<1
13061 */
13062static double gstar_a_data[30] = {
13063 2.16786447866463034423060819465,
13064 -0.05533249018745584258035832802,
13065 0.01800392431460719960888319748,
13066 -0.00580919269468937714480019814,
13067 0.00186523689488400339978881560,
13068 -0.00059746524113955531852595159,
13069 0.00019125169907783353925426722,
13070 -0.00006124996546944685735909697,
13071 0.00001963889633130842586440945,
13072 -6.3067741254637180272515795142e-06,
13073 2.0288698405861392526872789863e-06,
13074 -6.5384896660838465981983750582e-07,
13075 2.1108698058908865476480734911e-07,
13076 -6.8260714912274941677892994580e-08,
13077 2.2108560875880560555583978510e-08,
13078 -7.1710331930255456643627187187e-09,
13079 2.3290892983985406754602564745e-09,
13080 -7.5740371598505586754890405359e-10,
13081 2.4658267222594334398525312084e-10,
13082 -8.0362243171659883803428749516e-11,
13083 2.6215616826341594653521346229e-11,
13084 -8.5596155025948750540420068109e-12,
13085 2.7970831499487963614315315444e-12,
13086 -9.1471771211886202805502562414e-13,
13087 2.9934720198063397094916415927e-13,
13088 -9.8026575909753445931073620469e-14,
13089 3.2116773667767153777571410671e-14,
13090 -1.0518035333878147029650507254e-14,
13091 3.4144405720185253938994854173e-15,
13092 -1.0115153943081187052322643819e-15
13093};
13094static cheb_series gstar_a_cs = {
13095 gstar_a_data,
13096 29,
13097 -1, 1,
13098 17
13099};
13100
13101
13102/* Chebyshev coefficients for
13103 * x^2(Gamma*(x) - 1 - 1/(12x)), x = 4(t+1)+2, -1 < t < 1
13104 */
13105static double gstar_b_data[] = {
13106 0.0057502277273114339831606096782,
13107 0.0004496689534965685038254147807,
13108 -0.0001672763153188717308905047405,
13109 0.0000615137014913154794776670946,
13110 -0.0000223726551711525016380862195,
13111 8.0507405356647954540694800545e-06,
13112 -2.8671077107583395569766746448e-06,
13113 1.0106727053742747568362254106e-06,
13114 -3.5265558477595061262310873482e-07,
13115 1.2179216046419401193247254591e-07,
13116 -4.1619640180795366971160162267e-08,
13117 1.4066283500795206892487241294e-08,
13118 -4.6982570380537099016106141654e-09,
13119 1.5491248664620612686423108936e-09,
13120 -5.0340936319394885789686867772e-10,
13121 1.6084448673736032249959475006e-10,
13122 -5.0349733196835456497619787559e-11,
13123 1.5357154939762136997591808461e-11,
13124 -4.5233809655775649997667176224e-12,
13125 1.2664429179254447281068538964e-12,
13126 -3.2648287937449326771785041692e-13,
13127 7.1528272726086133795579071407e-14,
13128 -9.4831735252566034505739531258e-15,
13129 -2.3124001991413207293120906691e-15,
13130 2.8406613277170391482590129474e-15,
13131 -1.7245370321618816421281770927e-15,
13132 8.6507923128671112154695006592e-16,
13133 -3.9506563665427555895391869919e-16,
13134 1.6779342132074761078792361165e-16,
13135 -6.0483153034414765129837716260e-17
13136};
13137static cheb_series gstar_b_cs = {
13138 gstar_b_data,
13139 29,
13140 -1, 1,
13141 18
13142};
13143
13144
13145/* coefficients for gamma=7, kmax=8 Lanczos method */
13146static double lanczos_7_c[9] = {
13147 0.99999999999980993227684700473478,
13148 676.520368121885098567009190444019,
13149 -1259.13921672240287047156078755283,
13150 771.3234287776530788486528258894,
13151 -176.61502916214059906584551354,
13152 12.507343278686904814458936853,
13153 -0.13857109526572011689554707,
13154 9.984369578019570859563e-6,
13155 1.50563273514931155834e-7
13156};
13157
13158/* complex version of Lanczos method; this is not safe for export
13159 * since it becomes bad in the left half-plane
13160 */
13161static
13162int
13163lngamma_lanczos_complex(double zr, double zi, gsl_sf_result * yr, gsl_sf_result * yi)
13164{
13165 int k;
13166 gsl_sf_result log1_r, log1_i;
13167 gsl_sf_result logAg_r, logAg_i;
13168 double Ag_r, Ag_i;
13169 double yi_tmp_val, yi_tmp_err;
13170
13171 zr -= 1.0; /* Lanczos writes z! instead of Gamma(z) */
13172
13173 Ag_r = lanczos_7_c[0];
13174 Ag_i = 0.0;
13175 for(k=1; k<=8; k++) {
13176 double R = zr + k;
13177 double I = zi;
13178 double a = lanczos_7_c[k] / (R*R + I*I);
13179 Ag_r += a * R;
13180 Ag_i -= a * I;
13181 }
13182
13183 gsl_sf_complex_log_e(zr + 7.5, zi, &log1_r, &log1_i);
13184 gsl_sf_complex_log_e(Ag_r, Ag_i, &logAg_r, &logAg_i);
13185
13186 /* (z+0.5)*log(z+7.5) - (z+7.5) + LogRootTwoPi_ + log(Ag(z)) */
13187 yr->val = (zr+0.5)*log1_r.val - zi*log1_i.val - (zr+7.5) + LogRootTwoPi_ + logAg_r.val;
13188 yi->val = zi*log1_r.val + (zr+0.5)*log1_i.val - zi + logAg_i.val;
13189 yr->err = 4.0 * GSL_DBL_EPSILON * fabs(yr->val);
13190 yi->err = 4.0 * GSL_DBL_EPSILON * fabs(yi->val);
13191 yi_tmp_val = yi->val;
13192 yi_tmp_err = yi->err;
13193 gsl_sf_angle_restrict_symm_err_e(yi_tmp_val, yi);
13194 yi->err += yi_tmp_err;
13195 return GSL_SUCCESS;
13196}
13197
13198
13199/* Lanczos method for real x > 0;
13200 * gamma=7, truncated at 1/(z+8)
13201 * [J. SIAM Numer. Anal, Ser. B, 1 (1964) 86]
13202 */
13203static
13204int
13205lngamma_lanczos(double x, gsl_sf_result * result)
13206{
13207 int k;
13208 double Ag;
13209 double term1, term2;
13210
13211 x -= 1.0; /* Lanczos writes z! instead of Gamma(z) */
13212
13213 Ag = lanczos_7_c[0];
13214 for(k=1; k<=8; k++) { Ag += lanczos_7_c[k]/(x+k); }
13215
13216 /* (x+0.5)*log(x+7.5) - (x+7.5) + LogRootTwoPi_ + log(Ag(x)) */
13217 term1 = (x+0.5)*log((x+7.5)/M_E);
13218 term2 = LogRootTwoPi_ + log(Ag);
13219 result->val = term1 + (term2 - 7.0);
13220 result->err = 2.0 * GSL_DBL_EPSILON * (fabs(term1) + fabs(term2) + 7.0);
13221 result->err += GSL_DBL_EPSILON * fabs(result->val);
13222
13223 return GSL_SUCCESS;
13224}
13225
13226/* x = eps near zero
13227 * gives double-precision for |eps| < 0.02
13228 */
13229static
13230int
13231lngamma_sgn_0(double eps, gsl_sf_result * lng, double * sgn)
13232{
13233 /* calculate series for g(eps) = Gamma(eps) eps - 1/(1+eps) - eps/2 */
13234 const double c1 = -0.07721566490153286061;
13235 const double c2 = -0.01094400467202744461;
13236 const double c3 = 0.09252092391911371098;
13237 const double c4 = -0.01827191316559981266;
13238 const double c5 = 0.01800493109685479790;
13239 const double c6 = -0.00685088537872380685;
13240 const double c7 = 0.00399823955756846603;
13241 const double c8 = -0.00189430621687107802;
13242 const double c9 = 0.00097473237804513221;
13243 const double c10 = -0.00048434392722255893;
13244 const double g6 = c6+eps*(c7+eps*(c8 + eps*(c9 + eps*c10)));
13245 const double g = eps*(c1+eps*(c2+eps*(c3+eps*(c4+eps*(c5+eps*g6)))));
13246
13247 /* calculate Gamma(eps) eps, a positive quantity */
13248 const double gee = g + 1.0/(1.0+eps) + 0.5*eps;
13249
13250 lng->val = log(gee/fabs(eps));
13251 lng->err = 4.0 * GSL_DBL_EPSILON * fabs(lng->val);
13252 *sgn = GSL_SIGN(eps);
13253
13254 return GSL_SUCCESS;
13255}
13256
13257
13258/* x near a negative integer
13259 * Calculates sign as well as log(|gamma(x)|).
13260 * x = -N + eps
13261 * assumes N >= 1
13262 */
13263static
13264int
13265lngamma_sgn_sing(int N, double eps, gsl_sf_result * lng, double * sgn)
13266{
13267 if(eps == 0.0) {
13268 lng->val = 0.0;
13269 lng->err = 0.0;
13270 *sgn = 0.0;
13271 GSL_ERROR ("error", GSL_EDOM);
13272 }
13273 else if(N == 1) {
13274 /* calculate series for
13275 * g = eps gamma(-1+eps) + 1 + eps/2 (1+3eps)/(1-eps^2)
13276 * double-precision for |eps| < 0.02
13277 */
13278 const double c0 = 0.07721566490153286061;
13279 const double c1 = 0.08815966957356030521;
13280 const double c2 = -0.00436125434555340577;
13281 const double c3 = 0.01391065882004640689;
13282 const double c4 = -0.00409427227680839100;
13283 const double c5 = 0.00275661310191541584;
13284 const double c6 = -0.00124162645565305019;
13285 const double c7 = 0.00065267976121802783;
13286 const double c8 = -0.00032205261682710437;
13287 const double c9 = 0.00016229131039545456;
13288 const double g5 = c5 + eps*(c6 + eps*(c7 + eps*(c8 + eps*c9)));
13289 const double g = eps*(c0 + eps*(c1 + eps*(c2 + eps*(c3 + eps*(c4 + eps*g5)))));
13290
13291 /* calculate eps gamma(-1+eps), a negative quantity */
13292 const double gam_e = g - 1.0 - 0.5*eps*(1.0+3.0*eps)/(1.0 - eps*eps);
13293
13294 lng->val = log(fabs(gam_e)/fabs(eps));
13295 lng->err = 2.0 * GSL_DBL_EPSILON * fabs(lng->val);
13296 *sgn = ( eps > 0.0 ? -1.0 : 1.0 );
13297 return GSL_SUCCESS;
13298 }
13299 else {
13300 double g;
13301
13302 /* series for sin(Pi(N+1-eps))/(Pi eps) modulo the sign
13303 * double-precision for |eps| < 0.02
13304 */
13305 const double cs1 = -1.6449340668482264365;
13306 const double cs2 = 0.8117424252833536436;
13307 const double cs3 = -0.1907518241220842137;
13308 const double cs4 = 0.0261478478176548005;
13309 const double cs5 = -0.0023460810354558236;
13310 const double e2 = eps*eps;
13311 const double sin_ser = 1.0 + e2*(cs1+e2*(cs2+e2*(cs3+e2*(cs4+e2*cs5))));
13312
13313 /* calculate series for ln(gamma(1+N-eps))
13314 * double-precision for |eps| < 0.02
13315 */
13316 double aeps = fabs(eps);
13317 double c1, c2, c3, c4, c5, c6, c7;
13318 double lng_ser;
13319 gsl_sf_result c0;
13320 gsl_sf_result psi_0;
13321 gsl_sf_result psi_1;
13322 gsl_sf_result psi_2;
13323 gsl_sf_result psi_3;
13324 gsl_sf_result psi_4;
13325 gsl_sf_result psi_5;
13326 gsl_sf_result psi_6;
13327 psi_2.val = 0.0;
13328 psi_3.val = 0.0;
13329 psi_4.val = 0.0;
13330 psi_5.val = 0.0;
13331 psi_6.val = 0.0;
13332 gsl_sf_lnfact_e(N, &c0);
13333 gsl_sf_psi_int_e(N+1, &psi_0);
13334 gsl_sf_psi_1_int_e(N+1, &psi_1);
13335 if(aeps > 0.00001) gsl_sf_psi_n_e(2, N+1.0, &psi_2);
13336 if(aeps > 0.0002) gsl_sf_psi_n_e(3, N+1.0, &psi_3);
13337 if(aeps > 0.001) gsl_sf_psi_n_e(4, N+1.0, &psi_4);
13338 if(aeps > 0.005) gsl_sf_psi_n_e(5, N+1.0, &psi_5);
13339 if(aeps > 0.01) gsl_sf_psi_n_e(6, N+1.0, &psi_6);
13340 c1 = psi_0.val;
13341 c2 = psi_1.val/2.0;
13342 c3 = psi_2.val/6.0;
13343 c4 = psi_3.val/24.0;
13344 c5 = psi_4.val/120.0;
13345 c6 = psi_5.val/720.0;
13346 c7 = psi_6.val/5040.0;
13347 lng_ser = c0.val-eps*(c1-eps*(c2-eps*(c3-eps*(c4-eps*(c5-eps*(c6-eps*c7))))));
13348
13349 /* calculate
13350 * g = ln(|eps gamma(-N+eps)|)
13351 * = -ln(gamma(1+N-eps)) + ln(|eps Pi/sin(Pi(N+1+eps))|)
13352 */
13353 g = -lng_ser - log(sin_ser);
13354
13355 lng->val = g - log(fabs(eps));
13356 lng->err = c0.err + 2.0 * GSL_DBL_EPSILON * (fabs(g) + fabs(lng->val));
13357
13358 *sgn = ( GSL_IS_ODD(N) ? -1.0 : 1.0 ) * ( eps > 0.0 ? 1.0 : -1.0 );
13359
13360 return GSL_SUCCESS;
13361 }
13362}
13363
13364
13365/* This gets bad near the negative half axis. However, this
13366 * region can be avoided by use of the reflection formula, as usual.
13367 * Only the first two terms of the series are kept.
13368 */
13369#if 0
13370static
13371int
13372lngamma_complex_stirling(const double zr, const double zi, double * lg_r, double * arg)
13373{
13374 double re_zinv, im_zinv;
13375 double re_zinv2, im_zinv2;
13376 double re_zinv3, im_zinv3;
13377 double re_zhlnz, im_zhlnz;
13378 double r, lnr, theta;
13379 gsl_sf_complex_log_e(zr, zi, &lnr, &theta); /* z = r e^{i theta} */
13380 r = exp(lnr);
13381 re_zinv = (zr/r)/r;
13382 im_zinv = -(zi/r)/r;
13383 re_zinv2 = re_zinv*re_zinv - im_zinv*im_zinv;
13384 re_zinv2 = 2.0*re_zinv*im_zinv;
13385 re_zinv3 = re_zinv2*re_zinv - im_zinv2*im_zinv;
13386 re_zinv3 = re_zinv2*im_zinv + im_zinv2*re_zinv;
13387 re_zhlnz = (zr - 0.5)*lnr - zi*theta;
13388 im_zhlnz = zi*lnr + zr*theta;
13389 *lg_r = re_zhlnz - zr + 0.5*(M_LN2+M_LNPI) + re_zinv/12.0 - re_zinv3/360.0;
13390 *arg = im_zhlnz - zi + 1.0/12.0*im_zinv - im_zinv3/360.0;
13391 return GSL_SUCCESS;
13392}
13393#endif /* 0 */
13394
13395
13396inline
13397static
13398int
13399lngamma_1_pade(const double eps, gsl_sf_result * result)
13400{
13401 /* Use (2,2) Pade for Log[Gamma[1+eps]]/eps
13402 * plus a correction series.
13403 */
13404 const double n1 = -1.0017419282349508699871138440;
13405 const double n2 = 1.7364839209922879823280541733;
13406 const double d1 = 1.2433006018858751556055436011;
13407 const double d2 = 5.0456274100274010152489597514;
13408 const double num = (eps + n1) * (eps + n2);
13409 const double den = (eps + d1) * (eps + d2);
13410 const double pade = 2.0816265188662692474880210318 * num / den;
13411 const double c0 = 0.004785324257581753;
13412 const double c1 = -0.01192457083645441;
13413 const double c2 = 0.01931961413960498;
13414 const double c3 = -0.02594027398725020;
13415 const double c4 = 0.03141928755021455;
13416 const double eps5 = eps*eps*eps*eps*eps;
13417 const double corr = eps5 * (c0 + eps*(c1 + eps*(c2 + eps*(c3 + c4*eps))));
13418 result->val = eps * (pade + corr);
13419 result->err = 2.0 * GSL_DBL_EPSILON * fabs(result->val);
13420 return GSL_SUCCESS;
13421}
13422
13423inline
13424static
13425int
13426lngamma_2_pade(const double eps, gsl_sf_result * result)
13427{
13428 /* Use (2,2) Pade for Log[Gamma[2+eps]]/eps
13429 * plus a correction series.
13430 */
13431 const double n1 = 1.000895834786669227164446568;
13432 const double n2 = 4.209376735287755081642901277;
13433 const double d1 = 2.618851904903217274682578255;
13434 const double d2 = 10.85766559900983515322922936;
13435 const double num = (eps + n1) * (eps + n2);
13436 const double den = (eps + d1) * (eps + d2);
13437 const double pade = 2.85337998765781918463568869 * num/den;
13438 const double c0 = 0.0001139406357036744;
13439 const double c1 = -0.0001365435269792533;
13440 const double c2 = 0.0001067287169183665;
13441 const double c3 = -0.0000693271800931282;
13442 const double c4 = 0.0000407220927867950;
13443 const double eps5 = eps*eps*eps*eps*eps;
13444 const double corr = eps5 * (c0 + eps*(c1 + eps*(c2 + eps*(c3 + c4*eps))));
13445 result->val = eps * (pade + corr);
13446 result->err = 2.0 * GSL_DBL_EPSILON * fabs(result->val);
13447 return GSL_SUCCESS;
13448}
13449
13450
13451/* series for gammastar(x)
13452 * double-precision for x > 10.0
13453 */
13454static
13455int
13456gammastar_ser(const double x, gsl_sf_result * result)
13457{
13458 /* Use the Stirling series for the correction to Log(Gamma(x)),
13459 * which is better behaved and easier to compute than the
13460 * regular Stirling series for Gamma(x).
13461 */
13462 const double y = 1.0/(x*x);
13463 const double c0 = 1.0/12.0;
13464 const double c1 = -1.0/360.0;
13465 const double c2 = 1.0/1260.0;
13466 const double c3 = -1.0/1680.0;
13467 const double c4 = 1.0/1188.0;
13468 const double c5 = -691.0/360360.0;
13469 const double c6 = 1.0/156.0;
13470 const double c7 = -3617.0/122400.0;
13471 const double ser = c0 + y*(c1 + y*(c2 + y*(c3 + y*(c4 + y*(c5 + y*(c6 + y*c7))))));
13472 result->val = exp(ser/x);
13473 result->err = 2.0 * GSL_DBL_EPSILON * result->val * GSL_MAX_DBL(1.0, ser/x);
13474 return GSL_SUCCESS;
13475}
13476
13477
13478/* Chebyshev expansion for log(gamma(x)/gamma(8))
13479 * 5 < x < 10
13480 * -1 < t < 1
13481 */
13482static double gamma_5_10_data[24] = {
13483 -1.5285594096661578881275075214,
13484 4.8259152300595906319768555035,
13485 0.2277712320977614992970601978,
13486 -0.0138867665685617873604917300,
13487 0.0012704876495201082588139723,
13488 -0.0001393841240254993658962470,
13489 0.0000169709242992322702260663,
13490 -2.2108528820210580075775889168e-06,
13491 3.0196602854202309805163918716e-07,
13492 -4.2705675000079118380587357358e-08,
13493 6.2026423818051402794663551945e-09,
13494 -9.1993973208880910416311405656e-10,
13495 1.3875551258028145778301211638e-10,
13496 -2.1218861491906788718519522978e-11,
13497 3.2821736040381439555133562600e-12,
13498 -5.1260001009953791220611135264e-13,
13499 8.0713532554874636696982146610e-14,
13500 -1.2798522376569209083811628061e-14,
13501 2.0417711600852502310258808643e-15,
13502 -3.2745239502992355776882614137e-16,
13503 5.2759418422036579482120897453e-17,
13504 -8.5354147151695233960425725513e-18,
13505 1.3858639703888078291599886143e-18,
13506 -2.2574398807738626571560124396e-19
13507};
13508static const cheb_series gamma_5_10_cs = {
13509 gamma_5_10_data,
13510 23,
13511 -1, 1,
13512 11
13513};
13514
13515
13516/* gamma(x) for x >= 1/2
13517 * assumes x >= 1/2
13518 */
13519static
13520int
13521gamma_xgthalf(const double x, gsl_sf_result * result)
13522{
13523 /* CHECK_POINTER(result) */
13524
13525 if(x == 0.5) {
13526 result->val = 1.77245385090551602729817;
13527 result->err = GSL_DBL_EPSILON * result->val;
13528 return GSL_SUCCESS;
13529 } else if (x <= (GSL_SF_FACT_NMAX + 1.0) && x == floor(x)) {
13530 int n = (int) floor (x);
13531 result->val = fact_table[n - 1].f;
13532 result->err = GSL_DBL_EPSILON * result->val;
13533 return GSL_SUCCESS;
13534 }
13535 else if(fabs(x - 1.0) < 0.01) {
13536 /* Use series for Gamma[1+eps] - 1/(1+eps).
13537 */
13538 const double eps = x - 1.0;
13539 const double c1 = 0.4227843350984671394;
13540 const double c2 = -0.01094400467202744461;
13541 const double c3 = 0.09252092391911371098;
13542 const double c4 = -0.018271913165599812664;
13543 const double c5 = 0.018004931096854797895;
13544 const double c6 = -0.006850885378723806846;
13545 const double c7 = 0.003998239557568466030;
13546 result->val = 1.0/x + eps*(c1+eps*(c2+eps*(c3+eps*(c4+eps*(c5+eps*(c6+eps*c7))))));
13547 result->err = GSL_DBL_EPSILON;
13548 return GSL_SUCCESS;
13549 }
13550 else if(fabs(x - 2.0) < 0.01) {
13551 /* Use series for Gamma[1 + eps].
13552 */
13553 const double eps = x - 2.0;
13554 const double c1 = 0.4227843350984671394;
13555 const double c2 = 0.4118403304264396948;
13556 const double c3 = 0.08157691924708626638;
13557 const double c4 = 0.07424901075351389832;
13558 const double c5 = -0.00026698206874501476832;
13559 const double c6 = 0.011154045718130991049;
13560 const double c7 = -0.002852645821155340816;
13561 const double c8 = 0.0021039333406973880085;
13562 result->val = 1.0 + eps*(c1+eps*(c2+eps*(c3+eps*(c4+eps*(c5+eps*(c6+eps*(c7+eps*c8)))))));
13563 result->err = GSL_DBL_EPSILON;
13564 return GSL_SUCCESS;
13565 }
13566 else if(x < 5.0) {
13567 /* Exponentiating the logarithm is fine, as
13568 * long as the exponential is not so large
13569 * that it greatly amplifies the error.
13570 */
13571 gsl_sf_result lg;
13572 lngamma_lanczos(x, &lg);
13573 result->val = exp(lg.val);
13574 result->err = result->val * (lg.err + 2.0 * GSL_DBL_EPSILON);
13575 return GSL_SUCCESS;
13576 }
13577 else if(x < 10.0) {
13578 /* This is a sticky area. The logarithm
13579 * is too large and the gammastar series
13580 * is not good.
13581 */
13582 const double gamma_8 = 5040.0;
13583 const double t = (2.0*x - 15.0)/5.0;
13584 gsl_sf_result c;
13585 cheb_eval_e(&gamma_5_10_cs, t, &c);
13586 result->val = exp(c.val) * gamma_8;
13587 result->err = result->val * c.err;
13588 result->err += 2.0 * GSL_DBL_EPSILON * result->val;
13589 return GSL_SUCCESS;
13590 }
13591 else if(x < GSL_SF_GAMMA_XMAX) {
13592 /* We do not want to exponentiate the logarithm
13593 * if x is large because of the inevitable
13594 * inflation of the error. So we carefully
13595 * use pow() and exp() with exact quantities.
13596 */
13597 double p = pow(x, 0.5*x);
13598 double e = exp(-x);
13599 double q = (p * e) * p;
13600 double pre = M_SQRT2 * M_SQRTPI * q/sqrt(x);
13601 gsl_sf_result gstar;
13602 int stat_gs = gammastar_ser(x, &gstar);
13603 result->val = pre * gstar.val;
13604 result->err = (x + 2.5) * GSL_DBL_EPSILON * result->val;
13605 return stat_gs;
13606 }
13607 else {
13608 OVERFLOW_ERROR(result);
13609 }
13610}
13611
13612
13613/*-*-*-*-*-*-*-*-*-*-*-* Functions with Error Codes *-*-*-*-*-*-*-*-*-*-*-*/
13614
13615
13616int gsl_sf_lngamma_e(double x, gsl_sf_result * result)
13617{
13618 /* CHECK_POINTER(result) */
13619
13620 if(fabs(x - 1.0) < 0.01) {
13621 /* Note that we must amplify the errors
13622 * from the Pade evaluations because of
13623 * the way we must pass the argument, i.e.
13624 * writing (1-x) is a loss of precision
13625 * when x is near 1.
13626 */
13627 int stat = lngamma_1_pade(x - 1.0, result);
13628 result->err *= 1.0/(GSL_DBL_EPSILON + fabs(x - 1.0));
13629 return stat;
13630 }
13631 else if(fabs(x - 2.0) < 0.01) {
13632 int stat = lngamma_2_pade(x - 2.0, result);
13633 result->err *= 1.0/(GSL_DBL_EPSILON + fabs(x - 2.0));
13634 return stat;
13635 }
13636 else if(x >= 0.5) {
13637 return lngamma_lanczos(x, result);
13638 }
13639 else if(x == 0.0) {
13640 DOMAIN_ERROR(result);
13641 }
13642 else if(fabs(x) < 0.02) {
13643 double sgn;
13644 return lngamma_sgn_0(x, result, &sgn);
13645 }
13646 else if(x > -0.5/(GSL_DBL_EPSILON*M_PI)) {
13647 /* Try to extract a fractional
13648 * part from x.
13649 */
13650 double z = 1.0 - x;
13651 double s = sin(M_PI*z);
13652 double as = fabs(s);
13653 if(s == 0.0) {
13654 DOMAIN_ERROR(result);
13655 }
13656 else if(as < M_PI*0.015) {
13657 /* x is near a negative integer, -N */
13658 if(x < INT_MIN + 2.0) {
13659 result->val = 0.0;
13660 result->err = 0.0;
13661 GSL_ERROR ("error", GSL_EROUND);
13662 }
13663 else {
13664 int N = -(int)(x - 0.5);
13665 double eps = x + N;
13666 double sgn;
13667 return lngamma_sgn_sing(N, eps, result, &sgn);
13668 }
13669 }
13670 else {
13671 gsl_sf_result lg_z;
13672 lngamma_lanczos(z, &lg_z);
13673 result->val = M_LNPI - (log(as) + lg_z.val);
13674 result->err = 2.0 * GSL_DBL_EPSILON * fabs(result->val) + lg_z.err;
13675 return GSL_SUCCESS;
13676 }
13677 }
13678 else {
13679 /* |x| was too large to extract any fractional part */
13680 result->val = 0.0;
13681 result->err = 0.0;
13682 GSL_ERROR ("error", GSL_EROUND);
13683 }
13684}
13685
13686
13687int gsl_sf_lngamma_sgn_e(double x, gsl_sf_result * result_lg, double * sgn)
13688{
13689 if(fabs(x - 1.0) < 0.01) {
13690 int stat = lngamma_1_pade(x - 1.0, result_lg);
13691 result_lg->err *= 1.0/(GSL_DBL_EPSILON + fabs(x - 1.0));
13692 *sgn = 1.0;
13693 return stat;
13694 }
13695 else if(fabs(x - 2.0) < 0.01) {
13696 int stat = lngamma_2_pade(x - 2.0, result_lg);
13697 result_lg->err *= 1.0/(GSL_DBL_EPSILON + fabs(x - 2.0));
13698 *sgn = 1.0;
13699 return stat;
13700 }
13701 else if(x >= 0.5) {
13702 *sgn = 1.0;
13703 return lngamma_lanczos(x, result_lg);
13704 }
13705 else if(x == 0.0) {
13706 *sgn = 0.0;
13707 DOMAIN_ERROR(result_lg);
13708 }
13709 else if(fabs(x) < 0.02) {
13710 return lngamma_sgn_0(x, result_lg, sgn);
13711 }
13712 else if(x > -0.5/(GSL_DBL_EPSILON*M_PI)) {
13713 /* Try to extract a fractional
13714 * part from x.
13715 */
13716 double z = 1.0 - x;
13717 double s = sin(M_PI*x);
13718 double as = fabs(s);
13719 if(s == 0.0) {
13720 *sgn = 0.0;
13721 DOMAIN_ERROR(result_lg);
13722 }
13723 else if(as < M_PI*0.015) {
13724 /* x is near a negative integer, -N */
13725 if(x < INT_MIN + 2.0) {
13726 result_lg->val = 0.0;
13727 result_lg->err = 0.0;
13728 *sgn = 0.0;
13729 GSL_ERROR ("error", GSL_EROUND);
13730 }
13731 else {
13732 int N = -(int)(x - 0.5);
13733 double eps = x + N;
13734 return lngamma_sgn_sing(N, eps, result_lg, sgn);
13735 }
13736 }
13737 else {
13738 gsl_sf_result lg_z;
13739 lngamma_lanczos(z, &lg_z);
13740 *sgn = (s > 0.0 ? 1.0 : -1.0);
13741 result_lg->val = M_LNPI - (log(as) + lg_z.val);
13742 result_lg->err = 2.0 * GSL_DBL_EPSILON * fabs(result_lg->val) + lg_z.err;
13743 return GSL_SUCCESS;
13744 }
13745 }
13746 else {
13747 /* |x| was too large to extract any fractional part */
13748 result_lg->val = 0.0;
13749 result_lg->err = 0.0;
13750 *sgn = 0.0;
13751 GSL_ERROR ("x too large to extract fraction part", GSL_EROUND);
13752 }
13753}
13754
13755
13756int
13757gsl_sf_gamma_e(const double x, gsl_sf_result * result)
13758{
13759 if(x < 0.5) {
13760 int rint_x = (int)floor(x+0.5);
13761 double f_x = x - rint_x;
13762 double sgn_gamma = ( GSL_IS_EVEN(rint_x) ? 1.0 : -1.0 );
13763 double sin_term = sgn_gamma * sin(M_PI * f_x) / M_PI;
13764
13765 if(sin_term == 0.0) {
13766 DOMAIN_ERROR(result);
13767 }
13768 else if(x > -169.0) {
13769 gsl_sf_result g;
13770 gamma_xgthalf(1.0-x, &g);
13771 if(fabs(sin_term) * g.val * GSL_DBL_MIN < 1.0) {
13772 result->val = 1.0/(sin_term * g.val);
13773 result->err = fabs(g.err/g.val) * fabs(result->val);
13774 result->err += 2.0 * GSL_DBL_EPSILON * fabs(result->val);
13775 return GSL_SUCCESS;
13776 }
13777 else {
13778 UNDERFLOW_ERROR(result);
13779 }
13780 }
13781 else {
13782 /* It is hard to control it here.
13783 * We can only exponentiate the
13784 * logarithm and eat the loss of
13785 * precision.
13786 */
13787 gsl_sf_result lng;
13788 double sgn;
13789 int stat_lng = gsl_sf_lngamma_sgn_e(x, &lng, &sgn);
13790 int stat_e = gsl_sf_exp_mult_err_e(lng.val, lng.err, sgn, 0.0, result);
13791 return GSL_ERROR_SELECT_2(stat_e, stat_lng);
13792 }
13793 }
13794 else {
13795 return gamma_xgthalf(x, result);
13796 }
13797}
13798
13799
13800int
13801gsl_sf_gammastar_e(const double x, gsl_sf_result * result)
13802{
13803 /* CHECK_POINTER(result) */
13804
13805 if(x <= 0.0) {
13806 DOMAIN_ERROR(result);
13807 }
13808 else if(x < 0.5) {
13809 gsl_sf_result lg;
13810 const int stat_lg = gsl_sf_lngamma_e(x, &lg);
13811 const double lx = log(x);
13812 const double c = 0.5*(M_LN2+M_LNPI);
13813 const double lnr_val = lg.val - (x-0.5)*lx + x - c;
13814 const double lnr_err = lg.err + 2.0 * GSL_DBL_EPSILON *((x+0.5)*fabs(lx) + c);
13815 const int stat_e = gsl_sf_exp_err_e(lnr_val, lnr_err, result);
13816 return GSL_ERROR_SELECT_2(stat_lg, stat_e);
13817 }
13818 else if(x < 2.0) {
13819 const double t = 4.0/3.0*(x-0.5) - 1.0;
13820 return cheb_eval_e(&gstar_a_cs, t, result);
13821 }
13822 else if(x < 10.0) {
13823 const double t = 0.25*(x-2.0) - 1.0;
13824 gsl_sf_result c;
13825 cheb_eval_e(&gstar_b_cs, t, &c);
13826 result->val = c.val/(x*x) + 1.0 + 1.0/(12.0*x);
13827 result->err = c.err/(x*x);
13828 result->err += 2.0 * GSL_DBL_EPSILON * fabs(result->val);
13829 return GSL_SUCCESS;
13830 }
13831 else if(x < 1.0/GSL_ROOT4_DBL_EPSILON) {
13832 return gammastar_ser(x, result);
13833 }
13834 else if(x < 1.0/GSL_DBL_EPSILON) {
13835 /* Use Stirling formula for Gamma(x).
13836 */
13837 const double xi = 1.0/x;
13838 result->val = 1.0 + xi/12.0*(1.0 + xi/24.0*(1.0 - xi*(139.0/180.0 + 571.0/8640.0*xi)));
13839 result->err = 2.0 * GSL_DBL_EPSILON * fabs(result->val);
13840 return GSL_SUCCESS;
13841 }
13842 else {
13843 result->val = 1.0;
13844 result->err = 1.0/x;
13845 return GSL_SUCCESS;
13846 }
13847}
13848
13849
13850int
13851gsl_sf_gammainv_e(const double x, gsl_sf_result * result)
13852{
13853 /* CHECK_POINTER(result) */
13854
13855 if (x <= 0.0 && x == floor(x)) { /* negative integer */
13856 result->val = 0.0;
13857 result->err = 0.0;
13858 return GSL_SUCCESS;
13859 } else if(x < 0.5) {
13860 gsl_sf_result lng;
13861 double sgn;
13862 int stat_lng = gsl_sf_lngamma_sgn_e(x, &lng, &sgn);
13863 if(stat_lng == GSL_EDOM) {
13864 result->val = 0.0;
13865 result->err = 0.0;
13866 return GSL_SUCCESS;
13867 }
13868 else if(stat_lng != GSL_SUCCESS) {
13869 result->val = 0.0;
13870 result->err = 0.0;
13871 return stat_lng;
13872 }
13873 else {
13874 return gsl_sf_exp_mult_err_e(-lng.val, lng.err, sgn, 0.0, result);
13875 }
13876 }
13877 else {
13878 gsl_sf_result g;
13879 int stat_g = gamma_xgthalf(x, &g);
13880 if(stat_g == GSL_EOVRFLW) {
13881 UNDERFLOW_ERROR(result);
13882 }
13883 else {
13884 result->val = 1.0/g.val;
13885 result->err = fabs(g.err/g.val) * fabs(result->val);
13886 result->err += 2.0 * GSL_DBL_EPSILON * fabs(result->val);
13887 CHECK_UNDERFLOW(result);
13888 return GSL_SUCCESS;
13889 }
13890 }
13891}
13892
13893
13894int
13895gsl_sf_lngamma_complex_e(double zr, double zi, gsl_sf_result * lnr, gsl_sf_result * arg)
13896{
13897 if(zr <= 0.5) {
13898 /* Transform to right half plane using reflection;
13899 * in fact we do a little better by stopping at 1/2.
13900 */
13901 double x = 1.0-zr;
13902 double y = -zi;
13903 gsl_sf_result a, b;
13904 gsl_sf_result lnsin_r, lnsin_i;
13905
13906 int stat_l = lngamma_lanczos_complex(x, y, &a, &b);
13907 int stat_s = gsl_sf_complex_logsin_e(M_PI*zr, M_PI*zi, &lnsin_r, &lnsin_i);
13908
13909 if(stat_s == GSL_SUCCESS) {
13910 int stat_r;
13911 lnr->val = M_LNPI - lnsin_r.val - a.val;
13912 lnr->err = lnsin_r.err + a.err + 2.0 * GSL_DBL_EPSILON * fabs(lnr->val);
13913 arg->val = -lnsin_i.val - b.val;
13914 arg->err = lnsin_i.err + b.err + 2.0 * GSL_DBL_EPSILON * fabs(arg->val);
13915 stat_r = gsl_sf_angle_restrict_symm_e(&(arg->val));
13916 return GSL_ERROR_SELECT_2(stat_r, stat_l);
13917 }
13918 else {
13919 DOMAIN_ERROR_2(lnr,arg);
13920 }
13921 }
13922 else {
13923 /* otherwise plain vanilla Lanczos */
13924 return lngamma_lanczos_complex(zr, zi, lnr, arg);
13925 }
13926}
13927
13928
13929int gsl_sf_taylorcoeff_e(const int n, const double x, gsl_sf_result * result)
13930{
13931 /* CHECK_POINTER(result) */
13932
13933 if(x < 0.0 || n < 0) {
13934 DOMAIN_ERROR(result);
13935 }
13936 else if(n == 0) {
13937 result->val = 1.0;
13938 result->err = 0.0;
13939 return GSL_SUCCESS;
13940 }
13941 else if(n == 1) {
13942 result->val = x;
13943 result->err = 0.0;
13944 return GSL_SUCCESS;
13945 }
13946 else if(x == 0.0) {
13947 result->val = 0.0;
13948 result->err = 0.0;
13949 return GSL_SUCCESS;
13950 }
13951 else {
13952 const double log2pi = M_LNPI + M_LN2;
13953 const double ln_test = n*(log(x)+1.0) + 1.0 - (n+0.5)*log(n+1.0) + 0.5*log2pi;
13954
13955 if(ln_test < GSL_LOG_DBL_MIN+1.0) {
13956 UNDERFLOW_ERROR(result);
13957 }
13958 else if(ln_test > GSL_LOG_DBL_MAX-1.0) {
13959 OVERFLOW_ERROR(result);
13960 }
13961 else {
13962 double product = 1.0;
13963 int k;
13964 for(k=1; k<=n; k++) {
13965 product *= (x/k);
13966 }
13967 result->val = product;
13968 result->err = n * GSL_DBL_EPSILON * product;
13969 CHECK_UNDERFLOW(result);
13970 return GSL_SUCCESS;
13971 }
13972 }
13973}
13974
13975
13976int gsl_sf_fact_e(const unsigned int n, gsl_sf_result * result)
13977{
13978 /* CHECK_POINTER(result) */
13979
13980 if(n < 18) {
13981 result->val = fact_table[n].f;
13982 result->err = 0.0;
13983 return GSL_SUCCESS;
13984 }
13985 else if(n <= GSL_SF_FACT_NMAX){
13986 result->val = fact_table[n].f;
13987 result->err = 2.0 * GSL_DBL_EPSILON * fabs(result->val);
13988 return GSL_SUCCESS;
13989 }
13990 else {
13991 OVERFLOW_ERROR(result);
13992 }
13993}
13994
13995
13996int gsl_sf_doublefact_e(const unsigned int n, gsl_sf_result * result)
13997{
13998 /* CHECK_POINTER(result) */
13999
14000 if(n < 26) {
14001 result->val = doub_fact_table[n].f;
14002 result->err = 0.0;
14003 return GSL_SUCCESS;
14004 }
14005 else if(n <= GSL_SF_DOUBLEFACT_NMAX){
14006 result->val = doub_fact_table[n].f;
14007 result->err = 2.0 * GSL_DBL_EPSILON * fabs(result->val);
14008 return GSL_SUCCESS;
14009 }
14010 else {
14011 OVERFLOW_ERROR(result);
14012 }
14013}
14014
14015
14016int gsl_sf_lnfact_e(const unsigned int n, gsl_sf_result * result)
14017{
14018 /* CHECK_POINTER(result) */
14019
14020 if(n <= GSL_SF_FACT_NMAX){
14021 result->val = log(fact_table[n].f);
14022 result->err = 2.0 * GSL_DBL_EPSILON * fabs(result->val);
14023 return GSL_SUCCESS;
14024 }
14025 else {
14026 gsl_sf_lngamma_e(n+1.0, result);
14027 return GSL_SUCCESS;
14028 }
14029}
14030
14031
14032int gsl_sf_lndoublefact_e(const unsigned int n, gsl_sf_result * result)
14033{
14034 /* CHECK_POINTER(result) */
14035
14036 if(n <= GSL_SF_DOUBLEFACT_NMAX){
14037 result->val = log(doub_fact_table[n].f);
14038 result->err = 2.0 * GSL_DBL_EPSILON * fabs(result->val);
14039 return GSL_SUCCESS;
14040 }
14041 else if(GSL_IS_ODD(n)) {
14042 gsl_sf_result lg;
14043 gsl_sf_lngamma_e(0.5*(n+2.0), &lg);
14044 result->val = 0.5*(n+1.0) * M_LN2 - 0.5*M_LNPI + lg.val;
14045 result->err = 2.0 * GSL_DBL_EPSILON * fabs(result->val) + lg.err;
14046 return GSL_SUCCESS;
14047 }
14048 else {
14049 gsl_sf_result lg;
14050 gsl_sf_lngamma_e(0.5*n+1.0, &lg);
14051 result->val = 0.5*n*M_LN2 + lg.val;
14052 result->err = 2.0 * GSL_DBL_EPSILON * fabs(result->val) + lg.err;
14053 return GSL_SUCCESS;
14054 }
14055}
14056
14057
14058int gsl_sf_lnchoose_e(unsigned int n, unsigned int m, gsl_sf_result * result)
14059{
14060 /* CHECK_POINTER(result) */
14061
14062 if(m > n) {
14063 DOMAIN_ERROR(result);
14064 }
14065 else if(m == n || m == 0) {
14066 result->val = 0.0;
14067 result->err = 0.0;
14068 return GSL_SUCCESS;
14069 }
14070 else {
14071 gsl_sf_result nf;
14072 gsl_sf_result mf;
14073 gsl_sf_result nmmf;
14074 if(m*2 > n) m = n-m;
14075 gsl_sf_lnfact_e(n, &nf);
14076 gsl_sf_lnfact_e(m, &mf);
14077 gsl_sf_lnfact_e(n-m, &nmmf);
14078 result->val = nf.val - mf.val - nmmf.val;
14079 result->err = nf.err + mf.err + nmmf.err;
14080 result->err += 2.0 * GSL_DBL_EPSILON * fabs(result->val);
14081 return GSL_SUCCESS;
14082 }
14083}
14084
14085
14086int gsl_sf_choose_e(unsigned int n, unsigned int m, gsl_sf_result * result)
14087{
14088 if(m > n) {
14089 DOMAIN_ERROR(result);
14090 }
14091 else if(m == n || m == 0) {
14092 result->val = 1.0;
14093 result->err = 0.0;
14094 return GSL_SUCCESS;
14095 }
14096 else if (n <= GSL_SF_FACT_NMAX) {
14097 result->val = (fact_table[n].f / fact_table[m].f) / fact_table[n-m].f;
14098 result->err = 6.0 * GSL_DBL_EPSILON * fabs(result->val);
14099 return GSL_SUCCESS;
14100 } else {
14101 if(m*2 < n) m = n-m;
14102
14103 if (n - m < 64) /* compute product for a manageable number of terms */
14104 {
14105 double prod = 1.0;
14106 unsigned int k;
14107
14108 for(k=n; k>=m+1; k--) {
14109 double tk = (double)k / (double)(k-m);
14110 if(tk > GSL_DBL_MAX/prod) {
14111 OVERFLOW_ERROR(result);
14112 }
14113 prod *= tk;
14114 }
14115 result->val = prod;
14116 result->err = 2.0 * GSL_DBL_EPSILON * prod * fabs((double) (n-m));
14117 return GSL_SUCCESS;
14118 }
14119 else
14120 {
14121 gsl_sf_result lc;
14122 const int stat_lc = gsl_sf_lnchoose_e (n, m, &lc);
14123 const int stat_e = gsl_sf_exp_err_e(lc.val, lc.err, result);
14124 return GSL_ERROR_SELECT_2(stat_lc, stat_e);
14125 }
14126 }
14127}
14128
14129
14130/*-*-*-*-*-*-*-*-*-* Functions w/ Natural Prototypes *-*-*-*-*-*-*-*-*-*-*/
14131
14132/* inlined: eval.h */
14133
14134double gsl_sf_fact(const unsigned int n)
14135{
14136 EVAL_RESULT(gsl_sf_fact_e(n, &result));
14137}
14138
14139double gsl_sf_lnfact(const unsigned int n)
14140{
14141 EVAL_RESULT(gsl_sf_lnfact_e(n, &result));
14142}
14143
14144double gsl_sf_doublefact(const unsigned int n)
14145{
14146 EVAL_RESULT(gsl_sf_doublefact_e(n, &result));
14147}
14148
14149double gsl_sf_lndoublefact(const unsigned int n)
14150{
14151 EVAL_RESULT(gsl_sf_lndoublefact_e(n, &result));
14152}
14153
14154double gsl_sf_lngamma(const double x)
14155{
14156 EVAL_RESULT(gsl_sf_lngamma_e(x, &result));
14157}
14158
14159double gsl_sf_gamma(const double x)
14160{
14161 EVAL_RESULT(gsl_sf_gamma_e(x, &result));
14162}
14163
14164double gsl_sf_gammastar(const double x)
14165{
14166 EVAL_RESULT(gsl_sf_gammastar_e(x, &result));
14167}
14168
14169double gsl_sf_gammainv(const double x)
14170{
14171 EVAL_RESULT(gsl_sf_gammainv_e(x, &result));
14172}
14173
14174double gsl_sf_taylorcoeff(const int n, const double x)
14175{
14176 EVAL_RESULT(gsl_sf_taylorcoeff_e(n, x, &result));
14177}
14178
14179double gsl_sf_choose(unsigned int n, unsigned int m)
14180{
14181 EVAL_RESULT(gsl_sf_choose_e(n, m, &result));
14182}
14183
14184double gsl_sf_lnchoose(unsigned int n, unsigned int m)
14185{
14186 EVAL_RESULT(gsl_sf_lnchoose_e(n, m, &result));
14187}
14188/* end inlined source: specfunc/gamma.c */
14189/* begin inlined source: specfunc/elementary.c */
14190/* specfunc/elementary.c
14191 *
14192 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
14193 *
14194 * This program is free software; you can redistribute it and/or modify
14195 * it under the terms of the GNU General Public License as published by
14196 * the Free Software Foundation; either version 3 of the License, or (at
14197 * your option) any later version.
14198 *
14199 * This program is distributed in the hope that it will be useful, but
14200 * WITHOUT ANY WARRANTY; without even the implied warranty of
14201 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14202 * General Public License for more details.
14203 *
14204 * You should have received a copy of the GNU General Public License
14205 * along with this program; if not, write to the Free Software
14206 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
14207 */
14208
14209/* Author: G. Jungman */
14210/* begin inlined header: config.h */
14211#ifndef MARLEY_BUILTIN_GSL_CONFIG_WRAPPER_H
14212#define MARLEY_BUILTIN_GSL_CONFIG_WRAPPER_H
14213/* begin inlined header: gsl_config.h */
14214#ifndef MARLEY_BUILTIN_GSL_CONFIG_H
14215#define MARLEY_BUILTIN_GSL_CONFIG_H
14216
14217#define HAVE_INLINE 1
14218#define HAVE_DECL_ISFINITE 1
14219#define HAVE_DECL_ISNAN 1
14220#define HAVE_DECL_ISINF 1
14221#define GSL_COERCE_DBL(x) (x)
14222
14223#define GSL_DISABLE_DEPRECATED 0
14224#define PACKAGE_VERSION "2.8"
14225#define VERSION "2.8"
14226
14227#endif
14228
14229/* end inlined header: gsl_config.h */
14230#endif
14231
14232/* end inlined header: config.h */
14233/* begin inlined header: gsl/gsl_math.h */
14234/* gsl_math.h
14235 *
14236 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2004, 2007 Gerard Jungman, Brian Gough
14237 *
14238 * This program is free software; you can redistribute it and/or modify
14239 * it under the terms of the GNU General Public License as published by
14240 * the Free Software Foundation; either version 3 of the License, or (at
14241 * your option) any later version.
14242 *
14243 * This program is distributed in the hope that it will be useful, but
14244 * WITHOUT ANY WARRANTY; without even the implied warranty of
14245 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14246 * General Public License for more details.
14247 *
14248 * You should have received a copy of the GNU General Public License
14249 * along with this program; if not, write to the Free Software
14250 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
14251 */
14252
14253#ifndef __GSL_MATH_H__
14254#define __GSL_MATH_H__
14255#include <math.h>
14256/* begin inlined header: gsl/gsl_sys.h */
14257/* sys/gsl_sys.h
14258 *
14259 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, Brian Gough
14260 *
14261 * This program is free software; you can redistribute it and/or modify
14262 * it under the terms of the GNU General Public License as published by
14263 * the Free Software Foundation; either version 3 of the License, or (at
14264 * your option) any later version.
14265 *
14266 * This program is distributed in the hope that it will be useful, but
14267 * WITHOUT ANY WARRANTY; without even the implied warranty of
14268 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14269 * General Public License for more details.
14270 *
14271 * You should have received a copy of the GNU General Public License
14272 * along with this program; if not, write to the Free Software
14273 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
14274 */
14275
14276#ifndef __GSL_SYS_H__
14277#define __GSL_SYS_H__
14278
14279
14280
14281__BEGIN_DECLS
14282
14283double gsl_log1p (const double x);
14284double gsl_expm1 (const double x);
14285double gsl_hypot (const double x, const double y);
14286double gsl_hypot3 (const double x, const double y, const double z);
14287double gsl_acosh (const double x);
14288double gsl_asinh (const double x);
14289double gsl_atanh (const double x);
14290
14291int gsl_isnan (const double x);
14292int gsl_isinf (const double x);
14293int gsl_finite (const double x);
14294
14295double gsl_nan (void);
14296double gsl_posinf (void);
14297double gsl_neginf (void);
14298double gsl_fdiv (const double x, const double y);
14299
14300double gsl_coerce_double (const double x);
14301float gsl_coerce_float (const float x);
14302long double gsl_coerce_long_double (const long double x);
14303
14304double gsl_ldexp(const double x, const int e);
14305double gsl_frexp(const double x, int * e);
14306
14307int gsl_fcmp (const double x1, const double x2, const double epsilon);
14308
14309__END_DECLS
14310
14311#endif /* __GSL_SYS_H__ */
14312
14313/* end inlined header: gsl/gsl_sys.h */
14314/* begin inlined header: gsl/gsl_inline.h */
14315/* gsl_inline.h
14316 *
14317 * Copyright (C) 2008, 2009 Brian Gough
14318 *
14319 * This program is free software; you can redistribute it and/or modify
14320 * it under the terms of the GNU General Public License as published by
14321 * the Free Software Foundation; either version 3 of the License, or (at
14322 * your option) any later version.
14323 *
14324 * This program is distributed in the hope that it will be useful, but
14325 * WITHOUT ANY WARRANTY; without even the implied warranty of
14326 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14327 * General Public License for more details.
14328 *
14329 * You should have received a copy of the GNU General Public License
14330 * along with this program; if not, write to the Free Software
14331 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
14332 */
14333
14334#ifndef __GSL_INLINE_H__
14335#define __GSL_INLINE_H__
14336
14337/* In recent versiions of GCC, the inline keyword has two different
14338 forms: GNU and C99.
14339
14340 In GNU mode we can use 'extern inline' to make inline functions
14341 work like macros. The function is only inlined--it is never output
14342 as a definition in an object file.
14343
14344 In the new C99 mode 'extern inline' has a different meaning--it
14345 causes the definition of the function to be output in each object
14346 file where it is used. This will result in multiple-definition
14347 errors on linking. The 'inline' keyword on its own (without
14348 extern) has the same behavior as the original GNU 'extern inline'.
14349
14350 The C99 style is the default with -std=c99 in GCC 4.3.
14351
14352 This header file allows either form of inline to be used by
14353 redefining the macros INLINE_DECL and INLINE_FUN. These are used
14354 in the public header files as
14355
14356 INLINE_DECL double gsl_foo (double x);
14357 #ifdef HAVE_INLINE
14358 INLINE_FUN double gsl_foo (double x) { return x+1.0; } ;
14359 #endif
14360
14361*/
14362
14363#ifdef HAVE_INLINE
14364# if defined(__GNUC_STDC_INLINE__) || defined(GSL_C99_INLINE) || defined(HAVE_C99_INLINE)
14365# define INLINE_DECL inline /* use C99 inline */
14366# define INLINE_FUN inline
14367# else
14368# define INLINE_DECL /* use GNU extern inline */
14369# define INLINE_FUN extern inline
14370# endif
14371#else
14372# define INLINE_DECL /* */
14373#endif
14374
14375/* Range checking conditions in headers do not require any run-time
14376 tests of the global variable gsl_check_range. They are enabled or
14377 disabled in user code at compile time with GSL_RANGE_CHECK macro.
14378 See also build.h. */
14379#define GSL_RANGE_COND(x) (x)
14380
14381#endif /* __GSL_INLINE_H__ */
14382
14383/* end inlined header: gsl/gsl_inline.h */
14384/* begin inlined header: gsl/gsl_machine.h */
14385/* Author: B. Gough and G. Jungman */
14386#ifndef __GSL_MACHINE_H__
14387#define __GSL_MACHINE_H__
14388
14389#include <limits.h>
14390#include <float.h>
14391
14392/* magic constants; mostly for the benefit of the implementation */
14393
14394/* -*-MACHINE CONSTANTS-*-
14395 *
14396 * PLATFORM: Whiz-O-Matic 9000
14397 * FP_PLATFORM: IEEE-Virtual
14398 * HOSTNAME: nnn.lanl.gov
14399 * DATE: Fri Nov 20 17:53:26 MST 1998
14400 */
14401#define GSL_DBL_EPSILON 2.2204460492503131e-16
14402#define GSL_SQRT_DBL_EPSILON 1.4901161193847656e-08
14403#define GSL_ROOT3_DBL_EPSILON 6.0554544523933429e-06
14404#define GSL_ROOT4_DBL_EPSILON 1.2207031250000000e-04
14405#define GSL_ROOT5_DBL_EPSILON 7.4009597974140505e-04
14406#define GSL_ROOT6_DBL_EPSILON 2.4607833005759251e-03
14407#define GSL_LOG_DBL_EPSILON (-3.6043653389117154e+01)
14408
14409#define GSL_DBL_MIN 2.2250738585072014e-308
14410#define GSL_SQRT_DBL_MIN 1.4916681462400413e-154
14411#define GSL_ROOT3_DBL_MIN 2.8126442852362996e-103
14412#define GSL_ROOT4_DBL_MIN 1.2213386697554620e-77
14413#define GSL_ROOT5_DBL_MIN 2.9476022969691763e-62
14414#define GSL_ROOT6_DBL_MIN 5.3034368905798218e-52
14415#define GSL_LOG_DBL_MIN (-7.0839641853226408e+02)
14416
14417#define GSL_DBL_MAX 1.7976931348623157e+308
14418#define GSL_SQRT_DBL_MAX 1.3407807929942596e+154
14419#define GSL_ROOT3_DBL_MAX 5.6438030941222897e+102
14420#define GSL_ROOT4_DBL_MAX 1.1579208923731620e+77
14421#define GSL_ROOT5_DBL_MAX 4.4765466227572707e+61
14422#define GSL_ROOT6_DBL_MAX 2.3756689782295612e+51
14423#define GSL_LOG_DBL_MAX 7.0978271289338397e+02
14424
14425#define GSL_FLT_EPSILON 1.1920928955078125e-07
14426#define GSL_SQRT_FLT_EPSILON 3.4526698300124393e-04
14427#define GSL_ROOT3_FLT_EPSILON 4.9215666011518501e-03
14428#define GSL_ROOT4_FLT_EPSILON 1.8581361171917516e-02
14429#define GSL_ROOT5_FLT_EPSILON 4.1234622211652937e-02
14430#define GSL_ROOT6_FLT_EPSILON 7.0153878019335827e-02
14431#define GSL_LOG_FLT_EPSILON (-1.5942385152878742e+01)
14432
14433#define GSL_FLT_MIN 1.1754943508222875e-38
14434#define GSL_SQRT_FLT_MIN 1.0842021724855044e-19
14435#define GSL_ROOT3_FLT_MIN 2.2737367544323241e-13
14436#define GSL_ROOT4_FLT_MIN 3.2927225399135965e-10
14437#define GSL_ROOT5_FLT_MIN 2.5944428542140822e-08
14438#define GSL_ROOT6_FLT_MIN 4.7683715820312542e-07
14439#define GSL_LOG_FLT_MIN (-8.7336544750553102e+01)
14440
14441#define GSL_FLT_MAX 3.4028234663852886e+38
14442#define GSL_SQRT_FLT_MAX 1.8446743523953730e+19
14443#define GSL_ROOT3_FLT_MAX 6.9814635196223242e+12
14444#define GSL_ROOT4_FLT_MAX 4.2949672319999986e+09
14445#define GSL_ROOT5_FLT_MAX 5.0859007855960041e+07
14446#define GSL_ROOT6_FLT_MAX 2.6422459233807749e+06
14447#define GSL_LOG_FLT_MAX 8.8722839052068352e+01
14448
14449#define GSL_SFLT_EPSILON 4.8828125000000000e-04
14450#define GSL_SQRT_SFLT_EPSILON 2.2097086912079612e-02
14451#define GSL_ROOT3_SFLT_EPSILON 7.8745065618429588e-02
14452#define GSL_ROOT4_SFLT_EPSILON 1.4865088937534013e-01
14453#define GSL_ROOT5_SFLT_EPSILON 2.1763764082403100e-01
14454#define GSL_ROOT6_SFLT_EPSILON 2.8061551207734325e-01
14455#define GSL_LOG_SFLT_EPSILON (-7.6246189861593985e+00)
14456
14457/* !MACHINE CONSTANTS! */
14458
14459
14460/* a little internal backwards compatibility */
14461#define GSL_MACH_EPS GSL_DBL_EPSILON
14462
14463
14464
14465/* Here are the constants related to or derived from
14466 * machine constants. These are not to be confused with
14467 * the constants that define various precision levels
14468 * for the precision/error system.
14469 *
14470 * This information is determined at configure time
14471 * and is platform dependent. Edit at your own risk.
14472 *
14473 * PLATFORM: WHIZ-O-MATIC
14474 * CONFIG-DATE: Thu Nov 19 19:27:18 MST 1998
14475 * CONFIG-HOST: nnn.lanl.gov
14476 */
14477
14478/* machine precision constants */
14479/* #define GSL_MACH_EPS 1.0e-15 */
14480#define GSL_SQRT_MACH_EPS 3.2e-08
14481#define GSL_ROOT3_MACH_EPS 1.0e-05
14482#define GSL_ROOT4_MACH_EPS 0.000178
14483#define GSL_ROOT5_MACH_EPS 0.00100
14484#define GSL_ROOT6_MACH_EPS 0.00316
14485#define GSL_LOG_MACH_EPS (-34.54)
14486
14487
14488#endif /* __GSL_MACHINE_H__ */
14489
14490/* end inlined header: gsl/gsl_machine.h */
14491/* begin inlined header: gsl/gsl_precision.h */
14492/* gsl_precision.h
14493 *
14494 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
14495 *
14496 * This program is free software; you can redistribute it and/or modify
14497 * it under the terms of the GNU General Public License as published by
14498 * the Free Software Foundation; either version 3 of the License, or (at
14499 * your option) any later version.
14500 *
14501 * This program is distributed in the hope that it will be useful, but
14502 * WITHOUT ANY WARRANTY; without even the implied warranty of
14503 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14504 * General Public License for more details.
14505 *
14506 * You should have received a copy of the GNU General Public License
14507 * along with this program; if not, write to the Free Software
14508 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
14509 */
14510
14511/* Author: B. Gough and G. Jungman */
14512
14513#ifndef __GSL_PRECISION_H__
14514#define __GSL_PRECISION_H__
14515/* begin inlined header: gsl/gsl_types.h */
14516/* gsl_types.h
14517 *
14518 * Copyright (C) 2001, 2007 Brian Gough
14519 *
14520 * This program is free software; you can redistribute it and/or modify
14521 * it under the terms of the GNU General Public License as published by
14522 * the Free Software Foundation; either version 3 of the License, or (at
14523 * your option) any later version.
14524 *
14525 * This program is distributed in the hope that it will be useful, but
14526 * WITHOUT ANY WARRANTY; without even the implied warranty of
14527 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14528 * General Public License for more details.
14529 *
14530 * You should have received a copy of the GNU General Public License
14531 * along with this program; if not, write to the Free Software
14532 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
14533 */
14534
14535#ifndef __GSL_TYPES_H__
14536#define __GSL_TYPES_H__
14537
14538#ifndef GSL_VAR
14539
14540#ifdef WIN32
14541# ifdef GSL_DLL
14542# ifdef DLL_EXPORT
14543# define GSL_VAR extern __declspec(dllexport)
14544# else
14545# define GSL_VAR extern __declspec(dllimport)
14546# endif
14547# else
14548# define GSL_VAR extern
14549# endif
14550#else
14551# define GSL_VAR extern
14552#endif
14553
14554#endif
14555
14556#endif /* __GSL_TYPES_H__ */
14557
14558/* end inlined header: gsl/gsl_types.h */
14559
14560
14561__BEGIN_DECLS
14562
14563
14564/* A type for the precision indicator.
14565 * This is mainly for pedagogy.
14566 */
14567typedef unsigned int gsl_prec_t;
14568
14569
14570/* The number of precision types.
14571 * Remember that precision-mode
14572 * can index an array.
14573 */
14574#define _GSL_PREC_T_NUM 3
14575
14576
14577/* Arrays containing derived
14578 * precision constants for the
14579 * different precision levels.
14580 */
14581GSL_VAR const double gsl_prec_eps[];
14582GSL_VAR const double gsl_prec_sqrt_eps[];
14583GSL_VAR const double gsl_prec_root3_eps[];
14584GSL_VAR const double gsl_prec_root4_eps[];
14585GSL_VAR const double gsl_prec_root5_eps[];
14586GSL_VAR const double gsl_prec_root6_eps[];
14587
14588
14589__END_DECLS
14590
14591#endif /* __GSL_PRECISION_H__ */
14592
14593/* end inlined header: gsl/gsl_precision.h */
14594/* begin inlined header: gsl/gsl_nan.h */
14595/* gsl_nan.h
14596 *
14597 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, Brian Gough
14598 *
14599 * This program is free software; you can redistribute it and/or modify
14600 * it under the terms of the GNU General Public License as published by
14601 * the Free Software Foundation; either version 3 of the License, or (at
14602 * your option) any later version.
14603 *
14604 * This program is distributed in the hope that it will be useful, but
14605 * WITHOUT ANY WARRANTY; without even the implied warranty of
14606 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14607 * General Public License for more details.
14608 *
14609 * You should have received a copy of the GNU General Public License
14610 * along with this program; if not, write to the Free Software
14611 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
14612 */
14613
14614#ifndef __GSL_NAN_H__
14615#define __GSL_NAN_H__
14616
14617#ifdef INFINITY
14618# define GSL_POSINF INFINITY
14619# define GSL_NEGINF (-INFINITY)
14620#elif defined(HUGE_VAL)
14621# define GSL_POSINF HUGE_VAL
14622# define GSL_NEGINF (-HUGE_VAL)
14623#else
14624# define GSL_POSINF (gsl_posinf())
14625# define GSL_NEGINF (gsl_neginf())
14626#endif
14627
14628#ifdef NAN
14629# define GSL_NAN NAN
14630#elif defined(INFINITY)
14631# define GSL_NAN (INFINITY/INFINITY)
14632#else
14633# define GSL_NAN (gsl_nan())
14634#endif
14635
14636#define GSL_POSZERO (+0.0)
14637#define GSL_NEGZERO (-0.0)
14638
14639#endif /* __GSL_NAN_H__ */
14640
14641/* end inlined header: gsl/gsl_nan.h */
14642/* begin inlined header: gsl/gsl_pow_int.h */
14643/* gsl_pow_int.h
14644 *
14645 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2004, 2007 Gerard Jungman, Brian Gough
14646 *
14647 * This program is free software; you can redistribute it and/or modify
14648 * it under the terms of the GNU General Public License as published by
14649 * the Free Software Foundation; either version 3 of the License, or (at
14650 * your option) any later version.
14651 *
14652 * This program is distributed in the hope that it will be useful, but
14653 * WITHOUT ANY WARRANTY; without even the implied warranty of
14654 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14655 * General Public License for more details.
14656 *
14657 * You should have received a copy of the GNU General Public License
14658 * along with this program; if not, write to the Free Software
14659 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
14660 */
14661
14662#ifndef __GSL_POW_INT_H__
14663#define __GSL_POW_INT_H__
14664/* begin inlined header: gsl/gsl_inline.h */
14665/* gsl_inline.h
14666 *
14667 * Copyright (C) 2008, 2009 Brian Gough
14668 *
14669 * This program is free software; you can redistribute it and/or modify
14670 * it under the terms of the GNU General Public License as published by
14671 * the Free Software Foundation; either version 3 of the License, or (at
14672 * your option) any later version.
14673 *
14674 * This program is distributed in the hope that it will be useful, but
14675 * WITHOUT ANY WARRANTY; without even the implied warranty of
14676 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14677 * General Public License for more details.
14678 *
14679 * You should have received a copy of the GNU General Public License
14680 * along with this program; if not, write to the Free Software
14681 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
14682 */
14683
14684#ifndef __GSL_INLINE_H__
14685#define __GSL_INLINE_H__
14686
14687/* In recent versiions of GCC, the inline keyword has two different
14688 forms: GNU and C99.
14689
14690 In GNU mode we can use 'extern inline' to make inline functions
14691 work like macros. The function is only inlined--it is never output
14692 as a definition in an object file.
14693
14694 In the new C99 mode 'extern inline' has a different meaning--it
14695 causes the definition of the function to be output in each object
14696 file where it is used. This will result in multiple-definition
14697 errors on linking. The 'inline' keyword on its own (without
14698 extern) has the same behavior as the original GNU 'extern inline'.
14699
14700 The C99 style is the default with -std=c99 in GCC 4.3.
14701
14702 This header file allows either form of inline to be used by
14703 redefining the macros INLINE_DECL and INLINE_FUN. These are used
14704 in the public header files as
14705
14706 INLINE_DECL double gsl_foo (double x);
14707 #ifdef HAVE_INLINE
14708 INLINE_FUN double gsl_foo (double x) { return x+1.0; } ;
14709 #endif
14710
14711*/
14712
14713#ifdef HAVE_INLINE
14714# if defined(__GNUC_STDC_INLINE__) || defined(GSL_C99_INLINE) || defined(HAVE_C99_INLINE)
14715# define INLINE_DECL inline /* use C99 inline */
14716# define INLINE_FUN inline
14717# else
14718# define INLINE_DECL /* use GNU extern inline */
14719# define INLINE_FUN extern inline
14720# endif
14721#else
14722# define INLINE_DECL /* */
14723#endif
14724
14725/* Range checking conditions in headers do not require any run-time
14726 tests of the global variable gsl_check_range. They are enabled or
14727 disabled in user code at compile time with GSL_RANGE_CHECK macro.
14728 See also build.h. */
14729#define GSL_RANGE_COND(x) (x)
14730
14731#endif /* __GSL_INLINE_H__ */
14732
14733/* end inlined header: gsl/gsl_inline.h */
14734
14735
14736__BEGIN_DECLS
14737
14738INLINE_DECL double gsl_pow_2(const double x);
14739INLINE_DECL double gsl_pow_3(const double x);
14740INLINE_DECL double gsl_pow_4(const double x);
14741INLINE_DECL double gsl_pow_5(const double x);
14742INLINE_DECL double gsl_pow_6(const double x);
14743INLINE_DECL double gsl_pow_7(const double x);
14744INLINE_DECL double gsl_pow_8(const double x);
14745INLINE_DECL double gsl_pow_9(const double x);
14746
14747#ifdef HAVE_INLINE
14748INLINE_FUN double gsl_pow_2(const double x) { return x*x; }
14749INLINE_FUN double gsl_pow_3(const double x) { return x*x*x; }
14750INLINE_FUN double gsl_pow_4(const double x) { double x2 = x*x; return x2*x2; }
14751INLINE_FUN double gsl_pow_5(const double x) { double x2 = x*x; return x2*x2*x; }
14752INLINE_FUN double gsl_pow_6(const double x) { double x2 = x*x; return x2*x2*x2; }
14753INLINE_FUN double gsl_pow_7(const double x) { double x3 = x*x*x; return x3*x3*x; }
14754INLINE_FUN double gsl_pow_8(const double x) { double x2 = x*x; double x4 = x2*x2; return x4*x4; }
14755INLINE_FUN double gsl_pow_9(const double x) { double x3 = x*x*x; return x3*x3*x3; }
14756#endif
14757
14758double gsl_pow_int(double x, int n);
14759double gsl_pow_uint(double x, unsigned int n);
14760
14761__END_DECLS
14762
14763#endif /* __GSL_POW_INT_H__ */
14764
14765/* end inlined header: gsl/gsl_pow_int.h */
14766/* begin inlined header: gsl/gsl_minmax.h */
14767/* gsl_minmax.h
14768 *
14769 * Copyright (C) 2008 Gerard Jungman, Brian Gough
14770 *
14771 * This program is free software; you can redistribute it and/or modify
14772 * it under the terms of the GNU General Public License as published by
14773 * the Free Software Foundation; either version 3 of the License, or (at
14774 * your option) any later version.
14775 *
14776 * This program is distributed in the hope that it will be useful, but
14777 * WITHOUT ANY WARRANTY; without even the implied warranty of
14778 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14779 * General Public License for more details.
14780 *
14781 * You should have received a copy of the GNU General Public License
14782 * along with this program; if not, write to the Free Software
14783 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
14784 */
14785
14786#ifndef __GSL_MINMAX_H__
14787#define __GSL_MINMAX_H__
14788/* begin inlined header: gsl/gsl_inline.h */
14789/* gsl_inline.h
14790 *
14791 * Copyright (C) 2008, 2009 Brian Gough
14792 *
14793 * This program is free software; you can redistribute it and/or modify
14794 * it under the terms of the GNU General Public License as published by
14795 * the Free Software Foundation; either version 3 of the License, or (at
14796 * your option) any later version.
14797 *
14798 * This program is distributed in the hope that it will be useful, but
14799 * WITHOUT ANY WARRANTY; without even the implied warranty of
14800 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14801 * General Public License for more details.
14802 *
14803 * You should have received a copy of the GNU General Public License
14804 * along with this program; if not, write to the Free Software
14805 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
14806 */
14807
14808#ifndef __GSL_INLINE_H__
14809#define __GSL_INLINE_H__
14810
14811/* In recent versiions of GCC, the inline keyword has two different
14812 forms: GNU and C99.
14813
14814 In GNU mode we can use 'extern inline' to make inline functions
14815 work like macros. The function is only inlined--it is never output
14816 as a definition in an object file.
14817
14818 In the new C99 mode 'extern inline' has a different meaning--it
14819 causes the definition of the function to be output in each object
14820 file where it is used. This will result in multiple-definition
14821 errors on linking. The 'inline' keyword on its own (without
14822 extern) has the same behavior as the original GNU 'extern inline'.
14823
14824 The C99 style is the default with -std=c99 in GCC 4.3.
14825
14826 This header file allows either form of inline to be used by
14827 redefining the macros INLINE_DECL and INLINE_FUN. These are used
14828 in the public header files as
14829
14830 INLINE_DECL double gsl_foo (double x);
14831 #ifdef HAVE_INLINE
14832 INLINE_FUN double gsl_foo (double x) { return x+1.0; } ;
14833 #endif
14834
14835*/
14836
14837#ifdef HAVE_INLINE
14838# if defined(__GNUC_STDC_INLINE__) || defined(GSL_C99_INLINE) || defined(HAVE_C99_INLINE)
14839# define INLINE_DECL inline /* use C99 inline */
14840# define INLINE_FUN inline
14841# else
14842# define INLINE_DECL /* use GNU extern inline */
14843# define INLINE_FUN extern inline
14844# endif
14845#else
14846# define INLINE_DECL /* */
14847#endif
14848
14849/* Range checking conditions in headers do not require any run-time
14850 tests of the global variable gsl_check_range. They are enabled or
14851 disabled in user code at compile time with GSL_RANGE_CHECK macro.
14852 See also build.h. */
14853#define GSL_RANGE_COND(x) (x)
14854
14855#endif /* __GSL_INLINE_H__ */
14856
14857/* end inlined header: gsl/gsl_inline.h */
14858
14859
14860__BEGIN_DECLS
14861
14862/* Define MAX and MIN macros/functions if they don't exist. */
14863
14864/* plain old macros for general use */
14865#define GSL_MAX(a,b) ((a) > (b) ? (a) : (b))
14866#define GSL_MIN(a,b) ((a) < (b) ? (a) : (b))
14867
14868/* function versions of the above, in case they are needed */
14869double gsl_max (double a, double b);
14870double gsl_min (double a, double b);
14871
14872/* inline-friendly strongly typed versions */
14873#ifdef HAVE_INLINE
14874
14875INLINE_FUN int GSL_MAX_INT (int a, int b);
14876INLINE_FUN int GSL_MIN_INT (int a, int b);
14877INLINE_FUN double GSL_MAX_DBL (double a, double b);
14878INLINE_FUN double GSL_MIN_DBL (double a, double b);
14879INLINE_FUN long double GSL_MAX_LDBL (long double a, long double b);
14880INLINE_FUN long double GSL_MIN_LDBL (long double a, long double b);
14881
14882INLINE_FUN int
14883GSL_MAX_INT (int a, int b)
14884{
14885 return GSL_MAX (a, b);
14886}
14887
14888INLINE_FUN int
14889GSL_MIN_INT (int a, int b)
14890{
14891 return GSL_MIN (a, b);
14892}
14893
14894INLINE_FUN double
14895GSL_MAX_DBL (double a, double b)
14896{
14897 return GSL_MAX (a, b);
14898}
14899
14900INLINE_FUN double
14901GSL_MIN_DBL (double a, double b)
14902{
14903 return GSL_MIN (a, b);
14904}
14905
14906INLINE_FUN long double
14907GSL_MAX_LDBL (long double a, long double b)
14908{
14909 return GSL_MAX (a, b);
14910}
14911
14912INLINE_FUN long double
14913GSL_MIN_LDBL (long double a, long double b)
14914{
14915 return GSL_MIN (a, b);
14916}
14917#else
14918#define GSL_MAX_INT(a,b) GSL_MAX(a,b)
14919#define GSL_MIN_INT(a,b) GSL_MIN(a,b)
14920#define GSL_MAX_DBL(a,b) GSL_MAX(a,b)
14921#define GSL_MIN_DBL(a,b) GSL_MIN(a,b)
14922#define GSL_MAX_LDBL(a,b) GSL_MAX(a,b)
14923#define GSL_MIN_LDBL(a,b) GSL_MIN(a,b)
14924#endif /* HAVE_INLINE */
14925
14926__END_DECLS
14927
14928#endif /* __GSL_POW_INT_H__ */
14929
14930/* end inlined header: gsl/gsl_minmax.h */
14931#ifndef M_E
14932#define M_E 2.71828182845904523536028747135 /* e */
14933#endif
14934
14935#ifndef M_LOG2E
14936#define M_LOG2E 1.44269504088896340735992468100 /* log_2 (e) */
14937#endif
14938
14939#ifndef M_LOG10E
14940#define M_LOG10E 0.43429448190325182765112891892 /* log_10 (e) */
14941#endif
14942
14943#ifndef M_SQRT2
14944#define M_SQRT2 1.41421356237309504880168872421 /* sqrt(2) */
14945#endif
14946
14947#ifndef M_SQRT1_2
14948#define M_SQRT1_2 0.70710678118654752440084436210 /* sqrt(1/2) */
14949#endif
14950
14951
14952#ifndef M_SQRT3
14953#define M_SQRT3 1.73205080756887729352744634151 /* sqrt(3) */
14954#endif
14955
14956#ifndef M_PI
14957#define M_PI 3.14159265358979323846264338328 /* pi */
14958#endif
14959
14960#ifndef M_PI_2
14961#define M_PI_2 1.57079632679489661923132169164 /* pi/2 */
14962#endif
14963
14964#ifndef M_PI_4
14965#define M_PI_4 0.78539816339744830961566084582 /* pi/4 */
14966#endif
14967
14968#ifndef M_SQRTPI
14969#define M_SQRTPI 1.77245385090551602729816748334 /* sqrt(pi) */
14970#endif
14971
14972#ifndef M_2_SQRTPI
14973#define M_2_SQRTPI 1.12837916709551257389615890312 /* 2/sqrt(pi) */
14974#endif
14975
14976#ifndef M_1_PI
14977#define M_1_PI 0.31830988618379067153776752675 /* 1/pi */
14978#endif
14979
14980#ifndef M_2_PI
14981#define M_2_PI 0.63661977236758134307553505349 /* 2/pi */
14982#endif
14983
14984#ifndef M_LN10
14985#define M_LN10 2.30258509299404568401799145468 /* ln(10) */
14986#endif
14987
14988#ifndef M_LN2
14989#define M_LN2 0.69314718055994530941723212146 /* ln(2) */
14990#endif
14991
14992#ifndef M_LNPI
14993#define M_LNPI 1.14472988584940017414342735135 /* ln(pi) */
14994#endif
14995
14996#ifndef M_EULER
14997#define M_EULER 0.57721566490153286060651209008 /* Euler constant */
14998#endif
14999
15000
15001
15002__BEGIN_DECLS
15003
15004/* other needlessly compulsive abstractions */
15005
15006#define GSL_IS_ODD(n) ((n) & 1)
15007#define GSL_IS_EVEN(n) (!(GSL_IS_ODD(n)))
15008#define GSL_SIGN(x) ((x) >= 0.0 ? 1 : -1)
15009
15010/* Return nonzero if x is a real number, i.e. non NaN or infinite. */
15011#define GSL_IS_REAL(x) (gsl_finite(x))
15012
15013/* Definition of an arbitrary function with parameters */
15014
15016{
15017 double (* function) (double x, void * params);
15018 void * params;
15019};
15020
15021typedef struct gsl_function_struct gsl_function ;
15022
15023#define GSL_FN_EVAL(F,x) (*((F)->function))(x,(F)->params)
15024
15025/* Definition of an arbitrary function returning two values, r1, r2 */
15026
15028{
15029 double (* f) (double x, void * params);
15030 double (* df) (double x, void * params);
15031 void (* fdf) (double x, void * params, double * f, double * df);
15032 void * params;
15033};
15034
15035typedef struct gsl_function_fdf_struct gsl_function_fdf ;
15036
15037#define GSL_FN_FDF_EVAL_F(FDF,x) (*((FDF)->f))(x,(FDF)->params)
15038#define GSL_FN_FDF_EVAL_DF(FDF,x) (*((FDF)->df))(x,(FDF)->params)
15039#define GSL_FN_FDF_EVAL_F_DF(FDF,x,y,dy) (*((FDF)->fdf))(x,(FDF)->params,(y),(dy))
15040
15041
15042/* Definition of an arbitrary vector-valued function with parameters */
15043
15045{
15046 int (* function) (double x, double y[], void * params);
15047 void * params;
15048};
15049
15050typedef struct gsl_function_vec_struct gsl_function_vec ;
15051
15052#define GSL_FN_VEC_EVAL(F,x,y) (*((F)->function))(x,y,(F)->params)
15053
15054__END_DECLS
15055
15056#endif /* __GSL_MATH_H__ */
15057
15058/* end inlined header: gsl/gsl_math.h */
15059/* begin inlined header: gsl/gsl_errno.h */
15060/* err/gsl_errno.h
15061 *
15062 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, Brian Gough
15063 *
15064 * This program is free software; you can redistribute it and/or modify
15065 * it under the terms of the GNU General Public License as published by
15066 * the Free Software Foundation; either version 3 of the License, or (at
15067 * your option) any later version.
15068 *
15069 * This program is distributed in the hope that it will be useful, but
15070 * WITHOUT ANY WARRANTY; without even the implied warranty of
15071 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15072 * General Public License for more details.
15073 *
15074 * You should have received a copy of the GNU General Public License
15075 * along with this program; if not, write to the Free Software
15076 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15077 */
15078
15079#ifndef __GSL_ERRNO_H__
15080#define __GSL_ERRNO_H__
15081
15082#include <stdio.h>
15083#include <errno.h>
15084/* begin inlined header: gsl/gsl_types.h */
15085/* gsl_types.h
15086 *
15087 * Copyright (C) 2001, 2007 Brian Gough
15088 *
15089 * This program is free software; you can redistribute it and/or modify
15090 * it under the terms of the GNU General Public License as published by
15091 * the Free Software Foundation; either version 3 of the License, or (at
15092 * your option) any later version.
15093 *
15094 * This program is distributed in the hope that it will be useful, but
15095 * WITHOUT ANY WARRANTY; without even the implied warranty of
15096 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15097 * General Public License for more details.
15098 *
15099 * You should have received a copy of the GNU General Public License
15100 * along with this program; if not, write to the Free Software
15101 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15102 */
15103
15104#ifndef __GSL_TYPES_H__
15105#define __GSL_TYPES_H__
15106
15107#ifndef GSL_VAR
15108
15109#ifdef WIN32
15110# ifdef GSL_DLL
15111# ifdef DLL_EXPORT
15112# define GSL_VAR extern __declspec(dllexport)
15113# else
15114# define GSL_VAR extern __declspec(dllimport)
15115# endif
15116# else
15117# define GSL_VAR extern
15118# endif
15119#else
15120# define GSL_VAR extern
15121#endif
15122
15123#endif
15124
15125#endif /* __GSL_TYPES_H__ */
15126
15127/* end inlined header: gsl/gsl_types.h */
15128
15129
15130__BEGIN_DECLS
15131
15132enum {
15133 GSL_SUCCESS = 0,
15134 GSL_FAILURE = -1,
15135 GSL_CONTINUE = -2, /* iteration has not converged */
15136 GSL_EDOM = 1, /* input domain error, e.g sqrt(-1) */
15137 GSL_ERANGE = 2, /* output range error, e.g. exp(1e100) */
15138 GSL_EFAULT = 3, /* invalid pointer */
15139 GSL_EINVAL = 4, /* invalid argument supplied by user */
15140 GSL_EFAILED = 5, /* generic failure */
15141 GSL_EFACTOR = 6, /* factorization failed */
15142 GSL_ESANITY = 7, /* sanity check failed - shouldn't happen */
15143 GSL_ENOMEM = 8, /* malloc failed */
15144 GSL_EBADFUNC = 9, /* problem with user-supplied function */
15145 GSL_ERUNAWAY = 10, /* iterative process is out of control */
15146 GSL_EMAXITER = 11, /* exceeded max number of iterations */
15147 GSL_EZERODIV = 12, /* tried to divide by zero */
15148 GSL_EBADTOL = 13, /* user specified an invalid tolerance */
15149 GSL_ETOL = 14, /* failed to reach the specified tolerance */
15150 GSL_EUNDRFLW = 15, /* underflow */
15151 GSL_EOVRFLW = 16, /* overflow */
15152 GSL_ELOSS = 17, /* loss of accuracy */
15153 GSL_EROUND = 18, /* failed because of roundoff error */
15154 GSL_EBADLEN = 19, /* matrix, vector lengths are not conformant */
15155 GSL_ENOTSQR = 20, /* matrix not square */
15156 GSL_ESING = 21, /* apparent singularity detected */
15157 GSL_EDIVERGE = 22, /* integral or series is divergent */
15158 GSL_EUNSUP = 23, /* requested feature is not supported by the hardware */
15159 GSL_EUNIMPL = 24, /* requested feature not (yet) implemented */
15160 GSL_ECACHE = 25, /* cache limit exceeded */
15161 GSL_ETABLE = 26, /* table limit exceeded */
15162 GSL_ENOPROG = 27, /* iteration is not making progress towards solution */
15163 GSL_ENOPROGJ = 28, /* jacobian evaluations are not improving the solution */
15164 GSL_ETOLF = 29, /* cannot reach the specified tolerance in F */
15165 GSL_ETOLX = 30, /* cannot reach the specified tolerance in X */
15166 GSL_ETOLG = 31, /* cannot reach the specified tolerance in gradient */
15167 GSL_EOF = 32 /* end of file */
15168} ;
15169
15170void gsl_error (const char * reason, const char * file, int line,
15171 int gsl_errno);
15172
15173void gsl_stream_printf (const char *label, const char *file,
15174 int line, const char *reason);
15175
15176typedef void gsl_error_handler_t (const char * reason, const char * file,
15177 int line, int gsl_errno);
15178
15179gsl_error_handler_t *
15180gsl_set_error_handler (gsl_error_handler_t * new_handler);
15181
15182/* GSL_ERROR: call the error handler, and return the error code */
15183
15184#define GSL_ERROR(reason, gsl_errno) \
15185 do { \
15186 gsl_error (reason, __FILE__, __LINE__, gsl_errno) ; \
15187 return gsl_errno ; \
15188 } while (0)
15189
15190/* GSL_ERROR_VAL: call the error handler, and return the given value */
15191
15192#define GSL_ERROR_VAL(reason, gsl_errno, value) \
15193 do { \
15194 gsl_error (reason, __FILE__, __LINE__, gsl_errno) ; \
15195 return value ; \
15196 } while (0)
15197
15198/* GSL_ERROR_VOID: call the error handler, and then return
15199 (for void functions which still need to generate an error) */
15200
15201#define GSL_ERROR_VOID(reason, gsl_errno) \
15202 do { \
15203 gsl_error (reason, __FILE__, __LINE__, gsl_errno) ; \
15204 return ; \
15205 } while (0)
15206
15207/* GSL_ERROR_NULL suitable for out-of-memory conditions */
15208
15209#define GSL_ERROR_NULL(reason, gsl_errno) GSL_ERROR_VAL(reason, gsl_errno, 0)
15210
15211/* Sometimes you have several status results returned from
15212 * function calls and you want to combine them in some sensible
15213 * way. You cannot produce a "total" status condition, but you can
15214 * pick one from a set of conditions based on an implied hierarchy.
15215 *
15216 * In other words:
15217 * you have: status_a, status_b, ...
15218 * you want: status = (status_a if it is bad, or status_b if it is bad,...)
15219 *
15220 * In this example you consider status_a to be more important and
15221 * it is checked first, followed by the others in the order specified.
15222 *
15223 * Here are some dumb macros to do this.
15224 */
15225#define GSL_ERROR_SELECT_2(a,b) ((a) != GSL_SUCCESS ? (a) : ((b) != GSL_SUCCESS ? (b) : GSL_SUCCESS))
15226#define GSL_ERROR_SELECT_3(a,b,c) ((a) != GSL_SUCCESS ? (a) : GSL_ERROR_SELECT_2(b,c))
15227#define GSL_ERROR_SELECT_4(a,b,c,d) ((a) != GSL_SUCCESS ? (a) : GSL_ERROR_SELECT_3(b,c,d))
15228#define GSL_ERROR_SELECT_5(a,b,c,d,e) ((a) != GSL_SUCCESS ? (a) : GSL_ERROR_SELECT_4(b,c,d,e))
15229
15230#define GSL_STATUS_UPDATE(sp, s) do { if ((s) != GSL_SUCCESS) *(sp) = (s);} while(0)
15231
15232__END_DECLS
15233
15234#endif /* __GSL_ERRNO_H__ */
15235
15236/* end inlined header: gsl/gsl_errno.h */
15237/* begin inlined header: gsl/gsl_sf_elementary.h */
15238/* specfunc/gsl_sf_elementary.h
15239 *
15240 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
15241 *
15242 * This program is free software; you can redistribute it and/or modify
15243 * it under the terms of the GNU General Public License as published by
15244 * the Free Software Foundation; either version 3 of the License, or (at
15245 * your option) any later version.
15246 *
15247 * This program is distributed in the hope that it will be useful, but
15248 * WITHOUT ANY WARRANTY; without even the implied warranty of
15249 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15250 * General Public License for more details.
15251 *
15252 * You should have received a copy of the GNU General Public License
15253 * along with this program; if not, write to the Free Software
15254 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15255 */
15256
15257/* Author: G. Jungman */
15258
15259/* Miscellaneous elementary functions and operations.
15260 */
15261#ifndef __GSL_SF_ELEMENTARY_H__
15262#define __GSL_SF_ELEMENTARY_H__
15263/* begin inlined header: gsl/gsl_sf_result.h */
15264/* specfunc/gsl_sf_result.h
15265 *
15266 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
15267 *
15268 * This program is free software; you can redistribute it and/or modify
15269 * it under the terms of the GNU General Public License as published by
15270 * the Free Software Foundation; either version 3 of the License, or (at
15271 * your option) any later version.
15272 *
15273 * This program is distributed in the hope that it will be useful, but
15274 * WITHOUT ANY WARRANTY; without even the implied warranty of
15275 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15276 * General Public License for more details.
15277 *
15278 * You should have received a copy of the GNU General Public License
15279 * along with this program; if not, write to the Free Software
15280 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15281 */
15282
15283/* Author: G. Jungman */
15284
15285#ifndef __GSL_SF_RESULT_H__
15286#define __GSL_SF_RESULT_H__
15287
15288
15289
15290__BEGIN_DECLS
15291
15292struct gsl_sf_result_struct {
15293 double val;
15294 double err;
15295};
15296typedef struct gsl_sf_result_struct gsl_sf_result;
15297
15298#define GSL_SF_RESULT_SET(r,v,e) do { (r)->val=(v); (r)->err=(e); } while(0)
15299
15300
15302 double val;
15303 double err;
15304 int e10;
15305};
15306typedef struct gsl_sf_result_e10_struct gsl_sf_result_e10;
15307
15308
15309int gsl_sf_result_smash_e(const gsl_sf_result_e10 * re, gsl_sf_result * r);
15310
15311
15312__END_DECLS
15313
15314#endif /* __GSL_SF_RESULT_H__ */
15315
15316/* end inlined header: gsl/gsl_sf_result.h */
15317
15318
15319__BEGIN_DECLS
15320
15321
15322/* Multiplication.
15323 *
15324 * exceptions: GSL_EOVRFLW, GSL_EUNDRFLW
15325 */
15326int gsl_sf_multiply_e(const double x, const double y, gsl_sf_result * result);
15327double gsl_sf_multiply(const double x, const double y);
15328
15329
15330/* Multiplication of quantities with associated errors.
15331 */
15332int gsl_sf_multiply_err_e(const double x, const double dx, const double y, const double dy, gsl_sf_result * result);
15333
15334
15335__END_DECLS
15336
15337#endif /* __GSL_SF_ELEMENTARY_H__ */
15338
15339/* end inlined header: gsl/gsl_sf_elementary.h */
15340/* inlined: error.h */
15341/* inlined: check.h */
15342
15343int
15344gsl_sf_multiply_e(const double x, const double y, gsl_sf_result * result)
15345{
15346 const double ax = fabs(x);
15347 const double ay = fabs(y);
15348
15349 if(x == 0.0 || y == 0.0) {
15350 /* It is necessary to eliminate this immediately.
15351 */
15352 result->val = 0.0;
15353 result->err = 0.0;
15354 return GSL_SUCCESS;
15355 }
15356 else if((ax <= 1.0 && ay >= 1.0) || (ay <= 1.0 && ax >= 1.0)) {
15357 /* Straddling 1.0 is always safe.
15358 */
15359 result->val = x*y;
15360 result->err = 2.0 * GSL_DBL_EPSILON * fabs(result->val);
15361 return GSL_SUCCESS;
15362 }
15363 else {
15364 const double f = 1.0 - 2.0 * GSL_DBL_EPSILON;
15365 const double min = GSL_MIN_DBL(fabs(x), fabs(y));
15366 const double max = GSL_MAX_DBL(fabs(x), fabs(y));
15367 if(max < 0.9 * GSL_SQRT_DBL_MAX || min < (f * DBL_MAX)/max) {
15368 result->val = GSL_COERCE_DBL(x*y);
15369 result->err = 2.0 * GSL_DBL_EPSILON * fabs(result->val);
15370 CHECK_UNDERFLOW(result);
15371 return GSL_SUCCESS;
15372 }
15373 else {
15374 OVERFLOW_ERROR(result);
15375 }
15376 }
15377}
15378
15379
15380int
15381gsl_sf_multiply_err_e(const double x, const double dx,
15382 const double y, const double dy,
15383 gsl_sf_result * result)
15384{
15385 int status = gsl_sf_multiply_e(x, y, result);
15386 result->err += fabs(dx*y) + fabs(dy*x);
15387 return status;
15388}
15389
15390
15391/*-*-*-*-*-*-*-*-*-* Functions w/ Natural Prototypes *-*-*-*-*-*-*-*-*-*-*/
15392
15393/* inlined: eval.h */
15394
15395double gsl_sf_multiply(const double x, const double y)
15396{
15397 EVAL_RESULT(gsl_sf_multiply_e(x, y, &result));
15398}
15399
15400/* end inlined source: specfunc/elementary.c */
15401/* begin inlined source: specfunc/zeta.c */
15402/* specfunc/zeta.c
15403 *
15404 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2004 Gerard Jungman
15405 *
15406 * This program is free software; you can redistribute it and/or modify
15407 * it under the terms of the GNU General Public License as published by
15408 * the Free Software Foundation; either version 3 of the License, or (at
15409 * your option) any later version.
15410 *
15411 * This program is distributed in the hope that it will be useful, but
15412 * WITHOUT ANY WARRANTY; without even the implied warranty of
15413 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15414 * General Public License for more details.
15415 *
15416 * You should have received a copy of the GNU General Public License
15417 * along with this program; if not, write to the Free Software
15418 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15419 */
15420
15421/* Author: G. Jungman */
15422/* begin inlined header: config.h */
15423#ifndef MARLEY_BUILTIN_GSL_CONFIG_WRAPPER_H
15424#define MARLEY_BUILTIN_GSL_CONFIG_WRAPPER_H
15425/* begin inlined header: gsl_config.h */
15426#ifndef MARLEY_BUILTIN_GSL_CONFIG_H
15427#define MARLEY_BUILTIN_GSL_CONFIG_H
15428
15429#define HAVE_INLINE 1
15430#define HAVE_DECL_ISFINITE 1
15431#define HAVE_DECL_ISNAN 1
15432#define HAVE_DECL_ISINF 1
15433#define GSL_COERCE_DBL(x) (x)
15434
15435#define GSL_DISABLE_DEPRECATED 0
15436#define PACKAGE_VERSION "2.8"
15437#define VERSION "2.8"
15438
15439#endif
15440
15441/* end inlined header: gsl_config.h */
15442#endif
15443
15444/* end inlined header: config.h */
15445/* begin inlined header: gsl/gsl_math.h */
15446/* gsl_math.h
15447 *
15448 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2004, 2007 Gerard Jungman, Brian Gough
15449 *
15450 * This program is free software; you can redistribute it and/or modify
15451 * it under the terms of the GNU General Public License as published by
15452 * the Free Software Foundation; either version 3 of the License, or (at
15453 * your option) any later version.
15454 *
15455 * This program is distributed in the hope that it will be useful, but
15456 * WITHOUT ANY WARRANTY; without even the implied warranty of
15457 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15458 * General Public License for more details.
15459 *
15460 * You should have received a copy of the GNU General Public License
15461 * along with this program; if not, write to the Free Software
15462 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15463 */
15464
15465#ifndef __GSL_MATH_H__
15466#define __GSL_MATH_H__
15467#include <math.h>
15468/* begin inlined header: gsl/gsl_sys.h */
15469/* sys/gsl_sys.h
15470 *
15471 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, Brian Gough
15472 *
15473 * This program is free software; you can redistribute it and/or modify
15474 * it under the terms of the GNU General Public License as published by
15475 * the Free Software Foundation; either version 3 of the License, or (at
15476 * your option) any later version.
15477 *
15478 * This program is distributed in the hope that it will be useful, but
15479 * WITHOUT ANY WARRANTY; without even the implied warranty of
15480 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15481 * General Public License for more details.
15482 *
15483 * You should have received a copy of the GNU General Public License
15484 * along with this program; if not, write to the Free Software
15485 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15486 */
15487
15488#ifndef __GSL_SYS_H__
15489#define __GSL_SYS_H__
15490
15491
15492
15493__BEGIN_DECLS
15494
15495double gsl_log1p (const double x);
15496double gsl_expm1 (const double x);
15497double gsl_hypot (const double x, const double y);
15498double gsl_hypot3 (const double x, const double y, const double z);
15499double gsl_acosh (const double x);
15500double gsl_asinh (const double x);
15501double gsl_atanh (const double x);
15502
15503int gsl_isnan (const double x);
15504int gsl_isinf (const double x);
15505int gsl_finite (const double x);
15506
15507double gsl_nan (void);
15508double gsl_posinf (void);
15509double gsl_neginf (void);
15510double gsl_fdiv (const double x, const double y);
15511
15512double gsl_coerce_double (const double x);
15513float gsl_coerce_float (const float x);
15514long double gsl_coerce_long_double (const long double x);
15515
15516double gsl_ldexp(const double x, const int e);
15517double gsl_frexp(const double x, int * e);
15518
15519int gsl_fcmp (const double x1, const double x2, const double epsilon);
15520
15521__END_DECLS
15522
15523#endif /* __GSL_SYS_H__ */
15524
15525/* end inlined header: gsl/gsl_sys.h */
15526/* begin inlined header: gsl/gsl_inline.h */
15527/* gsl_inline.h
15528 *
15529 * Copyright (C) 2008, 2009 Brian Gough
15530 *
15531 * This program is free software; you can redistribute it and/or modify
15532 * it under the terms of the GNU General Public License as published by
15533 * the Free Software Foundation; either version 3 of the License, or (at
15534 * your option) any later version.
15535 *
15536 * This program is distributed in the hope that it will be useful, but
15537 * WITHOUT ANY WARRANTY; without even the implied warranty of
15538 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15539 * General Public License for more details.
15540 *
15541 * You should have received a copy of the GNU General Public License
15542 * along with this program; if not, write to the Free Software
15543 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15544 */
15545
15546#ifndef __GSL_INLINE_H__
15547#define __GSL_INLINE_H__
15548
15549/* In recent versiions of GCC, the inline keyword has two different
15550 forms: GNU and C99.
15551
15552 In GNU mode we can use 'extern inline' to make inline functions
15553 work like macros. The function is only inlined--it is never output
15554 as a definition in an object file.
15555
15556 In the new C99 mode 'extern inline' has a different meaning--it
15557 causes the definition of the function to be output in each object
15558 file where it is used. This will result in multiple-definition
15559 errors on linking. The 'inline' keyword on its own (without
15560 extern) has the same behavior as the original GNU 'extern inline'.
15561
15562 The C99 style is the default with -std=c99 in GCC 4.3.
15563
15564 This header file allows either form of inline to be used by
15565 redefining the macros INLINE_DECL and INLINE_FUN. These are used
15566 in the public header files as
15567
15568 INLINE_DECL double gsl_foo (double x);
15569 #ifdef HAVE_INLINE
15570 INLINE_FUN double gsl_foo (double x) { return x+1.0; } ;
15571 #endif
15572
15573*/
15574
15575#ifdef HAVE_INLINE
15576# if defined(__GNUC_STDC_INLINE__) || defined(GSL_C99_INLINE) || defined(HAVE_C99_INLINE)
15577# define INLINE_DECL inline /* use C99 inline */
15578# define INLINE_FUN inline
15579# else
15580# define INLINE_DECL /* use GNU extern inline */
15581# define INLINE_FUN extern inline
15582# endif
15583#else
15584# define INLINE_DECL /* */
15585#endif
15586
15587/* Range checking conditions in headers do not require any run-time
15588 tests of the global variable gsl_check_range. They are enabled or
15589 disabled in user code at compile time with GSL_RANGE_CHECK macro.
15590 See also build.h. */
15591#define GSL_RANGE_COND(x) (x)
15592
15593#endif /* __GSL_INLINE_H__ */
15594
15595/* end inlined header: gsl/gsl_inline.h */
15596/* begin inlined header: gsl/gsl_machine.h */
15597/* Author: B. Gough and G. Jungman */
15598#ifndef __GSL_MACHINE_H__
15599#define __GSL_MACHINE_H__
15600
15601#include <limits.h>
15602#include <float.h>
15603
15604/* magic constants; mostly for the benefit of the implementation */
15605
15606/* -*-MACHINE CONSTANTS-*-
15607 *
15608 * PLATFORM: Whiz-O-Matic 9000
15609 * FP_PLATFORM: IEEE-Virtual
15610 * HOSTNAME: nnn.lanl.gov
15611 * DATE: Fri Nov 20 17:53:26 MST 1998
15612 */
15613#define GSL_DBL_EPSILON 2.2204460492503131e-16
15614#define GSL_SQRT_DBL_EPSILON 1.4901161193847656e-08
15615#define GSL_ROOT3_DBL_EPSILON 6.0554544523933429e-06
15616#define GSL_ROOT4_DBL_EPSILON 1.2207031250000000e-04
15617#define GSL_ROOT5_DBL_EPSILON 7.4009597974140505e-04
15618#define GSL_ROOT6_DBL_EPSILON 2.4607833005759251e-03
15619#define GSL_LOG_DBL_EPSILON (-3.6043653389117154e+01)
15620
15621#define GSL_DBL_MIN 2.2250738585072014e-308
15622#define GSL_SQRT_DBL_MIN 1.4916681462400413e-154
15623#define GSL_ROOT3_DBL_MIN 2.8126442852362996e-103
15624#define GSL_ROOT4_DBL_MIN 1.2213386697554620e-77
15625#define GSL_ROOT5_DBL_MIN 2.9476022969691763e-62
15626#define GSL_ROOT6_DBL_MIN 5.3034368905798218e-52
15627#define GSL_LOG_DBL_MIN (-7.0839641853226408e+02)
15628
15629#define GSL_DBL_MAX 1.7976931348623157e+308
15630#define GSL_SQRT_DBL_MAX 1.3407807929942596e+154
15631#define GSL_ROOT3_DBL_MAX 5.6438030941222897e+102
15632#define GSL_ROOT4_DBL_MAX 1.1579208923731620e+77
15633#define GSL_ROOT5_DBL_MAX 4.4765466227572707e+61
15634#define GSL_ROOT6_DBL_MAX 2.3756689782295612e+51
15635#define GSL_LOG_DBL_MAX 7.0978271289338397e+02
15636
15637#define GSL_FLT_EPSILON 1.1920928955078125e-07
15638#define GSL_SQRT_FLT_EPSILON 3.4526698300124393e-04
15639#define GSL_ROOT3_FLT_EPSILON 4.9215666011518501e-03
15640#define GSL_ROOT4_FLT_EPSILON 1.8581361171917516e-02
15641#define GSL_ROOT5_FLT_EPSILON 4.1234622211652937e-02
15642#define GSL_ROOT6_FLT_EPSILON 7.0153878019335827e-02
15643#define GSL_LOG_FLT_EPSILON (-1.5942385152878742e+01)
15644
15645#define GSL_FLT_MIN 1.1754943508222875e-38
15646#define GSL_SQRT_FLT_MIN 1.0842021724855044e-19
15647#define GSL_ROOT3_FLT_MIN 2.2737367544323241e-13
15648#define GSL_ROOT4_FLT_MIN 3.2927225399135965e-10
15649#define GSL_ROOT5_FLT_MIN 2.5944428542140822e-08
15650#define GSL_ROOT6_FLT_MIN 4.7683715820312542e-07
15651#define GSL_LOG_FLT_MIN (-8.7336544750553102e+01)
15652
15653#define GSL_FLT_MAX 3.4028234663852886e+38
15654#define GSL_SQRT_FLT_MAX 1.8446743523953730e+19
15655#define GSL_ROOT3_FLT_MAX 6.9814635196223242e+12
15656#define GSL_ROOT4_FLT_MAX 4.2949672319999986e+09
15657#define GSL_ROOT5_FLT_MAX 5.0859007855960041e+07
15658#define GSL_ROOT6_FLT_MAX 2.6422459233807749e+06
15659#define GSL_LOG_FLT_MAX 8.8722839052068352e+01
15660
15661#define GSL_SFLT_EPSILON 4.8828125000000000e-04
15662#define GSL_SQRT_SFLT_EPSILON 2.2097086912079612e-02
15663#define GSL_ROOT3_SFLT_EPSILON 7.8745065618429588e-02
15664#define GSL_ROOT4_SFLT_EPSILON 1.4865088937534013e-01
15665#define GSL_ROOT5_SFLT_EPSILON 2.1763764082403100e-01
15666#define GSL_ROOT6_SFLT_EPSILON 2.8061551207734325e-01
15667#define GSL_LOG_SFLT_EPSILON (-7.6246189861593985e+00)
15668
15669/* !MACHINE CONSTANTS! */
15670
15671
15672/* a little internal backwards compatibility */
15673#define GSL_MACH_EPS GSL_DBL_EPSILON
15674
15675
15676
15677/* Here are the constants related to or derived from
15678 * machine constants. These are not to be confused with
15679 * the constants that define various precision levels
15680 * for the precision/error system.
15681 *
15682 * This information is determined at configure time
15683 * and is platform dependent. Edit at your own risk.
15684 *
15685 * PLATFORM: WHIZ-O-MATIC
15686 * CONFIG-DATE: Thu Nov 19 19:27:18 MST 1998
15687 * CONFIG-HOST: nnn.lanl.gov
15688 */
15689
15690/* machine precision constants */
15691/* #define GSL_MACH_EPS 1.0e-15 */
15692#define GSL_SQRT_MACH_EPS 3.2e-08
15693#define GSL_ROOT3_MACH_EPS 1.0e-05
15694#define GSL_ROOT4_MACH_EPS 0.000178
15695#define GSL_ROOT5_MACH_EPS 0.00100
15696#define GSL_ROOT6_MACH_EPS 0.00316
15697#define GSL_LOG_MACH_EPS (-34.54)
15698
15699
15700#endif /* __GSL_MACHINE_H__ */
15701
15702/* end inlined header: gsl/gsl_machine.h */
15703/* begin inlined header: gsl/gsl_precision.h */
15704/* gsl_precision.h
15705 *
15706 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
15707 *
15708 * This program is free software; you can redistribute it and/or modify
15709 * it under the terms of the GNU General Public License as published by
15710 * the Free Software Foundation; either version 3 of the License, or (at
15711 * your option) any later version.
15712 *
15713 * This program is distributed in the hope that it will be useful, but
15714 * WITHOUT ANY WARRANTY; without even the implied warranty of
15715 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15716 * General Public License for more details.
15717 *
15718 * You should have received a copy of the GNU General Public License
15719 * along with this program; if not, write to the Free Software
15720 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15721 */
15722
15723/* Author: B. Gough and G. Jungman */
15724
15725#ifndef __GSL_PRECISION_H__
15726#define __GSL_PRECISION_H__
15727/* begin inlined header: gsl/gsl_types.h */
15728/* gsl_types.h
15729 *
15730 * Copyright (C) 2001, 2007 Brian Gough
15731 *
15732 * This program is free software; you can redistribute it and/or modify
15733 * it under the terms of the GNU General Public License as published by
15734 * the Free Software Foundation; either version 3 of the License, or (at
15735 * your option) any later version.
15736 *
15737 * This program is distributed in the hope that it will be useful, but
15738 * WITHOUT ANY WARRANTY; without even the implied warranty of
15739 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15740 * General Public License for more details.
15741 *
15742 * You should have received a copy of the GNU General Public License
15743 * along with this program; if not, write to the Free Software
15744 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15745 */
15746
15747#ifndef __GSL_TYPES_H__
15748#define __GSL_TYPES_H__
15749
15750#ifndef GSL_VAR
15751
15752#ifdef WIN32
15753# ifdef GSL_DLL
15754# ifdef DLL_EXPORT
15755# define GSL_VAR extern __declspec(dllexport)
15756# else
15757# define GSL_VAR extern __declspec(dllimport)
15758# endif
15759# else
15760# define GSL_VAR extern
15761# endif
15762#else
15763# define GSL_VAR extern
15764#endif
15765
15766#endif
15767
15768#endif /* __GSL_TYPES_H__ */
15769
15770/* end inlined header: gsl/gsl_types.h */
15771
15772
15773__BEGIN_DECLS
15774
15775
15776/* A type for the precision indicator.
15777 * This is mainly for pedagogy.
15778 */
15779typedef unsigned int gsl_prec_t;
15780
15781
15782/* The number of precision types.
15783 * Remember that precision-mode
15784 * can index an array.
15785 */
15786#define _GSL_PREC_T_NUM 3
15787
15788
15789/* Arrays containing derived
15790 * precision constants for the
15791 * different precision levels.
15792 */
15793GSL_VAR const double gsl_prec_eps[];
15794GSL_VAR const double gsl_prec_sqrt_eps[];
15795GSL_VAR const double gsl_prec_root3_eps[];
15796GSL_VAR const double gsl_prec_root4_eps[];
15797GSL_VAR const double gsl_prec_root5_eps[];
15798GSL_VAR const double gsl_prec_root6_eps[];
15799
15800
15801__END_DECLS
15802
15803#endif /* __GSL_PRECISION_H__ */
15804
15805/* end inlined header: gsl/gsl_precision.h */
15806/* begin inlined header: gsl/gsl_nan.h */
15807/* gsl_nan.h
15808 *
15809 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, Brian Gough
15810 *
15811 * This program is free software; you can redistribute it and/or modify
15812 * it under the terms of the GNU General Public License as published by
15813 * the Free Software Foundation; either version 3 of the License, or (at
15814 * your option) any later version.
15815 *
15816 * This program is distributed in the hope that it will be useful, but
15817 * WITHOUT ANY WARRANTY; without even the implied warranty of
15818 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15819 * General Public License for more details.
15820 *
15821 * You should have received a copy of the GNU General Public License
15822 * along with this program; if not, write to the Free Software
15823 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15824 */
15825
15826#ifndef __GSL_NAN_H__
15827#define __GSL_NAN_H__
15828
15829#ifdef INFINITY
15830# define GSL_POSINF INFINITY
15831# define GSL_NEGINF (-INFINITY)
15832#elif defined(HUGE_VAL)
15833# define GSL_POSINF HUGE_VAL
15834# define GSL_NEGINF (-HUGE_VAL)
15835#else
15836# define GSL_POSINF (gsl_posinf())
15837# define GSL_NEGINF (gsl_neginf())
15838#endif
15839
15840#ifdef NAN
15841# define GSL_NAN NAN
15842#elif defined(INFINITY)
15843# define GSL_NAN (INFINITY/INFINITY)
15844#else
15845# define GSL_NAN (gsl_nan())
15846#endif
15847
15848#define GSL_POSZERO (+0.0)
15849#define GSL_NEGZERO (-0.0)
15850
15851#endif /* __GSL_NAN_H__ */
15852
15853/* end inlined header: gsl/gsl_nan.h */
15854/* begin inlined header: gsl/gsl_pow_int.h */
15855/* gsl_pow_int.h
15856 *
15857 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2004, 2007 Gerard Jungman, Brian Gough
15858 *
15859 * This program is free software; you can redistribute it and/or modify
15860 * it under the terms of the GNU General Public License as published by
15861 * the Free Software Foundation; either version 3 of the License, or (at
15862 * your option) any later version.
15863 *
15864 * This program is distributed in the hope that it will be useful, but
15865 * WITHOUT ANY WARRANTY; without even the implied warranty of
15866 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15867 * General Public License for more details.
15868 *
15869 * You should have received a copy of the GNU General Public License
15870 * along with this program; if not, write to the Free Software
15871 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15872 */
15873
15874#ifndef __GSL_POW_INT_H__
15875#define __GSL_POW_INT_H__
15876/* begin inlined header: gsl/gsl_inline.h */
15877/* gsl_inline.h
15878 *
15879 * Copyright (C) 2008, 2009 Brian Gough
15880 *
15881 * This program is free software; you can redistribute it and/or modify
15882 * it under the terms of the GNU General Public License as published by
15883 * the Free Software Foundation; either version 3 of the License, or (at
15884 * your option) any later version.
15885 *
15886 * This program is distributed in the hope that it will be useful, but
15887 * WITHOUT ANY WARRANTY; without even the implied warranty of
15888 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15889 * General Public License for more details.
15890 *
15891 * You should have received a copy of the GNU General Public License
15892 * along with this program; if not, write to the Free Software
15893 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15894 */
15895
15896#ifndef __GSL_INLINE_H__
15897#define __GSL_INLINE_H__
15898
15899/* In recent versiions of GCC, the inline keyword has two different
15900 forms: GNU and C99.
15901
15902 In GNU mode we can use 'extern inline' to make inline functions
15903 work like macros. The function is only inlined--it is never output
15904 as a definition in an object file.
15905
15906 In the new C99 mode 'extern inline' has a different meaning--it
15907 causes the definition of the function to be output in each object
15908 file where it is used. This will result in multiple-definition
15909 errors on linking. The 'inline' keyword on its own (without
15910 extern) has the same behavior as the original GNU 'extern inline'.
15911
15912 The C99 style is the default with -std=c99 in GCC 4.3.
15913
15914 This header file allows either form of inline to be used by
15915 redefining the macros INLINE_DECL and INLINE_FUN. These are used
15916 in the public header files as
15917
15918 INLINE_DECL double gsl_foo (double x);
15919 #ifdef HAVE_INLINE
15920 INLINE_FUN double gsl_foo (double x) { return x+1.0; } ;
15921 #endif
15922
15923*/
15924
15925#ifdef HAVE_INLINE
15926# if defined(__GNUC_STDC_INLINE__) || defined(GSL_C99_INLINE) || defined(HAVE_C99_INLINE)
15927# define INLINE_DECL inline /* use C99 inline */
15928# define INLINE_FUN inline
15929# else
15930# define INLINE_DECL /* use GNU extern inline */
15931# define INLINE_FUN extern inline
15932# endif
15933#else
15934# define INLINE_DECL /* */
15935#endif
15936
15937/* Range checking conditions in headers do not require any run-time
15938 tests of the global variable gsl_check_range. They are enabled or
15939 disabled in user code at compile time with GSL_RANGE_CHECK macro.
15940 See also build.h. */
15941#define GSL_RANGE_COND(x) (x)
15942
15943#endif /* __GSL_INLINE_H__ */
15944
15945/* end inlined header: gsl/gsl_inline.h */
15946
15947
15948__BEGIN_DECLS
15949
15950INLINE_DECL double gsl_pow_2(const double x);
15951INLINE_DECL double gsl_pow_3(const double x);
15952INLINE_DECL double gsl_pow_4(const double x);
15953INLINE_DECL double gsl_pow_5(const double x);
15954INLINE_DECL double gsl_pow_6(const double x);
15955INLINE_DECL double gsl_pow_7(const double x);
15956INLINE_DECL double gsl_pow_8(const double x);
15957INLINE_DECL double gsl_pow_9(const double x);
15958
15959#ifdef HAVE_INLINE
15960INLINE_FUN double gsl_pow_2(const double x) { return x*x; }
15961INLINE_FUN double gsl_pow_3(const double x) { return x*x*x; }
15962INLINE_FUN double gsl_pow_4(const double x) { double x2 = x*x; return x2*x2; }
15963INLINE_FUN double gsl_pow_5(const double x) { double x2 = x*x; return x2*x2*x; }
15964INLINE_FUN double gsl_pow_6(const double x) { double x2 = x*x; return x2*x2*x2; }
15965INLINE_FUN double gsl_pow_7(const double x) { double x3 = x*x*x; return x3*x3*x; }
15966INLINE_FUN double gsl_pow_8(const double x) { double x2 = x*x; double x4 = x2*x2; return x4*x4; }
15967INLINE_FUN double gsl_pow_9(const double x) { double x3 = x*x*x; return x3*x3*x3; }
15968#endif
15969
15970double gsl_pow_int(double x, int n);
15971double gsl_pow_uint(double x, unsigned int n);
15972
15973__END_DECLS
15974
15975#endif /* __GSL_POW_INT_H__ */
15976
15977/* end inlined header: gsl/gsl_pow_int.h */
15978/* begin inlined header: gsl/gsl_minmax.h */
15979/* gsl_minmax.h
15980 *
15981 * Copyright (C) 2008 Gerard Jungman, Brian Gough
15982 *
15983 * This program is free software; you can redistribute it and/or modify
15984 * it under the terms of the GNU General Public License as published by
15985 * the Free Software Foundation; either version 3 of the License, or (at
15986 * your option) any later version.
15987 *
15988 * This program is distributed in the hope that it will be useful, but
15989 * WITHOUT ANY WARRANTY; without even the implied warranty of
15990 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15991 * General Public License for more details.
15992 *
15993 * You should have received a copy of the GNU General Public License
15994 * along with this program; if not, write to the Free Software
15995 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15996 */
15997
15998#ifndef __GSL_MINMAX_H__
15999#define __GSL_MINMAX_H__
16000/* begin inlined header: gsl/gsl_inline.h */
16001/* gsl_inline.h
16002 *
16003 * Copyright (C) 2008, 2009 Brian Gough
16004 *
16005 * This program is free software; you can redistribute it and/or modify
16006 * it under the terms of the GNU General Public License as published by
16007 * the Free Software Foundation; either version 3 of the License, or (at
16008 * your option) any later version.
16009 *
16010 * This program is distributed in the hope that it will be useful, but
16011 * WITHOUT ANY WARRANTY; without even the implied warranty of
16012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16013 * General Public License for more details.
16014 *
16015 * You should have received a copy of the GNU General Public License
16016 * along with this program; if not, write to the Free Software
16017 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16018 */
16019
16020#ifndef __GSL_INLINE_H__
16021#define __GSL_INLINE_H__
16022
16023/* In recent versiions of GCC, the inline keyword has two different
16024 forms: GNU and C99.
16025
16026 In GNU mode we can use 'extern inline' to make inline functions
16027 work like macros. The function is only inlined--it is never output
16028 as a definition in an object file.
16029
16030 In the new C99 mode 'extern inline' has a different meaning--it
16031 causes the definition of the function to be output in each object
16032 file where it is used. This will result in multiple-definition
16033 errors on linking. The 'inline' keyword on its own (without
16034 extern) has the same behavior as the original GNU 'extern inline'.
16035
16036 The C99 style is the default with -std=c99 in GCC 4.3.
16037
16038 This header file allows either form of inline to be used by
16039 redefining the macros INLINE_DECL and INLINE_FUN. These are used
16040 in the public header files as
16041
16042 INLINE_DECL double gsl_foo (double x);
16043 #ifdef HAVE_INLINE
16044 INLINE_FUN double gsl_foo (double x) { return x+1.0; } ;
16045 #endif
16046
16047*/
16048
16049#ifdef HAVE_INLINE
16050# if defined(__GNUC_STDC_INLINE__) || defined(GSL_C99_INLINE) || defined(HAVE_C99_INLINE)
16051# define INLINE_DECL inline /* use C99 inline */
16052# define INLINE_FUN inline
16053# else
16054# define INLINE_DECL /* use GNU extern inline */
16055# define INLINE_FUN extern inline
16056# endif
16057#else
16058# define INLINE_DECL /* */
16059#endif
16060
16061/* Range checking conditions in headers do not require any run-time
16062 tests of the global variable gsl_check_range. They are enabled or
16063 disabled in user code at compile time with GSL_RANGE_CHECK macro.
16064 See also build.h. */
16065#define GSL_RANGE_COND(x) (x)
16066
16067#endif /* __GSL_INLINE_H__ */
16068
16069/* end inlined header: gsl/gsl_inline.h */
16070
16071
16072__BEGIN_DECLS
16073
16074/* Define MAX and MIN macros/functions if they don't exist. */
16075
16076/* plain old macros for general use */
16077#define GSL_MAX(a,b) ((a) > (b) ? (a) : (b))
16078#define GSL_MIN(a,b) ((a) < (b) ? (a) : (b))
16079
16080/* function versions of the above, in case they are needed */
16081double gsl_max (double a, double b);
16082double gsl_min (double a, double b);
16083
16084/* inline-friendly strongly typed versions */
16085#ifdef HAVE_INLINE
16086
16087INLINE_FUN int GSL_MAX_INT (int a, int b);
16088INLINE_FUN int GSL_MIN_INT (int a, int b);
16089INLINE_FUN double GSL_MAX_DBL (double a, double b);
16090INLINE_FUN double GSL_MIN_DBL (double a, double b);
16091INLINE_FUN long double GSL_MAX_LDBL (long double a, long double b);
16092INLINE_FUN long double GSL_MIN_LDBL (long double a, long double b);
16093
16094INLINE_FUN int
16095GSL_MAX_INT (int a, int b)
16096{
16097 return GSL_MAX (a, b);
16098}
16099
16100INLINE_FUN int
16101GSL_MIN_INT (int a, int b)
16102{
16103 return GSL_MIN (a, b);
16104}
16105
16106INLINE_FUN double
16107GSL_MAX_DBL (double a, double b)
16108{
16109 return GSL_MAX (a, b);
16110}
16111
16112INLINE_FUN double
16113GSL_MIN_DBL (double a, double b)
16114{
16115 return GSL_MIN (a, b);
16116}
16117
16118INLINE_FUN long double
16119GSL_MAX_LDBL (long double a, long double b)
16120{
16121 return GSL_MAX (a, b);
16122}
16123
16124INLINE_FUN long double
16125GSL_MIN_LDBL (long double a, long double b)
16126{
16127 return GSL_MIN (a, b);
16128}
16129#else
16130#define GSL_MAX_INT(a,b) GSL_MAX(a,b)
16131#define GSL_MIN_INT(a,b) GSL_MIN(a,b)
16132#define GSL_MAX_DBL(a,b) GSL_MAX(a,b)
16133#define GSL_MIN_DBL(a,b) GSL_MIN(a,b)
16134#define GSL_MAX_LDBL(a,b) GSL_MAX(a,b)
16135#define GSL_MIN_LDBL(a,b) GSL_MIN(a,b)
16136#endif /* HAVE_INLINE */
16137
16138__END_DECLS
16139
16140#endif /* __GSL_POW_INT_H__ */
16141
16142/* end inlined header: gsl/gsl_minmax.h */
16143#ifndef M_E
16144#define M_E 2.71828182845904523536028747135 /* e */
16145#endif
16146
16147#ifndef M_LOG2E
16148#define M_LOG2E 1.44269504088896340735992468100 /* log_2 (e) */
16149#endif
16150
16151#ifndef M_LOG10E
16152#define M_LOG10E 0.43429448190325182765112891892 /* log_10 (e) */
16153#endif
16154
16155#ifndef M_SQRT2
16156#define M_SQRT2 1.41421356237309504880168872421 /* sqrt(2) */
16157#endif
16158
16159#ifndef M_SQRT1_2
16160#define M_SQRT1_2 0.70710678118654752440084436210 /* sqrt(1/2) */
16161#endif
16162
16163
16164#ifndef M_SQRT3
16165#define M_SQRT3 1.73205080756887729352744634151 /* sqrt(3) */
16166#endif
16167
16168#ifndef M_PI
16169#define M_PI 3.14159265358979323846264338328 /* pi */
16170#endif
16171
16172#ifndef M_PI_2
16173#define M_PI_2 1.57079632679489661923132169164 /* pi/2 */
16174#endif
16175
16176#ifndef M_PI_4
16177#define M_PI_4 0.78539816339744830961566084582 /* pi/4 */
16178#endif
16179
16180#ifndef M_SQRTPI
16181#define M_SQRTPI 1.77245385090551602729816748334 /* sqrt(pi) */
16182#endif
16183
16184#ifndef M_2_SQRTPI
16185#define M_2_SQRTPI 1.12837916709551257389615890312 /* 2/sqrt(pi) */
16186#endif
16187
16188#ifndef M_1_PI
16189#define M_1_PI 0.31830988618379067153776752675 /* 1/pi */
16190#endif
16191
16192#ifndef M_2_PI
16193#define M_2_PI 0.63661977236758134307553505349 /* 2/pi */
16194#endif
16195
16196#ifndef M_LN10
16197#define M_LN10 2.30258509299404568401799145468 /* ln(10) */
16198#endif
16199
16200#ifndef M_LN2
16201#define M_LN2 0.69314718055994530941723212146 /* ln(2) */
16202#endif
16203
16204#ifndef M_LNPI
16205#define M_LNPI 1.14472988584940017414342735135 /* ln(pi) */
16206#endif
16207
16208#ifndef M_EULER
16209#define M_EULER 0.57721566490153286060651209008 /* Euler constant */
16210#endif
16211
16212
16213
16214__BEGIN_DECLS
16215
16216/* other needlessly compulsive abstractions */
16217
16218#define GSL_IS_ODD(n) ((n) & 1)
16219#define GSL_IS_EVEN(n) (!(GSL_IS_ODD(n)))
16220#define GSL_SIGN(x) ((x) >= 0.0 ? 1 : -1)
16221
16222/* Return nonzero if x is a real number, i.e. non NaN or infinite. */
16223#define GSL_IS_REAL(x) (gsl_finite(x))
16224
16225/* Definition of an arbitrary function with parameters */
16226
16228{
16229 double (* function) (double x, void * params);
16230 void * params;
16231};
16232
16233typedef struct gsl_function_struct gsl_function ;
16234
16235#define GSL_FN_EVAL(F,x) (*((F)->function))(x,(F)->params)
16236
16237/* Definition of an arbitrary function returning two values, r1, r2 */
16238
16240{
16241 double (* f) (double x, void * params);
16242 double (* df) (double x, void * params);
16243 void (* fdf) (double x, void * params, double * f, double * df);
16244 void * params;
16245};
16246
16247typedef struct gsl_function_fdf_struct gsl_function_fdf ;
16248
16249#define GSL_FN_FDF_EVAL_F(FDF,x) (*((FDF)->f))(x,(FDF)->params)
16250#define GSL_FN_FDF_EVAL_DF(FDF,x) (*((FDF)->df))(x,(FDF)->params)
16251#define GSL_FN_FDF_EVAL_F_DF(FDF,x,y,dy) (*((FDF)->fdf))(x,(FDF)->params,(y),(dy))
16252
16253
16254/* Definition of an arbitrary vector-valued function with parameters */
16255
16257{
16258 int (* function) (double x, double y[], void * params);
16259 void * params;
16260};
16261
16262typedef struct gsl_function_vec_struct gsl_function_vec ;
16263
16264#define GSL_FN_VEC_EVAL(F,x,y) (*((F)->function))(x,y,(F)->params)
16265
16266__END_DECLS
16267
16268#endif /* __GSL_MATH_H__ */
16269
16270/* end inlined header: gsl/gsl_math.h */
16271/* begin inlined header: gsl/gsl_errno.h */
16272/* err/gsl_errno.h
16273 *
16274 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, Brian Gough
16275 *
16276 * This program is free software; you can redistribute it and/or modify
16277 * it under the terms of the GNU General Public License as published by
16278 * the Free Software Foundation; either version 3 of the License, or (at
16279 * your option) any later version.
16280 *
16281 * This program is distributed in the hope that it will be useful, but
16282 * WITHOUT ANY WARRANTY; without even the implied warranty of
16283 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16284 * General Public License for more details.
16285 *
16286 * You should have received a copy of the GNU General Public License
16287 * along with this program; if not, write to the Free Software
16288 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16289 */
16290
16291#ifndef __GSL_ERRNO_H__
16292#define __GSL_ERRNO_H__
16293
16294#include <stdio.h>
16295#include <errno.h>
16296/* begin inlined header: gsl/gsl_types.h */
16297/* gsl_types.h
16298 *
16299 * Copyright (C) 2001, 2007 Brian Gough
16300 *
16301 * This program is free software; you can redistribute it and/or modify
16302 * it under the terms of the GNU General Public License as published by
16303 * the Free Software Foundation; either version 3 of the License, or (at
16304 * your option) any later version.
16305 *
16306 * This program is distributed in the hope that it will be useful, but
16307 * WITHOUT ANY WARRANTY; without even the implied warranty of
16308 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16309 * General Public License for more details.
16310 *
16311 * You should have received a copy of the GNU General Public License
16312 * along with this program; if not, write to the Free Software
16313 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16314 */
16315
16316#ifndef __GSL_TYPES_H__
16317#define __GSL_TYPES_H__
16318
16319#ifndef GSL_VAR
16320
16321#ifdef WIN32
16322# ifdef GSL_DLL
16323# ifdef DLL_EXPORT
16324# define GSL_VAR extern __declspec(dllexport)
16325# else
16326# define GSL_VAR extern __declspec(dllimport)
16327# endif
16328# else
16329# define GSL_VAR extern
16330# endif
16331#else
16332# define GSL_VAR extern
16333#endif
16334
16335#endif
16336
16337#endif /* __GSL_TYPES_H__ */
16338
16339/* end inlined header: gsl/gsl_types.h */
16340
16341
16342__BEGIN_DECLS
16343
16344enum {
16345 GSL_SUCCESS = 0,
16346 GSL_FAILURE = -1,
16347 GSL_CONTINUE = -2, /* iteration has not converged */
16348 GSL_EDOM = 1, /* input domain error, e.g sqrt(-1) */
16349 GSL_ERANGE = 2, /* output range error, e.g. exp(1e100) */
16350 GSL_EFAULT = 3, /* invalid pointer */
16351 GSL_EINVAL = 4, /* invalid argument supplied by user */
16352 GSL_EFAILED = 5, /* generic failure */
16353 GSL_EFACTOR = 6, /* factorization failed */
16354 GSL_ESANITY = 7, /* sanity check failed - shouldn't happen */
16355 GSL_ENOMEM = 8, /* malloc failed */
16356 GSL_EBADFUNC = 9, /* problem with user-supplied function */
16357 GSL_ERUNAWAY = 10, /* iterative process is out of control */
16358 GSL_EMAXITER = 11, /* exceeded max number of iterations */
16359 GSL_EZERODIV = 12, /* tried to divide by zero */
16360 GSL_EBADTOL = 13, /* user specified an invalid tolerance */
16361 GSL_ETOL = 14, /* failed to reach the specified tolerance */
16362 GSL_EUNDRFLW = 15, /* underflow */
16363 GSL_EOVRFLW = 16, /* overflow */
16364 GSL_ELOSS = 17, /* loss of accuracy */
16365 GSL_EROUND = 18, /* failed because of roundoff error */
16366 GSL_EBADLEN = 19, /* matrix, vector lengths are not conformant */
16367 GSL_ENOTSQR = 20, /* matrix not square */
16368 GSL_ESING = 21, /* apparent singularity detected */
16369 GSL_EDIVERGE = 22, /* integral or series is divergent */
16370 GSL_EUNSUP = 23, /* requested feature is not supported by the hardware */
16371 GSL_EUNIMPL = 24, /* requested feature not (yet) implemented */
16372 GSL_ECACHE = 25, /* cache limit exceeded */
16373 GSL_ETABLE = 26, /* table limit exceeded */
16374 GSL_ENOPROG = 27, /* iteration is not making progress towards solution */
16375 GSL_ENOPROGJ = 28, /* jacobian evaluations are not improving the solution */
16376 GSL_ETOLF = 29, /* cannot reach the specified tolerance in F */
16377 GSL_ETOLX = 30, /* cannot reach the specified tolerance in X */
16378 GSL_ETOLG = 31, /* cannot reach the specified tolerance in gradient */
16379 GSL_EOF = 32 /* end of file */
16380} ;
16381
16382void gsl_error (const char * reason, const char * file, int line,
16383 int gsl_errno);
16384
16385void gsl_stream_printf (const char *label, const char *file,
16386 int line, const char *reason);
16387
16388typedef void gsl_error_handler_t (const char * reason, const char * file,
16389 int line, int gsl_errno);
16390
16391gsl_error_handler_t *
16392gsl_set_error_handler (gsl_error_handler_t * new_handler);
16393
16394/* GSL_ERROR: call the error handler, and return the error code */
16395
16396#define GSL_ERROR(reason, gsl_errno) \
16397 do { \
16398 gsl_error (reason, __FILE__, __LINE__, gsl_errno) ; \
16399 return gsl_errno ; \
16400 } while (0)
16401
16402/* GSL_ERROR_VAL: call the error handler, and return the given value */
16403
16404#define GSL_ERROR_VAL(reason, gsl_errno, value) \
16405 do { \
16406 gsl_error (reason, __FILE__, __LINE__, gsl_errno) ; \
16407 return value ; \
16408 } while (0)
16409
16410/* GSL_ERROR_VOID: call the error handler, and then return
16411 (for void functions which still need to generate an error) */
16412
16413#define GSL_ERROR_VOID(reason, gsl_errno) \
16414 do { \
16415 gsl_error (reason, __FILE__, __LINE__, gsl_errno) ; \
16416 return ; \
16417 } while (0)
16418
16419/* GSL_ERROR_NULL suitable for out-of-memory conditions */
16420
16421#define GSL_ERROR_NULL(reason, gsl_errno) GSL_ERROR_VAL(reason, gsl_errno, 0)
16422
16423/* Sometimes you have several status results returned from
16424 * function calls and you want to combine them in some sensible
16425 * way. You cannot produce a "total" status condition, but you can
16426 * pick one from a set of conditions based on an implied hierarchy.
16427 *
16428 * In other words:
16429 * you have: status_a, status_b, ...
16430 * you want: status = (status_a if it is bad, or status_b if it is bad,...)
16431 *
16432 * In this example you consider status_a to be more important and
16433 * it is checked first, followed by the others in the order specified.
16434 *
16435 * Here are some dumb macros to do this.
16436 */
16437#define GSL_ERROR_SELECT_2(a,b) ((a) != GSL_SUCCESS ? (a) : ((b) != GSL_SUCCESS ? (b) : GSL_SUCCESS))
16438#define GSL_ERROR_SELECT_3(a,b,c) ((a) != GSL_SUCCESS ? (a) : GSL_ERROR_SELECT_2(b,c))
16439#define GSL_ERROR_SELECT_4(a,b,c,d) ((a) != GSL_SUCCESS ? (a) : GSL_ERROR_SELECT_3(b,c,d))
16440#define GSL_ERROR_SELECT_5(a,b,c,d,e) ((a) != GSL_SUCCESS ? (a) : GSL_ERROR_SELECT_4(b,c,d,e))
16441
16442#define GSL_STATUS_UPDATE(sp, s) do { if ((s) != GSL_SUCCESS) *(sp) = (s);} while(0)
16443
16444__END_DECLS
16445
16446#endif /* __GSL_ERRNO_H__ */
16447
16448/* end inlined header: gsl/gsl_errno.h */
16449/* begin inlined header: gsl/gsl_sf_elementary.h */
16450/* specfunc/gsl_sf_elementary.h
16451 *
16452 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
16453 *
16454 * This program is free software; you can redistribute it and/or modify
16455 * it under the terms of the GNU General Public License as published by
16456 * the Free Software Foundation; either version 3 of the License, or (at
16457 * your option) any later version.
16458 *
16459 * This program is distributed in the hope that it will be useful, but
16460 * WITHOUT ANY WARRANTY; without even the implied warranty of
16461 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16462 * General Public License for more details.
16463 *
16464 * You should have received a copy of the GNU General Public License
16465 * along with this program; if not, write to the Free Software
16466 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16467 */
16468
16469/* Author: G. Jungman */
16470
16471/* Miscellaneous elementary functions and operations.
16472 */
16473#ifndef __GSL_SF_ELEMENTARY_H__
16474#define __GSL_SF_ELEMENTARY_H__
16475/* begin inlined header: gsl/gsl_sf_result.h */
16476/* specfunc/gsl_sf_result.h
16477 *
16478 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
16479 *
16480 * This program is free software; you can redistribute it and/or modify
16481 * it under the terms of the GNU General Public License as published by
16482 * the Free Software Foundation; either version 3 of the License, or (at
16483 * your option) any later version.
16484 *
16485 * This program is distributed in the hope that it will be useful, but
16486 * WITHOUT ANY WARRANTY; without even the implied warranty of
16487 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16488 * General Public License for more details.
16489 *
16490 * You should have received a copy of the GNU General Public License
16491 * along with this program; if not, write to the Free Software
16492 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16493 */
16494
16495/* Author: G. Jungman */
16496
16497#ifndef __GSL_SF_RESULT_H__
16498#define __GSL_SF_RESULT_H__
16499
16500
16501
16502__BEGIN_DECLS
16503
16504struct gsl_sf_result_struct {
16505 double val;
16506 double err;
16507};
16508typedef struct gsl_sf_result_struct gsl_sf_result;
16509
16510#define GSL_SF_RESULT_SET(r,v,e) do { (r)->val=(v); (r)->err=(e); } while(0)
16511
16512
16514 double val;
16515 double err;
16516 int e10;
16517};
16518typedef struct gsl_sf_result_e10_struct gsl_sf_result_e10;
16519
16520
16521int gsl_sf_result_smash_e(const gsl_sf_result_e10 * re, gsl_sf_result * r);
16522
16523
16524__END_DECLS
16525
16526#endif /* __GSL_SF_RESULT_H__ */
16527
16528/* end inlined header: gsl/gsl_sf_result.h */
16529
16530
16531__BEGIN_DECLS
16532
16533
16534/* Multiplication.
16535 *
16536 * exceptions: GSL_EOVRFLW, GSL_EUNDRFLW
16537 */
16538int gsl_sf_multiply_e(const double x, const double y, gsl_sf_result * result);
16539double gsl_sf_multiply(const double x, const double y);
16540
16541
16542/* Multiplication of quantities with associated errors.
16543 */
16544int gsl_sf_multiply_err_e(const double x, const double dx, const double y, const double dy, gsl_sf_result * result);
16545
16546
16547__END_DECLS
16548
16549#endif /* __GSL_SF_ELEMENTARY_H__ */
16550
16551/* end inlined header: gsl/gsl_sf_elementary.h */
16552/* begin inlined header: gsl/gsl_sf_exp.h */
16553/* specfunc/gsl_sf_exp.h
16554 *
16555 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2004 Gerard Jungman
16556 *
16557 * This program is free software; you can redistribute it and/or modify
16558 * it under the terms of the GNU General Public License as published by
16559 * the Free Software Foundation; either version 3 of the License, or (at
16560 * your option) any later version.
16561 *
16562 * This program is distributed in the hope that it will be useful, but
16563 * WITHOUT ANY WARRANTY; without even the implied warranty of
16564 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16565 * General Public License for more details.
16566 *
16567 * You should have received a copy of the GNU General Public License
16568 * along with this program; if not, write to the Free Software
16569 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16570 */
16571
16572/* Author: G. Jungman */
16573
16574#ifndef __GSL_SF_EXP_H__
16575#define __GSL_SF_EXP_H__
16576/* begin inlined header: gsl/gsl_sf_result.h */
16577/* specfunc/gsl_sf_result.h
16578 *
16579 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
16580 *
16581 * This program is free software; you can redistribute it and/or modify
16582 * it under the terms of the GNU General Public License as published by
16583 * the Free Software Foundation; either version 3 of the License, or (at
16584 * your option) any later version.
16585 *
16586 * This program is distributed in the hope that it will be useful, but
16587 * WITHOUT ANY WARRANTY; without even the implied warranty of
16588 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16589 * General Public License for more details.
16590 *
16591 * You should have received a copy of the GNU General Public License
16592 * along with this program; if not, write to the Free Software
16593 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16594 */
16595
16596/* Author: G. Jungman */
16597
16598#ifndef __GSL_SF_RESULT_H__
16599#define __GSL_SF_RESULT_H__
16600
16601
16602
16603__BEGIN_DECLS
16604
16605struct gsl_sf_result_struct {
16606 double val;
16607 double err;
16608};
16609typedef struct gsl_sf_result_struct gsl_sf_result;
16610
16611#define GSL_SF_RESULT_SET(r,v,e) do { (r)->val=(v); (r)->err=(e); } while(0)
16612
16613
16615 double val;
16616 double err;
16617 int e10;
16618};
16619typedef struct gsl_sf_result_e10_struct gsl_sf_result_e10;
16620
16621
16622int gsl_sf_result_smash_e(const gsl_sf_result_e10 * re, gsl_sf_result * r);
16623
16624
16625__END_DECLS
16626
16627#endif /* __GSL_SF_RESULT_H__ */
16628
16629/* end inlined header: gsl/gsl_sf_result.h */
16630/* begin inlined header: gsl/gsl_precision.h */
16631/* gsl_precision.h
16632 *
16633 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
16634 *
16635 * This program is free software; you can redistribute it and/or modify
16636 * it under the terms of the GNU General Public License as published by
16637 * the Free Software Foundation; either version 3 of the License, or (at
16638 * your option) any later version.
16639 *
16640 * This program is distributed in the hope that it will be useful, but
16641 * WITHOUT ANY WARRANTY; without even the implied warranty of
16642 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16643 * General Public License for more details.
16644 *
16645 * You should have received a copy of the GNU General Public License
16646 * along with this program; if not, write to the Free Software
16647 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16648 */
16649
16650/* Author: B. Gough and G. Jungman */
16651
16652#ifndef __GSL_PRECISION_H__
16653#define __GSL_PRECISION_H__
16654/* begin inlined header: gsl/gsl_types.h */
16655/* gsl_types.h
16656 *
16657 * Copyright (C) 2001, 2007 Brian Gough
16658 *
16659 * This program is free software; you can redistribute it and/or modify
16660 * it under the terms of the GNU General Public License as published by
16661 * the Free Software Foundation; either version 3 of the License, or (at
16662 * your option) any later version.
16663 *
16664 * This program is distributed in the hope that it will be useful, but
16665 * WITHOUT ANY WARRANTY; without even the implied warranty of
16666 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16667 * General Public License for more details.
16668 *
16669 * You should have received a copy of the GNU General Public License
16670 * along with this program; if not, write to the Free Software
16671 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16672 */
16673
16674#ifndef __GSL_TYPES_H__
16675#define __GSL_TYPES_H__
16676
16677#ifndef GSL_VAR
16678
16679#ifdef WIN32
16680# ifdef GSL_DLL
16681# ifdef DLL_EXPORT
16682# define GSL_VAR extern __declspec(dllexport)
16683# else
16684# define GSL_VAR extern __declspec(dllimport)
16685# endif
16686# else
16687# define GSL_VAR extern
16688# endif
16689#else
16690# define GSL_VAR extern
16691#endif
16692
16693#endif
16694
16695#endif /* __GSL_TYPES_H__ */
16696
16697/* end inlined header: gsl/gsl_types.h */
16698
16699
16700__BEGIN_DECLS
16701
16702
16703/* A type for the precision indicator.
16704 * This is mainly for pedagogy.
16705 */
16706typedef unsigned int gsl_prec_t;
16707
16708
16709/* The number of precision types.
16710 * Remember that precision-mode
16711 * can index an array.
16712 */
16713#define _GSL_PREC_T_NUM 3
16714
16715
16716/* Arrays containing derived
16717 * precision constants for the
16718 * different precision levels.
16719 */
16720GSL_VAR const double gsl_prec_eps[];
16721GSL_VAR const double gsl_prec_sqrt_eps[];
16722GSL_VAR const double gsl_prec_root3_eps[];
16723GSL_VAR const double gsl_prec_root4_eps[];
16724GSL_VAR const double gsl_prec_root5_eps[];
16725GSL_VAR const double gsl_prec_root6_eps[];
16726
16727
16728__END_DECLS
16729
16730#endif /* __GSL_PRECISION_H__ */
16731
16732/* end inlined header: gsl/gsl_precision.h */
16733
16734
16735__BEGIN_DECLS
16736
16737/* Provide an exp() function with GSL semantics,
16738 * i.e. with proper error checking, etc.
16739 *
16740 * exceptions: GSL_EOVRFLW, GSL_EUNDRFLW
16741 */
16742int gsl_sf_exp_e(const double x, gsl_sf_result * result);
16743double gsl_sf_exp(const double x);
16744
16745
16746/* Exp(x)
16747 *
16748 * exceptions: GSL_EOVRFLW, GSL_EUNDRFLW
16749 */
16750int gsl_sf_exp_e10_e(const double x, gsl_sf_result_e10 * result);
16751
16752
16753/* Exponentiate and multiply by a given factor: y * Exp(x)
16754 *
16755 * exceptions: GSL_EOVRFLW, GSL_EUNDRFLW
16756 */
16757int gsl_sf_exp_mult_e(const double x, const double y, gsl_sf_result * result);
16758double gsl_sf_exp_mult(const double x, const double y);
16759
16760
16761/* Exponentiate and multiply by a given factor: y * Exp(x)
16762 *
16763 * exceptions: GSL_EOVRFLW, GSL_EUNDRFLW
16764 */
16765int gsl_sf_exp_mult_e10_e(const double x, const double y, gsl_sf_result_e10 * result);
16766
16767
16768/* exp(x)-1
16769 *
16770 * exceptions: GSL_EOVRFLW
16771 */
16772int gsl_sf_expm1_e(const double x, gsl_sf_result * result);
16773double gsl_sf_expm1(const double x);
16774
16775
16776/* (exp(x)-1)/x = 1 + x/2 + x^2/(2*3) + x^3/(2*3*4) + ...
16777 *
16778 * exceptions: GSL_EOVRFLW
16779 */
16780int gsl_sf_exprel_e(const double x, gsl_sf_result * result);
16781double gsl_sf_exprel(const double x);
16782
16783
16784/* 2(exp(x)-1-x)/x^2 = 1 + x/3 + x^2/(3*4) + x^3/(3*4*5) + ...
16785 *
16786 * exceptions: GSL_EOVRFLW
16787 */
16788int gsl_sf_exprel_2_e(double x, gsl_sf_result * result);
16789double gsl_sf_exprel_2(const double x);
16790
16791
16792/* Similarly for the N-th generalization of
16793 * the above. The so-called N-relative exponential
16794 *
16795 * exprel_N(x) = N!/x^N (exp(x) - Sum[x^k/k!, {k,0,N-1}])
16796 * = 1 + x/(N+1) + x^2/((N+1)(N+2)) + ...
16797 * = 1F1(1,1+N,x)
16798 */
16799int gsl_sf_exprel_n_e(const int n, const double x, gsl_sf_result * result);
16800double gsl_sf_exprel_n(const int n, const double x);
16801
16802int gsl_sf_exprel_n_CF_e(const double n, const double x, gsl_sf_result * result);
16803
16804
16805/* Exponentiate a quantity with an associated error.
16806 */
16807int gsl_sf_exp_err_e(const double x, const double dx, gsl_sf_result * result);
16808
16809/* Exponentiate a quantity with an associated error.
16810 */
16811int gsl_sf_exp_err_e10_e(const double x, const double dx, gsl_sf_result_e10 * result);
16812
16813
16814/* Exponentiate and multiply by a given factor: y * Exp(x),
16815 * for quantities with associated errors.
16816 *
16817 * exceptions: GSL_EOVRFLW, GSL_EUNDRFLW
16818 */
16819int gsl_sf_exp_mult_err_e(const double x, const double dx, const double y, const double dy, gsl_sf_result * result);
16820
16821
16822/* Exponentiate and multiply by a given factor: y * Exp(x),
16823 * for quantities with associated errors.
16824 *
16825 * exceptions: GSL_EOVRFLW, GSL_EUNDRFLW
16826 */
16827int gsl_sf_exp_mult_err_e10_e(const double x, const double dx, const double y, const double dy, gsl_sf_result_e10 * result);
16828
16829__END_DECLS
16830
16831#endif /* __GSL_SF_EXP_H__ */
16832
16833/* end inlined header: gsl/gsl_sf_exp.h */
16834/* begin inlined header: gsl/gsl_sf_gamma.h */
16835/* specfunc/gsl_sf_gamma.h
16836 *
16837 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
16838 *
16839 * This program is free software; you can redistribute it and/or modify
16840 * it under the terms of the GNU General Public License as published by
16841 * the Free Software Foundation; either version 3 of the License, or (at
16842 * your option) any later version.
16843 *
16844 * This program is distributed in the hope that it will be useful, but
16845 * WITHOUT ANY WARRANTY; without even the implied warranty of
16846 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16847 * General Public License for more details.
16848 *
16849 * You should have received a copy of the GNU General Public License
16850 * along with this program; if not, write to the Free Software
16851 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16852 */
16853
16854/* Author: G. Jungman */
16855
16856#ifndef __GSL_SF_GAMMA_H__
16857#define __GSL_SF_GAMMA_H__
16858/* begin inlined header: gsl/gsl_sf_result.h */
16859/* specfunc/gsl_sf_result.h
16860 *
16861 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
16862 *
16863 * This program is free software; you can redistribute it and/or modify
16864 * it under the terms of the GNU General Public License as published by
16865 * the Free Software Foundation; either version 3 of the License, or (at
16866 * your option) any later version.
16867 *
16868 * This program is distributed in the hope that it will be useful, but
16869 * WITHOUT ANY WARRANTY; without even the implied warranty of
16870 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16871 * General Public License for more details.
16872 *
16873 * You should have received a copy of the GNU General Public License
16874 * along with this program; if not, write to the Free Software
16875 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16876 */
16877
16878/* Author: G. Jungman */
16879
16880#ifndef __GSL_SF_RESULT_H__
16881#define __GSL_SF_RESULT_H__
16882
16883
16884
16885__BEGIN_DECLS
16886
16887struct gsl_sf_result_struct {
16888 double val;
16889 double err;
16890};
16891typedef struct gsl_sf_result_struct gsl_sf_result;
16892
16893#define GSL_SF_RESULT_SET(r,v,e) do { (r)->val=(v); (r)->err=(e); } while(0)
16894
16895
16897 double val;
16898 double err;
16899 int e10;
16900};
16901typedef struct gsl_sf_result_e10_struct gsl_sf_result_e10;
16902
16903
16904int gsl_sf_result_smash_e(const gsl_sf_result_e10 * re, gsl_sf_result * r);
16905
16906
16907__END_DECLS
16908
16909#endif /* __GSL_SF_RESULT_H__ */
16910
16911/* end inlined header: gsl/gsl_sf_result.h */
16912
16913
16914__BEGIN_DECLS
16915
16916
16917/* Log[Gamma(x)], x not a negative integer
16918 * Uses real Lanczos method.
16919 * Returns the real part of Log[Gamma[x]] when x < 0,
16920 * i.e. Log[|Gamma[x]|].
16921 *
16922 * exceptions: GSL_EDOM, GSL_EROUND
16923 */
16924int gsl_sf_lngamma_e(double x, gsl_sf_result * result);
16925double gsl_sf_lngamma(const double x);
16926
16927
16928/* Log[Gamma(x)], x not a negative integer
16929 * Uses real Lanczos method. Determines
16930 * the sign of Gamma[x] as well as Log[|Gamma[x]|] for x < 0.
16931 * So Gamma[x] = sgn * Exp[result_lg].
16932 *
16933 * exceptions: GSL_EDOM, GSL_EROUND
16934 */
16935int gsl_sf_lngamma_sgn_e(double x, gsl_sf_result * result_lg, double *sgn);
16936
16937
16938/* Gamma(x), x not a negative integer
16939 * Uses real Lanczos method.
16940 *
16941 * exceptions: GSL_EDOM, GSL_EOVRFLW, GSL_EROUND
16942 */
16943int gsl_sf_gamma_e(const double x, gsl_sf_result * result);
16944double gsl_sf_gamma(const double x);
16945
16946
16947/* Regulated Gamma Function, x > 0
16948 * Gamma^*(x) = Gamma(x)/(Sqrt[2Pi] x^(x-1/2) exp(-x))
16949 * = (1 + 1/(12x) + ...), x->Inf
16950 * A useful suggestion of Temme.
16951 *
16952 * exceptions: GSL_EDOM
16953 */
16954int gsl_sf_gammastar_e(const double x, gsl_sf_result * result);
16955double gsl_sf_gammastar(const double x);
16956
16957
16958/* 1/Gamma(x)
16959 * Uses real Lanczos method.
16960 *
16961 * exceptions: GSL_EUNDRFLW, GSL_EROUND
16962 */
16963int gsl_sf_gammainv_e(const double x, gsl_sf_result * result);
16964double gsl_sf_gammainv(const double x);
16965
16966
16967/* Log[Gamma(z)] for z complex, z not a negative integer
16968 * Uses complex Lanczos method. Note that the phase part (arg)
16969 * is not well-determined when |z| is very large, due
16970 * to inevitable roundoff in restricting to (-Pi,Pi].
16971 * This will raise the GSL_ELOSS exception when it occurs.
16972 * The absolute value part (lnr), however, never suffers.
16973 *
16974 * Calculates:
16975 * lnr = log|Gamma(z)|
16976 * arg = arg(Gamma(z)) in (-Pi, Pi]
16977 *
16978 * exceptions: GSL_EDOM, GSL_ELOSS
16979 */
16980int gsl_sf_lngamma_complex_e(double zr, double zi, gsl_sf_result * lnr, gsl_sf_result * arg);
16981
16982
16983/* x^n / n!
16984 *
16985 * x >= 0.0, n >= 0
16986 * exceptions: GSL_EDOM, GSL_EOVRFLW, GSL_EUNDRFLW
16987 */
16988int gsl_sf_taylorcoeff_e(const int n, const double x, gsl_sf_result * result);
16989double gsl_sf_taylorcoeff(const int n, const double x);
16990
16991
16992/* n!
16993 *
16994 * exceptions: GSL_EDOM, GSL_EOVRFLW
16995 */
16996int gsl_sf_fact_e(const unsigned int n, gsl_sf_result * result);
16997double gsl_sf_fact(const unsigned int n);
16998
16999
17000/* n!! = n(n-2)(n-4) ...
17001 *
17002 * exceptions: GSL_EDOM, GSL_EOVRFLW
17003 */
17004int gsl_sf_doublefact_e(const unsigned int n, gsl_sf_result * result);
17005double gsl_sf_doublefact(const unsigned int n);
17006
17007
17008/* log(n!)
17009 * Faster than ln(Gamma(n+1)) for n < 170; defers for larger n.
17010 *
17011 * exceptions: none
17012 */
17013int gsl_sf_lnfact_e(const unsigned int n, gsl_sf_result * result);
17014double gsl_sf_lnfact(const unsigned int n);
17015
17016
17017/* log(n!!)
17018 *
17019 * exceptions: none
17020 */
17021int gsl_sf_lndoublefact_e(const unsigned int n, gsl_sf_result * result);
17022double gsl_sf_lndoublefact(const unsigned int n);
17023
17024
17025/* log(n choose m)
17026 *
17027 * exceptions: GSL_EDOM
17028 */
17029int gsl_sf_lnchoose_e(unsigned int n, unsigned int m, gsl_sf_result * result);
17030double gsl_sf_lnchoose(unsigned int n, unsigned int m);
17031
17032
17033/* n choose m
17034 *
17035 * exceptions: GSL_EDOM, GSL_EOVRFLW
17036 */
17037int gsl_sf_choose_e(unsigned int n, unsigned int m, gsl_sf_result * result);
17038double gsl_sf_choose(unsigned int n, unsigned int m);
17039
17040
17041/* Logarithm of Pochhammer (Apell) symbol
17042 * log( (a)_x )
17043 * where (a)_x := Gamma[a + x]/Gamma[a]
17044 *
17045 * a > 0, a+x > 0
17046 *
17047 * exceptions: GSL_EDOM
17048 */
17049int gsl_sf_lnpoch_e(const double a, const double x, gsl_sf_result * result);
17050double gsl_sf_lnpoch(const double a, const double x);
17051
17052
17053/* Logarithm of Pochhammer (Apell) symbol, with sign information.
17054 * result = log( |(a)_x| )
17055 * sgn = sgn( (a)_x )
17056 * where (a)_x := Gamma[a + x]/Gamma[a]
17057 *
17058 * a != neg integer, a+x != neg integer
17059 *
17060 * exceptions: GSL_EDOM
17061 */
17062int gsl_sf_lnpoch_sgn_e(const double a, const double x, gsl_sf_result * result, double * sgn);
17063
17064
17065/* Pochhammer (Apell) symbol
17066 * (a)_x := Gamma[a + x]/Gamma[x]
17067 *
17068 * a != neg integer, a+x != neg integer
17069 *
17070 * exceptions: GSL_EDOM, GSL_EOVRFLW
17071 */
17072int gsl_sf_poch_e(const double a, const double x, gsl_sf_result * result);
17073double gsl_sf_poch(const double a, const double x);
17074
17075
17076/* Relative Pochhammer (Apell) symbol
17077 * ((a,x) - 1)/x
17078 * where (a,x) = (a)_x := Gamma[a + x]/Gamma[a]
17079 *
17080 * exceptions: GSL_EDOM
17081 */
17082int gsl_sf_pochrel_e(const double a, const double x, gsl_sf_result * result);
17083double gsl_sf_pochrel(const double a, const double x);
17084
17085
17086/* Normalized Incomplete Gamma Function
17087 *
17088 * Q(a,x) = 1/Gamma(a) Integral[ t^(a-1) e^(-t), {t,x,Infinity} ]
17089 *
17090 * a >= 0, x >= 0
17091 * Q(a,0) := 1
17092 * Q(0,x) := 0, x != 0
17093 *
17094 * exceptions: GSL_EDOM
17095 */
17096int gsl_sf_gamma_inc_Q_e(const double a, const double x, gsl_sf_result * result);
17097double gsl_sf_gamma_inc_Q(const double a, const double x);
17098
17099
17100/* Complementary Normalized Incomplete Gamma Function
17101 *
17102 * P(a,x) = 1/Gamma(a) Integral[ t^(a-1) e^(-t), {t,0,x} ]
17103 *
17104 * a > 0, x >= 0
17105 *
17106 * exceptions: GSL_EDOM
17107 */
17108int gsl_sf_gamma_inc_P_e(const double a, const double x, gsl_sf_result * result);
17109double gsl_sf_gamma_inc_P(const double a, const double x);
17110
17111
17112/* Non-normalized Incomplete Gamma Function
17113 *
17114 * Gamma(a,x) := Integral[ t^(a-1) e^(-t), {t,x,Infinity} ]
17115 *
17116 * x >= 0.0
17117 * Gamma(a, 0) := Gamma(a)
17118 *
17119 * exceptions: GSL_EDOM
17120 */
17121int gsl_sf_gamma_inc_e(const double a, const double x, gsl_sf_result * result);
17122double gsl_sf_gamma_inc(const double a, const double x);
17123
17124
17125/* Logarithm of Beta Function
17126 * Log[B(a,b)]
17127 *
17128 * a > 0, b > 0
17129 * exceptions: GSL_EDOM
17130 */
17131int gsl_sf_lnbeta_e(const double a, const double b, gsl_sf_result * result);
17132double gsl_sf_lnbeta(const double a, const double b);
17133
17134int gsl_sf_lnbeta_sgn_e(const double x, const double y, gsl_sf_result * result, double * sgn);
17135
17136
17137/* Beta Function
17138 * B(a,b)
17139 *
17140 * a > 0, b > 0
17141 * exceptions: GSL_EDOM, GSL_EOVRFLW, GSL_EUNDRFLW
17142 */
17143int gsl_sf_beta_e(const double a, const double b, gsl_sf_result * result);
17144double gsl_sf_beta(const double a, const double b);
17145
17146
17147/* Normalized Incomplete Beta Function
17148 * B_x(a,b)/B(a,b)
17149 *
17150 * a > 0, b > 0, 0 <= x <= 1
17151 * exceptions: GSL_EDOM, GSL_EUNDRFLW
17152 */
17153int gsl_sf_beta_inc_e(const double a, const double b, const double x, gsl_sf_result * result);
17154double gsl_sf_beta_inc(const double a, const double b, const double x);
17155
17156
17157/* The maximum x such that gamma(x) is not
17158 * considered an overflow.
17159 */
17160#define GSL_SF_GAMMA_XMAX 171.0
17161
17162/* The maximum n such that gsl_sf_fact(n) does not give an overflow. */
17163#define GSL_SF_FACT_NMAX 170
17164
17165/* The maximum n such that gsl_sf_doublefact(n) does not give an overflow. */
17166#define GSL_SF_DOUBLEFACT_NMAX 297
17167
17168__END_DECLS
17169
17170#endif /* __GSL_SF_GAMMA_H__ */
17171
17172/* end inlined header: gsl/gsl_sf_gamma.h */
17173/* begin inlined header: gsl/gsl_sf_pow_int.h */
17174/* specfunc/gsl_sf_pow_int.h
17175 *
17176 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
17177 *
17178 * This program is free software; you can redistribute it and/or modify
17179 * it under the terms of the GNU General Public License as published by
17180 * the Free Software Foundation; either version 3 of the License, or (at
17181 * your option) any later version.
17182 *
17183 * This program is distributed in the hope that it will be useful, but
17184 * WITHOUT ANY WARRANTY; without even the implied warranty of
17185 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17186 * General Public License for more details.
17187 *
17188 * You should have received a copy of the GNU General Public License
17189 * along with this program; if not, write to the Free Software
17190 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17191 */
17192
17193/* Author: G. Jungman */
17194
17195#ifndef __GSL_SF_POW_INT_H__
17196#define __GSL_SF_POW_INT_H__
17197/* begin inlined header: gsl/gsl_sf_result.h */
17198/* specfunc/gsl_sf_result.h
17199 *
17200 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
17201 *
17202 * This program is free software; you can redistribute it and/or modify
17203 * it under the terms of the GNU General Public License as published by
17204 * the Free Software Foundation; either version 3 of the License, or (at
17205 * your option) any later version.
17206 *
17207 * This program is distributed in the hope that it will be useful, but
17208 * WITHOUT ANY WARRANTY; without even the implied warranty of
17209 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17210 * General Public License for more details.
17211 *
17212 * You should have received a copy of the GNU General Public License
17213 * along with this program; if not, write to the Free Software
17214 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17215 */
17216
17217/* Author: G. Jungman */
17218
17219#ifndef __GSL_SF_RESULT_H__
17220#define __GSL_SF_RESULT_H__
17221
17222
17223
17224__BEGIN_DECLS
17225
17226struct gsl_sf_result_struct {
17227 double val;
17228 double err;
17229};
17230typedef struct gsl_sf_result_struct gsl_sf_result;
17231
17232#define GSL_SF_RESULT_SET(r,v,e) do { (r)->val=(v); (r)->err=(e); } while(0)
17233
17234
17236 double val;
17237 double err;
17238 int e10;
17239};
17240typedef struct gsl_sf_result_e10_struct gsl_sf_result_e10;
17241
17242
17243int gsl_sf_result_smash_e(const gsl_sf_result_e10 * re, gsl_sf_result * r);
17244
17245
17246__END_DECLS
17247
17248#endif /* __GSL_SF_RESULT_H__ */
17249
17250/* end inlined header: gsl/gsl_sf_result.h */
17251
17252
17253__BEGIN_DECLS
17254
17255
17256/* Calculate x^n.
17257 * Does not check for overflow/underflow.
17258 */
17259int gsl_sf_pow_int_e(double x, int n, gsl_sf_result * result);
17260double gsl_sf_pow_int(const double x, const int n);
17261
17262
17263__END_DECLS
17264
17265#endif /* __GSL_SF_POW_INT_H__ */
17266
17267/* end inlined header: gsl/gsl_sf_pow_int.h */
17268/* begin inlined header: gsl/gsl_sf_zeta.h */
17269/* specfunc/gsl_sf_zeta.h
17270 *
17271 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2004 Gerard Jungman
17272 *
17273 * This program is free software; you can redistribute it and/or modify
17274 * it under the terms of the GNU General Public License as published by
17275 * the Free Software Foundation; either version 3 of the License, or (at
17276 * your option) any later version.
17277 *
17278 * This program is distributed in the hope that it will be useful, but
17279 * WITHOUT ANY WARRANTY; without even the implied warranty of
17280 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17281 * General Public License for more details.
17282 *
17283 * You should have received a copy of the GNU General Public License
17284 * along with this program; if not, write to the Free Software
17285 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17286 */
17287
17288/* Author: G. Jungman */
17289
17290#ifndef __GSL_SF_ZETA_H__
17291#define __GSL_SF_ZETA_H__
17292/* begin inlined header: gsl/gsl_sf_result.h */
17293/* specfunc/gsl_sf_result.h
17294 *
17295 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
17296 *
17297 * This program is free software; you can redistribute it and/or modify
17298 * it under the terms of the GNU General Public License as published by
17299 * the Free Software Foundation; either version 3 of the License, or (at
17300 * your option) any later version.
17301 *
17302 * This program is distributed in the hope that it will be useful, but
17303 * WITHOUT ANY WARRANTY; without even the implied warranty of
17304 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17305 * General Public License for more details.
17306 *
17307 * You should have received a copy of the GNU General Public License
17308 * along with this program; if not, write to the Free Software
17309 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17310 */
17311
17312/* Author: G. Jungman */
17313
17314#ifndef __GSL_SF_RESULT_H__
17315#define __GSL_SF_RESULT_H__
17316
17317
17318
17319__BEGIN_DECLS
17320
17321struct gsl_sf_result_struct {
17322 double val;
17323 double err;
17324};
17325typedef struct gsl_sf_result_struct gsl_sf_result;
17326
17327#define GSL_SF_RESULT_SET(r,v,e) do { (r)->val=(v); (r)->err=(e); } while(0)
17328
17329
17331 double val;
17332 double err;
17333 int e10;
17334};
17335typedef struct gsl_sf_result_e10_struct gsl_sf_result_e10;
17336
17337
17338int gsl_sf_result_smash_e(const gsl_sf_result_e10 * re, gsl_sf_result * r);
17339
17340
17341__END_DECLS
17342
17343#endif /* __GSL_SF_RESULT_H__ */
17344
17345/* end inlined header: gsl/gsl_sf_result.h */
17346
17347
17348__BEGIN_DECLS
17349
17350
17351/* Riemann Zeta Function
17352 * zeta(n) = Sum[ k^(-n), {k,1,Infinity} ]
17353 *
17354 * n=integer, n != 1
17355 * exceptions: GSL_EDOM, GSL_EOVRFLW
17356 */
17357int gsl_sf_zeta_int_e(const int n, gsl_sf_result * result);
17358double gsl_sf_zeta_int(const int n);
17359
17360
17361/* Riemann Zeta Function
17362 * zeta(x) = Sum[ k^(-s), {k,1,Infinity} ], s != 1.0
17363 *
17364 * s != 1.0
17365 * exceptions: GSL_EDOM, GSL_EOVRFLW
17366 */
17367int gsl_sf_zeta_e(const double s, gsl_sf_result * result);
17368double gsl_sf_zeta(const double s);
17369
17370
17371/* Riemann Zeta Function minus 1
17372 * useful for evaluating the fractional part
17373 * of Riemann zeta for large argument
17374 *
17375 * s != 1.0
17376 * exceptions: GSL_EDOM, GSL_EOVRFLW
17377 */
17378int gsl_sf_zetam1_e(const double s, gsl_sf_result * result);
17379double gsl_sf_zetam1(const double s);
17380
17381
17382/* Riemann Zeta Function minus 1 for integer arg
17383 * useful for evaluating the fractional part
17384 * of Riemann zeta for large argument
17385 *
17386 * s != 1.0
17387 * exceptions: GSL_EDOM, GSL_EOVRFLW
17388 */
17389int gsl_sf_zetam1_int_e(const int s, gsl_sf_result * result);
17390double gsl_sf_zetam1_int(const int s);
17391
17392
17393/* Hurwitz Zeta Function
17394 * zeta(s,q) = Sum[ (k+q)^(-s), {k,0,Infinity} ]
17395 *
17396 * s > 1.0, q > 0.0
17397 * exceptions: GSL_EDOM, GSL_EUNDRFLW, GSL_EOVRFLW
17398 */
17399int gsl_sf_hzeta_e(const double s, const double q, gsl_sf_result * result);
17400double gsl_sf_hzeta(const double s, const double q);
17401
17402
17403/* Eta Function
17404 * eta(n) = (1-2^(1-n)) zeta(n)
17405 *
17406 * exceptions: GSL_EUNDRFLW, GSL_EOVRFLW
17407 */
17408int gsl_sf_eta_int_e(int n, gsl_sf_result * result);
17409double gsl_sf_eta_int(const int n);
17410
17411
17412/* Eta Function
17413 * eta(s) = (1-2^(1-s)) zeta(s)
17414 *
17415 * exceptions: GSL_EUNDRFLW, GSL_EOVRFLW
17416 */
17417int gsl_sf_eta_e(const double s, gsl_sf_result * result);
17418double gsl_sf_eta(const double s);
17419
17420
17421__END_DECLS
17422
17423#endif /* __GSL_SF_ZETA_H__ */
17424
17425/* end inlined header: gsl/gsl_sf_zeta.h */
17426/* inlined: error.h */
17427
17428/* inlined: chebyshev.h */
17429/* inlined once already: specfunc/cheb_eval.c */
17430
17431#define LogTwoPi_ 1.8378770664093454835606594728111235279723
17432
17433
17434/*-*-*-*-*-*-*-*-*-*-*-* Private Section *-*-*-*-*-*-*-*-*-*-*-*/
17435
17436/* chebyshev fit for (s(t)-1)Zeta[s(t)]
17437 * s(t)= (t+1)/2
17438 * -1 <= t <= 1
17439 */
17440static double zeta_xlt1_data[14] = {
17441 1.48018677156931561235192914649,
17442 0.25012062539889426471999938167,
17443 0.00991137502135360774243761467,
17444 -0.00012084759656676410329833091,
17445 -4.7585866367662556504652535281e-06,
17446 2.2229946694466391855561441361e-07,
17447 -2.2237496498030257121309056582e-09,
17448 -1.0173226513229028319420799028e-10,
17449 4.3756643450424558284466248449e-12,
17450 -6.2229632593100551465504090814e-14,
17451 -6.6116201003272207115277520305e-16,
17452 4.9477279533373912324518463830e-17,
17453 -1.0429819093456189719660003522e-18,
17454 6.9925216166580021051464412040e-21,
17455};
17456static cheb_series zeta_xlt1_cs = {
17457 zeta_xlt1_data,
17458 13,
17459 -1, 1,
17460 8
17461};
17462
17463/* chebyshev fit for (s(t)-1)Zeta[s(t)]
17464 * s(t)= (19t+21)/2
17465 * -1 <= t <= 1
17466 */
17467static double zeta_xgt1_data[30] = {
17468 19.3918515726724119415911269006,
17469 9.1525329692510756181581271500,
17470 0.2427897658867379985365270155,
17471 -0.1339000688262027338316641329,
17472 0.0577827064065028595578410202,
17473 -0.0187625983754002298566409700,
17474 0.0039403014258320354840823803,
17475 -0.0000581508273158127963598882,
17476 -0.0003756148907214820704594549,
17477 0.0001892530548109214349092999,
17478 -0.0000549032199695513496115090,
17479 8.7086484008939038610413331863e-6,
17480 6.4609477924811889068410083425e-7,
17481 -9.6749773915059089205835337136e-7,
17482 3.6585400766767257736982342461e-7,
17483 -8.4592516427275164351876072573e-8,
17484 9.9956786144497936572288988883e-9,
17485 1.4260036420951118112457144842e-9,
17486 -1.1761968823382879195380320948e-9,
17487 3.7114575899785204664648987295e-10,
17488 -7.4756855194210961661210215325e-11,
17489 7.8536934209183700456512982968e-12,
17490 9.9827182259685539619810406271e-13,
17491 -7.5276687030192221587850302453e-13,
17492 2.1955026393964279988917878654e-13,
17493 -4.1934859852834647427576319246e-14,
17494 4.6341149635933550715779074274e-15,
17495 2.3742488509048340106830309402e-16,
17496 -2.7276516388124786119323824391e-16,
17497 7.8473570134636044722154797225e-17
17498};
17499static cheb_series zeta_xgt1_cs = {
17500 zeta_xgt1_data,
17501 29,
17502 -1, 1,
17503 17
17504};
17505
17506
17507/* chebyshev fit for Ln[Zeta[s(t)] - 1 - 2^(-s(t))]
17508 * s(t)= 10 + 5t
17509 * -1 <= t <= 1; 5 <= s <= 15
17510 */
17511static double zetam1_inter_data[24] = {
17512 -21.7509435653088483422022339374,
17513 -5.63036877698121782876372020472,
17514 0.0528041358684229425504861579635,
17515 -0.0156381809179670789342700883562,
17516 0.00408218474372355881195080781927,
17517 -0.0010264867349474874045036628282,
17518 0.000260469880409886900143834962387,
17519 -0.0000676175847209968878098566819447,
17520 0.0000179284472587833525426660171124,
17521 -4.83238651318556188834107605116e-6,
17522 1.31913788964999288471371329447e-6,
17523 -3.63760500656329972578222188542e-7,
17524 1.01146847513194744989748396574e-7,
17525 -2.83215225141806501619105289509e-8,
17526 7.97733710252021423361012829496e-9,
17527 -2.25850168553956886676250696891e-9,
17528 6.42269392950164306086395744145e-10,
17529 -1.83363861846127284505060843614e-10,
17530 5.25309763895283179960368072104e-11,
17531 -1.50958687042589821074710575446e-11,
17532 4.34997545516049244697776942981e-12,
17533 -1.25597782748190416118082322061e-12,
17534 3.61280740072222650030134104162e-13,
17535 -9.66437239205745207188920348801e-14
17536};
17537static cheb_series zetam1_inter_cs = {
17538 zetam1_inter_data,
17539 22,
17540 -1, 1,
17541 12
17542};
17543
17544
17545
17546/* assumes s >= 0 and s != 1.0 */
17547inline
17548static int
17549riemann_zeta_sgt0(double s, gsl_sf_result * result)
17550{
17551 if(s < 1.0) {
17552 gsl_sf_result c;
17553 cheb_eval_e(&zeta_xlt1_cs, 2.0*s - 1.0, &c);
17554 result->val = c.val / (s - 1.0);
17555 result->err = c.err / fabs(s-1.0) + GSL_DBL_EPSILON * fabs(result->val);
17556 return GSL_SUCCESS;
17557 }
17558 else if(s <= 20.0) {
17559 double x = (2.0*s - 21.0)/19.0;
17560 gsl_sf_result c;
17561 cheb_eval_e(&zeta_xgt1_cs, x, &c);
17562 result->val = c.val / (s - 1.0);
17563 result->err = c.err / (s - 1.0) + GSL_DBL_EPSILON * fabs(result->val);
17564 return GSL_SUCCESS;
17565 }
17566 else {
17567 double f2 = 1.0 - pow(2.0,-s);
17568 double f3 = 1.0 - pow(3.0,-s);
17569 double f5 = 1.0 - pow(5.0,-s);
17570 double f7 = 1.0 - pow(7.0,-s);
17571 result->val = 1.0/(f2*f3*f5*f7);
17572 result->err = 3.0 * GSL_DBL_EPSILON * fabs(result->val);
17573 return GSL_SUCCESS;
17574 }
17575}
17576
17577
17578inline
17579static int
17580riemann_zeta1ms_slt0(double s, gsl_sf_result * result)
17581{
17582 if(s > -19.0) {
17583 double x = (-19 - 2.0*s)/19.0;
17584 gsl_sf_result c;
17585 cheb_eval_e(&zeta_xgt1_cs, x, &c);
17586 result->val = c.val / (-s);
17587 result->err = c.err / (-s) + GSL_DBL_EPSILON * fabs(result->val);
17588 return GSL_SUCCESS;
17589 }
17590 else {
17591 double f2 = 1.0 - pow(2.0,-(1.0-s));
17592 double f3 = 1.0 - pow(3.0,-(1.0-s));
17593 double f5 = 1.0 - pow(5.0,-(1.0-s));
17594 double f7 = 1.0 - pow(7.0,-(1.0-s));
17595 result->val = 1.0/(f2*f3*f5*f7);
17596 result->err = 3.0 * GSL_DBL_EPSILON * fabs(result->val);
17597 return GSL_SUCCESS;
17598 }
17599}
17600
17601
17602/* works for 5 < s < 15*/
17603static int
17604riemann_zeta_minus_1_intermediate_s(double s, gsl_sf_result * result)
17605{
17606 double t = (s - 10.0)/5.0;
17607 gsl_sf_result c;
17608 cheb_eval_e(&zetam1_inter_cs, t, &c);
17609 result->val = exp(c.val) + pow(2.0, -s);
17610 result->err = (c.err + 2.0*GSL_DBL_EPSILON)*result->val;
17611 return GSL_SUCCESS;
17612}
17613
17614
17615/* assumes s is large and positive
17616 * write: zeta(s) - 1 = zeta(s) * (1 - 1/zeta(s))
17617 * and expand a few terms of the product formula to evaluate 1 - 1/zeta(s)
17618 *
17619 * works well for s > 15
17620 */
17621static int
17622riemann_zeta_minus1_large_s(double s, gsl_sf_result * result)
17623{
17624 double a = pow( 2.0,-s);
17625 double b = pow( 3.0,-s);
17626 double c = pow( 5.0,-s);
17627 double d = pow( 7.0,-s);
17628 double e = pow(11.0,-s);
17629 double f = pow(13.0,-s);
17630 double t1 = a + b + c + d + e + f;
17631 double t2 = a*(b+c+d+e+f) + b*(c+d+e+f) + c*(d+e+f) + d*(e+f) + e*f;
17632 /*
17633 double t3 = a*(b*(c+d+e+f) + c*(d+e+f) + d*(e+f) + e*f) +
17634 b*(c*(d+e+f) + d*(e+f) + e*f) +
17635 c*(d*(e+f) + e*f) +
17636 d*e*f;
17637 double t4 = a*(b*(c*(d + e + f) + d*(e + f) + e*f) + c*(d*(e+f) + e*f) + d*e*f) +
17638 b*(c*(d*(e+f) + e*f) + d*e*f) +
17639 c*d*e*f;
17640 double t5 = b*c*d*e*f + a*c*d*e*f+ a*b*d*e*f+ a*b*c*e*f+ a*b*c*d*f+ a*b*c*d*e;
17641 double t6 = a*b*c*d*e*f;
17642 */
17643 double numt = t1 - t2 /* + t3 - t4 + t5 - t6 */;
17644 double zeta = 1.0/((1.0-a)*(1.0-b)*(1.0-c)*(1.0-d)*(1.0-e)*(1.0-f));
17645 result->val = numt*zeta;
17646 result->err = (15.0/s + 1.0) * 6.0*GSL_DBL_EPSILON*result->val;
17647 return GSL_SUCCESS;
17648}
17649
17650
17651#if 0
17652/* zeta(n) */
17653#define ZETA_POS_TABLE_NMAX 100
17654static double zeta_pos_int_table_OLD[ZETA_POS_TABLE_NMAX+1] = {
17655 -0.50000000000000000000000000000, /* zeta(0) */
17656 0.0 /* FIXME: DirectedInfinity() */, /* zeta(1) */
17657 1.64493406684822643647241516665, /* ... */
17658 1.20205690315959428539973816151,
17659 1.08232323371113819151600369654,
17660 1.03692775514336992633136548646,
17661 1.01734306198444913971451792979,
17662 1.00834927738192282683979754985,
17663 1.00407735619794433937868523851,
17664 1.00200839282608221441785276923,
17665 1.00099457512781808533714595890,
17666 1.00049418860411946455870228253,
17667 1.00024608655330804829863799805,
17668 1.00012271334757848914675183653,
17669 1.00006124813505870482925854511,
17670 1.00003058823630702049355172851,
17671 1.00001528225940865187173257149,
17672 1.00000763719763789976227360029,
17673 1.00000381729326499983985646164,
17674 1.00000190821271655393892565696,
17675 1.00000095396203387279611315204,
17676 1.00000047693298678780646311672,
17677 1.00000023845050272773299000365,
17678 1.00000011921992596531107306779,
17679 1.00000005960818905125947961244,
17680 1.00000002980350351465228018606,
17681 1.00000001490155482836504123466,
17682 1.00000000745071178983542949198,
17683 1.00000000372533402478845705482,
17684 1.00000000186265972351304900640,
17685 1.00000000093132743241966818287,
17686 1.00000000046566290650337840730,
17687 1.00000000023283118336765054920,
17688 1.00000000011641550172700519776,
17689 1.00000000005820772087902700889,
17690 1.00000000002910385044497099687,
17691 1.00000000001455192189104198424,
17692 1.00000000000727595983505748101,
17693 1.00000000000363797954737865119,
17694 1.00000000000181898965030706595,
17695 1.00000000000090949478402638893,
17696 1.00000000000045474737830421540,
17697 1.00000000000022737368458246525,
17698 1.00000000000011368684076802278,
17699 1.00000000000005684341987627586,
17700 1.00000000000002842170976889302,
17701 1.00000000000001421085482803161,
17702 1.00000000000000710542739521085,
17703 1.00000000000000355271369133711,
17704 1.00000000000000177635684357912,
17705 1.00000000000000088817842109308,
17706 1.00000000000000044408921031438,
17707 1.00000000000000022204460507980,
17708 1.00000000000000011102230251411,
17709 1.00000000000000005551115124845,
17710 1.00000000000000002775557562136,
17711 1.00000000000000001387778780973,
17712 1.00000000000000000693889390454,
17713 1.00000000000000000346944695217,
17714 1.00000000000000000173472347605,
17715 1.00000000000000000086736173801,
17716 1.00000000000000000043368086900,
17717 1.00000000000000000021684043450,
17718 1.00000000000000000010842021725,
17719 1.00000000000000000005421010862,
17720 1.00000000000000000002710505431,
17721 1.00000000000000000001355252716,
17722 1.00000000000000000000677626358,
17723 1.00000000000000000000338813179,
17724 1.00000000000000000000169406589,
17725 1.00000000000000000000084703295,
17726 1.00000000000000000000042351647,
17727 1.00000000000000000000021175824,
17728 1.00000000000000000000010587912,
17729 1.00000000000000000000005293956,
17730 1.00000000000000000000002646978,
17731 1.00000000000000000000001323489,
17732 1.00000000000000000000000661744,
17733 1.00000000000000000000000330872,
17734 1.00000000000000000000000165436,
17735 1.00000000000000000000000082718,
17736 1.00000000000000000000000041359,
17737 1.00000000000000000000000020680,
17738 1.00000000000000000000000010340,
17739 1.00000000000000000000000005170,
17740 1.00000000000000000000000002585,
17741 1.00000000000000000000000001292,
17742 1.00000000000000000000000000646,
17743 1.00000000000000000000000000323,
17744 1.00000000000000000000000000162,
17745 1.00000000000000000000000000081,
17746 1.00000000000000000000000000040,
17747 1.00000000000000000000000000020,
17748 1.00000000000000000000000000010,
17749 1.00000000000000000000000000005,
17750 1.00000000000000000000000000003,
17751 1.00000000000000000000000000001,
17752 1.00000000000000000000000000001,
17753 1.00000000000000000000000000000,
17754 1.00000000000000000000000000000,
17755 1.00000000000000000000000000000
17756};
17757#endif /* 0 */
17758
17759
17760/* zeta(n) - 1 */
17761#define ZETA_POS_TABLE_NMAX 100
17762static double zetam1_pos_int_table[ZETA_POS_TABLE_NMAX+1] = {
17763 -1.5, /* zeta(0) */
17764 0.0, /* FIXME: Infinity */ /* zeta(1) - 1 */
17765 0.644934066848226436472415166646, /* zeta(2) - 1 */
17766 0.202056903159594285399738161511,
17767 0.082323233711138191516003696541,
17768 0.036927755143369926331365486457,
17769 0.017343061984449139714517929790,
17770 0.008349277381922826839797549849,
17771 0.004077356197944339378685238508,
17772 0.002008392826082214417852769232,
17773 0.000994575127818085337145958900,
17774 0.000494188604119464558702282526,
17775 0.000246086553308048298637998047,
17776 0.000122713347578489146751836526,
17777 0.000061248135058704829258545105,
17778 0.000030588236307020493551728510,
17779 0.000015282259408651871732571487,
17780 7.6371976378997622736002935630e-6,
17781 3.8172932649998398564616446219e-6,
17782 1.9082127165539389256569577951e-6,
17783 9.5396203387279611315203868344e-7,
17784 4.7693298678780646311671960437e-7,
17785 2.3845050272773299000364818675e-7,
17786 1.1921992596531107306778871888e-7,
17787 5.9608189051259479612440207935e-8,
17788 2.9803503514652280186063705069e-8,
17789 1.4901554828365041234658506630e-8,
17790 7.4507117898354294919810041706e-9,
17791 3.7253340247884570548192040184e-9,
17792 1.8626597235130490064039099454e-9,
17793 9.3132743241966818287176473502e-10,
17794 4.6566290650337840729892332512e-10,
17795 2.3283118336765054920014559759e-10,
17796 1.1641550172700519775929738354e-10,
17797 5.8207720879027008892436859891e-11,
17798 2.9103850444970996869294252278e-11,
17799 1.4551921891041984235929632245e-11,
17800 7.2759598350574810145208690123e-12,
17801 3.6379795473786511902372363558e-12,
17802 1.8189896503070659475848321007e-12,
17803 9.0949478402638892825331183869e-13,
17804 4.5474737830421540267991120294e-13,
17805 2.2737368458246525152268215779e-13,
17806 1.1368684076802278493491048380e-13,
17807 5.6843419876275856092771829675e-14,
17808 2.8421709768893018554550737049e-14,
17809 1.4210854828031606769834307141e-14,
17810 7.1054273952108527128773544799e-15,
17811 3.5527136913371136732984695340e-15,
17812 1.7763568435791203274733490144e-15,
17813 8.8817842109308159030960913863e-16,
17814 4.4408921031438133641977709402e-16,
17815 2.2204460507980419839993200942e-16,
17816 1.1102230251410661337205445699e-16,
17817 5.5511151248454812437237365905e-17,
17818 2.7755575621361241725816324538e-17,
17819 1.3877787809725232762839094906e-17,
17820 6.9388939045441536974460853262e-18,
17821 3.4694469521659226247442714961e-18,
17822 1.7347234760475765720489729699e-18,
17823 8.6736173801199337283420550673e-19,
17824 4.3368086900206504874970235659e-19,
17825 2.1684043449972197850139101683e-19,
17826 1.0842021724942414063012711165e-19,
17827 5.4210108624566454109187004043e-20,
17828 2.7105054312234688319546213119e-20,
17829 1.3552527156101164581485233996e-20,
17830 6.7762635780451890979952987415e-21,
17831 3.3881317890207968180857031004e-21,
17832 1.6940658945097991654064927471e-21,
17833 8.4703294725469983482469926091e-22,
17834 4.2351647362728333478622704833e-22,
17835 2.1175823681361947318442094398e-22,
17836 1.0587911840680233852265001539e-22,
17837 5.2939559203398703238139123029e-23,
17838 2.6469779601698529611341166842e-23,
17839 1.3234889800848990803094510250e-23,
17840 6.6174449004244040673552453323e-24,
17841 3.3087224502121715889469563843e-24,
17842 1.6543612251060756462299236771e-24,
17843 8.2718061255303444036711056167e-25,
17844 4.1359030627651609260093824555e-25,
17845 2.0679515313825767043959679193e-25,
17846 1.0339757656912870993284095591e-25,
17847 5.1698788284564313204101332166e-26,
17848 2.5849394142282142681277617708e-26,
17849 1.2924697071141066700381126118e-26,
17850 6.4623485355705318034380021611e-27,
17851 3.2311742677852653861348141180e-27,
17852 1.6155871338926325212060114057e-27,
17853 8.0779356694631620331587381863e-28,
17854 4.0389678347315808256222628129e-28,
17855 2.0194839173657903491587626465e-28,
17856 1.0097419586828951533619250700e-28,
17857 5.0487097934144756960847711725e-29,
17858 2.5243548967072378244674341938e-29,
17859 1.2621774483536189043753999660e-29,
17860 6.3108872417680944956826093943e-30,
17861 3.1554436208840472391098412184e-30,
17862 1.5777218104420236166444327830e-30,
17863 7.8886090522101180735205378276e-31
17864};
17865
17866
17867#define ZETA_NEG_TABLE_NMAX 99
17868#define ZETA_NEG_TABLE_SIZE 50
17869static double zeta_neg_int_table[ZETA_NEG_TABLE_SIZE] = {
17870 -0.083333333333333333333333333333, /* zeta(-1) */
17871 0.008333333333333333333333333333, /* zeta(-3) */
17872 -0.003968253968253968253968253968, /* ... */
17873 0.004166666666666666666666666667,
17874 -0.007575757575757575757575757576,
17875 0.021092796092796092796092796093,
17876 -0.083333333333333333333333333333,
17877 0.44325980392156862745098039216,
17878 -3.05395433027011974380395433027,
17879 26.4562121212121212121212121212,
17880 -281.460144927536231884057971014,
17881 3607.5105463980463980463980464,
17882 -54827.583333333333333333333333,
17883 974936.82385057471264367816092,
17884 -2.0052695796688078946143462272e+07,
17885 4.7238486772162990196078431373e+08,
17886 -1.2635724795916666666666666667e+10,
17887 3.8087931125245368811553022079e+11,
17888 -1.2850850499305083333333333333e+13,
17889 4.8241448354850170371581670362e+14,
17890 -2.0040310656516252738108421663e+16,
17891 9.1677436031953307756992753623e+17,
17892 -4.5979888343656503490437943262e+19,
17893 2.5180471921451095697089023320e+21,
17894 -1.5001733492153928733711440151e+23,
17895 9.6899578874635940656497942895e+24,
17896 -6.7645882379292820990945242302e+26,
17897 5.0890659468662289689766332916e+28,
17898 -4.1147288792557978697665486068e+30,
17899 3.5666582095375556109684574609e+32,
17900 -3.3066089876577576725680214670e+34,
17901 3.2715634236478716264211227016e+36,
17902 -3.4473782558278053878256455080e+38,
17903 3.8614279832705258893092720200e+40,
17904 -4.5892974432454332168863989006e+42,
17905 5.7775386342770431824884825688e+44,
17906 -7.6919858759507135167410075972e+46,
17907 1.0813635449971654696354033351e+49,
17908 -1.6029364522008965406067102346e+51,
17909 2.5019479041560462843656661499e+53,
17910 -4.1067052335810212479752045004e+55,
17911 7.0798774408494580617452972433e+57,
17912 -1.2804546887939508790190849756e+60,
17913 2.4267340392333524078020892067e+62,
17914 -4.8143218874045769355129570066e+64,
17915 9.9875574175727530680652777408e+66,
17916 -2.1645634868435185631335136160e+69,
17917 4.8962327039620553206849224516e+71, /* ... */
17918 -1.1549023923963519663954271692e+74, /* zeta(-97) */
17919 2.8382249570693706959264156336e+76 /* zeta(-99) */
17920};
17921
17922
17923/* coefficients for Maclaurin summation in hzeta()
17924 * B_{2j}/(2j)!
17925 */
17926static double hzeta_c[15] = {
17927 1.00000000000000000000000000000,
17928 0.083333333333333333333333333333,
17929 -0.00138888888888888888888888888889,
17930 0.000033068783068783068783068783069,
17931 -8.2671957671957671957671957672e-07,
17932 2.0876756987868098979210090321e-08,
17933 -5.2841901386874931848476822022e-10,
17934 1.3382536530684678832826980975e-11,
17935 -3.3896802963225828668301953912e-13,
17936 8.5860620562778445641359054504e-15,
17937 -2.1748686985580618730415164239e-16,
17938 5.5090028283602295152026526089e-18,
17939 -1.3954464685812523340707686264e-19,
17940 3.5347070396294674716932299778e-21,
17941 -8.9535174270375468504026113181e-23
17942};
17943
17944#define ETA_POS_TABLE_NMAX 100
17945static double eta_pos_int_table[ETA_POS_TABLE_NMAX+1] = {
179460.50000000000000000000000000000, /* eta(0) */
17947M_LN2, /* eta(1) */
179480.82246703342411321823620758332, /* ... */
179490.90154267736969571404980362113,
179500.94703282949724591757650323447,
179510.97211977044690930593565514355,
179520.98555109129743510409843924448,
179530.99259381992283028267042571313,
179540.99623300185264789922728926008,
179550.99809429754160533076778303185,
179560.99903950759827156563922184570,
179570.99951714349806075414409417483,
179580.99975768514385819085317967871,
179590.99987854276326511549217499282,
179600.99993917034597971817095419226,
179610.99996955121309923808263293263,
179620.99998476421490610644168277496,
179630.99999237829204101197693787224,
179640.99999618786961011347968922641,
179650.99999809350817167510685649297,
179660.99999904661158152211505084256,
179670.99999952325821554281631666433,
179680.99999976161323082254789720494,
179690.99999988080131843950322382485,
179700.99999994039889239462836140314,
179710.99999997019885696283441513311,
179720.99999998509923199656878766181,
179730.99999999254955048496351585274,
179740.99999999627475340010872752767,
179750.99999999813736941811218674656,
179760.99999999906868228145397862728,
179770.99999999953434033145421751469,
179780.99999999976716989595149082282,
179790.99999999988358485804603047265,
179800.99999999994179239904531592388,
179810.99999999997089618952980952258,
179820.99999999998544809143388476396,
179830.99999999999272404460658475006,
179840.99999999999636202193316875550,
179850.99999999999818101084320873555,
179860.99999999999909050538047887809,
179870.99999999999954525267653087357,
179880.99999999999977262633369589773,
179890.99999999999988631316532476488,
179900.99999999999994315658215465336,
179910.99999999999997157829090808339,
179920.99999999999998578914539762720,
179930.99999999999999289457268000875,
179940.99999999999999644728633373609,
179950.99999999999999822364316477861,
179960.99999999999999911182158169283,
179970.99999999999999955591079061426,
179980.99999999999999977795539522974,
179990.99999999999999988897769758908,
180000.99999999999999994448884878594,
180010.99999999999999997224442439010,
180020.99999999999999998612221219410,
180030.99999999999999999306110609673,
180040.99999999999999999653055304826,
180050.99999999999999999826527652409,
180060.99999999999999999913263826204,
180070.99999999999999999956631913101,
180080.99999999999999999978315956551,
180090.99999999999999999989157978275,
180100.99999999999999999994578989138,
180110.99999999999999999997289494569,
180120.99999999999999999998644747284,
180130.99999999999999999999322373642,
180140.99999999999999999999661186821,
180150.99999999999999999999830593411,
180160.99999999999999999999915296705,
180170.99999999999999999999957648353,
180180.99999999999999999999978824176,
180190.99999999999999999999989412088,
180200.99999999999999999999994706044,
180210.99999999999999999999997353022,
180220.99999999999999999999998676511,
180230.99999999999999999999999338256,
180240.99999999999999999999999669128,
180250.99999999999999999999999834564,
180260.99999999999999999999999917282,
180270.99999999999999999999999958641,
180280.99999999999999999999999979320,
180290.99999999999999999999999989660,
180300.99999999999999999999999994830,
180310.99999999999999999999999997415,
180320.99999999999999999999999998708,
180330.99999999999999999999999999354,
180340.99999999999999999999999999677,
180350.99999999999999999999999999838,
180360.99999999999999999999999999919,
180370.99999999999999999999999999960,
180380.99999999999999999999999999980,
180390.99999999999999999999999999990,
180400.99999999999999999999999999995,
180410.99999999999999999999999999997,
180420.99999999999999999999999999999,
180430.99999999999999999999999999999,
180441.00000000000000000000000000000,
180451.00000000000000000000000000000,
180461.00000000000000000000000000000,
18047};
18048
18049
18050#define ETA_NEG_TABLE_NMAX 99
18051#define ETA_NEG_TABLE_SIZE 50
18052static double eta_neg_int_table[ETA_NEG_TABLE_SIZE] = {
18053 0.25000000000000000000000000000, /* eta(-1) */
18054-0.12500000000000000000000000000, /* eta(-3) */
18055 0.25000000000000000000000000000, /* ... */
18056-1.06250000000000000000000000000,
18057 7.75000000000000000000000000000,
18058-86.3750000000000000000000000000,
18059 1365.25000000000000000000000000,
18060-29049.0312500000000000000000000,
18061 800572.750000000000000000000000,
18062-2.7741322625000000000000000000e+7,
18063 1.1805291302500000000000000000e+9,
18064-6.0523980051687500000000000000e+10,
18065 3.6794167785377500000000000000e+12,
18066-2.6170760990658387500000000000e+14,
18067 2.1531418140800295250000000000e+16,
18068-2.0288775575173015930156250000e+18,
18069 2.1708009902623770590275000000e+20,
18070-2.6173826968455814932120125000e+22,
18071 3.5324148876863877826668602500e+24,
18072-5.3042033406864906641493838981e+26,
18073 8.8138218364311576767253114668e+28,
18074-1.6128065107490778547354654864e+31,
18075 3.2355470001722734208527794569e+33,
18076-7.0876727476537493198506645215e+35,
18077 1.6890450341293965779175629389e+38,
18078-4.3639690731216831157655651358e+40,
18079 1.2185998827061261322605065672e+43,
18080-3.6670584803153006180101262324e+45,
18081 1.1859898526302099104271449748e+48,
18082-4.1120769493584015047981746438e+50,
18083 1.5249042436787620309090168687e+53,
18084-6.0349693196941307074572991901e+55,
18085 2.5437161764210695823197691519e+58,
18086-1.1396923802632287851130360170e+61,
18087 5.4180861064753979196802726455e+63,
18088-2.7283654799994373847287197104e+66,
18089 1.4529750514918543238511171663e+69,
18090-8.1705519371067450079777183386e+71,
18091 4.8445781606678367790247757259e+74,
18092-3.0246694206649519336179448018e+77,
18093 1.9858807961690493054169047970e+80,
18094-1.3694474620720086994386818232e+83,
18095 9.9070382984295807826303785989e+85,
18096-7.5103780796592645925968460677e+88,
18097 5.9598418264260880840077992227e+91,
18098-4.9455988887500020399263196307e+94,
18099 4.2873596927020241277675775935e+97,
18100-3.8791952037716162900707994047e+100,
18101 3.6600317773156342245401829308e+103,
18102-3.5978775704117283875784869570e+106 /* eta(-99) */
18103};
18104
18105
18106/*-*-*-*-*-*-*-*-*-*-*-* Functions with Error Codes *-*-*-*-*-*-*-*-*-*-*-*/
18107
18108
18109int gsl_sf_hzeta_e(const double s, const double q, gsl_sf_result * result)
18110{
18111 /* CHECK_POINTER(result) */
18112
18113 if(s <= 1.0 || q <= 0.0) {
18114 DOMAIN_ERROR(result);
18115 }
18116 else {
18117 const double max_bits = 54.0;
18118 const double ln_term0 = -s * log(q);
18119
18120 if(ln_term0 < GSL_LOG_DBL_MIN + 1.0) {
18121 UNDERFLOW_ERROR(result);
18122 }
18123 else if(ln_term0 > GSL_LOG_DBL_MAX - 1.0) {
18124 OVERFLOW_ERROR (result);
18125 }
18126 else if((s > max_bits && q < 1.0) || (s > 0.5*max_bits && q < 0.25)) {
18127 result->val = pow(q, -s);
18128 result->err = 2.0 * GSL_DBL_EPSILON * fabs(result->val);
18129 return GSL_SUCCESS;
18130 }
18131 else if(s > 0.5*max_bits && q < 1.0) {
18132 const double p1 = pow(q, -s);
18133 const double p2 = pow(q/(1.0+q), s);
18134 const double p3 = pow(q/(2.0+q), s);
18135 result->val = p1 * (1.0 + p2 + p3);
18136 result->err = GSL_DBL_EPSILON * (0.5*s + 2.0) * fabs(result->val);
18137 return GSL_SUCCESS;
18138 }
18139 else {
18140 /* Euler-Maclaurin summation formula
18141 * [Moshier, p. 400, with several typo corrections]
18142 */
18143 const int jmax = 12;
18144 const int kmax = 10;
18145 int j, k;
18146 const double pmax = pow(kmax + q, -s);
18147 double scp = s;
18148 double pcp = pmax / (kmax + q);
18149 double ans = pmax*((kmax+q)/(s-1.0) + 0.5);
18150
18151 for(k=0; k<kmax; k++) {
18152 ans += pow(k + q, -s);
18153 }
18154
18155 for(j=0; j<=jmax; j++) {
18156 double delta = hzeta_c[j+1] * scp * pcp;
18157 ans += delta;
18158 if(fabs(delta/ans) < 0.5*GSL_DBL_EPSILON) break;
18159 scp *= (s+2*j+1)*(s+2*j+2);
18160 pcp /= (kmax + q)*(kmax + q);
18161 }
18162
18163 result->val = ans;
18164 result->err = 2.0 * (jmax + 1.0) * GSL_DBL_EPSILON * fabs(ans);
18165 return GSL_SUCCESS;
18166 }
18167 }
18168}
18169
18170
18171int gsl_sf_zeta_e(const double s, gsl_sf_result * result)
18172{
18173 /* CHECK_POINTER(result) */
18174
18175 if(s == 1.0) {
18176 DOMAIN_ERROR(result);
18177 }
18178 else if(s >= 0.0) {
18179 return riemann_zeta_sgt0(s, result);
18180 }
18181 else {
18182 /* reflection formula, [Abramowitz+Stegun, 23.2.5] */
18183
18184 gsl_sf_result zeta_one_minus_s;
18185 const int stat_zoms = riemann_zeta1ms_slt0(s, &zeta_one_minus_s);
18186 const double sin_term = (fmod(s,2.0) == 0.0) ? 0.0 : sin(0.5*M_PI*fmod(s,4.0))/M_PI;
18187
18188 if(sin_term == 0.0) {
18189 result->val = 0.0;
18190 result->err = 0.0;
18191 return GSL_SUCCESS;
18192 }
18193 else if(s > -170) {
18194 /* We have to be careful about losing digits
18195 * in calculating pow(2 Pi, s). The gamma
18196 * function is fine because we were careful
18197 * with that implementation.
18198 * We keep an array of (2 Pi)^(10 n).
18199 */
18200 const double twopi_pow[18] = { 1.0,
18201 9.589560061550901348e+007,
18202 9.195966217409212684e+015,
18203 8.818527036583869903e+023,
18204 8.456579467173150313e+031,
18205 8.109487671573504384e+039,
18206 7.776641909496069036e+047,
18207 7.457457466828644277e+055,
18208 7.151373628461452286e+063,
18209 6.857852693272229709e+071,
18210 6.576379029540265771e+079,
18211 6.306458169130020789e+087,
18212 6.047615938853066678e+095,
18213 5.799397627482402614e+103,
18214 5.561367186955830005e+111,
18215 5.333106466365131227e+119,
18216 5.114214477385391780e+127,
18217 4.904306689854036836e+135
18218 };
18219 const int n = floor((-s)/10.0);
18220 const double fs = s + 10.0*n;
18221 const double p = pow(2.0*M_PI, fs) / twopi_pow[n];
18222
18223 gsl_sf_result g;
18224 const int stat_g = gsl_sf_gamma_e(1.0-s, &g);
18225 result->val = p * g.val * sin_term * zeta_one_minus_s.val;
18226 result->err = fabs(p * g.val * sin_term) * zeta_one_minus_s.err;
18227 result->err += fabs(p * sin_term * zeta_one_minus_s.val) * g.err;
18228 result->err += GSL_DBL_EPSILON * (fabs(s)+2.0) * fabs(result->val);
18229 return GSL_ERROR_SELECT_2(stat_g, stat_zoms);
18230 }
18231 else {
18232 /* The actual zeta function may or may not
18233 * overflow here. But we have no easy way
18234 * to calculate it when the prefactor(s)
18235 * overflow. Trying to use log's and exp
18236 * is no good because we loose a couple
18237 * digits to the exp error amplification.
18238 * When we gather a little more patience,
18239 * we can implement something here. Until
18240 * then just give up.
18241 */
18242 OVERFLOW_ERROR(result);
18243 }
18244 }
18245}
18246
18247
18248int gsl_sf_zeta_int_e(const int n, gsl_sf_result * result)
18249{
18250 /* CHECK_POINTER(result) */
18251
18252 if(n < 0) {
18253 if(!GSL_IS_ODD(n)) {
18254 result->val = 0.0; /* exactly zero at even negative integers */
18255 result->err = 0.0;
18256 return GSL_SUCCESS;
18257 }
18258 else if(n > -ZETA_NEG_TABLE_NMAX) {
18259 result->val = zeta_neg_int_table[-(n+1)/2];
18260 result->err = 2.0 * GSL_DBL_EPSILON * fabs(result->val);
18261 return GSL_SUCCESS;
18262 }
18263 else {
18264 return gsl_sf_zeta_e((double)n, result);
18265 }
18266 }
18267 else if(n == 1){
18268 DOMAIN_ERROR(result);
18269 }
18270 else if(n <= ZETA_POS_TABLE_NMAX){
18271 result->val = 1.0 + zetam1_pos_int_table[n];
18272 result->err = 2.0 * GSL_DBL_EPSILON * fabs(result->val);
18273 return GSL_SUCCESS;
18274 }
18275 else {
18276 result->val = 1.0;
18277 result->err = GSL_DBL_EPSILON;
18278 return GSL_SUCCESS;
18279 }
18280}
18281
18282
18283int gsl_sf_zetam1_e(const double s, gsl_sf_result * result)
18284{
18285 if(s <= 5.0)
18286 {
18287 int stat = gsl_sf_zeta_e(s, result);
18288 result->val = result->val - 1.0;
18289 return stat;
18290 }
18291 else if(s < 15.0)
18292 {
18293 return riemann_zeta_minus_1_intermediate_s(s, result);
18294 }
18295 else
18296 {
18297 return riemann_zeta_minus1_large_s(s, result);
18298 }
18299}
18300
18301
18302int gsl_sf_zetam1_int_e(const int n, gsl_sf_result * result)
18303{
18304 if(n < 0) {
18305 if(!GSL_IS_ODD(n)) {
18306 result->val = -1.0; /* at even negative integers zetam1 == -1 since zeta is exactly zero */
18307 result->err = 0.0;
18308 return GSL_SUCCESS;
18309 }
18310 else if(n > -ZETA_NEG_TABLE_NMAX) {
18311 result->val = zeta_neg_int_table[-(n+1)/2] - 1.0;
18312 result->err = 2.0 * GSL_DBL_EPSILON * fabs(result->val);
18313 return GSL_SUCCESS;
18314 }
18315 else {
18316 /* could use gsl_sf_zetam1_e here but subtracting 1 makes no difference
18317 for such large values, so go straight to the result */
18318 return gsl_sf_zeta_e((double)n, result);
18319 }
18320 }
18321 else if(n == 1){
18322 DOMAIN_ERROR(result);
18323 }
18324 else if(n <= ZETA_POS_TABLE_NMAX){
18325 result->val = zetam1_pos_int_table[n];
18326 result->err = 2.0 * GSL_DBL_EPSILON * fabs(result->val);
18327 return GSL_SUCCESS;
18328 }
18329 else {
18330 return gsl_sf_zetam1_e(n, result);
18331 }
18332}
18333
18334
18335int gsl_sf_eta_int_e(int n, gsl_sf_result * result)
18336{
18337 if(n > ETA_POS_TABLE_NMAX) {
18338 result->val = 1.0;
18339 result->err = GSL_DBL_EPSILON;
18340 return GSL_SUCCESS;
18341 }
18342 else if(n >= 0) {
18343 result->val = eta_pos_int_table[n];
18344 result->err = 2.0 * GSL_DBL_EPSILON * fabs(result->val);
18345 return GSL_SUCCESS;
18346 }
18347 else {
18348 /* n < 0 */
18349
18350 if(!GSL_IS_ODD(n)) {
18351 /* exactly zero at even negative integers */
18352 result->val = 0.0;
18353 result->err = 0.0;
18354 return GSL_SUCCESS;
18355 }
18356 else if(n > -ETA_NEG_TABLE_NMAX) {
18357 result->val = eta_neg_int_table[-(n+1)/2];
18358 result->err = 2.0 * GSL_DBL_EPSILON * fabs(result->val);
18359 return GSL_SUCCESS;
18360 }
18361 else {
18362 gsl_sf_result z;
18363 gsl_sf_result p;
18364 int stat_z = gsl_sf_zeta_int_e(n, &z);
18365 int stat_p = gsl_sf_exp_e((1.0-n)*M_LN2, &p);
18366 int stat_m = gsl_sf_multiply_e(-p.val, z.val, result);
18367 result->err = fabs(p.err * (M_LN2*(1.0-n)) * z.val) + z.err * fabs(p.val);
18368 result->err += 2.0 * GSL_DBL_EPSILON * fabs(result->val);
18369 return GSL_ERROR_SELECT_3(stat_m, stat_p, stat_z);
18370 }
18371 }
18372}
18373
18374
18375int gsl_sf_eta_e(const double s, gsl_sf_result * result)
18376{
18377 /* CHECK_POINTER(result) */
18378
18379 if(s > 100.0) {
18380 result->val = 1.0;
18381 result->err = GSL_DBL_EPSILON;
18382 return GSL_SUCCESS;
18383 }
18384 else if(fabs(s-1.0) < 10.0*GSL_ROOT5_DBL_EPSILON) {
18385 double del = s-1.0;
18386 double c0 = M_LN2;
18387 double c1 = M_LN2 * (M_EULER - 0.5*M_LN2);
18388 double c2 = -0.0326862962794492996;
18389 double c3 = 0.0015689917054155150;
18390 double c4 = 0.00074987242112047532;
18391 result->val = c0 + del * (c1 + del * (c2 + del * (c3 + del * c4)));
18392 result->err = 2.0 * GSL_DBL_EPSILON * fabs(result->val);
18393 return GSL_SUCCESS;
18394 }
18395 else {
18396 gsl_sf_result z;
18397 gsl_sf_result p;
18398 int stat_z = gsl_sf_zeta_e(s, &z);
18399 int stat_p = gsl_sf_exp_e((1.0-s)*M_LN2, &p);
18400 int stat_m = gsl_sf_multiply_e(1.0-p.val, z.val, result);
18401 result->err = fabs(p.err * (M_LN2*(1.0-s)) * z.val) + z.err * fabs(p.val);
18402 result->err += 2.0 * GSL_DBL_EPSILON * fabs(result->val);
18403 return GSL_ERROR_SELECT_3(stat_m, stat_p, stat_z);
18404 }
18405}
18406
18407
18408/*-*-*-*-*-*-*-*-*-* Functions w/ Natural Prototypes *-*-*-*-*-*-*-*-*-*-*/
18409
18410/* inlined: eval.h */
18411
18412double gsl_sf_zeta(const double s)
18413{
18414 EVAL_RESULT(gsl_sf_zeta_e(s, &result));
18415}
18416
18417double gsl_sf_hzeta(const double s, const double a)
18418{
18419 EVAL_RESULT(gsl_sf_hzeta_e(s, a, &result));
18420}
18421
18422double gsl_sf_zeta_int(const int s)
18423{
18424 EVAL_RESULT(gsl_sf_zeta_int_e(s, &result));
18425}
18426
18427double gsl_sf_zetam1(const double s)
18428{
18429 EVAL_RESULT(gsl_sf_zetam1_e(s, &result));
18430}
18431
18432double gsl_sf_zetam1_int(const int s)
18433{
18434 EVAL_RESULT(gsl_sf_zetam1_int_e(s, &result));
18435}
18436
18437double gsl_sf_eta_int(const int s)
18438{
18439 EVAL_RESULT(gsl_sf_eta_int_e(s, &result));
18440}
18441
18442double gsl_sf_eta(const double s)
18443{
18444 EVAL_RESULT(gsl_sf_eta_e(s, &result));
18445}
18446/* end inlined source: specfunc/zeta.c */
18447/* begin inlined source: specfunc/psi.c */
18448/* specfunc/psi.c
18449 *
18450 * Copyright (C) 2007 Brian Gough
18451 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2004, 2005, 2006 Gerard Jungman
18452 *
18453 * This program is free software; you can redistribute it and/or modify
18454 * it under the terms of the GNU General Public License as published by
18455 * the Free Software Foundation; either version 3 of the License, or (at
18456 * your option) any later version.
18457 *
18458 * This program is distributed in the hope that it will be useful, but
18459 * WITHOUT ANY WARRANTY; without even the implied warranty of
18460 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18461 * General Public License for more details.
18462 *
18463 * You should have received a copy of the GNU General Public License
18464 * along with this program; if not, write to the Free Software
18465 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18466 */
18467
18468/* Author: G. Jungman */
18469/* begin inlined header: config.h */
18470#ifndef MARLEY_BUILTIN_GSL_CONFIG_WRAPPER_H
18471#define MARLEY_BUILTIN_GSL_CONFIG_WRAPPER_H
18472/* begin inlined header: gsl_config.h */
18473#ifndef MARLEY_BUILTIN_GSL_CONFIG_H
18474#define MARLEY_BUILTIN_GSL_CONFIG_H
18475
18476#define HAVE_INLINE 1
18477#define HAVE_DECL_ISFINITE 1
18478#define HAVE_DECL_ISNAN 1
18479#define HAVE_DECL_ISINF 1
18480#define GSL_COERCE_DBL(x) (x)
18481
18482#define GSL_DISABLE_DEPRECATED 0
18483#define PACKAGE_VERSION "2.8"
18484#define VERSION "2.8"
18485
18486#endif
18487
18488/* end inlined header: gsl_config.h */
18489#endif
18490
18491/* end inlined header: config.h */
18492/* begin inlined header: gsl/gsl_math.h */
18493/* gsl_math.h
18494 *
18495 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2004, 2007 Gerard Jungman, Brian Gough
18496 *
18497 * This program is free software; you can redistribute it and/or modify
18498 * it under the terms of the GNU General Public License as published by
18499 * the Free Software Foundation; either version 3 of the License, or (at
18500 * your option) any later version.
18501 *
18502 * This program is distributed in the hope that it will be useful, but
18503 * WITHOUT ANY WARRANTY; without even the implied warranty of
18504 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18505 * General Public License for more details.
18506 *
18507 * You should have received a copy of the GNU General Public License
18508 * along with this program; if not, write to the Free Software
18509 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18510 */
18511
18512#ifndef __GSL_MATH_H__
18513#define __GSL_MATH_H__
18514#include <math.h>
18515/* begin inlined header: gsl/gsl_sys.h */
18516/* sys/gsl_sys.h
18517 *
18518 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, Brian Gough
18519 *
18520 * This program is free software; you can redistribute it and/or modify
18521 * it under the terms of the GNU General Public License as published by
18522 * the Free Software Foundation; either version 3 of the License, or (at
18523 * your option) any later version.
18524 *
18525 * This program is distributed in the hope that it will be useful, but
18526 * WITHOUT ANY WARRANTY; without even the implied warranty of
18527 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18528 * General Public License for more details.
18529 *
18530 * You should have received a copy of the GNU General Public License
18531 * along with this program; if not, write to the Free Software
18532 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18533 */
18534
18535#ifndef __GSL_SYS_H__
18536#define __GSL_SYS_H__
18537
18538
18539
18540__BEGIN_DECLS
18541
18542double gsl_log1p (const double x);
18543double gsl_expm1 (const double x);
18544double gsl_hypot (const double x, const double y);
18545double gsl_hypot3 (const double x, const double y, const double z);
18546double gsl_acosh (const double x);
18547double gsl_asinh (const double x);
18548double gsl_atanh (const double x);
18549
18550int gsl_isnan (const double x);
18551int gsl_isinf (const double x);
18552int gsl_finite (const double x);
18553
18554double gsl_nan (void);
18555double gsl_posinf (void);
18556double gsl_neginf (void);
18557double gsl_fdiv (const double x, const double y);
18558
18559double gsl_coerce_double (const double x);
18560float gsl_coerce_float (const float x);
18561long double gsl_coerce_long_double (const long double x);
18562
18563double gsl_ldexp(const double x, const int e);
18564double gsl_frexp(const double x, int * e);
18565
18566int gsl_fcmp (const double x1, const double x2, const double epsilon);
18567
18568__END_DECLS
18569
18570#endif /* __GSL_SYS_H__ */
18571
18572/* end inlined header: gsl/gsl_sys.h */
18573/* begin inlined header: gsl/gsl_inline.h */
18574/* gsl_inline.h
18575 *
18576 * Copyright (C) 2008, 2009 Brian Gough
18577 *
18578 * This program is free software; you can redistribute it and/or modify
18579 * it under the terms of the GNU General Public License as published by
18580 * the Free Software Foundation; either version 3 of the License, or (at
18581 * your option) any later version.
18582 *
18583 * This program is distributed in the hope that it will be useful, but
18584 * WITHOUT ANY WARRANTY; without even the implied warranty of
18585 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18586 * General Public License for more details.
18587 *
18588 * You should have received a copy of the GNU General Public License
18589 * along with this program; if not, write to the Free Software
18590 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18591 */
18592
18593#ifndef __GSL_INLINE_H__
18594#define __GSL_INLINE_H__
18595
18596/* In recent versiions of GCC, the inline keyword has two different
18597 forms: GNU and C99.
18598
18599 In GNU mode we can use 'extern inline' to make inline functions
18600 work like macros. The function is only inlined--it is never output
18601 as a definition in an object file.
18602
18603 In the new C99 mode 'extern inline' has a different meaning--it
18604 causes the definition of the function to be output in each object
18605 file where it is used. This will result in multiple-definition
18606 errors on linking. The 'inline' keyword on its own (without
18607 extern) has the same behavior as the original GNU 'extern inline'.
18608
18609 The C99 style is the default with -std=c99 in GCC 4.3.
18610
18611 This header file allows either form of inline to be used by
18612 redefining the macros INLINE_DECL and INLINE_FUN. These are used
18613 in the public header files as
18614
18615 INLINE_DECL double gsl_foo (double x);
18616 #ifdef HAVE_INLINE
18617 INLINE_FUN double gsl_foo (double x) { return x+1.0; } ;
18618 #endif
18619
18620*/
18621
18622#ifdef HAVE_INLINE
18623# if defined(__GNUC_STDC_INLINE__) || defined(GSL_C99_INLINE) || defined(HAVE_C99_INLINE)
18624# define INLINE_DECL inline /* use C99 inline */
18625# define INLINE_FUN inline
18626# else
18627# define INLINE_DECL /* use GNU extern inline */
18628# define INLINE_FUN extern inline
18629# endif
18630#else
18631# define INLINE_DECL /* */
18632#endif
18633
18634/* Range checking conditions in headers do not require any run-time
18635 tests of the global variable gsl_check_range. They are enabled or
18636 disabled in user code at compile time with GSL_RANGE_CHECK macro.
18637 See also build.h. */
18638#define GSL_RANGE_COND(x) (x)
18639
18640#endif /* __GSL_INLINE_H__ */
18641
18642/* end inlined header: gsl/gsl_inline.h */
18643/* begin inlined header: gsl/gsl_machine.h */
18644/* Author: B. Gough and G. Jungman */
18645#ifndef __GSL_MACHINE_H__
18646#define __GSL_MACHINE_H__
18647
18648#include <limits.h>
18649#include <float.h>
18650
18651/* magic constants; mostly for the benefit of the implementation */
18652
18653/* -*-MACHINE CONSTANTS-*-
18654 *
18655 * PLATFORM: Whiz-O-Matic 9000
18656 * FP_PLATFORM: IEEE-Virtual
18657 * HOSTNAME: nnn.lanl.gov
18658 * DATE: Fri Nov 20 17:53:26 MST 1998
18659 */
18660#define GSL_DBL_EPSILON 2.2204460492503131e-16
18661#define GSL_SQRT_DBL_EPSILON 1.4901161193847656e-08
18662#define GSL_ROOT3_DBL_EPSILON 6.0554544523933429e-06
18663#define GSL_ROOT4_DBL_EPSILON 1.2207031250000000e-04
18664#define GSL_ROOT5_DBL_EPSILON 7.4009597974140505e-04
18665#define GSL_ROOT6_DBL_EPSILON 2.4607833005759251e-03
18666#define GSL_LOG_DBL_EPSILON (-3.6043653389117154e+01)
18667
18668#define GSL_DBL_MIN 2.2250738585072014e-308
18669#define GSL_SQRT_DBL_MIN 1.4916681462400413e-154
18670#define GSL_ROOT3_DBL_MIN 2.8126442852362996e-103
18671#define GSL_ROOT4_DBL_MIN 1.2213386697554620e-77
18672#define GSL_ROOT5_DBL_MIN 2.9476022969691763e-62
18673#define GSL_ROOT6_DBL_MIN 5.3034368905798218e-52
18674#define GSL_LOG_DBL_MIN (-7.0839641853226408e+02)
18675
18676#define GSL_DBL_MAX 1.7976931348623157e+308
18677#define GSL_SQRT_DBL_MAX 1.3407807929942596e+154
18678#define GSL_ROOT3_DBL_MAX 5.6438030941222897e+102
18679#define GSL_ROOT4_DBL_MAX 1.1579208923731620e+77
18680#define GSL_ROOT5_DBL_MAX 4.4765466227572707e+61
18681#define GSL_ROOT6_DBL_MAX 2.3756689782295612e+51
18682#define GSL_LOG_DBL_MAX 7.0978271289338397e+02
18683
18684#define GSL_FLT_EPSILON 1.1920928955078125e-07
18685#define GSL_SQRT_FLT_EPSILON 3.4526698300124393e-04
18686#define GSL_ROOT3_FLT_EPSILON 4.9215666011518501e-03
18687#define GSL_ROOT4_FLT_EPSILON 1.8581361171917516e-02
18688#define GSL_ROOT5_FLT_EPSILON 4.1234622211652937e-02
18689#define GSL_ROOT6_FLT_EPSILON 7.0153878019335827e-02
18690#define GSL_LOG_FLT_EPSILON (-1.5942385152878742e+01)
18691
18692#define GSL_FLT_MIN 1.1754943508222875e-38
18693#define GSL_SQRT_FLT_MIN 1.0842021724855044e-19
18694#define GSL_ROOT3_FLT_MIN 2.2737367544323241e-13
18695#define GSL_ROOT4_FLT_MIN 3.2927225399135965e-10
18696#define GSL_ROOT5_FLT_MIN 2.5944428542140822e-08
18697#define GSL_ROOT6_FLT_MIN 4.7683715820312542e-07
18698#define GSL_LOG_FLT_MIN (-8.7336544750553102e+01)
18699
18700#define GSL_FLT_MAX 3.4028234663852886e+38
18701#define GSL_SQRT_FLT_MAX 1.8446743523953730e+19
18702#define GSL_ROOT3_FLT_MAX 6.9814635196223242e+12
18703#define GSL_ROOT4_FLT_MAX 4.2949672319999986e+09
18704#define GSL_ROOT5_FLT_MAX 5.0859007855960041e+07
18705#define GSL_ROOT6_FLT_MAX 2.6422459233807749e+06
18706#define GSL_LOG_FLT_MAX 8.8722839052068352e+01
18707
18708#define GSL_SFLT_EPSILON 4.8828125000000000e-04
18709#define GSL_SQRT_SFLT_EPSILON 2.2097086912079612e-02
18710#define GSL_ROOT3_SFLT_EPSILON 7.8745065618429588e-02
18711#define GSL_ROOT4_SFLT_EPSILON 1.4865088937534013e-01
18712#define GSL_ROOT5_SFLT_EPSILON 2.1763764082403100e-01
18713#define GSL_ROOT6_SFLT_EPSILON 2.8061551207734325e-01
18714#define GSL_LOG_SFLT_EPSILON (-7.6246189861593985e+00)
18715
18716/* !MACHINE CONSTANTS! */
18717
18718
18719/* a little internal backwards compatibility */
18720#define GSL_MACH_EPS GSL_DBL_EPSILON
18721
18722
18723
18724/* Here are the constants related to or derived from
18725 * machine constants. These are not to be confused with
18726 * the constants that define various precision levels
18727 * for the precision/error system.
18728 *
18729 * This information is determined at configure time
18730 * and is platform dependent. Edit at your own risk.
18731 *
18732 * PLATFORM: WHIZ-O-MATIC
18733 * CONFIG-DATE: Thu Nov 19 19:27:18 MST 1998
18734 * CONFIG-HOST: nnn.lanl.gov
18735 */
18736
18737/* machine precision constants */
18738/* #define GSL_MACH_EPS 1.0e-15 */
18739#define GSL_SQRT_MACH_EPS 3.2e-08
18740#define GSL_ROOT3_MACH_EPS 1.0e-05
18741#define GSL_ROOT4_MACH_EPS 0.000178
18742#define GSL_ROOT5_MACH_EPS 0.00100
18743#define GSL_ROOT6_MACH_EPS 0.00316
18744#define GSL_LOG_MACH_EPS (-34.54)
18745
18746
18747#endif /* __GSL_MACHINE_H__ */
18748
18749/* end inlined header: gsl/gsl_machine.h */
18750/* begin inlined header: gsl/gsl_precision.h */
18751/* gsl_precision.h
18752 *
18753 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
18754 *
18755 * This program is free software; you can redistribute it and/or modify
18756 * it under the terms of the GNU General Public License as published by
18757 * the Free Software Foundation; either version 3 of the License, or (at
18758 * your option) any later version.
18759 *
18760 * This program is distributed in the hope that it will be useful, but
18761 * WITHOUT ANY WARRANTY; without even the implied warranty of
18762 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18763 * General Public License for more details.
18764 *
18765 * You should have received a copy of the GNU General Public License
18766 * along with this program; if not, write to the Free Software
18767 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18768 */
18769
18770/* Author: B. Gough and G. Jungman */
18771
18772#ifndef __GSL_PRECISION_H__
18773#define __GSL_PRECISION_H__
18774/* begin inlined header: gsl/gsl_types.h */
18775/* gsl_types.h
18776 *
18777 * Copyright (C) 2001, 2007 Brian Gough
18778 *
18779 * This program is free software; you can redistribute it and/or modify
18780 * it under the terms of the GNU General Public License as published by
18781 * the Free Software Foundation; either version 3 of the License, or (at
18782 * your option) any later version.
18783 *
18784 * This program is distributed in the hope that it will be useful, but
18785 * WITHOUT ANY WARRANTY; without even the implied warranty of
18786 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18787 * General Public License for more details.
18788 *
18789 * You should have received a copy of the GNU General Public License
18790 * along with this program; if not, write to the Free Software
18791 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18792 */
18793
18794#ifndef __GSL_TYPES_H__
18795#define __GSL_TYPES_H__
18796
18797#ifndef GSL_VAR
18798
18799#ifdef WIN32
18800# ifdef GSL_DLL
18801# ifdef DLL_EXPORT
18802# define GSL_VAR extern __declspec(dllexport)
18803# else
18804# define GSL_VAR extern __declspec(dllimport)
18805# endif
18806# else
18807# define GSL_VAR extern
18808# endif
18809#else
18810# define GSL_VAR extern
18811#endif
18812
18813#endif
18814
18815#endif /* __GSL_TYPES_H__ */
18816
18817/* end inlined header: gsl/gsl_types.h */
18818
18819
18820__BEGIN_DECLS
18821
18822
18823/* A type for the precision indicator.
18824 * This is mainly for pedagogy.
18825 */
18826typedef unsigned int gsl_prec_t;
18827
18828
18829/* The number of precision types.
18830 * Remember that precision-mode
18831 * can index an array.
18832 */
18833#define _GSL_PREC_T_NUM 3
18834
18835
18836/* Arrays containing derived
18837 * precision constants for the
18838 * different precision levels.
18839 */
18840GSL_VAR const double gsl_prec_eps[];
18841GSL_VAR const double gsl_prec_sqrt_eps[];
18842GSL_VAR const double gsl_prec_root3_eps[];
18843GSL_VAR const double gsl_prec_root4_eps[];
18844GSL_VAR const double gsl_prec_root5_eps[];
18845GSL_VAR const double gsl_prec_root6_eps[];
18846
18847
18848__END_DECLS
18849
18850#endif /* __GSL_PRECISION_H__ */
18851
18852/* end inlined header: gsl/gsl_precision.h */
18853/* begin inlined header: gsl/gsl_nan.h */
18854/* gsl_nan.h
18855 *
18856 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, Brian Gough
18857 *
18858 * This program is free software; you can redistribute it and/or modify
18859 * it under the terms of the GNU General Public License as published by
18860 * the Free Software Foundation; either version 3 of the License, or (at
18861 * your option) any later version.
18862 *
18863 * This program is distributed in the hope that it will be useful, but
18864 * WITHOUT ANY WARRANTY; without even the implied warranty of
18865 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18866 * General Public License for more details.
18867 *
18868 * You should have received a copy of the GNU General Public License
18869 * along with this program; if not, write to the Free Software
18870 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18871 */
18872
18873#ifndef __GSL_NAN_H__
18874#define __GSL_NAN_H__
18875
18876#ifdef INFINITY
18877# define GSL_POSINF INFINITY
18878# define GSL_NEGINF (-INFINITY)
18879#elif defined(HUGE_VAL)
18880# define GSL_POSINF HUGE_VAL
18881# define GSL_NEGINF (-HUGE_VAL)
18882#else
18883# define GSL_POSINF (gsl_posinf())
18884# define GSL_NEGINF (gsl_neginf())
18885#endif
18886
18887#ifdef NAN
18888# define GSL_NAN NAN
18889#elif defined(INFINITY)
18890# define GSL_NAN (INFINITY/INFINITY)
18891#else
18892# define GSL_NAN (gsl_nan())
18893#endif
18894
18895#define GSL_POSZERO (+0.0)
18896#define GSL_NEGZERO (-0.0)
18897
18898#endif /* __GSL_NAN_H__ */
18899
18900/* end inlined header: gsl/gsl_nan.h */
18901/* begin inlined header: gsl/gsl_pow_int.h */
18902/* gsl_pow_int.h
18903 *
18904 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2004, 2007 Gerard Jungman, Brian Gough
18905 *
18906 * This program is free software; you can redistribute it and/or modify
18907 * it under the terms of the GNU General Public License as published by
18908 * the Free Software Foundation; either version 3 of the License, or (at
18909 * your option) any later version.
18910 *
18911 * This program is distributed in the hope that it will be useful, but
18912 * WITHOUT ANY WARRANTY; without even the implied warranty of
18913 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18914 * General Public License for more details.
18915 *
18916 * You should have received a copy of the GNU General Public License
18917 * along with this program; if not, write to the Free Software
18918 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18919 */
18920
18921#ifndef __GSL_POW_INT_H__
18922#define __GSL_POW_INT_H__
18923/* begin inlined header: gsl/gsl_inline.h */
18924/* gsl_inline.h
18925 *
18926 * Copyright (C) 2008, 2009 Brian Gough
18927 *
18928 * This program is free software; you can redistribute it and/or modify
18929 * it under the terms of the GNU General Public License as published by
18930 * the Free Software Foundation; either version 3 of the License, or (at
18931 * your option) any later version.
18932 *
18933 * This program is distributed in the hope that it will be useful, but
18934 * WITHOUT ANY WARRANTY; without even the implied warranty of
18935 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18936 * General Public License for more details.
18937 *
18938 * You should have received a copy of the GNU General Public License
18939 * along with this program; if not, write to the Free Software
18940 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18941 */
18942
18943#ifndef __GSL_INLINE_H__
18944#define __GSL_INLINE_H__
18945
18946/* In recent versiions of GCC, the inline keyword has two different
18947 forms: GNU and C99.
18948
18949 In GNU mode we can use 'extern inline' to make inline functions
18950 work like macros. The function is only inlined--it is never output
18951 as a definition in an object file.
18952
18953 In the new C99 mode 'extern inline' has a different meaning--it
18954 causes the definition of the function to be output in each object
18955 file where it is used. This will result in multiple-definition
18956 errors on linking. The 'inline' keyword on its own (without
18957 extern) has the same behavior as the original GNU 'extern inline'.
18958
18959 The C99 style is the default with -std=c99 in GCC 4.3.
18960
18961 This header file allows either form of inline to be used by
18962 redefining the macros INLINE_DECL and INLINE_FUN. These are used
18963 in the public header files as
18964
18965 INLINE_DECL double gsl_foo (double x);
18966 #ifdef HAVE_INLINE
18967 INLINE_FUN double gsl_foo (double x) { return x+1.0; } ;
18968 #endif
18969
18970*/
18971
18972#ifdef HAVE_INLINE
18973# if defined(__GNUC_STDC_INLINE__) || defined(GSL_C99_INLINE) || defined(HAVE_C99_INLINE)
18974# define INLINE_DECL inline /* use C99 inline */
18975# define INLINE_FUN inline
18976# else
18977# define INLINE_DECL /* use GNU extern inline */
18978# define INLINE_FUN extern inline
18979# endif
18980#else
18981# define INLINE_DECL /* */
18982#endif
18983
18984/* Range checking conditions in headers do not require any run-time
18985 tests of the global variable gsl_check_range. They are enabled or
18986 disabled in user code at compile time with GSL_RANGE_CHECK macro.
18987 See also build.h. */
18988#define GSL_RANGE_COND(x) (x)
18989
18990#endif /* __GSL_INLINE_H__ */
18991
18992/* end inlined header: gsl/gsl_inline.h */
18993
18994
18995__BEGIN_DECLS
18996
18997INLINE_DECL double gsl_pow_2(const double x);
18998INLINE_DECL double gsl_pow_3(const double x);
18999INLINE_DECL double gsl_pow_4(const double x);
19000INLINE_DECL double gsl_pow_5(const double x);
19001INLINE_DECL double gsl_pow_6(const double x);
19002INLINE_DECL double gsl_pow_7(const double x);
19003INLINE_DECL double gsl_pow_8(const double x);
19004INLINE_DECL double gsl_pow_9(const double x);
19005
19006#ifdef HAVE_INLINE
19007INLINE_FUN double gsl_pow_2(const double x) { return x*x; }
19008INLINE_FUN double gsl_pow_3(const double x) { return x*x*x; }
19009INLINE_FUN double gsl_pow_4(const double x) { double x2 = x*x; return x2*x2; }
19010INLINE_FUN double gsl_pow_5(const double x) { double x2 = x*x; return x2*x2*x; }
19011INLINE_FUN double gsl_pow_6(const double x) { double x2 = x*x; return x2*x2*x2; }
19012INLINE_FUN double gsl_pow_7(const double x) { double x3 = x*x*x; return x3*x3*x; }
19013INLINE_FUN double gsl_pow_8(const double x) { double x2 = x*x; double x4 = x2*x2; return x4*x4; }
19014INLINE_FUN double gsl_pow_9(const double x) { double x3 = x*x*x; return x3*x3*x3; }
19015#endif
19016
19017double gsl_pow_int(double x, int n);
19018double gsl_pow_uint(double x, unsigned int n);
19019
19020__END_DECLS
19021
19022#endif /* __GSL_POW_INT_H__ */
19023
19024/* end inlined header: gsl/gsl_pow_int.h */
19025/* begin inlined header: gsl/gsl_minmax.h */
19026/* gsl_minmax.h
19027 *
19028 * Copyright (C) 2008 Gerard Jungman, Brian Gough
19029 *
19030 * This program is free software; you can redistribute it and/or modify
19031 * it under the terms of the GNU General Public License as published by
19032 * the Free Software Foundation; either version 3 of the License, or (at
19033 * your option) any later version.
19034 *
19035 * This program is distributed in the hope that it will be useful, but
19036 * WITHOUT ANY WARRANTY; without even the implied warranty of
19037 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19038 * General Public License for more details.
19039 *
19040 * You should have received a copy of the GNU General Public License
19041 * along with this program; if not, write to the Free Software
19042 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19043 */
19044
19045#ifndef __GSL_MINMAX_H__
19046#define __GSL_MINMAX_H__
19047/* begin inlined header: gsl/gsl_inline.h */
19048/* gsl_inline.h
19049 *
19050 * Copyright (C) 2008, 2009 Brian Gough
19051 *
19052 * This program is free software; you can redistribute it and/or modify
19053 * it under the terms of the GNU General Public License as published by
19054 * the Free Software Foundation; either version 3 of the License, or (at
19055 * your option) any later version.
19056 *
19057 * This program is distributed in the hope that it will be useful, but
19058 * WITHOUT ANY WARRANTY; without even the implied warranty of
19059 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19060 * General Public License for more details.
19061 *
19062 * You should have received a copy of the GNU General Public License
19063 * along with this program; if not, write to the Free Software
19064 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19065 */
19066
19067#ifndef __GSL_INLINE_H__
19068#define __GSL_INLINE_H__
19069
19070/* In recent versiions of GCC, the inline keyword has two different
19071 forms: GNU and C99.
19072
19073 In GNU mode we can use 'extern inline' to make inline functions
19074 work like macros. The function is only inlined--it is never output
19075 as a definition in an object file.
19076
19077 In the new C99 mode 'extern inline' has a different meaning--it
19078 causes the definition of the function to be output in each object
19079 file where it is used. This will result in multiple-definition
19080 errors on linking. The 'inline' keyword on its own (without
19081 extern) has the same behavior as the original GNU 'extern inline'.
19082
19083 The C99 style is the default with -std=c99 in GCC 4.3.
19084
19085 This header file allows either form of inline to be used by
19086 redefining the macros INLINE_DECL and INLINE_FUN. These are used
19087 in the public header files as
19088
19089 INLINE_DECL double gsl_foo (double x);
19090 #ifdef HAVE_INLINE
19091 INLINE_FUN double gsl_foo (double x) { return x+1.0; } ;
19092 #endif
19093
19094*/
19095
19096#ifdef HAVE_INLINE
19097# if defined(__GNUC_STDC_INLINE__) || defined(GSL_C99_INLINE) || defined(HAVE_C99_INLINE)
19098# define INLINE_DECL inline /* use C99 inline */
19099# define INLINE_FUN inline
19100# else
19101# define INLINE_DECL /* use GNU extern inline */
19102# define INLINE_FUN extern inline
19103# endif
19104#else
19105# define INLINE_DECL /* */
19106#endif
19107
19108/* Range checking conditions in headers do not require any run-time
19109 tests of the global variable gsl_check_range. They are enabled or
19110 disabled in user code at compile time with GSL_RANGE_CHECK macro.
19111 See also build.h. */
19112#define GSL_RANGE_COND(x) (x)
19113
19114#endif /* __GSL_INLINE_H__ */
19115
19116/* end inlined header: gsl/gsl_inline.h */
19117
19118
19119__BEGIN_DECLS
19120
19121/* Define MAX and MIN macros/functions if they don't exist. */
19122
19123/* plain old macros for general use */
19124#define GSL_MAX(a,b) ((a) > (b) ? (a) : (b))
19125#define GSL_MIN(a,b) ((a) < (b) ? (a) : (b))
19126
19127/* function versions of the above, in case they are needed */
19128double gsl_max (double a, double b);
19129double gsl_min (double a, double b);
19130
19131/* inline-friendly strongly typed versions */
19132#ifdef HAVE_INLINE
19133
19134INLINE_FUN int GSL_MAX_INT (int a, int b);
19135INLINE_FUN int GSL_MIN_INT (int a, int b);
19136INLINE_FUN double GSL_MAX_DBL (double a, double b);
19137INLINE_FUN double GSL_MIN_DBL (double a, double b);
19138INLINE_FUN long double GSL_MAX_LDBL (long double a, long double b);
19139INLINE_FUN long double GSL_MIN_LDBL (long double a, long double b);
19140
19141INLINE_FUN int
19142GSL_MAX_INT (int a, int b)
19143{
19144 return GSL_MAX (a, b);
19145}
19146
19147INLINE_FUN int
19148GSL_MIN_INT (int a, int b)
19149{
19150 return GSL_MIN (a, b);
19151}
19152
19153INLINE_FUN double
19154GSL_MAX_DBL (double a, double b)
19155{
19156 return GSL_MAX (a, b);
19157}
19158
19159INLINE_FUN double
19160GSL_MIN_DBL (double a, double b)
19161{
19162 return GSL_MIN (a, b);
19163}
19164
19165INLINE_FUN long double
19166GSL_MAX_LDBL (long double a, long double b)
19167{
19168 return GSL_MAX (a, b);
19169}
19170
19171INLINE_FUN long double
19172GSL_MIN_LDBL (long double a, long double b)
19173{
19174 return GSL_MIN (a, b);
19175}
19176#else
19177#define GSL_MAX_INT(a,b) GSL_MAX(a,b)
19178#define GSL_MIN_INT(a,b) GSL_MIN(a,b)
19179#define GSL_MAX_DBL(a,b) GSL_MAX(a,b)
19180#define GSL_MIN_DBL(a,b) GSL_MIN(a,b)
19181#define GSL_MAX_LDBL(a,b) GSL_MAX(a,b)
19182#define GSL_MIN_LDBL(a,b) GSL_MIN(a,b)
19183#endif /* HAVE_INLINE */
19184
19185__END_DECLS
19186
19187#endif /* __GSL_POW_INT_H__ */
19188
19189/* end inlined header: gsl/gsl_minmax.h */
19190#ifndef M_E
19191#define M_E 2.71828182845904523536028747135 /* e */
19192#endif
19193
19194#ifndef M_LOG2E
19195#define M_LOG2E 1.44269504088896340735992468100 /* log_2 (e) */
19196#endif
19197
19198#ifndef M_LOG10E
19199#define M_LOG10E 0.43429448190325182765112891892 /* log_10 (e) */
19200#endif
19201
19202#ifndef M_SQRT2
19203#define M_SQRT2 1.41421356237309504880168872421 /* sqrt(2) */
19204#endif
19205
19206#ifndef M_SQRT1_2
19207#define M_SQRT1_2 0.70710678118654752440084436210 /* sqrt(1/2) */
19208#endif
19209
19210
19211#ifndef M_SQRT3
19212#define M_SQRT3 1.73205080756887729352744634151 /* sqrt(3) */
19213#endif
19214
19215#ifndef M_PI
19216#define M_PI 3.14159265358979323846264338328 /* pi */
19217#endif
19218
19219#ifndef M_PI_2
19220#define M_PI_2 1.57079632679489661923132169164 /* pi/2 */
19221#endif
19222
19223#ifndef M_PI_4
19224#define M_PI_4 0.78539816339744830961566084582 /* pi/4 */
19225#endif
19226
19227#ifndef M_SQRTPI
19228#define M_SQRTPI 1.77245385090551602729816748334 /* sqrt(pi) */
19229#endif
19230
19231#ifndef M_2_SQRTPI
19232#define M_2_SQRTPI 1.12837916709551257389615890312 /* 2/sqrt(pi) */
19233#endif
19234
19235#ifndef M_1_PI
19236#define M_1_PI 0.31830988618379067153776752675 /* 1/pi */
19237#endif
19238
19239#ifndef M_2_PI
19240#define M_2_PI 0.63661977236758134307553505349 /* 2/pi */
19241#endif
19242
19243#ifndef M_LN10
19244#define M_LN10 2.30258509299404568401799145468 /* ln(10) */
19245#endif
19246
19247#ifndef M_LN2
19248#define M_LN2 0.69314718055994530941723212146 /* ln(2) */
19249#endif
19250
19251#ifndef M_LNPI
19252#define M_LNPI 1.14472988584940017414342735135 /* ln(pi) */
19253#endif
19254
19255#ifndef M_EULER
19256#define M_EULER 0.57721566490153286060651209008 /* Euler constant */
19257#endif
19258
19259
19260
19261__BEGIN_DECLS
19262
19263/* other needlessly compulsive abstractions */
19264
19265#define GSL_IS_ODD(n) ((n) & 1)
19266#define GSL_IS_EVEN(n) (!(GSL_IS_ODD(n)))
19267#define GSL_SIGN(x) ((x) >= 0.0 ? 1 : -1)
19268
19269/* Return nonzero if x is a real number, i.e. non NaN or infinite. */
19270#define GSL_IS_REAL(x) (gsl_finite(x))
19271
19272/* Definition of an arbitrary function with parameters */
19273
19275{
19276 double (* function) (double x, void * params);
19277 void * params;
19278};
19279
19280typedef struct gsl_function_struct gsl_function ;
19281
19282#define GSL_FN_EVAL(F,x) (*((F)->function))(x,(F)->params)
19283
19284/* Definition of an arbitrary function returning two values, r1, r2 */
19285
19287{
19288 double (* f) (double x, void * params);
19289 double (* df) (double x, void * params);
19290 void (* fdf) (double x, void * params, double * f, double * df);
19291 void * params;
19292};
19293
19294typedef struct gsl_function_fdf_struct gsl_function_fdf ;
19295
19296#define GSL_FN_FDF_EVAL_F(FDF,x) (*((FDF)->f))(x,(FDF)->params)
19297#define GSL_FN_FDF_EVAL_DF(FDF,x) (*((FDF)->df))(x,(FDF)->params)
19298#define GSL_FN_FDF_EVAL_F_DF(FDF,x,y,dy) (*((FDF)->fdf))(x,(FDF)->params,(y),(dy))
19299
19300
19301/* Definition of an arbitrary vector-valued function with parameters */
19302
19304{
19305 int (* function) (double x, double y[], void * params);
19306 void * params;
19307};
19308
19309typedef struct gsl_function_vec_struct gsl_function_vec ;
19310
19311#define GSL_FN_VEC_EVAL(F,x,y) (*((F)->function))(x,y,(F)->params)
19312
19313__END_DECLS
19314
19315#endif /* __GSL_MATH_H__ */
19316
19317/* end inlined header: gsl/gsl_math.h */
19318/* begin inlined header: gsl/gsl_errno.h */
19319/* err/gsl_errno.h
19320 *
19321 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, Brian Gough
19322 *
19323 * This program is free software; you can redistribute it and/or modify
19324 * it under the terms of the GNU General Public License as published by
19325 * the Free Software Foundation; either version 3 of the License, or (at
19326 * your option) any later version.
19327 *
19328 * This program is distributed in the hope that it will be useful, but
19329 * WITHOUT ANY WARRANTY; without even the implied warranty of
19330 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19331 * General Public License for more details.
19332 *
19333 * You should have received a copy of the GNU General Public License
19334 * along with this program; if not, write to the Free Software
19335 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19336 */
19337
19338#ifndef __GSL_ERRNO_H__
19339#define __GSL_ERRNO_H__
19340
19341#include <stdio.h>
19342#include <errno.h>
19343/* begin inlined header: gsl/gsl_types.h */
19344/* gsl_types.h
19345 *
19346 * Copyright (C) 2001, 2007 Brian Gough
19347 *
19348 * This program is free software; you can redistribute it and/or modify
19349 * it under the terms of the GNU General Public License as published by
19350 * the Free Software Foundation; either version 3 of the License, or (at
19351 * your option) any later version.
19352 *
19353 * This program is distributed in the hope that it will be useful, but
19354 * WITHOUT ANY WARRANTY; without even the implied warranty of
19355 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19356 * General Public License for more details.
19357 *
19358 * You should have received a copy of the GNU General Public License
19359 * along with this program; if not, write to the Free Software
19360 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19361 */
19362
19363#ifndef __GSL_TYPES_H__
19364#define __GSL_TYPES_H__
19365
19366#ifndef GSL_VAR
19367
19368#ifdef WIN32
19369# ifdef GSL_DLL
19370# ifdef DLL_EXPORT
19371# define GSL_VAR extern __declspec(dllexport)
19372# else
19373# define GSL_VAR extern __declspec(dllimport)
19374# endif
19375# else
19376# define GSL_VAR extern
19377# endif
19378#else
19379# define GSL_VAR extern
19380#endif
19381
19382#endif
19383
19384#endif /* __GSL_TYPES_H__ */
19385
19386/* end inlined header: gsl/gsl_types.h */
19387
19388
19389__BEGIN_DECLS
19390
19391enum {
19392 GSL_SUCCESS = 0,
19393 GSL_FAILURE = -1,
19394 GSL_CONTINUE = -2, /* iteration has not converged */
19395 GSL_EDOM = 1, /* input domain error, e.g sqrt(-1) */
19396 GSL_ERANGE = 2, /* output range error, e.g. exp(1e100) */
19397 GSL_EFAULT = 3, /* invalid pointer */
19398 GSL_EINVAL = 4, /* invalid argument supplied by user */
19399 GSL_EFAILED = 5, /* generic failure */
19400 GSL_EFACTOR = 6, /* factorization failed */
19401 GSL_ESANITY = 7, /* sanity check failed - shouldn't happen */
19402 GSL_ENOMEM = 8, /* malloc failed */
19403 GSL_EBADFUNC = 9, /* problem with user-supplied function */
19404 GSL_ERUNAWAY = 10, /* iterative process is out of control */
19405 GSL_EMAXITER = 11, /* exceeded max number of iterations */
19406 GSL_EZERODIV = 12, /* tried to divide by zero */
19407 GSL_EBADTOL = 13, /* user specified an invalid tolerance */
19408 GSL_ETOL = 14, /* failed to reach the specified tolerance */
19409 GSL_EUNDRFLW = 15, /* underflow */
19410 GSL_EOVRFLW = 16, /* overflow */
19411 GSL_ELOSS = 17, /* loss of accuracy */
19412 GSL_EROUND = 18, /* failed because of roundoff error */
19413 GSL_EBADLEN = 19, /* matrix, vector lengths are not conformant */
19414 GSL_ENOTSQR = 20, /* matrix not square */
19415 GSL_ESING = 21, /* apparent singularity detected */
19416 GSL_EDIVERGE = 22, /* integral or series is divergent */
19417 GSL_EUNSUP = 23, /* requested feature is not supported by the hardware */
19418 GSL_EUNIMPL = 24, /* requested feature not (yet) implemented */
19419 GSL_ECACHE = 25, /* cache limit exceeded */
19420 GSL_ETABLE = 26, /* table limit exceeded */
19421 GSL_ENOPROG = 27, /* iteration is not making progress towards solution */
19422 GSL_ENOPROGJ = 28, /* jacobian evaluations are not improving the solution */
19423 GSL_ETOLF = 29, /* cannot reach the specified tolerance in F */
19424 GSL_ETOLX = 30, /* cannot reach the specified tolerance in X */
19425 GSL_ETOLG = 31, /* cannot reach the specified tolerance in gradient */
19426 GSL_EOF = 32 /* end of file */
19427} ;
19428
19429void gsl_error (const char * reason, const char * file, int line,
19430 int gsl_errno);
19431
19432void gsl_stream_printf (const char *label, const char *file,
19433 int line, const char *reason);
19434
19435typedef void gsl_error_handler_t (const char * reason, const char * file,
19436 int line, int gsl_errno);
19437
19438gsl_error_handler_t *
19439gsl_set_error_handler (gsl_error_handler_t * new_handler);
19440
19441/* GSL_ERROR: call the error handler, and return the error code */
19442
19443#define GSL_ERROR(reason, gsl_errno) \
19444 do { \
19445 gsl_error (reason, __FILE__, __LINE__, gsl_errno) ; \
19446 return gsl_errno ; \
19447 } while (0)
19448
19449/* GSL_ERROR_VAL: call the error handler, and return the given value */
19450
19451#define GSL_ERROR_VAL(reason, gsl_errno, value) \
19452 do { \
19453 gsl_error (reason, __FILE__, __LINE__, gsl_errno) ; \
19454 return value ; \
19455 } while (0)
19456
19457/* GSL_ERROR_VOID: call the error handler, and then return
19458 (for void functions which still need to generate an error) */
19459
19460#define GSL_ERROR_VOID(reason, gsl_errno) \
19461 do { \
19462 gsl_error (reason, __FILE__, __LINE__, gsl_errno) ; \
19463 return ; \
19464 } while (0)
19465
19466/* GSL_ERROR_NULL suitable for out-of-memory conditions */
19467
19468#define GSL_ERROR_NULL(reason, gsl_errno) GSL_ERROR_VAL(reason, gsl_errno, 0)
19469
19470/* Sometimes you have several status results returned from
19471 * function calls and you want to combine them in some sensible
19472 * way. You cannot produce a "total" status condition, but you can
19473 * pick one from a set of conditions based on an implied hierarchy.
19474 *
19475 * In other words:
19476 * you have: status_a, status_b, ...
19477 * you want: status = (status_a if it is bad, or status_b if it is bad,...)
19478 *
19479 * In this example you consider status_a to be more important and
19480 * it is checked first, followed by the others in the order specified.
19481 *
19482 * Here are some dumb macros to do this.
19483 */
19484#define GSL_ERROR_SELECT_2(a,b) ((a) != GSL_SUCCESS ? (a) : ((b) != GSL_SUCCESS ? (b) : GSL_SUCCESS))
19485#define GSL_ERROR_SELECT_3(a,b,c) ((a) != GSL_SUCCESS ? (a) : GSL_ERROR_SELECT_2(b,c))
19486#define GSL_ERROR_SELECT_4(a,b,c,d) ((a) != GSL_SUCCESS ? (a) : GSL_ERROR_SELECT_3(b,c,d))
19487#define GSL_ERROR_SELECT_5(a,b,c,d,e) ((a) != GSL_SUCCESS ? (a) : GSL_ERROR_SELECT_4(b,c,d,e))
19488
19489#define GSL_STATUS_UPDATE(sp, s) do { if ((s) != GSL_SUCCESS) *(sp) = (s);} while(0)
19490
19491__END_DECLS
19492
19493#endif /* __GSL_ERRNO_H__ */
19494
19495/* end inlined header: gsl/gsl_errno.h */
19496/* begin inlined header: gsl/gsl_sf_exp.h */
19497/* specfunc/gsl_sf_exp.h
19498 *
19499 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2004 Gerard Jungman
19500 *
19501 * This program is free software; you can redistribute it and/or modify
19502 * it under the terms of the GNU General Public License as published by
19503 * the Free Software Foundation; either version 3 of the License, or (at
19504 * your option) any later version.
19505 *
19506 * This program is distributed in the hope that it will be useful, but
19507 * WITHOUT ANY WARRANTY; without even the implied warranty of
19508 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19509 * General Public License for more details.
19510 *
19511 * You should have received a copy of the GNU General Public License
19512 * along with this program; if not, write to the Free Software
19513 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19514 */
19515
19516/* Author: G. Jungman */
19517
19518#ifndef __GSL_SF_EXP_H__
19519#define __GSL_SF_EXP_H__
19520/* begin inlined header: gsl/gsl_sf_result.h */
19521/* specfunc/gsl_sf_result.h
19522 *
19523 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
19524 *
19525 * This program is free software; you can redistribute it and/or modify
19526 * it under the terms of the GNU General Public License as published by
19527 * the Free Software Foundation; either version 3 of the License, or (at
19528 * your option) any later version.
19529 *
19530 * This program is distributed in the hope that it will be useful, but
19531 * WITHOUT ANY WARRANTY; without even the implied warranty of
19532 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19533 * General Public License for more details.
19534 *
19535 * You should have received a copy of the GNU General Public License
19536 * along with this program; if not, write to the Free Software
19537 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19538 */
19539
19540/* Author: G. Jungman */
19541
19542#ifndef __GSL_SF_RESULT_H__
19543#define __GSL_SF_RESULT_H__
19544
19545
19546
19547__BEGIN_DECLS
19548
19549struct gsl_sf_result_struct {
19550 double val;
19551 double err;
19552};
19553typedef struct gsl_sf_result_struct gsl_sf_result;
19554
19555#define GSL_SF_RESULT_SET(r,v,e) do { (r)->val=(v); (r)->err=(e); } while(0)
19556
19557
19559 double val;
19560 double err;
19561 int e10;
19562};
19563typedef struct gsl_sf_result_e10_struct gsl_sf_result_e10;
19564
19565
19566int gsl_sf_result_smash_e(const gsl_sf_result_e10 * re, gsl_sf_result * r);
19567
19568
19569__END_DECLS
19570
19571#endif /* __GSL_SF_RESULT_H__ */
19572
19573/* end inlined header: gsl/gsl_sf_result.h */
19574/* begin inlined header: gsl/gsl_precision.h */
19575/* gsl_precision.h
19576 *
19577 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
19578 *
19579 * This program is free software; you can redistribute it and/or modify
19580 * it under the terms of the GNU General Public License as published by
19581 * the Free Software Foundation; either version 3 of the License, or (at
19582 * your option) any later version.
19583 *
19584 * This program is distributed in the hope that it will be useful, but
19585 * WITHOUT ANY WARRANTY; without even the implied warranty of
19586 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19587 * General Public License for more details.
19588 *
19589 * You should have received a copy of the GNU General Public License
19590 * along with this program; if not, write to the Free Software
19591 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19592 */
19593
19594/* Author: B. Gough and G. Jungman */
19595
19596#ifndef __GSL_PRECISION_H__
19597#define __GSL_PRECISION_H__
19598/* begin inlined header: gsl/gsl_types.h */
19599/* gsl_types.h
19600 *
19601 * Copyright (C) 2001, 2007 Brian Gough
19602 *
19603 * This program is free software; you can redistribute it and/or modify
19604 * it under the terms of the GNU General Public License as published by
19605 * the Free Software Foundation; either version 3 of the License, or (at
19606 * your option) any later version.
19607 *
19608 * This program is distributed in the hope that it will be useful, but
19609 * WITHOUT ANY WARRANTY; without even the implied warranty of
19610 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19611 * General Public License for more details.
19612 *
19613 * You should have received a copy of the GNU General Public License
19614 * along with this program; if not, write to the Free Software
19615 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19616 */
19617
19618#ifndef __GSL_TYPES_H__
19619#define __GSL_TYPES_H__
19620
19621#ifndef GSL_VAR
19622
19623#ifdef WIN32
19624# ifdef GSL_DLL
19625# ifdef DLL_EXPORT
19626# define GSL_VAR extern __declspec(dllexport)
19627# else
19628# define GSL_VAR extern __declspec(dllimport)
19629# endif
19630# else
19631# define GSL_VAR extern
19632# endif
19633#else
19634# define GSL_VAR extern
19635#endif
19636
19637#endif
19638
19639#endif /* __GSL_TYPES_H__ */
19640
19641/* end inlined header: gsl/gsl_types.h */
19642
19643
19644__BEGIN_DECLS
19645
19646
19647/* A type for the precision indicator.
19648 * This is mainly for pedagogy.
19649 */
19650typedef unsigned int gsl_prec_t;
19651
19652
19653/* The number of precision types.
19654 * Remember that precision-mode
19655 * can index an array.
19656 */
19657#define _GSL_PREC_T_NUM 3
19658
19659
19660/* Arrays containing derived
19661 * precision constants for the
19662 * different precision levels.
19663 */
19664GSL_VAR const double gsl_prec_eps[];
19665GSL_VAR const double gsl_prec_sqrt_eps[];
19666GSL_VAR const double gsl_prec_root3_eps[];
19667GSL_VAR const double gsl_prec_root4_eps[];
19668GSL_VAR const double gsl_prec_root5_eps[];
19669GSL_VAR const double gsl_prec_root6_eps[];
19670
19671
19672__END_DECLS
19673
19674#endif /* __GSL_PRECISION_H__ */
19675
19676/* end inlined header: gsl/gsl_precision.h */
19677
19678
19679__BEGIN_DECLS
19680
19681/* Provide an exp() function with GSL semantics,
19682 * i.e. with proper error checking, etc.
19683 *
19684 * exceptions: GSL_EOVRFLW, GSL_EUNDRFLW
19685 */
19686int gsl_sf_exp_e(const double x, gsl_sf_result * result);
19687double gsl_sf_exp(const double x);
19688
19689
19690/* Exp(x)
19691 *
19692 * exceptions: GSL_EOVRFLW, GSL_EUNDRFLW
19693 */
19694int gsl_sf_exp_e10_e(const double x, gsl_sf_result_e10 * result);
19695
19696
19697/* Exponentiate and multiply by a given factor: y * Exp(x)
19698 *
19699 * exceptions: GSL_EOVRFLW, GSL_EUNDRFLW
19700 */
19701int gsl_sf_exp_mult_e(const double x, const double y, gsl_sf_result * result);
19702double gsl_sf_exp_mult(const double x, const double y);
19703
19704
19705/* Exponentiate and multiply by a given factor: y * Exp(x)
19706 *
19707 * exceptions: GSL_EOVRFLW, GSL_EUNDRFLW
19708 */
19709int gsl_sf_exp_mult_e10_e(const double x, const double y, gsl_sf_result_e10 * result);
19710
19711
19712/* exp(x)-1
19713 *
19714 * exceptions: GSL_EOVRFLW
19715 */
19716int gsl_sf_expm1_e(const double x, gsl_sf_result * result);
19717double gsl_sf_expm1(const double x);
19718
19719
19720/* (exp(x)-1)/x = 1 + x/2 + x^2/(2*3) + x^3/(2*3*4) + ...
19721 *
19722 * exceptions: GSL_EOVRFLW
19723 */
19724int gsl_sf_exprel_e(const double x, gsl_sf_result * result);
19725double gsl_sf_exprel(const double x);
19726
19727
19728/* 2(exp(x)-1-x)/x^2 = 1 + x/3 + x^2/(3*4) + x^3/(3*4*5) + ...
19729 *
19730 * exceptions: GSL_EOVRFLW
19731 */
19732int gsl_sf_exprel_2_e(double x, gsl_sf_result * result);
19733double gsl_sf_exprel_2(const double x);
19734
19735
19736/* Similarly for the N-th generalization of
19737 * the above. The so-called N-relative exponential
19738 *
19739 * exprel_N(x) = N!/x^N (exp(x) - Sum[x^k/k!, {k,0,N-1}])
19740 * = 1 + x/(N+1) + x^2/((N+1)(N+2)) + ...
19741 * = 1F1(1,1+N,x)
19742 */
19743int gsl_sf_exprel_n_e(const int n, const double x, gsl_sf_result * result);
19744double gsl_sf_exprel_n(const int n, const double x);
19745
19746int gsl_sf_exprel_n_CF_e(const double n, const double x, gsl_sf_result * result);
19747
19748
19749/* Exponentiate a quantity with an associated error.
19750 */
19751int gsl_sf_exp_err_e(const double x, const double dx, gsl_sf_result * result);
19752
19753/* Exponentiate a quantity with an associated error.
19754 */
19755int gsl_sf_exp_err_e10_e(const double x, const double dx, gsl_sf_result_e10 * result);
19756
19757
19758/* Exponentiate and multiply by a given factor: y * Exp(x),
19759 * for quantities with associated errors.
19760 *
19761 * exceptions: GSL_EOVRFLW, GSL_EUNDRFLW
19762 */
19763int gsl_sf_exp_mult_err_e(const double x, const double dx, const double y, const double dy, gsl_sf_result * result);
19764
19765
19766/* Exponentiate and multiply by a given factor: y * Exp(x),
19767 * for quantities with associated errors.
19768 *
19769 * exceptions: GSL_EOVRFLW, GSL_EUNDRFLW
19770 */
19771int gsl_sf_exp_mult_err_e10_e(const double x, const double dx, const double y, const double dy, gsl_sf_result_e10 * result);
19772
19773__END_DECLS
19774
19775#endif /* __GSL_SF_EXP_H__ */
19776
19777/* end inlined header: gsl/gsl_sf_exp.h */
19778/* begin inlined header: gsl/gsl_sf_gamma.h */
19779/* specfunc/gsl_sf_gamma.h
19780 *
19781 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
19782 *
19783 * This program is free software; you can redistribute it and/or modify
19784 * it under the terms of the GNU General Public License as published by
19785 * the Free Software Foundation; either version 3 of the License, or (at
19786 * your option) any later version.
19787 *
19788 * This program is distributed in the hope that it will be useful, but
19789 * WITHOUT ANY WARRANTY; without even the implied warranty of
19790 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19791 * General Public License for more details.
19792 *
19793 * You should have received a copy of the GNU General Public License
19794 * along with this program; if not, write to the Free Software
19795 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19796 */
19797
19798/* Author: G. Jungman */
19799
19800#ifndef __GSL_SF_GAMMA_H__
19801#define __GSL_SF_GAMMA_H__
19802/* begin inlined header: gsl/gsl_sf_result.h */
19803/* specfunc/gsl_sf_result.h
19804 *
19805 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
19806 *
19807 * This program is free software; you can redistribute it and/or modify
19808 * it under the terms of the GNU General Public License as published by
19809 * the Free Software Foundation; either version 3 of the License, or (at
19810 * your option) any later version.
19811 *
19812 * This program is distributed in the hope that it will be useful, but
19813 * WITHOUT ANY WARRANTY; without even the implied warranty of
19814 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19815 * General Public License for more details.
19816 *
19817 * You should have received a copy of the GNU General Public License
19818 * along with this program; if not, write to the Free Software
19819 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19820 */
19821
19822/* Author: G. Jungman */
19823
19824#ifndef __GSL_SF_RESULT_H__
19825#define __GSL_SF_RESULT_H__
19826
19827
19828
19829__BEGIN_DECLS
19830
19831struct gsl_sf_result_struct {
19832 double val;
19833 double err;
19834};
19835typedef struct gsl_sf_result_struct gsl_sf_result;
19836
19837#define GSL_SF_RESULT_SET(r,v,e) do { (r)->val=(v); (r)->err=(e); } while(0)
19838
19839
19841 double val;
19842 double err;
19843 int e10;
19844};
19845typedef struct gsl_sf_result_e10_struct gsl_sf_result_e10;
19846
19847
19848int gsl_sf_result_smash_e(const gsl_sf_result_e10 * re, gsl_sf_result * r);
19849
19850
19851__END_DECLS
19852
19853#endif /* __GSL_SF_RESULT_H__ */
19854
19855/* end inlined header: gsl/gsl_sf_result.h */
19856
19857
19858__BEGIN_DECLS
19859
19860
19861/* Log[Gamma(x)], x not a negative integer
19862 * Uses real Lanczos method.
19863 * Returns the real part of Log[Gamma[x]] when x < 0,
19864 * i.e. Log[|Gamma[x]|].
19865 *
19866 * exceptions: GSL_EDOM, GSL_EROUND
19867 */
19868int gsl_sf_lngamma_e(double x, gsl_sf_result * result);
19869double gsl_sf_lngamma(const double x);
19870
19871
19872/* Log[Gamma(x)], x not a negative integer
19873 * Uses real Lanczos method. Determines
19874 * the sign of Gamma[x] as well as Log[|Gamma[x]|] for x < 0.
19875 * So Gamma[x] = sgn * Exp[result_lg].
19876 *
19877 * exceptions: GSL_EDOM, GSL_EROUND
19878 */
19879int gsl_sf_lngamma_sgn_e(double x, gsl_sf_result * result_lg, double *sgn);
19880
19881
19882/* Gamma(x), x not a negative integer
19883 * Uses real Lanczos method.
19884 *
19885 * exceptions: GSL_EDOM, GSL_EOVRFLW, GSL_EROUND
19886 */
19887int gsl_sf_gamma_e(const double x, gsl_sf_result * result);
19888double gsl_sf_gamma(const double x);
19889
19890
19891/* Regulated Gamma Function, x > 0
19892 * Gamma^*(x) = Gamma(x)/(Sqrt[2Pi] x^(x-1/2) exp(-x))
19893 * = (1 + 1/(12x) + ...), x->Inf
19894 * A useful suggestion of Temme.
19895 *
19896 * exceptions: GSL_EDOM
19897 */
19898int gsl_sf_gammastar_e(const double x, gsl_sf_result * result);
19899double gsl_sf_gammastar(const double x);
19900
19901
19902/* 1/Gamma(x)
19903 * Uses real Lanczos method.
19904 *
19905 * exceptions: GSL_EUNDRFLW, GSL_EROUND
19906 */
19907int gsl_sf_gammainv_e(const double x, gsl_sf_result * result);
19908double gsl_sf_gammainv(const double x);
19909
19910
19911/* Log[Gamma(z)] for z complex, z not a negative integer
19912 * Uses complex Lanczos method. Note that the phase part (arg)
19913 * is not well-determined when |z| is very large, due
19914 * to inevitable roundoff in restricting to (-Pi,Pi].
19915 * This will raise the GSL_ELOSS exception when it occurs.
19916 * The absolute value part (lnr), however, never suffers.
19917 *
19918 * Calculates:
19919 * lnr = log|Gamma(z)|
19920 * arg = arg(Gamma(z)) in (-Pi, Pi]
19921 *
19922 * exceptions: GSL_EDOM, GSL_ELOSS
19923 */
19924int gsl_sf_lngamma_complex_e(double zr, double zi, gsl_sf_result * lnr, gsl_sf_result * arg);
19925
19926
19927/* x^n / n!
19928 *
19929 * x >= 0.0, n >= 0
19930 * exceptions: GSL_EDOM, GSL_EOVRFLW, GSL_EUNDRFLW
19931 */
19932int gsl_sf_taylorcoeff_e(const int n, const double x, gsl_sf_result * result);
19933double gsl_sf_taylorcoeff(const int n, const double x);
19934
19935
19936/* n!
19937 *
19938 * exceptions: GSL_EDOM, GSL_EOVRFLW
19939 */
19940int gsl_sf_fact_e(const unsigned int n, gsl_sf_result * result);
19941double gsl_sf_fact(const unsigned int n);
19942
19943
19944/* n!! = n(n-2)(n-4) ...
19945 *
19946 * exceptions: GSL_EDOM, GSL_EOVRFLW
19947 */
19948int gsl_sf_doublefact_e(const unsigned int n, gsl_sf_result * result);
19949double gsl_sf_doublefact(const unsigned int n);
19950
19951
19952/* log(n!)
19953 * Faster than ln(Gamma(n+1)) for n < 170; defers for larger n.
19954 *
19955 * exceptions: none
19956 */
19957int gsl_sf_lnfact_e(const unsigned int n, gsl_sf_result * result);
19958double gsl_sf_lnfact(const unsigned int n);
19959
19960
19961/* log(n!!)
19962 *
19963 * exceptions: none
19964 */
19965int gsl_sf_lndoublefact_e(const unsigned int n, gsl_sf_result * result);
19966double gsl_sf_lndoublefact(const unsigned int n);
19967
19968
19969/* log(n choose m)
19970 *
19971 * exceptions: GSL_EDOM
19972 */
19973int gsl_sf_lnchoose_e(unsigned int n, unsigned int m, gsl_sf_result * result);
19974double gsl_sf_lnchoose(unsigned int n, unsigned int m);
19975
19976
19977/* n choose m
19978 *
19979 * exceptions: GSL_EDOM, GSL_EOVRFLW
19980 */
19981int gsl_sf_choose_e(unsigned int n, unsigned int m, gsl_sf_result * result);
19982double gsl_sf_choose(unsigned int n, unsigned int m);
19983
19984
19985/* Logarithm of Pochhammer (Apell) symbol
19986 * log( (a)_x )
19987 * where (a)_x := Gamma[a + x]/Gamma[a]
19988 *
19989 * a > 0, a+x > 0
19990 *
19991 * exceptions: GSL_EDOM
19992 */
19993int gsl_sf_lnpoch_e(const double a, const double x, gsl_sf_result * result);
19994double gsl_sf_lnpoch(const double a, const double x);
19995
19996
19997/* Logarithm of Pochhammer (Apell) symbol, with sign information.
19998 * result = log( |(a)_x| )
19999 * sgn = sgn( (a)_x )
20000 * where (a)_x := Gamma[a + x]/Gamma[a]
20001 *
20002 * a != neg integer, a+x != neg integer
20003 *
20004 * exceptions: GSL_EDOM
20005 */
20006int gsl_sf_lnpoch_sgn_e(const double a, const double x, gsl_sf_result * result, double * sgn);
20007
20008
20009/* Pochhammer (Apell) symbol
20010 * (a)_x := Gamma[a + x]/Gamma[x]
20011 *
20012 * a != neg integer, a+x != neg integer
20013 *
20014 * exceptions: GSL_EDOM, GSL_EOVRFLW
20015 */
20016int gsl_sf_poch_e(const double a, const double x, gsl_sf_result * result);
20017double gsl_sf_poch(const double a, const double x);
20018
20019
20020/* Relative Pochhammer (Apell) symbol
20021 * ((a,x) - 1)/x
20022 * where (a,x) = (a)_x := Gamma[a + x]/Gamma[a]
20023 *
20024 * exceptions: GSL_EDOM
20025 */
20026int gsl_sf_pochrel_e(const double a, const double x, gsl_sf_result * result);
20027double gsl_sf_pochrel(const double a, const double x);
20028
20029
20030/* Normalized Incomplete Gamma Function
20031 *
20032 * Q(a,x) = 1/Gamma(a) Integral[ t^(a-1) e^(-t), {t,x,Infinity} ]
20033 *
20034 * a >= 0, x >= 0
20035 * Q(a,0) := 1
20036 * Q(0,x) := 0, x != 0
20037 *
20038 * exceptions: GSL_EDOM
20039 */
20040int gsl_sf_gamma_inc_Q_e(const double a, const double x, gsl_sf_result * result);
20041double gsl_sf_gamma_inc_Q(const double a, const double x);
20042
20043
20044/* Complementary Normalized Incomplete Gamma Function
20045 *
20046 * P(a,x) = 1/Gamma(a) Integral[ t^(a-1) e^(-t), {t,0,x} ]
20047 *
20048 * a > 0, x >= 0
20049 *
20050 * exceptions: GSL_EDOM
20051 */
20052int gsl_sf_gamma_inc_P_e(const double a, const double x, gsl_sf_result * result);
20053double gsl_sf_gamma_inc_P(const double a, const double x);
20054
20055
20056/* Non-normalized Incomplete Gamma Function
20057 *
20058 * Gamma(a,x) := Integral[ t^(a-1) e^(-t), {t,x,Infinity} ]
20059 *
20060 * x >= 0.0
20061 * Gamma(a, 0) := Gamma(a)
20062 *
20063 * exceptions: GSL_EDOM
20064 */
20065int gsl_sf_gamma_inc_e(const double a, const double x, gsl_sf_result * result);
20066double gsl_sf_gamma_inc(const double a, const double x);
20067
20068
20069/* Logarithm of Beta Function
20070 * Log[B(a,b)]
20071 *
20072 * a > 0, b > 0
20073 * exceptions: GSL_EDOM
20074 */
20075int gsl_sf_lnbeta_e(const double a, const double b, gsl_sf_result * result);
20076double gsl_sf_lnbeta(const double a, const double b);
20077
20078int gsl_sf_lnbeta_sgn_e(const double x, const double y, gsl_sf_result * result, double * sgn);
20079
20080
20081/* Beta Function
20082 * B(a,b)
20083 *
20084 * a > 0, b > 0
20085 * exceptions: GSL_EDOM, GSL_EOVRFLW, GSL_EUNDRFLW
20086 */
20087int gsl_sf_beta_e(const double a, const double b, gsl_sf_result * result);
20088double gsl_sf_beta(const double a, const double b);
20089
20090
20091/* Normalized Incomplete Beta Function
20092 * B_x(a,b)/B(a,b)
20093 *
20094 * a > 0, b > 0, 0 <= x <= 1
20095 * exceptions: GSL_EDOM, GSL_EUNDRFLW
20096 */
20097int gsl_sf_beta_inc_e(const double a, const double b, const double x, gsl_sf_result * result);
20098double gsl_sf_beta_inc(const double a, const double b, const double x);
20099
20100
20101/* The maximum x such that gamma(x) is not
20102 * considered an overflow.
20103 */
20104#define GSL_SF_GAMMA_XMAX 171.0
20105
20106/* The maximum n such that gsl_sf_fact(n) does not give an overflow. */
20107#define GSL_SF_FACT_NMAX 170
20108
20109/* The maximum n such that gsl_sf_doublefact(n) does not give an overflow. */
20110#define GSL_SF_DOUBLEFACT_NMAX 297
20111
20112__END_DECLS
20113
20114#endif /* __GSL_SF_GAMMA_H__ */
20115
20116/* end inlined header: gsl/gsl_sf_gamma.h */
20117/* begin inlined header: gsl/gsl_sf_zeta.h */
20118/* specfunc/gsl_sf_zeta.h
20119 *
20120 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2004 Gerard Jungman
20121 *
20122 * This program is free software; you can redistribute it and/or modify
20123 * it under the terms of the GNU General Public License as published by
20124 * the Free Software Foundation; either version 3 of the License, or (at
20125 * your option) any later version.
20126 *
20127 * This program is distributed in the hope that it will be useful, but
20128 * WITHOUT ANY WARRANTY; without even the implied warranty of
20129 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20130 * General Public License for more details.
20131 *
20132 * You should have received a copy of the GNU General Public License
20133 * along with this program; if not, write to the Free Software
20134 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20135 */
20136
20137/* Author: G. Jungman */
20138
20139#ifndef __GSL_SF_ZETA_H__
20140#define __GSL_SF_ZETA_H__
20141/* begin inlined header: gsl/gsl_sf_result.h */
20142/* specfunc/gsl_sf_result.h
20143 *
20144 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
20145 *
20146 * This program is free software; you can redistribute it and/or modify
20147 * it under the terms of the GNU General Public License as published by
20148 * the Free Software Foundation; either version 3 of the License, or (at
20149 * your option) any later version.
20150 *
20151 * This program is distributed in the hope that it will be useful, but
20152 * WITHOUT ANY WARRANTY; without even the implied warranty of
20153 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20154 * General Public License for more details.
20155 *
20156 * You should have received a copy of the GNU General Public License
20157 * along with this program; if not, write to the Free Software
20158 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20159 */
20160
20161/* Author: G. Jungman */
20162
20163#ifndef __GSL_SF_RESULT_H__
20164#define __GSL_SF_RESULT_H__
20165
20166
20167
20168__BEGIN_DECLS
20169
20170struct gsl_sf_result_struct {
20171 double val;
20172 double err;
20173};
20174typedef struct gsl_sf_result_struct gsl_sf_result;
20175
20176#define GSL_SF_RESULT_SET(r,v,e) do { (r)->val=(v); (r)->err=(e); } while(0)
20177
20178
20180 double val;
20181 double err;
20182 int e10;
20183};
20184typedef struct gsl_sf_result_e10_struct gsl_sf_result_e10;
20185
20186
20187int gsl_sf_result_smash_e(const gsl_sf_result_e10 * re, gsl_sf_result * r);
20188
20189
20190__END_DECLS
20191
20192#endif /* __GSL_SF_RESULT_H__ */
20193
20194/* end inlined header: gsl/gsl_sf_result.h */
20195
20196
20197__BEGIN_DECLS
20198
20199
20200/* Riemann Zeta Function
20201 * zeta(n) = Sum[ k^(-n), {k,1,Infinity} ]
20202 *
20203 * n=integer, n != 1
20204 * exceptions: GSL_EDOM, GSL_EOVRFLW
20205 */
20206int gsl_sf_zeta_int_e(const int n, gsl_sf_result * result);
20207double gsl_sf_zeta_int(const int n);
20208
20209
20210/* Riemann Zeta Function
20211 * zeta(x) = Sum[ k^(-s), {k,1,Infinity} ], s != 1.0
20212 *
20213 * s != 1.0
20214 * exceptions: GSL_EDOM, GSL_EOVRFLW
20215 */
20216int gsl_sf_zeta_e(const double s, gsl_sf_result * result);
20217double gsl_sf_zeta(const double s);
20218
20219
20220/* Riemann Zeta Function minus 1
20221 * useful for evaluating the fractional part
20222 * of Riemann zeta for large argument
20223 *
20224 * s != 1.0
20225 * exceptions: GSL_EDOM, GSL_EOVRFLW
20226 */
20227int gsl_sf_zetam1_e(const double s, gsl_sf_result * result);
20228double gsl_sf_zetam1(const double s);
20229
20230
20231/* Riemann Zeta Function minus 1 for integer arg
20232 * useful for evaluating the fractional part
20233 * of Riemann zeta for large argument
20234 *
20235 * s != 1.0
20236 * exceptions: GSL_EDOM, GSL_EOVRFLW
20237 */
20238int gsl_sf_zetam1_int_e(const int s, gsl_sf_result * result);
20239double gsl_sf_zetam1_int(const int s);
20240
20241
20242/* Hurwitz Zeta Function
20243 * zeta(s,q) = Sum[ (k+q)^(-s), {k,0,Infinity} ]
20244 *
20245 * s > 1.0, q > 0.0
20246 * exceptions: GSL_EDOM, GSL_EUNDRFLW, GSL_EOVRFLW
20247 */
20248int gsl_sf_hzeta_e(const double s, const double q, gsl_sf_result * result);
20249double gsl_sf_hzeta(const double s, const double q);
20250
20251
20252/* Eta Function
20253 * eta(n) = (1-2^(1-n)) zeta(n)
20254 *
20255 * exceptions: GSL_EUNDRFLW, GSL_EOVRFLW
20256 */
20257int gsl_sf_eta_int_e(int n, gsl_sf_result * result);
20258double gsl_sf_eta_int(const int n);
20259
20260
20261/* Eta Function
20262 * eta(s) = (1-2^(1-s)) zeta(s)
20263 *
20264 * exceptions: GSL_EUNDRFLW, GSL_EOVRFLW
20265 */
20266int gsl_sf_eta_e(const double s, gsl_sf_result * result);
20267double gsl_sf_eta(const double s);
20268
20269
20270__END_DECLS
20271
20272#endif /* __GSL_SF_ZETA_H__ */
20273
20274/* end inlined header: gsl/gsl_sf_zeta.h */
20275/* begin inlined header: gsl/gsl_sf_psi.h */
20276/* specfunc/gsl_sf_psi.h
20277 *
20278 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2004 Gerard Jungman
20279 *
20280 * This program is free software; you can redistribute it and/or modify
20281 * it under the terms of the GNU General Public License as published by
20282 * the Free Software Foundation; either version 3 of the License, or (at
20283 * your option) any later version.
20284 *
20285 * This program is distributed in the hope that it will be useful, but
20286 * WITHOUT ANY WARRANTY; without even the implied warranty of
20287 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20288 * General Public License for more details.
20289 *
20290 * You should have received a copy of the GNU General Public License
20291 * along with this program; if not, write to the Free Software
20292 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20293 */
20294
20295/* Author: G. Jungman */
20296
20297#ifndef __GSL_SF_PSI_H__
20298#define __GSL_SF_PSI_H__
20299/* begin inlined header: gsl/gsl_sf_result.h */
20300/* specfunc/gsl_sf_result.h
20301 *
20302 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
20303 *
20304 * This program is free software; you can redistribute it and/or modify
20305 * it under the terms of the GNU General Public License as published by
20306 * the Free Software Foundation; either version 3 of the License, or (at
20307 * your option) any later version.
20308 *
20309 * This program is distributed in the hope that it will be useful, but
20310 * WITHOUT ANY WARRANTY; without even the implied warranty of
20311 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20312 * General Public License for more details.
20313 *
20314 * You should have received a copy of the GNU General Public License
20315 * along with this program; if not, write to the Free Software
20316 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20317 */
20318
20319/* Author: G. Jungman */
20320
20321#ifndef __GSL_SF_RESULT_H__
20322#define __GSL_SF_RESULT_H__
20323
20324
20325
20326__BEGIN_DECLS
20327
20328struct gsl_sf_result_struct {
20329 double val;
20330 double err;
20331};
20332typedef struct gsl_sf_result_struct gsl_sf_result;
20333
20334#define GSL_SF_RESULT_SET(r,v,e) do { (r)->val=(v); (r)->err=(e); } while(0)
20335
20336
20338 double val;
20339 double err;
20340 int e10;
20341};
20342typedef struct gsl_sf_result_e10_struct gsl_sf_result_e10;
20343
20344
20345int gsl_sf_result_smash_e(const gsl_sf_result_e10 * re, gsl_sf_result * r);
20346
20347
20348__END_DECLS
20349
20350#endif /* __GSL_SF_RESULT_H__ */
20351
20352/* end inlined header: gsl/gsl_sf_result.h */
20353
20354
20355__BEGIN_DECLS
20356
20357
20358/* Poly-Gamma Functions
20359 *
20360 * psi(m,x) := (d/dx)^m psi(0,x) = (d/dx)^{m+1} log(gamma(x))
20361 */
20362
20363
20364/* Di-Gamma Function psi(n) = psi(0,n)
20365 *
20366 * n > 0
20367 * exceptions: GSL_EDOM
20368 */
20369int gsl_sf_psi_int_e(const int n, gsl_sf_result * result);
20370double gsl_sf_psi_int(const int n);
20371
20372
20373/* Di-Gamma Function psi(x) = psi(0, x)
20374 *
20375 * x != 0.0, -1.0, -2.0, ...
20376 * exceptions: GSL_EDOM, GSL_ELOSS
20377 */
20378int gsl_sf_psi_e(const double x, gsl_sf_result * result);
20379double gsl_sf_psi(const double x);
20380
20381
20382/* Di-Gamma Function Re[psi(1 + I y)]
20383 *
20384 * exceptions: none
20385 */
20386int gsl_sf_psi_1piy_e(const double y, gsl_sf_result * result);
20387double gsl_sf_psi_1piy(const double y);
20388
20389
20390/* Di-Gamma Function psi(z) for general complex argument z = x + iy
20391 *
20392 * exceptions: GSL_EDOM
20393 */
20394int gsl_sf_complex_psi_e(
20395 const double x,
20396 const double y,
20397 gsl_sf_result * result_re,
20398 gsl_sf_result * result_im
20399 );
20400
20401
20402/* Tri-Gamma Function psi^(1)(n)
20403 *
20404 * n > 0
20405 * exceptions: GSL_EDOM
20406 */
20407int gsl_sf_psi_1_int_e(const int n, gsl_sf_result * result);
20408double gsl_sf_psi_1_int(const int n);
20409
20410
20411/* Tri-Gamma Function psi^(1)(x)
20412 *
20413 * x != 0.0, -1.0, -2.0, ...
20414 * exceptions: GSL_EDOM, GSL_ELOSS
20415 */
20416int gsl_sf_psi_1_e(const double x, gsl_sf_result * result);
20417double gsl_sf_psi_1(const double x);
20418
20419
20420/* Poly-Gamma Function psi^(n)(x)
20421 *
20422 * n >= 0, x > 0.0
20423 * exceptions: GSL_EDOM
20424 */
20425int gsl_sf_psi_n_e(const int n, const double x, gsl_sf_result * result);
20426double gsl_sf_psi_n(const int n, const double x);
20427
20428
20429__END_DECLS
20430
20431#endif /* __GSL_SF_PSI_H__ */
20432
20433/* end inlined header: gsl/gsl_sf_psi.h */
20434/* begin inlined header: gsl/gsl_complex_math.h */
20435/* complex/gsl_complex_math.h
20436 *
20437 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2004, 2007 Jorma Olavi T�htinen, Brian Gough
20438 *
20439 * This program is free software; you can redistribute it and/or modify
20440 * it under the terms of the GNU General Public License as published by
20441 * the Free Software Foundation; either version 3 of the License, or (at
20442 * your option) any later version.
20443 *
20444 * This program is distributed in the hope that it will be useful, but
20445 * WITHOUT ANY WARRANTY; without even the implied warranty of
20446 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20447 * General Public License for more details.
20448 *
20449 * You should have received a copy of the GNU General Public License
20450 * along with this program; if not, write to the Free Software
20451 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20452 */
20453
20454#ifndef __GSL_COMPLEX_MATH_H__
20455#define __GSL_COMPLEX_MATH_H__
20456/* begin inlined header: gsl/gsl_inline.h */
20457/* gsl_inline.h
20458 *
20459 * Copyright (C) 2008, 2009 Brian Gough
20460 *
20461 * This program is free software; you can redistribute it and/or modify
20462 * it under the terms of the GNU General Public License as published by
20463 * the Free Software Foundation; either version 3 of the License, or (at
20464 * your option) any later version.
20465 *
20466 * This program is distributed in the hope that it will be useful, but
20467 * WITHOUT ANY WARRANTY; without even the implied warranty of
20468 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20469 * General Public License for more details.
20470 *
20471 * You should have received a copy of the GNU General Public License
20472 * along with this program; if not, write to the Free Software
20473 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20474 */
20475
20476#ifndef __GSL_INLINE_H__
20477#define __GSL_INLINE_H__
20478
20479/* In recent versiions of GCC, the inline keyword has two different
20480 forms: GNU and C99.
20481
20482 In GNU mode we can use 'extern inline' to make inline functions
20483 work like macros. The function is only inlined--it is never output
20484 as a definition in an object file.
20485
20486 In the new C99 mode 'extern inline' has a different meaning--it
20487 causes the definition of the function to be output in each object
20488 file where it is used. This will result in multiple-definition
20489 errors on linking. The 'inline' keyword on its own (without
20490 extern) has the same behavior as the original GNU 'extern inline'.
20491
20492 The C99 style is the default with -std=c99 in GCC 4.3.
20493
20494 This header file allows either form of inline to be used by
20495 redefining the macros INLINE_DECL and INLINE_FUN. These are used
20496 in the public header files as
20497
20498 INLINE_DECL double gsl_foo (double x);
20499 #ifdef HAVE_INLINE
20500 INLINE_FUN double gsl_foo (double x) { return x+1.0; } ;
20501 #endif
20502
20503*/
20504
20505#ifdef HAVE_INLINE
20506# if defined(__GNUC_STDC_INLINE__) || defined(GSL_C99_INLINE) || defined(HAVE_C99_INLINE)
20507# define INLINE_DECL inline /* use C99 inline */
20508# define INLINE_FUN inline
20509# else
20510# define INLINE_DECL /* use GNU extern inline */
20511# define INLINE_FUN extern inline
20512# endif
20513#else
20514# define INLINE_DECL /* */
20515#endif
20516
20517/* Range checking conditions in headers do not require any run-time
20518 tests of the global variable gsl_check_range. They are enabled or
20519 disabled in user code at compile time with GSL_RANGE_CHECK macro.
20520 See also build.h. */
20521#define GSL_RANGE_COND(x) (x)
20522
20523#endif /* __GSL_INLINE_H__ */
20524
20525/* end inlined header: gsl/gsl_inline.h */
20526/* begin inlined header: gsl/gsl_complex.h */
20527/* complex/gsl_complex.h
20528 *
20529 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, Brian Gough
20530 * Copyright (C) 2020, 2021 Patrick Alken
20531 *
20532 * This program is free software; you can redistribute it and/or modify
20533 * it under the terms of the GNU General Public License as published by
20534 * the Free Software Foundation; either version 3 of the License, or (at
20535 * your option) any later version.
20536 *
20537 * This program is distributed in the hope that it will be useful, but
20538 * WITHOUT ANY WARRANTY; without even the implied warranty of
20539 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20540 * General Public License for more details.
20541 *
20542 * You should have received a copy of the GNU General Public License
20543 * along with this program; if not, write to the Free Software
20544 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20545 */
20546
20547#ifndef __GSL_COMPLEX_H__
20548#define __GSL_COMPLEX_H__
20549
20550
20551
20552__BEGIN_DECLS
20553
20554
20555/* two consecutive built-in types as a complex number */
20556typedef double * gsl_complex_packed ;
20557typedef float * gsl_complex_packed_float ;
20558typedef long double * gsl_complex_packed_long_double ;
20559
20560typedef const double * gsl_const_complex_packed ;
20561typedef const float * gsl_const_complex_packed_float ;
20562typedef const long double * gsl_const_complex_packed_long_double ;
20563
20564
20565/* 2N consecutive built-in types as N complex numbers */
20566typedef double * gsl_complex_packed_array ;
20567typedef float * gsl_complex_packed_array_float ;
20568typedef long double * gsl_complex_packed_array_long_double ;
20569
20570typedef const double * gsl_const_complex_packed_array ;
20571typedef const float * gsl_const_complex_packed_array_float ;
20572typedef const long double * gsl_const_complex_packed_array_long_double ;
20573
20574
20575/* Yes... this seems weird. Trust us. The point is just that
20576 sometimes you want to make it obvious that something is
20577 an output value. The fact that it lacks a 'const' may not
20578 be enough of a clue for people in some contexts.
20579 */
20580typedef double * gsl_complex_packed_ptr ;
20581typedef float * gsl_complex_packed_float_ptr ;
20582typedef long double * gsl_complex_packed_long_double_ptr ;
20583
20584typedef const double * gsl_const_complex_packed_ptr ;
20585typedef const float * gsl_const_complex_packed_float_ptr ;
20586typedef const long double * gsl_const_complex_packed_long_double_ptr ;
20587
20588/*
20589 * If <complex.h> is included, use the C99 complex type. Otherwise
20590 * define a type bit-compatible with C99 complex. The GSL_REAL and GSL_IMAG
20591 * macros require C11 functionality also (_Generic)
20592 */
20593
20594/* older gcc compilers claim to be C11 compliant but do not support _Generic */
20595#if defined(__GNUC__) && (__GNUC__ < 7)
20596# define GSL_COMPLEX_LEGACY 1
20597#endif
20598
20599#if !defined(GSL_COMPLEX_LEGACY) && \
20600 defined(_Complex_I) && \
20601 defined(complex) && \
20602 defined(I) && \
20603 defined(__STDC__) && (__STDC__ == 1) && \
20604 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) /* C11 */
20605
20606# define GSL_COMPLEX_DEFINE(R, C) typedef R _Complex C ;
20607
20608# define GSL_COMPLEX_P(zp) (&(zp))
20609# define GSL_COMPLEX_EQ(z1,z2) ((z1) == (z2))
20610# define GSL_SET_COMPLEX(zp,x,y) (*(zp) = (x) + I * (y))
20611
20612# define GSL_REAL(z) (_Generic((z), \
20613 complex float : ((float *) &(z)), \
20614 complex double : ((double *) &(z)), \
20615 complex long double : ((long double *) &(z)))[0])
20616
20617# define GSL_IMAG(z) (_Generic((z), \
20618 complex float : ((float *) &(z)), \
20619 complex double : ((double *) &(z)), \
20620 complex long double : ((long double *) &(z)))[1])
20621
20622# define GSL_COMPLEX_P_REAL(zp) GSL_REAL(*(zp))
20623# define GSL_COMPLEX_P_IMAG(zp) GSL_IMAG(*(zp))
20624# define GSL_SET_REAL(zp,x) do { GSL_REAL(*(zp)) = (x); } while(0)
20625# define GSL_SET_IMAG(zp,x) do { GSL_IMAG(*(zp)) = (x); } while(0)
20626
20627#else /* legacy complex definitions */
20628
20629/*
20630 * According to the C17 standard, 6.2.5 paragraph 13:
20631 *
20632 * "Each complex type has the same representation and alignment requirements
20633 * as an array type containing exactly two elements of the corresponding real
20634 * type; the first element is equal to the real part, and the second element to
20635 * the imaginary part, of the complex number."
20636 */
20637
20638/*# define GSL_COMPLEX_DEFINE(R, C) typedef R C[2]*/
20639# define GSL_COMPLEX_DEFINE(R, C) typedef struct { R dat[2]; } C ;
20640
20641# define GSL_REAL(z) ((z).dat[0])
20642# define GSL_IMAG(z) ((z).dat[1])
20643# define GSL_COMPLEX_P(zp) ((zp)->dat)
20644# define GSL_COMPLEX_P_REAL(zp) ((zp)->dat[0])
20645# define GSL_COMPLEX_P_IMAG(zp) ((zp)->dat[1])
20646# define GSL_COMPLEX_EQ(z1,z2) (((z1).dat[0] == (z2).dat[0]) && ((z1).dat[1] == (z2).dat[1]))
20647
20648# define GSL_SET_COMPLEX(zp,x,y) do {(zp)->dat[0]=(x); (zp)->dat[1]=(y);} while(0)
20649# define GSL_SET_REAL(zp,x) do {(zp)->dat[0]=(x);} while(0)
20650# define GSL_SET_IMAG(zp,y) do {(zp)->dat[1]=(y);} while(0)
20651
20652#endif
20653
20654GSL_COMPLEX_DEFINE(double, gsl_complex)
20655GSL_COMPLEX_DEFINE(long double, gsl_complex_long_double)
20656GSL_COMPLEX_DEFINE(float, gsl_complex_float)
20657
20658#define GSL_SET_COMPLEX_PACKED(zp,n,x,y) do {*((zp)+2*(n))=(x); *((zp)+(2*(n)+1))=(y);} while(0)
20659
20660__END_DECLS
20661
20662#endif /* __GSL_COMPLEX_H__ */
20663
20664/* end inlined header: gsl/gsl_complex.h */
20665#undef __BEGIN_DECLS
20666#undef __END_DECLS
20667#ifdef __cplusplus
20668#define __BEGIN_DECLS extern "C" {
20669#define __END_DECLS }
20670#else
20671#define __BEGIN_DECLS /* empty */
20672#define __END_DECLS /* empty */
20673#endif
20674
20675__BEGIN_DECLS
20676
20677/* Complex numbers */
20678
20679gsl_complex gsl_complex_polar (double r, double theta); /* r= r e^(i theta) */
20680
20681INLINE_DECL gsl_complex gsl_complex_rect (double x, double y); /* r= real+i*imag */
20682
20683#ifdef HAVE_INLINE
20684INLINE_FUN gsl_complex
20685gsl_complex_rect (double x, double y)
20686{ /* return z = x + i y */
20687 gsl_complex z;
20688 GSL_SET_COMPLEX (&z, x, y);
20689 return z;
20690}
20691#endif
20692
20693#define GSL_COMPLEX_ONE (gsl_complex_rect(1.0,0.0))
20694#define GSL_COMPLEX_ZERO (gsl_complex_rect(0.0,0.0))
20695#define GSL_COMPLEX_NEGONE (gsl_complex_rect(-1.0,0.0))
20696
20697/* Properties of complex numbers */
20698
20699double gsl_complex_arg (gsl_complex z); /* return arg(z), -pi< arg(z) <=+pi */
20700double gsl_complex_abs (gsl_complex z); /* return |z| */
20701double gsl_complex_abs2 (gsl_complex z); /* return |z|^2 */
20702double gsl_complex_logabs (gsl_complex z); /* return log|z| */
20703
20704/* Complex arithmetic operators */
20705
20706gsl_complex gsl_complex_add (gsl_complex a, gsl_complex b); /* r=a+b */
20707gsl_complex gsl_complex_sub (gsl_complex a, gsl_complex b); /* r=a-b */
20708gsl_complex gsl_complex_mul (gsl_complex a, gsl_complex b); /* r=a*b */
20709gsl_complex gsl_complex_div (gsl_complex a, gsl_complex b); /* r=a/b */
20710
20711gsl_complex gsl_complex_add_real (gsl_complex a, double x); /* r=a+x */
20712gsl_complex gsl_complex_sub_real (gsl_complex a, double x); /* r=a-x */
20713gsl_complex gsl_complex_mul_real (gsl_complex a, double x); /* r=a*x */
20714gsl_complex gsl_complex_div_real (gsl_complex a, double x); /* r=a/x */
20715
20716gsl_complex gsl_complex_add_imag (gsl_complex a, double y); /* r=a+iy */
20717gsl_complex gsl_complex_sub_imag (gsl_complex a, double y); /* r=a-iy */
20718gsl_complex gsl_complex_mul_imag (gsl_complex a, double y); /* r=a*iy */
20719gsl_complex gsl_complex_div_imag (gsl_complex a, double y); /* r=a/iy */
20720
20721gsl_complex gsl_complex_conjugate (gsl_complex z); /* r=conj(z) */
20722gsl_complex gsl_complex_inverse (gsl_complex a); /* r=1/a */
20723gsl_complex gsl_complex_negative (gsl_complex a); /* r=-a */
20724
20725/* Elementary Complex Functions */
20726
20727gsl_complex gsl_complex_sqrt (gsl_complex z); /* r=sqrt(z) */
20728gsl_complex gsl_complex_sqrt_real (double x); /* r=sqrt(x) (x<0 ok) */
20729
20730gsl_complex gsl_complex_pow (gsl_complex a, gsl_complex b); /* r=a^b */
20731gsl_complex gsl_complex_pow_real (gsl_complex a, double b); /* r=a^b */
20732
20733gsl_complex gsl_complex_exp (gsl_complex a); /* r=exp(a) */
20734gsl_complex gsl_complex_log (gsl_complex a); /* r=log(a) (base e) */
20735gsl_complex gsl_complex_log10 (gsl_complex a); /* r=log10(a) (base 10) */
20736gsl_complex gsl_complex_log_b (gsl_complex a, gsl_complex b); /* r=log_b(a) (base=b) */
20737
20738/* Complex Trigonometric Functions */
20739
20740gsl_complex gsl_complex_sin (gsl_complex a); /* r=sin(a) */
20741gsl_complex gsl_complex_cos (gsl_complex a); /* r=cos(a) */
20742gsl_complex gsl_complex_sec (gsl_complex a); /* r=sec(a) */
20743gsl_complex gsl_complex_csc (gsl_complex a); /* r=csc(a) */
20744gsl_complex gsl_complex_tan (gsl_complex a); /* r=tan(a) */
20745gsl_complex gsl_complex_cot (gsl_complex a); /* r=cot(a) */
20746
20747/* Inverse Complex Trigonometric Functions */
20748
20749gsl_complex gsl_complex_arcsin (gsl_complex a); /* r=arcsin(a) */
20750gsl_complex gsl_complex_arcsin_real (double a); /* r=arcsin(a) */
20751gsl_complex gsl_complex_arccos (gsl_complex a); /* r=arccos(a) */
20752gsl_complex gsl_complex_arccos_real (double a); /* r=arccos(a) */
20753gsl_complex gsl_complex_arcsec (gsl_complex a); /* r=arcsec(a) */
20754gsl_complex gsl_complex_arcsec_real (double a); /* r=arcsec(a) */
20755gsl_complex gsl_complex_arccsc (gsl_complex a); /* r=arccsc(a) */
20756gsl_complex gsl_complex_arccsc_real (double a); /* r=arccsc(a) */
20757gsl_complex gsl_complex_arctan (gsl_complex a); /* r=arctan(a) */
20758gsl_complex gsl_complex_arccot (gsl_complex a); /* r=arccot(a) */
20759
20760/* Complex Hyperbolic Functions */
20761
20762gsl_complex gsl_complex_sinh (gsl_complex a); /* r=sinh(a) */
20763gsl_complex gsl_complex_cosh (gsl_complex a); /* r=coshh(a) */
20764gsl_complex gsl_complex_sech (gsl_complex a); /* r=sech(a) */
20765gsl_complex gsl_complex_csch (gsl_complex a); /* r=csch(a) */
20766gsl_complex gsl_complex_tanh (gsl_complex a); /* r=tanh(a) */
20767gsl_complex gsl_complex_coth (gsl_complex a); /* r=coth(a) */
20768
20769/* Inverse Complex Hyperbolic Functions */
20770
20771gsl_complex gsl_complex_arcsinh (gsl_complex a); /* r=arcsinh(a) */
20772gsl_complex gsl_complex_arccosh (gsl_complex a); /* r=arccosh(a) */
20773gsl_complex gsl_complex_arccosh_real (double a); /* r=arccosh(a) */
20774gsl_complex gsl_complex_arcsech (gsl_complex a); /* r=arcsech(a) */
20775gsl_complex gsl_complex_arccsch (gsl_complex a); /* r=arccsch(a) */
20776gsl_complex gsl_complex_arctanh (gsl_complex a); /* r=arctanh(a) */
20777gsl_complex gsl_complex_arctanh_real (double a); /* r=arctanh(a) */
20778gsl_complex gsl_complex_arccoth (gsl_complex a); /* r=arccoth(a) */
20779
20780__END_DECLS
20781
20782#endif /* __GSL_COMPLEX_MATH_H__ */
20783
20784/* end inlined header: gsl/gsl_complex_math.h */
20785#include <stdio.h>
20786
20787/* inlined: error.h */
20788
20789/* inlined: chebyshev.h */
20790/* inlined once already: specfunc/cheb_eval.c */
20791
20792/*-*-*-*-*-*-*-*-*-*-*-* Private Section *-*-*-*-*-*-*-*-*-*-*-*/
20793
20794
20795/* Chebyshev fit for f(y) = Re(Psi(1+Iy)) + M_EULER - y^2/(1+y^2) - y^2/(2(4+y^2))
20796 * 1 < y < 10
20797 * ==>
20798 * y(x) = (9x + 11)/2, -1 < x < 1
20799 * x(y) = (2y - 11)/9
20800 *
20801 * g(x) := f(y(x))
20802 */
20803static double r1py_data[] = {
20804 1.59888328244976954803168395603,
20805 0.67905625353213463845115658455,
20806 -0.068485802980122530009506482524,
20807 -0.005788184183095866792008831182,
20808 0.008511258167108615980419855648,
20809 -0.004042656134699693434334556409,
20810 0.001352328406159402601778462956,
20811 -0.000311646563930660566674525382,
20812 0.000018507563785249135437219139,
20813 0.000028348705427529850296492146,
20814 -0.000019487536014574535567541960,
20815 8.0709788710834469408621587335e-06,
20816 -2.2983564321340518037060346561e-06,
20817 3.0506629599604749843855962658e-07,
20818 1.3042238632418364610774284846e-07,
20819 -1.2308657181048950589464690208e-07,
20820 5.7710855710682427240667414345e-08,
20821 -1.8275559342450963966092636354e-08,
20822 3.1020471300626589420759518930e-09,
20823 6.8989327480593812470039430640e-10,
20824 -8.7182290258923059852334818997e-10,
20825 4.4069147710243611798213548777e-10,
20826 -1.4727311099198535963467200277e-10,
20827 2.7589682523262644748825844248e-11,
20828 4.1871826756975856411554363568e-12,
20829 -6.5673460487260087541400767340e-12,
20830 3.4487900886723214020103638000e-12,
20831 -1.1807251417448690607973794078e-12,
20832 2.3798314343969589258709315574e-13,
20833 2.1663630410818831824259465821e-15
20834};
20835static cheb_series r1py_cs = {
20836 r1py_data,
20837 29,
20838 -1,1,
20839 18
20840};
20841
20842
20843/* Chebyshev fits from SLATEC code for psi(x)
20844
20845 Series for PSI on the interval 0. to 1.00000D+00
20846 with weighted error 2.03E-17
20847 log weighted error 16.69
20848 significant figures required 16.39
20849 decimal places required 17.37
20850
20851 Series for APSI on the interval 0. to 2.50000D-01
20852 with weighted error 5.54E-17
20853 log weighted error 16.26
20854 significant figures required 14.42
20855 decimal places required 16.86
20856
20857*/
20858
20859static double psics_data[23] = {
20860 -.038057080835217922,
20861 .491415393029387130,
20862 -.056815747821244730,
20863 .008357821225914313,
20864 -.001333232857994342,
20865 .000220313287069308,
20866 -.000037040238178456,
20867 .000006283793654854,
20868 -.000001071263908506,
20869 .000000183128394654,
20870 -.000000031353509361,
20871 .000000005372808776,
20872 -.000000000921168141,
20873 .000000000157981265,
20874 -.000000000027098646,
20875 .000000000004648722,
20876 -.000000000000797527,
20877 .000000000000136827,
20878 -.000000000000023475,
20879 .000000000000004027,
20880 -.000000000000000691,
20881 .000000000000000118,
20882 -.000000000000000020
20883};
20884static cheb_series psi_cs = {
20885 psics_data,
20886 22,
20887 -1, 1,
20888 17
20889};
20890
20891static double apsics_data[16] = {
20892 -.0204749044678185,
20893 -.0101801271534859,
20894 .0000559718725387,
20895 -.0000012917176570,
20896 .0000000572858606,
20897 -.0000000038213539,
20898 .0000000003397434,
20899 -.0000000000374838,
20900 .0000000000048990,
20901 -.0000000000007344,
20902 .0000000000001233,
20903 -.0000000000000228,
20904 .0000000000000045,
20905 -.0000000000000009,
20906 .0000000000000002,
20907 -.0000000000000000
20908};
20909static cheb_series apsi_cs = {
20910 apsics_data,
20911 15,
20912 -1, 1,
20913 9
20914};
20915
20916#define PSI_TABLE_NMAX 100
20917static double psi_table[PSI_TABLE_NMAX+1] = {
20918 0.0, /* Infinity */ /* psi(0) */
20919 -M_EULER, /* psi(1) */
20920 0.42278433509846713939348790992, /* ... */
20921 0.92278433509846713939348790992,
20922 1.25611766843180047272682124325,
20923 1.50611766843180047272682124325,
20924 1.70611766843180047272682124325,
20925 1.87278433509846713939348790992,
20926 2.01564147795560999653634505277,
20927 2.14064147795560999653634505277,
20928 2.25175258906672110764745616389,
20929 2.35175258906672110764745616389,
20930 2.44266167997581201673836525479,
20931 2.52599501330914535007169858813,
20932 2.60291809023222227314862166505,
20933 2.67434666166079370172005023648,
20934 2.74101332832746036838671690315,
20935 2.80351332832746036838671690315,
20936 2.86233685773922507426906984432,
20937 2.91789241329478062982462539988,
20938 2.97052399224214905087725697883,
20939 3.02052399224214905087725697883,
20940 3.06814303986119666992487602645,
20941 3.11359758531574212447033057190,
20942 3.15707584618530734186163491973,
20943 3.1987425128519740085283015864,
20944 3.2387425128519740085283015864,
20945 3.2772040513135124700667631249,
20946 3.3142410883505495071038001619,
20947 3.3499553740648352213895144476,
20948 3.3844381326855248765619282407,
20949 3.4177714660188582098952615740,
20950 3.4500295305349872421533260902,
20951 3.4812795305349872421533260902,
20952 3.5115825608380175451836291205,
20953 3.5409943255438998981248055911,
20954 3.5695657541153284695533770196,
20955 3.5973435318931062473311547974,
20956 3.6243705589201332743581818244,
20957 3.6506863483938174848844976139,
20958 3.6763273740348431259101386396,
20959 3.7013273740348431259101386396,
20960 3.7257176179372821503003825420,
20961 3.7495271417468059598241920658,
20962 3.7727829557002943319172153216,
20963 3.7955102284275670591899425943,
20964 3.8177324506497892814121648166,
20965 3.8394715810845718901078169905,
20966 3.8607481768292527411716467777,
20967 3.8815815101625860745049801110,
20968 3.9019896734278921969539597029,
20969 3.9219896734278921969539597029,
20970 3.9415975165651470989147440166,
20971 3.9608282857959163296839747858,
20972 3.9796962103242182164764276160,
20973 3.9982147288427367349949461345,
20974 4.0163965470245549168131279527,
20975 4.0342536898816977739559850956,
20976 4.0517975495308205809735289552,
20977 4.0690389288411654085597358518,
20978 4.0859880813835382899156680552,
20979 4.1026547480502049565823347218,
20980 4.1190481906731557762544658694,
20981 4.1351772229312202923834981274,
20982 4.1510502388042361653993711433,
20983 4.1666752388042361653993711433,
20984 4.1820598541888515500147557587,
20985 4.1972113693403667015299072739,
20986 4.2121367424746950597388624977,
20987 4.2268426248276362362094507330,
20988 4.2413353784508246420065521823,
20989 4.2556210927365389277208378966,
20990 4.2697055997787924488475984600,
20991 4.2835944886676813377364873489,
20992 4.2972931188046676391063503626,
20993 4.3108066323181811526198638761,
20994 4.3241399656515144859531972094,
20995 4.3372978603883565912163551041,
20996 4.3502848733753695782293421171,
20997 4.3631053861958823987421626300,
20998 4.3757636140439836645649474401,
20999 4.3882636140439836645649474401,
21000 4.4006092930563293435772931191,
21001 4.4128044150075488557724150703,
21002 4.4248526077786331931218126607,
21003 4.4367573696833950978837174226,
21004 4.4485220755657480390601880108,
21005 4.4601499825424922251066996387,
21006 4.4716442354160554434975042364,
21007 4.4830078717796918071338678728,
21008 4.4942438268358715824147667492,
21009 4.5053549379469826935258778603,
21010 4.5163439489359936825368668713,
21011 4.5272135141533849868846929582,
21012 4.5379662023254279976373811303,
21013 4.5486045001977684231692960239,
21014 4.5591308159872421073798223397,
21015 4.5695474826539087740464890064,
21016 4.5798567610044242379640147796,
21017 4.5900608426370772991885045755,
21018 4.6001618527380874001986055856
21019};
21020
21021
21022#define PSI_1_TABLE_NMAX 100
21023static double psi_1_table[PSI_1_TABLE_NMAX+1] = {
21024 0.0, /* Infinity */ /* psi(1,0) */
21025 M_PI*M_PI/6.0, /* psi(1,1) */
21026 0.644934066848226436472415, /* ... */
21027 0.394934066848226436472415,
21028 0.2838229557371153253613041,
21029 0.2213229557371153253613041,
21030 0.1813229557371153253613041,
21031 0.1535451779593375475835263,
21032 0.1331370146940314251345467,
21033 0.1175120146940314251345467,
21034 0.1051663356816857461222010,
21035 0.0951663356816857461222010,
21036 0.0869018728717683907503002,
21037 0.0799574284273239463058557,
21038 0.0740402686640103368384001,
21039 0.0689382278476838062261552,
21040 0.0644937834032393617817108,
21041 0.0605875334032393617817108,
21042 0.0571273257907826143768665,
21043 0.0540409060376961946237801,
21044 0.0512708229352031198315363,
21045 0.0487708229352031198315363,
21046 0.0465032492390579951149830,
21047 0.0444371335365786562720078,
21048 0.0425467743683366902984728,
21049 0.0408106632572255791873617,
21050 0.0392106632572255791873617,
21051 0.0377313733163971768204978,
21052 0.0363596312039143235969038,
21053 0.0350841209998326909438426,
21054 0.0338950603577399442137594,
21055 0.0327839492466288331026483,
21056 0.0317433665203020901265817,
21057 0.03076680402030209012658168,
21058 0.02984853037475571730748159,
21059 0.02898347847164153045627052,
21060 0.02816715194102928555831133,
21061 0.02739554700275768062003973,
21062 0.02666508681283803124093089,
21063 0.02597256603721476254286995,
21064 0.02531510384129102815759710,
21065 0.02469010384129102815759710,
21066 0.02409521984367056414807896,
21067 0.02352832641963428296894063,
21068 0.02298749353699501850166102,
21069 0.02247096461137518379091722,
21070 0.02197713745088135663042339,
21071 0.02150454765882086513703965,
21072 0.02105185413233829383780923,
21073 0.02061782635456051606003145,
21074 0.02020133322669712580597065,
21075 0.01980133322669712580597065,
21076 0.01941686571420193164987683,
21077 0.01904704322899483105816086,
21078 0.01869104465298913508094477,
21079 0.01834810912486842177504628,
21080 0.01801753061247172756017024,
21081 0.01769865306145131939690494,
21082 0.01739086605006319997554452,
21083 0.01709360088954001329302371,
21084 0.01680632711763538818529605,
21085 0.01652854933985761040751827,
21086 0.01625980437882562975715546,
21087 0.01599965869724394401313881,
21088 0.01574770606433893015574400,
21089 0.01550356543933893015574400,
21090 0.01526687904880638577704578,
21091 0.01503731063741979257227076,
21092 0.01481454387422086185273411,
21093 0.01459828089844231513993134,
21094 0.01438824099085987447620523,
21095 0.01418415935820681325171544,
21096 0.01398578601958352422176106,
21097 0.01379288478501562298719316,
21098 0.01360523231738567365335942,
21099 0.01342261726990576130858221,
21100 0.01324483949212798353080444,
21101 0.01307170929822216635628920,
21102 0.01290304679189732236910755,
21103 0.01273868124291638877278934,
21104 0.01257845051066194236996928,
21105 0.01242220051066194236996928,
21106 0.01226978472038606978956995,
21107 0.01212106372098095378719041,
21108 0.01197590477193174490346273,
21109 0.01183418141592267460867815,
21110 0.01169577311142440471248438,
21111 0.01156056489076458859566448,
21112 0.01142844704164317229232189,
21113 0.01129931481023821361463594,
21114 0.01117306812421372175754719,
21115 0.01104961133409026496742374,
21116 0.01092885297157366069257770,
21117 0.01081070552355853781923177,
21118 0.01069508522063334415522437,
21119 0.01058191183901270133041676,
21120 0.01047110851491297833872701,
21121 0.01036260157046853389428257,
21122 0.01025632035036012704977199, /* ... */
21123 0.01015219706839427948625679, /* psi(1,99) */
21124 0.01005016666333357139524567 /* psi(1,100) */
21125};
21126
21127
21128/* digamma for x both positive and negative; we do both
21129 * cases here because of the way we use even/odd parts
21130 * of the function
21131 */
21132static int
21133psi_x(const double x, gsl_sf_result * result)
21134{
21135 const double y = fabs(x);
21136
21137 if(x == 0.0 || x == -1.0 || x == -2.0) {
21138 DOMAIN_ERROR(result);
21139 }
21140 else if(y >= 2.0) {
21141 const double t = 8.0/(y*y)-1.0;
21142 gsl_sf_result result_c;
21143 cheb_eval_e(&apsi_cs, t, &result_c);
21144 if(x < 0.0) {
21145 const double s = sin(M_PI*x);
21146 const double c = cos(M_PI*x);
21147 if(fabs(s) < 2.0*GSL_SQRT_DBL_MIN) {
21148 DOMAIN_ERROR(result);
21149 }
21150 else {
21151 result->val = log(y) - 0.5/x + result_c.val - M_PI * c/s;
21152 result->err = M_PI*fabs(x)*GSL_DBL_EPSILON/(s*s);
21153 result->err += result_c.err;
21154 result->err += GSL_DBL_EPSILON * fabs(result->val);
21155 return GSL_SUCCESS;
21156 }
21157 }
21158 else {
21159 result->val = log(y) - 0.5/x + result_c.val;
21160 result->err = result_c.err;
21161 result->err += GSL_DBL_EPSILON * fabs(result->val);
21162 return GSL_SUCCESS;
21163 }
21164 }
21165 else { /* -2 < x < 2 */
21166 gsl_sf_result result_c;
21167
21168 if(x < -1.0) { /* x = -2 + v */
21169 const double v = x + 2.0;
21170 const double t1 = 1.0/x;
21171 const double t2 = 1.0/(x+1.0);
21172 const double t3 = 1.0/v;
21173 cheb_eval_e(&psi_cs, 2.0*v-1.0, &result_c);
21174
21175 result->val = -(t1 + t2 + t3) + result_c.val;
21176 result->err = GSL_DBL_EPSILON * (fabs(t1) + fabs(x/(t2*t2)) + fabs(x/(t3*t3)));
21177 result->err += result_c.err;
21178 result->err += GSL_DBL_EPSILON * fabs(result->val);
21179 return GSL_SUCCESS;
21180 }
21181 else if(x < 0.0) { /* x = -1 + v */
21182 const double v = x + 1.0;
21183 const double t1 = 1.0/x;
21184 const double t2 = 1.0/v;
21185 cheb_eval_e(&psi_cs, 2.0*v-1.0, &result_c);
21186
21187 result->val = -(t1 + t2) + result_c.val;
21188 result->err = GSL_DBL_EPSILON * (fabs(t1) + fabs(x/(t2*t2)));
21189 result->err += result_c.err;
21190 result->err += GSL_DBL_EPSILON * fabs(result->val);
21191 return GSL_SUCCESS;
21192 }
21193 else if(x < 1.0) { /* x = v */
21194 const double t1 = 1.0/x;
21195 cheb_eval_e(&psi_cs, 2.0*x-1.0, &result_c);
21196
21197 result->val = -t1 + result_c.val;
21198 result->err = GSL_DBL_EPSILON * t1;
21199 result->err += result_c.err;
21200 result->err += GSL_DBL_EPSILON * fabs(result->val);
21201 return GSL_SUCCESS;
21202 }
21203 else { /* x = 1 + v */
21204 const double v = x - 1.0;
21205 return cheb_eval_e(&psi_cs, 2.0*v-1.0, result);
21206 }
21207 }
21208}
21209
21210
21211/* psi(z) for large |z| in the right half-plane; [Abramowitz + Stegun, 6.3.18] */
21212static
21213gsl_complex
21214psi_complex_asymp(gsl_complex z)
21215{
21216 /* coefficients in the asymptotic expansion for large z;
21217 * let w = z^(-2) and write the expression in the form
21218 *
21219 * ln(z) - 1/(2z) - 1/12 w (1 + c1 w + c2 w + c3 w + ... )
21220 */
21221 static const double c1 = -0.1;
21222 static const double c2 = 1.0/21.0;
21223 static const double c3 = -0.05;
21224
21225 gsl_complex zi = gsl_complex_inverse(z);
21226 gsl_complex w = gsl_complex_mul(zi, zi);
21227 gsl_complex cs;
21228
21229 /* Horner method evaluation of term in parentheses */
21230 gsl_complex sum;
21231 sum = gsl_complex_mul_real(w, c3/c2);
21232 sum = gsl_complex_add_real(sum, 1.0);
21233 sum = gsl_complex_mul_real(sum, c2/c1);
21234 sum = gsl_complex_mul(sum, w);
21235 sum = gsl_complex_add_real(sum, 1.0);
21236 sum = gsl_complex_mul_real(sum, c1);
21237 sum = gsl_complex_mul(sum, w);
21238 sum = gsl_complex_add_real(sum, 1.0);
21239
21240 /* correction added to log(z) */
21241 cs = gsl_complex_mul(sum, w);
21242 cs = gsl_complex_mul_real(cs, -1.0/12.0);
21243 cs = gsl_complex_add(cs, gsl_complex_mul_real(zi, -0.5));
21244
21245 return gsl_complex_add(gsl_complex_log(z), cs);
21246}
21247
21248
21249
21250/* psi(z) for complex z in the right half-plane */
21251static int
21252psi_complex_rhp(
21253 gsl_complex z,
21254 gsl_sf_result * result_re,
21255 gsl_sf_result * result_im
21256 )
21257{
21258 int n_recurse = 0;
21259 int i;
21260 gsl_complex a;
21261
21262 if(GSL_REAL(z) == 0.0 && GSL_IMAG(z) == 0.0)
21263 {
21264 result_re->val = 0.0;
21265 result_im->val = 0.0;
21266 result_re->err = 0.0;
21267 result_im->err = 0.0;
21268 return GSL_EDOM;
21269 }
21270
21271 /* compute the number of recurrences to apply */
21272 if(GSL_REAL(z) < 20.0 && fabs(GSL_IMAG(z)) < 20.0)
21273 {
21274 const double sp = sqrt(20.0 + GSL_IMAG(z));
21275 const double sn = sqrt(20.0 - GSL_IMAG(z));
21276 const double rhs = sp*sn - GSL_REAL(z);
21277 if(rhs > 0.0) n_recurse = ceil(rhs);
21278 }
21279
21280 /* compute asymptotic at the large value z + n_recurse */
21281 a = psi_complex_asymp(gsl_complex_add_real(z, n_recurse));
21282
21283 result_re->err = 2.0 * GSL_DBL_EPSILON * fabs(GSL_REAL(a));
21284 result_im->err = 2.0 * GSL_DBL_EPSILON * fabs(GSL_IMAG(a));
21285
21286 /* descend recursively, if necessary */
21287 for(i = n_recurse; i >= 1; --i)
21288 {
21289 gsl_complex zn = gsl_complex_add_real(z, i - 1.0);
21290 gsl_complex zn_inverse = gsl_complex_inverse(zn);
21291 a = gsl_complex_sub(a, zn_inverse);
21292
21293 /* accumulate the error, to catch cancellations */
21294 result_re->err += 2.0 * GSL_DBL_EPSILON * fabs(GSL_REAL(zn_inverse));
21295 result_im->err += 2.0 * GSL_DBL_EPSILON * fabs(GSL_IMAG(zn_inverse));
21296 }
21297
21298 result_re->val = GSL_REAL(a);
21299 result_im->val = GSL_IMAG(a);
21300
21301 result_re->err += 2.0 * GSL_DBL_EPSILON * fabs(result_re->val);
21302 result_im->err += 2.0 * GSL_DBL_EPSILON * fabs(result_im->val);
21303
21304 return GSL_SUCCESS;
21305}
21306
21307
21308
21309/* generic polygamma; assumes n >= 0 and x > 0
21310 */
21311static int
21312psi_n_xg0(const int n, const double x, gsl_sf_result * result)
21313{
21314 if(n == 0) {
21315 return gsl_sf_psi_e(x, result);
21316 }
21317 else {
21318 /* Abramowitz + Stegun 6.4.10 */
21319 gsl_sf_result ln_nf;
21320 gsl_sf_result hzeta;
21321 int stat_hz = gsl_sf_hzeta_e(n+1.0, x, &hzeta);
21322 int stat_nf = gsl_sf_lnfact_e((unsigned int) n, &ln_nf);
21323 int stat_e = gsl_sf_exp_mult_err_e(ln_nf.val, ln_nf.err,
21324 hzeta.val, hzeta.err,
21325 result);
21326 if(GSL_IS_EVEN(n)) result->val = -result->val;
21327 return GSL_ERROR_SELECT_3(stat_e, stat_nf, stat_hz);
21328 }
21329}
21330
21331
21332
21333/*-*-*-*-*-*-*-*-*-*-*-* Functions with Error Codes *-*-*-*-*-*-*-*-*-*-*-*/
21334
21335int gsl_sf_psi_int_e(const int n, gsl_sf_result * result)
21336{
21337 /* CHECK_POINTER(result) */
21338
21339 if(n <= 0) {
21340 DOMAIN_ERROR(result);
21341 }
21342 else if(n <= PSI_TABLE_NMAX) {
21343 result->val = psi_table[n];
21344 result->err = GSL_DBL_EPSILON * fabs(result->val);
21345 return GSL_SUCCESS;
21346 }
21347 else {
21348 /* Abramowitz+Stegun 6.3.18 */
21349 const double c2 = -1.0/12.0;
21350 const double c3 = 1.0/120.0;
21351 const double c4 = -1.0/252.0;
21352 const double c5 = 1.0/240.0;
21353 const double ni2 = (1.0/n)*(1.0/n);
21354 const double ser = ni2 * (c2 + ni2 * (c3 + ni2 * (c4 + ni2*c5)));
21355 result->val = log(n) - 0.5/n + ser;
21356 result->err = GSL_DBL_EPSILON * (fabs(log(n)) + fabs(0.5/n) + fabs(ser));
21357 result->err += GSL_DBL_EPSILON * fabs(result->val);
21358 return GSL_SUCCESS;
21359 }
21360}
21361
21362
21363int gsl_sf_psi_e(const double x, gsl_sf_result * result)
21364{
21365 /* CHECK_POINTER(result) */
21366 return psi_x(x, result);
21367}
21368
21369
21370int
21371gsl_sf_psi_1piy_e(const double y, gsl_sf_result * result)
21372{
21373 const double ay = fabs(y);
21374
21375 /* CHECK_POINTER(result) */
21376
21377 if(ay > 1000.0) {
21378 /* [Abramowitz+Stegun, 6.3.19] */
21379 const double yi2 = 1.0/(ay*ay);
21380 const double lny = log(ay);
21381 const double sum = yi2 * (1.0/12.0 + 1.0/120.0 * yi2 + 1.0/252.0 * yi2*yi2);
21382 result->val = lny + sum;
21383 result->err = 2.0 * GSL_DBL_EPSILON * (fabs(lny) + fabs(sum));
21384 return GSL_SUCCESS;
21385 }
21386 else if(ay > 10.0) {
21387 /* [Abramowitz+Stegun, 6.3.19] */
21388 const double yi2 = 1.0/(ay*ay);
21389 const double lny = log(ay);
21390 const double sum = yi2 * (1.0/12.0 +
21391 yi2 * (1.0/120.0 +
21392 yi2 * (1.0/252.0 +
21393 yi2 * (1.0/240.0 +
21394 yi2 * (1.0/132.0 + 691.0/32760.0 * yi2)))));
21395 result->val = lny + sum;
21396 result->err = 2.0 * GSL_DBL_EPSILON * (fabs(lny) + fabs(sum));
21397 return GSL_SUCCESS;
21398 }
21399 else if(ay > 1.0){
21400 const double y2 = ay*ay;
21401 const double x = (2.0*ay - 11.0)/9.0;
21402 const double v = y2*(1.0/(1.0+y2) + 0.5/(4.0+y2));
21403 gsl_sf_result result_c;
21404 cheb_eval_e(&r1py_cs, x, &result_c);
21405 result->val = result_c.val - M_EULER + v;
21406 result->err = result_c.err;
21407 result->err += 2.0 * GSL_DBL_EPSILON * (fabs(v) + M_EULER + fabs(result_c.val));
21408 result->err += 2.0 * GSL_DBL_EPSILON * fabs(result->val);
21409 result->err *= 5.0; /* FIXME: losing a digit somewhere... maybe at x=... ? */
21410 return GSL_SUCCESS;
21411 }
21412 else {
21413 /* [Abramowitz+Stegun, 6.3.17]
21414 *
21415 * -M_EULER + y^2 Sum[1/n 1/(n^2 + y^2), {n,1,M}]
21416 * + Sum[1/n^3, {n,M+1,Infinity}]
21417 * - y^2 Sum[1/n^5, {n,M+1,Infinity}]
21418 * + y^4 Sum[1/n^7, {n,M+1,Infinity}]
21419 * - y^6 Sum[1/n^9, {n,M+1,Infinity}]
21420 * + O(y^8)
21421 *
21422 * We take M=50 for at least 15 digit precision.
21423 */
21424 const int M = 50;
21425 const double y2 = y*y;
21426 const double c0 = 0.00019603999466879846570;
21427 const double c2 = 3.8426659205114376860e-08;
21428 const double c4 = 1.0041592839497643554e-11;
21429 const double c6 = 2.9516743763500191289e-15;
21430 const double p = c0 + y2 *(-c2 + y2*(c4 - y2*c6));
21431 double sum = 0.0;
21432 double v;
21433
21434 int n;
21435 for(n=1; n<=M; n++) {
21436 sum += 1.0/(n * (n*n + y*y));
21437 }
21438
21439 v = y2 * (sum + p);
21440 result->val = -M_EULER + v;
21441 result->err = GSL_DBL_EPSILON * (M_EULER + fabs(v));
21442 result->err += 2.0 * GSL_DBL_EPSILON * fabs(result->val);
21443 return GSL_SUCCESS;
21444 }
21445}
21446
21447
21448int gsl_sf_psi_1_int_e(const int n, gsl_sf_result * result)
21449{
21450 /* CHECK_POINTER(result) */
21451 if(n <= 0) {
21452 DOMAIN_ERROR(result);
21453 }
21454 else if(n <= PSI_1_TABLE_NMAX) {
21455 result->val = psi_1_table[n];
21456 result->err = GSL_DBL_EPSILON * result->val;
21457 return GSL_SUCCESS;
21458 }
21459 else {
21460 /* Abramowitz+Stegun 6.4.12
21461 * double-precision for n > 100
21462 */
21463 const double c0 = -1.0/30.0;
21464 const double c1 = 1.0/42.0;
21465 const double c2 = -1.0/30.0;
21466 const double ni2 = (1.0/n)*(1.0/n);
21467 const double ser = ni2*ni2 * (c0 + ni2*(c1 + c2*ni2));
21468 result->val = (1.0 + 0.5/n + 1.0/(6.0*n*n) + ser) / n;
21469 result->err = GSL_DBL_EPSILON * result->val;
21470 return GSL_SUCCESS;
21471 }
21472}
21473
21474
21475int gsl_sf_psi_1_e(const double x, gsl_sf_result * result)
21476{
21477 /* CHECK_POINTER(result) */
21478
21479 if(x == 0.0 || x == -1.0 || x == -2.0) {
21480 DOMAIN_ERROR(result);
21481 }
21482 else if(x > 0.0)
21483 {
21484 return psi_n_xg0(1, x, result);
21485 }
21486 else if(x > -5.0)
21487 {
21488 /* Abramowitz + Stegun 6.4.6 */
21489 int M = -floor(x);
21490 double fx = x + M;
21491 double sum = 0.0;
21492 int m;
21493
21494 if(fx == 0.0)
21495 DOMAIN_ERROR(result);
21496
21497 for(m = 0; m < M; ++m)
21498 sum += 1.0/((x+m)*(x+m));
21499
21500 {
21501 int stat_psi = psi_n_xg0(1, fx, result);
21502 result->val += sum;
21503 result->err += M * GSL_DBL_EPSILON * sum;
21504 return stat_psi;
21505 }
21506 }
21507 else
21508 {
21509 /* Abramowitz + Stegun 6.4.7 */
21510 const double sin_px = sin(M_PI * x);
21511 const double d = M_PI*M_PI/(sin_px*sin_px);
21512 gsl_sf_result r;
21513 int stat_psi = psi_n_xg0(1, 1.0-x, &r);
21514 result->val = d - r.val;
21515 result->err = r.err + 2.0*GSL_DBL_EPSILON*d;
21516 return stat_psi;
21517 }
21518}
21519
21520
21521int gsl_sf_psi_n_e(const int n, const double x, gsl_sf_result * result)
21522{
21523 /* CHECK_POINTER(result) */
21524
21525 if(n == 0)
21526 {
21527 return gsl_sf_psi_e(x, result);
21528 }
21529 else if(n == 1)
21530 {
21531 return gsl_sf_psi_1_e(x, result);
21532 }
21533 else if(n < 0 || x <= 0.0) {
21534 DOMAIN_ERROR(result);
21535 }
21536 else {
21537 gsl_sf_result ln_nf;
21538 gsl_sf_result hzeta;
21539 int stat_hz = gsl_sf_hzeta_e(n+1.0, x, &hzeta);
21540 int stat_nf = gsl_sf_lnfact_e((unsigned int) n, &ln_nf);
21541 int stat_e = gsl_sf_exp_mult_err_e(ln_nf.val, ln_nf.err,
21542 hzeta.val, hzeta.err,
21543 result);
21544 if(GSL_IS_EVEN(n)) result->val = -result->val;
21545 return GSL_ERROR_SELECT_3(stat_e, stat_nf, stat_hz);
21546 }
21547}
21548
21549
21550int
21551gsl_sf_complex_psi_e(
21552 const double x,
21553 const double y,
21554 gsl_sf_result * result_re,
21555 gsl_sf_result * result_im
21556 )
21557{
21558 if(x >= 0.0)
21559 {
21560 gsl_complex z = gsl_complex_rect(x, y);
21561 return psi_complex_rhp(z, result_re, result_im);
21562 }
21563 else
21564 {
21565 /* reflection formula [Abramowitz+Stegun, 6.3.7] */
21566 gsl_complex z = gsl_complex_rect(x, y);
21567 gsl_complex omz = gsl_complex_rect(1.0 - x, -y);
21568 gsl_complex zpi = gsl_complex_mul_real(z, M_PI);
21569 gsl_complex cotzpi = gsl_complex_cot(zpi);
21570 int ret_val = psi_complex_rhp(omz, result_re, result_im);
21571
21572 if(GSL_IS_REAL(GSL_REAL(cotzpi)) && GSL_IS_REAL(GSL_IMAG(cotzpi)))
21573 {
21574 result_re->val -= M_PI * GSL_REAL(cotzpi);
21575 result_im->val -= M_PI * GSL_IMAG(cotzpi);
21576 return ret_val;
21577 }
21578 else
21579 {
21580 GSL_ERROR("singularity", GSL_EDOM);
21581 }
21582 }
21583}
21584
21585
21586
21587/*-*-*-*-*-*-*-*-*-* Functions w/ Natural Prototypes *-*-*-*-*-*-*-*-*-*-*/
21588
21589/* inlined: eval.h */
21590
21591double gsl_sf_psi_int(const int n)
21592{
21593 EVAL_RESULT(gsl_sf_psi_int_e(n, &result));
21594}
21595
21596double gsl_sf_psi(const double x)
21597{
21598 EVAL_RESULT(gsl_sf_psi_e(x, &result));
21599}
21600
21601double gsl_sf_psi_1piy(const double x)
21602{
21603 EVAL_RESULT(gsl_sf_psi_1piy_e(x, &result));
21604}
21605
21606double gsl_sf_psi_1_int(const int n)
21607{
21608 EVAL_RESULT(gsl_sf_psi_1_int_e(n, &result));
21609}
21610
21611double gsl_sf_psi_1(const double x)
21612{
21613 EVAL_RESULT(gsl_sf_psi_1_e(x, &result));
21614}
21615
21616double gsl_sf_psi_n(const int n, const double x)
21617{
21618 EVAL_RESULT(gsl_sf_psi_n_e(n, x, &result));
21619}
21620/* end inlined source: specfunc/psi.c */
21621/* begin inlined source: specfunc/airy.c */
21622/* specfunc/airy.c
21623 *
21624 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
21625 *
21626 * This program is free software; you can redistribute it and/or modify
21627 * it under the terms of the GNU General Public License as published by
21628 * the Free Software Foundation; either version 3 of the License, or (at
21629 * your option) any later version.
21630 *
21631 * This program is distributed in the hope that it will be useful, but
21632 * WITHOUT ANY WARRANTY; without even the implied warranty of
21633 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21634 * General Public License for more details.
21635 *
21636 * You should have received a copy of the GNU General Public License
21637 * along with this program; if not, write to the Free Software
21638 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21639 */
21640
21641/* Author: G. Jungman */
21642/* begin inlined header: config.h */
21643#ifndef MARLEY_BUILTIN_GSL_CONFIG_WRAPPER_H
21644#define MARLEY_BUILTIN_GSL_CONFIG_WRAPPER_H
21645/* begin inlined header: gsl_config.h */
21646#ifndef MARLEY_BUILTIN_GSL_CONFIG_H
21647#define MARLEY_BUILTIN_GSL_CONFIG_H
21648
21649#define HAVE_INLINE 1
21650#define HAVE_DECL_ISFINITE 1
21651#define HAVE_DECL_ISNAN 1
21652#define HAVE_DECL_ISINF 1
21653#define GSL_COERCE_DBL(x) (x)
21654
21655#define GSL_DISABLE_DEPRECATED 0
21656#define PACKAGE_VERSION "2.8"
21657#define VERSION "2.8"
21658
21659#endif
21660
21661/* end inlined header: gsl_config.h */
21662#endif
21663
21664/* end inlined header: config.h */
21665/* begin inlined header: gsl/gsl_math.h */
21666/* gsl_math.h
21667 *
21668 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2004, 2007 Gerard Jungman, Brian Gough
21669 *
21670 * This program is free software; you can redistribute it and/or modify
21671 * it under the terms of the GNU General Public License as published by
21672 * the Free Software Foundation; either version 3 of the License, or (at
21673 * your option) any later version.
21674 *
21675 * This program is distributed in the hope that it will be useful, but
21676 * WITHOUT ANY WARRANTY; without even the implied warranty of
21677 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21678 * General Public License for more details.
21679 *
21680 * You should have received a copy of the GNU General Public License
21681 * along with this program; if not, write to the Free Software
21682 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21683 */
21684
21685#ifndef __GSL_MATH_H__
21686#define __GSL_MATH_H__
21687#include <math.h>
21688/* begin inlined header: gsl/gsl_sys.h */
21689/* sys/gsl_sys.h
21690 *
21691 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, Brian Gough
21692 *
21693 * This program is free software; you can redistribute it and/or modify
21694 * it under the terms of the GNU General Public License as published by
21695 * the Free Software Foundation; either version 3 of the License, or (at
21696 * your option) any later version.
21697 *
21698 * This program is distributed in the hope that it will be useful, but
21699 * WITHOUT ANY WARRANTY; without even the implied warranty of
21700 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21701 * General Public License for more details.
21702 *
21703 * You should have received a copy of the GNU General Public License
21704 * along with this program; if not, write to the Free Software
21705 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21706 */
21707
21708#ifndef __GSL_SYS_H__
21709#define __GSL_SYS_H__
21710
21711
21712
21713__BEGIN_DECLS
21714
21715double gsl_log1p (const double x);
21716double gsl_expm1 (const double x);
21717double gsl_hypot (const double x, const double y);
21718double gsl_hypot3 (const double x, const double y, const double z);
21719double gsl_acosh (const double x);
21720double gsl_asinh (const double x);
21721double gsl_atanh (const double x);
21722
21723int gsl_isnan (const double x);
21724int gsl_isinf (const double x);
21725int gsl_finite (const double x);
21726
21727double gsl_nan (void);
21728double gsl_posinf (void);
21729double gsl_neginf (void);
21730double gsl_fdiv (const double x, const double y);
21731
21732double gsl_coerce_double (const double x);
21733float gsl_coerce_float (const float x);
21734long double gsl_coerce_long_double (const long double x);
21735
21736double gsl_ldexp(const double x, const int e);
21737double gsl_frexp(const double x, int * e);
21738
21739int gsl_fcmp (const double x1, const double x2, const double epsilon);
21740
21741__END_DECLS
21742
21743#endif /* __GSL_SYS_H__ */
21744
21745/* end inlined header: gsl/gsl_sys.h */
21746/* begin inlined header: gsl/gsl_inline.h */
21747/* gsl_inline.h
21748 *
21749 * Copyright (C) 2008, 2009 Brian Gough
21750 *
21751 * This program is free software; you can redistribute it and/or modify
21752 * it under the terms of the GNU General Public License as published by
21753 * the Free Software Foundation; either version 3 of the License, or (at
21754 * your option) any later version.
21755 *
21756 * This program is distributed in the hope that it will be useful, but
21757 * WITHOUT ANY WARRANTY; without even the implied warranty of
21758 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21759 * General Public License for more details.
21760 *
21761 * You should have received a copy of the GNU General Public License
21762 * along with this program; if not, write to the Free Software
21763 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21764 */
21765
21766#ifndef __GSL_INLINE_H__
21767#define __GSL_INLINE_H__
21768
21769/* In recent versiions of GCC, the inline keyword has two different
21770 forms: GNU and C99.
21771
21772 In GNU mode we can use 'extern inline' to make inline functions
21773 work like macros. The function is only inlined--it is never output
21774 as a definition in an object file.
21775
21776 In the new C99 mode 'extern inline' has a different meaning--it
21777 causes the definition of the function to be output in each object
21778 file where it is used. This will result in multiple-definition
21779 errors on linking. The 'inline' keyword on its own (without
21780 extern) has the same behavior as the original GNU 'extern inline'.
21781
21782 The C99 style is the default with -std=c99 in GCC 4.3.
21783
21784 This header file allows either form of inline to be used by
21785 redefining the macros INLINE_DECL and INLINE_FUN. These are used
21786 in the public header files as
21787
21788 INLINE_DECL double gsl_foo (double x);
21789 #ifdef HAVE_INLINE
21790 INLINE_FUN double gsl_foo (double x) { return x+1.0; } ;
21791 #endif
21792
21793*/
21794
21795#ifdef HAVE_INLINE
21796# if defined(__GNUC_STDC_INLINE__) || defined(GSL_C99_INLINE) || defined(HAVE_C99_INLINE)
21797# define INLINE_DECL inline /* use C99 inline */
21798# define INLINE_FUN inline
21799# else
21800# define INLINE_DECL /* use GNU extern inline */
21801# define INLINE_FUN extern inline
21802# endif
21803#else
21804# define INLINE_DECL /* */
21805#endif
21806
21807/* Range checking conditions in headers do not require any run-time
21808 tests of the global variable gsl_check_range. They are enabled or
21809 disabled in user code at compile time with GSL_RANGE_CHECK macro.
21810 See also build.h. */
21811#define GSL_RANGE_COND(x) (x)
21812
21813#endif /* __GSL_INLINE_H__ */
21814
21815/* end inlined header: gsl/gsl_inline.h */
21816/* begin inlined header: gsl/gsl_machine.h */
21817/* Author: B. Gough and G. Jungman */
21818#ifndef __GSL_MACHINE_H__
21819#define __GSL_MACHINE_H__
21820
21821#include <limits.h>
21822#include <float.h>
21823
21824/* magic constants; mostly for the benefit of the implementation */
21825
21826/* -*-MACHINE CONSTANTS-*-
21827 *
21828 * PLATFORM: Whiz-O-Matic 9000
21829 * FP_PLATFORM: IEEE-Virtual
21830 * HOSTNAME: nnn.lanl.gov
21831 * DATE: Fri Nov 20 17:53:26 MST 1998
21832 */
21833#define GSL_DBL_EPSILON 2.2204460492503131e-16
21834#define GSL_SQRT_DBL_EPSILON 1.4901161193847656e-08
21835#define GSL_ROOT3_DBL_EPSILON 6.0554544523933429e-06
21836#define GSL_ROOT4_DBL_EPSILON 1.2207031250000000e-04
21837#define GSL_ROOT5_DBL_EPSILON 7.4009597974140505e-04
21838#define GSL_ROOT6_DBL_EPSILON 2.4607833005759251e-03
21839#define GSL_LOG_DBL_EPSILON (-3.6043653389117154e+01)
21840
21841#define GSL_DBL_MIN 2.2250738585072014e-308
21842#define GSL_SQRT_DBL_MIN 1.4916681462400413e-154
21843#define GSL_ROOT3_DBL_MIN 2.8126442852362996e-103
21844#define GSL_ROOT4_DBL_MIN 1.2213386697554620e-77
21845#define GSL_ROOT5_DBL_MIN 2.9476022969691763e-62
21846#define GSL_ROOT6_DBL_MIN 5.3034368905798218e-52
21847#define GSL_LOG_DBL_MIN (-7.0839641853226408e+02)
21848
21849#define GSL_DBL_MAX 1.7976931348623157e+308
21850#define GSL_SQRT_DBL_MAX 1.3407807929942596e+154
21851#define GSL_ROOT3_DBL_MAX 5.6438030941222897e+102
21852#define GSL_ROOT4_DBL_MAX 1.1579208923731620e+77
21853#define GSL_ROOT5_DBL_MAX 4.4765466227572707e+61
21854#define GSL_ROOT6_DBL_MAX 2.3756689782295612e+51
21855#define GSL_LOG_DBL_MAX 7.0978271289338397e+02
21856
21857#define GSL_FLT_EPSILON 1.1920928955078125e-07
21858#define GSL_SQRT_FLT_EPSILON 3.4526698300124393e-04
21859#define GSL_ROOT3_FLT_EPSILON 4.9215666011518501e-03
21860#define GSL_ROOT4_FLT_EPSILON 1.8581361171917516e-02
21861#define GSL_ROOT5_FLT_EPSILON 4.1234622211652937e-02
21862#define GSL_ROOT6_FLT_EPSILON 7.0153878019335827e-02
21863#define GSL_LOG_FLT_EPSILON (-1.5942385152878742e+01)
21864
21865#define GSL_FLT_MIN 1.1754943508222875e-38
21866#define GSL_SQRT_FLT_MIN 1.0842021724855044e-19
21867#define GSL_ROOT3_FLT_MIN 2.2737367544323241e-13
21868#define GSL_ROOT4_FLT_MIN 3.2927225399135965e-10
21869#define GSL_ROOT5_FLT_MIN 2.5944428542140822e-08
21870#define GSL_ROOT6_FLT_MIN 4.7683715820312542e-07
21871#define GSL_LOG_FLT_MIN (-8.7336544750553102e+01)
21872
21873#define GSL_FLT_MAX 3.4028234663852886e+38
21874#define GSL_SQRT_FLT_MAX 1.8446743523953730e+19
21875#define GSL_ROOT3_FLT_MAX 6.9814635196223242e+12
21876#define GSL_ROOT4_FLT_MAX 4.2949672319999986e+09
21877#define GSL_ROOT5_FLT_MAX 5.0859007855960041e+07
21878#define GSL_ROOT6_FLT_MAX 2.6422459233807749e+06
21879#define GSL_LOG_FLT_MAX 8.8722839052068352e+01
21880
21881#define GSL_SFLT_EPSILON 4.8828125000000000e-04
21882#define GSL_SQRT_SFLT_EPSILON 2.2097086912079612e-02
21883#define GSL_ROOT3_SFLT_EPSILON 7.8745065618429588e-02
21884#define GSL_ROOT4_SFLT_EPSILON 1.4865088937534013e-01
21885#define GSL_ROOT5_SFLT_EPSILON 2.1763764082403100e-01
21886#define GSL_ROOT6_SFLT_EPSILON 2.8061551207734325e-01
21887#define GSL_LOG_SFLT_EPSILON (-7.6246189861593985e+00)
21888
21889/* !MACHINE CONSTANTS! */
21890
21891
21892/* a little internal backwards compatibility */
21893#define GSL_MACH_EPS GSL_DBL_EPSILON
21894
21895
21896
21897/* Here are the constants related to or derived from
21898 * machine constants. These are not to be confused with
21899 * the constants that define various precision levels
21900 * for the precision/error system.
21901 *
21902 * This information is determined at configure time
21903 * and is platform dependent. Edit at your own risk.
21904 *
21905 * PLATFORM: WHIZ-O-MATIC
21906 * CONFIG-DATE: Thu Nov 19 19:27:18 MST 1998
21907 * CONFIG-HOST: nnn.lanl.gov
21908 */
21909
21910/* machine precision constants */
21911/* #define GSL_MACH_EPS 1.0e-15 */
21912#define GSL_SQRT_MACH_EPS 3.2e-08
21913#define GSL_ROOT3_MACH_EPS 1.0e-05
21914#define GSL_ROOT4_MACH_EPS 0.000178
21915#define GSL_ROOT5_MACH_EPS 0.00100
21916#define GSL_ROOT6_MACH_EPS 0.00316
21917#define GSL_LOG_MACH_EPS (-34.54)
21918
21919
21920#endif /* __GSL_MACHINE_H__ */
21921
21922/* end inlined header: gsl/gsl_machine.h */
21923/* begin inlined header: gsl/gsl_precision.h */
21924/* gsl_precision.h
21925 *
21926 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
21927 *
21928 * This program is free software; you can redistribute it and/or modify
21929 * it under the terms of the GNU General Public License as published by
21930 * the Free Software Foundation; either version 3 of the License, or (at
21931 * your option) any later version.
21932 *
21933 * This program is distributed in the hope that it will be useful, but
21934 * WITHOUT ANY WARRANTY; without even the implied warranty of
21935 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21936 * General Public License for more details.
21937 *
21938 * You should have received a copy of the GNU General Public License
21939 * along with this program; if not, write to the Free Software
21940 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21941 */
21942
21943/* Author: B. Gough and G. Jungman */
21944
21945#ifndef __GSL_PRECISION_H__
21946#define __GSL_PRECISION_H__
21947/* begin inlined header: gsl/gsl_types.h */
21948/* gsl_types.h
21949 *
21950 * Copyright (C) 2001, 2007 Brian Gough
21951 *
21952 * This program is free software; you can redistribute it and/or modify
21953 * it under the terms of the GNU General Public License as published by
21954 * the Free Software Foundation; either version 3 of the License, or (at
21955 * your option) any later version.
21956 *
21957 * This program is distributed in the hope that it will be useful, but
21958 * WITHOUT ANY WARRANTY; without even the implied warranty of
21959 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21960 * General Public License for more details.
21961 *
21962 * You should have received a copy of the GNU General Public License
21963 * along with this program; if not, write to the Free Software
21964 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21965 */
21966
21967#ifndef __GSL_TYPES_H__
21968#define __GSL_TYPES_H__
21969
21970#ifndef GSL_VAR
21971
21972#ifdef WIN32
21973# ifdef GSL_DLL
21974# ifdef DLL_EXPORT
21975# define GSL_VAR extern __declspec(dllexport)
21976# else
21977# define GSL_VAR extern __declspec(dllimport)
21978# endif
21979# else
21980# define GSL_VAR extern
21981# endif
21982#else
21983# define GSL_VAR extern
21984#endif
21985
21986#endif
21987
21988#endif /* __GSL_TYPES_H__ */
21989
21990/* end inlined header: gsl/gsl_types.h */
21991
21992
21993__BEGIN_DECLS
21994
21995
21996/* A type for the precision indicator.
21997 * This is mainly for pedagogy.
21998 */
21999typedef unsigned int gsl_prec_t;
22000
22001
22002/* The number of precision types.
22003 * Remember that precision-mode
22004 * can index an array.
22005 */
22006#define _GSL_PREC_T_NUM 3
22007
22008
22009/* Arrays containing derived
22010 * precision constants for the
22011 * different precision levels.
22012 */
22013GSL_VAR const double gsl_prec_eps[];
22014GSL_VAR const double gsl_prec_sqrt_eps[];
22015GSL_VAR const double gsl_prec_root3_eps[];
22016GSL_VAR const double gsl_prec_root4_eps[];
22017GSL_VAR const double gsl_prec_root5_eps[];
22018GSL_VAR const double gsl_prec_root6_eps[];
22019
22020
22021__END_DECLS
22022
22023#endif /* __GSL_PRECISION_H__ */
22024
22025/* end inlined header: gsl/gsl_precision.h */
22026/* begin inlined header: gsl/gsl_nan.h */
22027/* gsl_nan.h
22028 *
22029 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, Brian Gough
22030 *
22031 * This program is free software; you can redistribute it and/or modify
22032 * it under the terms of the GNU General Public License as published by
22033 * the Free Software Foundation; either version 3 of the License, or (at
22034 * your option) any later version.
22035 *
22036 * This program is distributed in the hope that it will be useful, but
22037 * WITHOUT ANY WARRANTY; without even the implied warranty of
22038 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22039 * General Public License for more details.
22040 *
22041 * You should have received a copy of the GNU General Public License
22042 * along with this program; if not, write to the Free Software
22043 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22044 */
22045
22046#ifndef __GSL_NAN_H__
22047#define __GSL_NAN_H__
22048
22049#ifdef INFINITY
22050# define GSL_POSINF INFINITY
22051# define GSL_NEGINF (-INFINITY)
22052#elif defined(HUGE_VAL)
22053# define GSL_POSINF HUGE_VAL
22054# define GSL_NEGINF (-HUGE_VAL)
22055#else
22056# define GSL_POSINF (gsl_posinf())
22057# define GSL_NEGINF (gsl_neginf())
22058#endif
22059
22060#ifdef NAN
22061# define GSL_NAN NAN
22062#elif defined(INFINITY)
22063# define GSL_NAN (INFINITY/INFINITY)
22064#else
22065# define GSL_NAN (gsl_nan())
22066#endif
22067
22068#define GSL_POSZERO (+0.0)
22069#define GSL_NEGZERO (-0.0)
22070
22071#endif /* __GSL_NAN_H__ */
22072
22073/* end inlined header: gsl/gsl_nan.h */
22074/* begin inlined header: gsl/gsl_pow_int.h */
22075/* gsl_pow_int.h
22076 *
22077 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2004, 2007 Gerard Jungman, Brian Gough
22078 *
22079 * This program is free software; you can redistribute it and/or modify
22080 * it under the terms of the GNU General Public License as published by
22081 * the Free Software Foundation; either version 3 of the License, or (at
22082 * your option) any later version.
22083 *
22084 * This program is distributed in the hope that it will be useful, but
22085 * WITHOUT ANY WARRANTY; without even the implied warranty of
22086 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22087 * General Public License for more details.
22088 *
22089 * You should have received a copy of the GNU General Public License
22090 * along with this program; if not, write to the Free Software
22091 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22092 */
22093
22094#ifndef __GSL_POW_INT_H__
22095#define __GSL_POW_INT_H__
22096/* begin inlined header: gsl/gsl_inline.h */
22097/* gsl_inline.h
22098 *
22099 * Copyright (C) 2008, 2009 Brian Gough
22100 *
22101 * This program is free software; you can redistribute it and/or modify
22102 * it under the terms of the GNU General Public License as published by
22103 * the Free Software Foundation; either version 3 of the License, or (at
22104 * your option) any later version.
22105 *
22106 * This program is distributed in the hope that it will be useful, but
22107 * WITHOUT ANY WARRANTY; without even the implied warranty of
22108 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22109 * General Public License for more details.
22110 *
22111 * You should have received a copy of the GNU General Public License
22112 * along with this program; if not, write to the Free Software
22113 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22114 */
22115
22116#ifndef __GSL_INLINE_H__
22117#define __GSL_INLINE_H__
22118
22119/* In recent versiions of GCC, the inline keyword has two different
22120 forms: GNU and C99.
22121
22122 In GNU mode we can use 'extern inline' to make inline functions
22123 work like macros. The function is only inlined--it is never output
22124 as a definition in an object file.
22125
22126 In the new C99 mode 'extern inline' has a different meaning--it
22127 causes the definition of the function to be output in each object
22128 file where it is used. This will result in multiple-definition
22129 errors on linking. The 'inline' keyword on its own (without
22130 extern) has the same behavior as the original GNU 'extern inline'.
22131
22132 The C99 style is the default with -std=c99 in GCC 4.3.
22133
22134 This header file allows either form of inline to be used by
22135 redefining the macros INLINE_DECL and INLINE_FUN. These are used
22136 in the public header files as
22137
22138 INLINE_DECL double gsl_foo (double x);
22139 #ifdef HAVE_INLINE
22140 INLINE_FUN double gsl_foo (double x) { return x+1.0; } ;
22141 #endif
22142
22143*/
22144
22145#ifdef HAVE_INLINE
22146# if defined(__GNUC_STDC_INLINE__) || defined(GSL_C99_INLINE) || defined(HAVE_C99_INLINE)
22147# define INLINE_DECL inline /* use C99 inline */
22148# define INLINE_FUN inline
22149# else
22150# define INLINE_DECL /* use GNU extern inline */
22151# define INLINE_FUN extern inline
22152# endif
22153#else
22154# define INLINE_DECL /* */
22155#endif
22156
22157/* Range checking conditions in headers do not require any run-time
22158 tests of the global variable gsl_check_range. They are enabled or
22159 disabled in user code at compile time with GSL_RANGE_CHECK macro.
22160 See also build.h. */
22161#define GSL_RANGE_COND(x) (x)
22162
22163#endif /* __GSL_INLINE_H__ */
22164
22165/* end inlined header: gsl/gsl_inline.h */
22166
22167
22168__BEGIN_DECLS
22169
22170INLINE_DECL double gsl_pow_2(const double x);
22171INLINE_DECL double gsl_pow_3(const double x);
22172INLINE_DECL double gsl_pow_4(const double x);
22173INLINE_DECL double gsl_pow_5(const double x);
22174INLINE_DECL double gsl_pow_6(const double x);
22175INLINE_DECL double gsl_pow_7(const double x);
22176INLINE_DECL double gsl_pow_8(const double x);
22177INLINE_DECL double gsl_pow_9(const double x);
22178
22179#ifdef HAVE_INLINE
22180INLINE_FUN double gsl_pow_2(const double x) { return x*x; }
22181INLINE_FUN double gsl_pow_3(const double x) { return x*x*x; }
22182INLINE_FUN double gsl_pow_4(const double x) { double x2 = x*x; return x2*x2; }
22183INLINE_FUN double gsl_pow_5(const double x) { double x2 = x*x; return x2*x2*x; }
22184INLINE_FUN double gsl_pow_6(const double x) { double x2 = x*x; return x2*x2*x2; }
22185INLINE_FUN double gsl_pow_7(const double x) { double x3 = x*x*x; return x3*x3*x; }
22186INLINE_FUN double gsl_pow_8(const double x) { double x2 = x*x; double x4 = x2*x2; return x4*x4; }
22187INLINE_FUN double gsl_pow_9(const double x) { double x3 = x*x*x; return x3*x3*x3; }
22188#endif
22189
22190double gsl_pow_int(double x, int n);
22191double gsl_pow_uint(double x, unsigned int n);
22192
22193__END_DECLS
22194
22195#endif /* __GSL_POW_INT_H__ */
22196
22197/* end inlined header: gsl/gsl_pow_int.h */
22198/* begin inlined header: gsl/gsl_minmax.h */
22199/* gsl_minmax.h
22200 *
22201 * Copyright (C) 2008 Gerard Jungman, Brian Gough
22202 *
22203 * This program is free software; you can redistribute it and/or modify
22204 * it under the terms of the GNU General Public License as published by
22205 * the Free Software Foundation; either version 3 of the License, or (at
22206 * your option) any later version.
22207 *
22208 * This program is distributed in the hope that it will be useful, but
22209 * WITHOUT ANY WARRANTY; without even the implied warranty of
22210 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22211 * General Public License for more details.
22212 *
22213 * You should have received a copy of the GNU General Public License
22214 * along with this program; if not, write to the Free Software
22215 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22216 */
22217
22218#ifndef __GSL_MINMAX_H__
22219#define __GSL_MINMAX_H__
22220/* begin inlined header: gsl/gsl_inline.h */
22221/* gsl_inline.h
22222 *
22223 * Copyright (C) 2008, 2009 Brian Gough
22224 *
22225 * This program is free software; you can redistribute it and/or modify
22226 * it under the terms of the GNU General Public License as published by
22227 * the Free Software Foundation; either version 3 of the License, or (at
22228 * your option) any later version.
22229 *
22230 * This program is distributed in the hope that it will be useful, but
22231 * WITHOUT ANY WARRANTY; without even the implied warranty of
22232 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22233 * General Public License for more details.
22234 *
22235 * You should have received a copy of the GNU General Public License
22236 * along with this program; if not, write to the Free Software
22237 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22238 */
22239
22240#ifndef __GSL_INLINE_H__
22241#define __GSL_INLINE_H__
22242
22243/* In recent versiions of GCC, the inline keyword has two different
22244 forms: GNU and C99.
22245
22246 In GNU mode we can use 'extern inline' to make inline functions
22247 work like macros. The function is only inlined--it is never output
22248 as a definition in an object file.
22249
22250 In the new C99 mode 'extern inline' has a different meaning--it
22251 causes the definition of the function to be output in each object
22252 file where it is used. This will result in multiple-definition
22253 errors on linking. The 'inline' keyword on its own (without
22254 extern) has the same behavior as the original GNU 'extern inline'.
22255
22256 The C99 style is the default with -std=c99 in GCC 4.3.
22257
22258 This header file allows either form of inline to be used by
22259 redefining the macros INLINE_DECL and INLINE_FUN. These are used
22260 in the public header files as
22261
22262 INLINE_DECL double gsl_foo (double x);
22263 #ifdef HAVE_INLINE
22264 INLINE_FUN double gsl_foo (double x) { return x+1.0; } ;
22265 #endif
22266
22267*/
22268
22269#ifdef HAVE_INLINE
22270# if defined(__GNUC_STDC_INLINE__) || defined(GSL_C99_INLINE) || defined(HAVE_C99_INLINE)
22271# define INLINE_DECL inline /* use C99 inline */
22272# define INLINE_FUN inline
22273# else
22274# define INLINE_DECL /* use GNU extern inline */
22275# define INLINE_FUN extern inline
22276# endif
22277#else
22278# define INLINE_DECL /* */
22279#endif
22280
22281/* Range checking conditions in headers do not require any run-time
22282 tests of the global variable gsl_check_range. They are enabled or
22283 disabled in user code at compile time with GSL_RANGE_CHECK macro.
22284 See also build.h. */
22285#define GSL_RANGE_COND(x) (x)
22286
22287#endif /* __GSL_INLINE_H__ */
22288
22289/* end inlined header: gsl/gsl_inline.h */
22290
22291
22292__BEGIN_DECLS
22293
22294/* Define MAX and MIN macros/functions if they don't exist. */
22295
22296/* plain old macros for general use */
22297#define GSL_MAX(a,b) ((a) > (b) ? (a) : (b))
22298#define GSL_MIN(a,b) ((a) < (b) ? (a) : (b))
22299
22300/* function versions of the above, in case they are needed */
22301double gsl_max (double a, double b);
22302double gsl_min (double a, double b);
22303
22304/* inline-friendly strongly typed versions */
22305#ifdef HAVE_INLINE
22306
22307INLINE_FUN int GSL_MAX_INT (int a, int b);
22308INLINE_FUN int GSL_MIN_INT (int a, int b);
22309INLINE_FUN double GSL_MAX_DBL (double a, double b);
22310INLINE_FUN double GSL_MIN_DBL (double a, double b);
22311INLINE_FUN long double GSL_MAX_LDBL (long double a, long double b);
22312INLINE_FUN long double GSL_MIN_LDBL (long double a, long double b);
22313
22314INLINE_FUN int
22315GSL_MAX_INT (int a, int b)
22316{
22317 return GSL_MAX (a, b);
22318}
22319
22320INLINE_FUN int
22321GSL_MIN_INT (int a, int b)
22322{
22323 return GSL_MIN (a, b);
22324}
22325
22326INLINE_FUN double
22327GSL_MAX_DBL (double a, double b)
22328{
22329 return GSL_MAX (a, b);
22330}
22331
22332INLINE_FUN double
22333GSL_MIN_DBL (double a, double b)
22334{
22335 return GSL_MIN (a, b);
22336}
22337
22338INLINE_FUN long double
22339GSL_MAX_LDBL (long double a, long double b)
22340{
22341 return GSL_MAX (a, b);
22342}
22343
22344INLINE_FUN long double
22345GSL_MIN_LDBL (long double a, long double b)
22346{
22347 return GSL_MIN (a, b);
22348}
22349#else
22350#define GSL_MAX_INT(a,b) GSL_MAX(a,b)
22351#define GSL_MIN_INT(a,b) GSL_MIN(a,b)
22352#define GSL_MAX_DBL(a,b) GSL_MAX(a,b)
22353#define GSL_MIN_DBL(a,b) GSL_MIN(a,b)
22354#define GSL_MAX_LDBL(a,b) GSL_MAX(a,b)
22355#define GSL_MIN_LDBL(a,b) GSL_MIN(a,b)
22356#endif /* HAVE_INLINE */
22357
22358__END_DECLS
22359
22360#endif /* __GSL_POW_INT_H__ */
22361
22362/* end inlined header: gsl/gsl_minmax.h */
22363#ifndef M_E
22364#define M_E 2.71828182845904523536028747135 /* e */
22365#endif
22366
22367#ifndef M_LOG2E
22368#define M_LOG2E 1.44269504088896340735992468100 /* log_2 (e) */
22369#endif
22370
22371#ifndef M_LOG10E
22372#define M_LOG10E 0.43429448190325182765112891892 /* log_10 (e) */
22373#endif
22374
22375#ifndef M_SQRT2
22376#define M_SQRT2 1.41421356237309504880168872421 /* sqrt(2) */
22377#endif
22378
22379#ifndef M_SQRT1_2
22380#define M_SQRT1_2 0.70710678118654752440084436210 /* sqrt(1/2) */
22381#endif
22382
22383
22384#ifndef M_SQRT3
22385#define M_SQRT3 1.73205080756887729352744634151 /* sqrt(3) */
22386#endif
22387
22388#ifndef M_PI
22389#define M_PI 3.14159265358979323846264338328 /* pi */
22390#endif
22391
22392#ifndef M_PI_2
22393#define M_PI_2 1.57079632679489661923132169164 /* pi/2 */
22394#endif
22395
22396#ifndef M_PI_4
22397#define M_PI_4 0.78539816339744830961566084582 /* pi/4 */
22398#endif
22399
22400#ifndef M_SQRTPI
22401#define M_SQRTPI 1.77245385090551602729816748334 /* sqrt(pi) */
22402#endif
22403
22404#ifndef M_2_SQRTPI
22405#define M_2_SQRTPI 1.12837916709551257389615890312 /* 2/sqrt(pi) */
22406#endif
22407
22408#ifndef M_1_PI
22409#define M_1_PI 0.31830988618379067153776752675 /* 1/pi */
22410#endif
22411
22412#ifndef M_2_PI
22413#define M_2_PI 0.63661977236758134307553505349 /* 2/pi */
22414#endif
22415
22416#ifndef M_LN10
22417#define M_LN10 2.30258509299404568401799145468 /* ln(10) */
22418#endif
22419
22420#ifndef M_LN2
22421#define M_LN2 0.69314718055994530941723212146 /* ln(2) */
22422#endif
22423
22424#ifndef M_LNPI
22425#define M_LNPI 1.14472988584940017414342735135 /* ln(pi) */
22426#endif
22427
22428#ifndef M_EULER
22429#define M_EULER 0.57721566490153286060651209008 /* Euler constant */
22430#endif
22431
22432
22433
22434__BEGIN_DECLS
22435
22436/* other needlessly compulsive abstractions */
22437
22438#define GSL_IS_ODD(n) ((n) & 1)
22439#define GSL_IS_EVEN(n) (!(GSL_IS_ODD(n)))
22440#define GSL_SIGN(x) ((x) >= 0.0 ? 1 : -1)
22441
22442/* Return nonzero if x is a real number, i.e. non NaN or infinite. */
22443#define GSL_IS_REAL(x) (gsl_finite(x))
22444
22445/* Definition of an arbitrary function with parameters */
22446
22448{
22449 double (* function) (double x, void * params);
22450 void * params;
22451};
22452
22453typedef struct gsl_function_struct gsl_function ;
22454
22455#define GSL_FN_EVAL(F,x) (*((F)->function))(x,(F)->params)
22456
22457/* Definition of an arbitrary function returning two values, r1, r2 */
22458
22460{
22461 double (* f) (double x, void * params);
22462 double (* df) (double x, void * params);
22463 void (* fdf) (double x, void * params, double * f, double * df);
22464 void * params;
22465};
22466
22467typedef struct gsl_function_fdf_struct gsl_function_fdf ;
22468
22469#define GSL_FN_FDF_EVAL_F(FDF,x) (*((FDF)->f))(x,(FDF)->params)
22470#define GSL_FN_FDF_EVAL_DF(FDF,x) (*((FDF)->df))(x,(FDF)->params)
22471#define GSL_FN_FDF_EVAL_F_DF(FDF,x,y,dy) (*((FDF)->fdf))(x,(FDF)->params,(y),(dy))
22472
22473
22474/* Definition of an arbitrary vector-valued function with parameters */
22475
22477{
22478 int (* function) (double x, double y[], void * params);
22479 void * params;
22480};
22481
22482typedef struct gsl_function_vec_struct gsl_function_vec ;
22483
22484#define GSL_FN_VEC_EVAL(F,x,y) (*((F)->function))(x,y,(F)->params)
22485
22486__END_DECLS
22487
22488#endif /* __GSL_MATH_H__ */
22489
22490/* end inlined header: gsl/gsl_math.h */
22491/* begin inlined header: gsl/gsl_errno.h */
22492/* err/gsl_errno.h
22493 *
22494 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, Brian Gough
22495 *
22496 * This program is free software; you can redistribute it and/or modify
22497 * it under the terms of the GNU General Public License as published by
22498 * the Free Software Foundation; either version 3 of the License, or (at
22499 * your option) any later version.
22500 *
22501 * This program is distributed in the hope that it will be useful, but
22502 * WITHOUT ANY WARRANTY; without even the implied warranty of
22503 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22504 * General Public License for more details.
22505 *
22506 * You should have received a copy of the GNU General Public License
22507 * along with this program; if not, write to the Free Software
22508 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22509 */
22510
22511#ifndef __GSL_ERRNO_H__
22512#define __GSL_ERRNO_H__
22513
22514#include <stdio.h>
22515#include <errno.h>
22516/* begin inlined header: gsl/gsl_types.h */
22517/* gsl_types.h
22518 *
22519 * Copyright (C) 2001, 2007 Brian Gough
22520 *
22521 * This program is free software; you can redistribute it and/or modify
22522 * it under the terms of the GNU General Public License as published by
22523 * the Free Software Foundation; either version 3 of the License, or (at
22524 * your option) any later version.
22525 *
22526 * This program is distributed in the hope that it will be useful, but
22527 * WITHOUT ANY WARRANTY; without even the implied warranty of
22528 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22529 * General Public License for more details.
22530 *
22531 * You should have received a copy of the GNU General Public License
22532 * along with this program; if not, write to the Free Software
22533 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22534 */
22535
22536#ifndef __GSL_TYPES_H__
22537#define __GSL_TYPES_H__
22538
22539#ifndef GSL_VAR
22540
22541#ifdef WIN32
22542# ifdef GSL_DLL
22543# ifdef DLL_EXPORT
22544# define GSL_VAR extern __declspec(dllexport)
22545# else
22546# define GSL_VAR extern __declspec(dllimport)
22547# endif
22548# else
22549# define GSL_VAR extern
22550# endif
22551#else
22552# define GSL_VAR extern
22553#endif
22554
22555#endif
22556
22557#endif /* __GSL_TYPES_H__ */
22558
22559/* end inlined header: gsl/gsl_types.h */
22560
22561
22562__BEGIN_DECLS
22563
22564enum {
22565 GSL_SUCCESS = 0,
22566 GSL_FAILURE = -1,
22567 GSL_CONTINUE = -2, /* iteration has not converged */
22568 GSL_EDOM = 1, /* input domain error, e.g sqrt(-1) */
22569 GSL_ERANGE = 2, /* output range error, e.g. exp(1e100) */
22570 GSL_EFAULT = 3, /* invalid pointer */
22571 GSL_EINVAL = 4, /* invalid argument supplied by user */
22572 GSL_EFAILED = 5, /* generic failure */
22573 GSL_EFACTOR = 6, /* factorization failed */
22574 GSL_ESANITY = 7, /* sanity check failed - shouldn't happen */
22575 GSL_ENOMEM = 8, /* malloc failed */
22576 GSL_EBADFUNC = 9, /* problem with user-supplied function */
22577 GSL_ERUNAWAY = 10, /* iterative process is out of control */
22578 GSL_EMAXITER = 11, /* exceeded max number of iterations */
22579 GSL_EZERODIV = 12, /* tried to divide by zero */
22580 GSL_EBADTOL = 13, /* user specified an invalid tolerance */
22581 GSL_ETOL = 14, /* failed to reach the specified tolerance */
22582 GSL_EUNDRFLW = 15, /* underflow */
22583 GSL_EOVRFLW = 16, /* overflow */
22584 GSL_ELOSS = 17, /* loss of accuracy */
22585 GSL_EROUND = 18, /* failed because of roundoff error */
22586 GSL_EBADLEN = 19, /* matrix, vector lengths are not conformant */
22587 GSL_ENOTSQR = 20, /* matrix not square */
22588 GSL_ESING = 21, /* apparent singularity detected */
22589 GSL_EDIVERGE = 22, /* integral or series is divergent */
22590 GSL_EUNSUP = 23, /* requested feature is not supported by the hardware */
22591 GSL_EUNIMPL = 24, /* requested feature not (yet) implemented */
22592 GSL_ECACHE = 25, /* cache limit exceeded */
22593 GSL_ETABLE = 26, /* table limit exceeded */
22594 GSL_ENOPROG = 27, /* iteration is not making progress towards solution */
22595 GSL_ENOPROGJ = 28, /* jacobian evaluations are not improving the solution */
22596 GSL_ETOLF = 29, /* cannot reach the specified tolerance in F */
22597 GSL_ETOLX = 30, /* cannot reach the specified tolerance in X */
22598 GSL_ETOLG = 31, /* cannot reach the specified tolerance in gradient */
22599 GSL_EOF = 32 /* end of file */
22600} ;
22601
22602void gsl_error (const char * reason, const char * file, int line,
22603 int gsl_errno);
22604
22605void gsl_stream_printf (const char *label, const char *file,
22606 int line, const char *reason);
22607
22608typedef void gsl_error_handler_t (const char * reason, const char * file,
22609 int line, int gsl_errno);
22610
22611gsl_error_handler_t *
22612gsl_set_error_handler (gsl_error_handler_t * new_handler);
22613
22614/* GSL_ERROR: call the error handler, and return the error code */
22615
22616#define GSL_ERROR(reason, gsl_errno) \
22617 do { \
22618 gsl_error (reason, __FILE__, __LINE__, gsl_errno) ; \
22619 return gsl_errno ; \
22620 } while (0)
22621
22622/* GSL_ERROR_VAL: call the error handler, and return the given value */
22623
22624#define GSL_ERROR_VAL(reason, gsl_errno, value) \
22625 do { \
22626 gsl_error (reason, __FILE__, __LINE__, gsl_errno) ; \
22627 return value ; \
22628 } while (0)
22629
22630/* GSL_ERROR_VOID: call the error handler, and then return
22631 (for void functions which still need to generate an error) */
22632
22633#define GSL_ERROR_VOID(reason, gsl_errno) \
22634 do { \
22635 gsl_error (reason, __FILE__, __LINE__, gsl_errno) ; \
22636 return ; \
22637 } while (0)
22638
22639/* GSL_ERROR_NULL suitable for out-of-memory conditions */
22640
22641#define GSL_ERROR_NULL(reason, gsl_errno) GSL_ERROR_VAL(reason, gsl_errno, 0)
22642
22643/* Sometimes you have several status results returned from
22644 * function calls and you want to combine them in some sensible
22645 * way. You cannot produce a "total" status condition, but you can
22646 * pick one from a set of conditions based on an implied hierarchy.
22647 *
22648 * In other words:
22649 * you have: status_a, status_b, ...
22650 * you want: status = (status_a if it is bad, or status_b if it is bad,...)
22651 *
22652 * In this example you consider status_a to be more important and
22653 * it is checked first, followed by the others in the order specified.
22654 *
22655 * Here are some dumb macros to do this.
22656 */
22657#define GSL_ERROR_SELECT_2(a,b) ((a) != GSL_SUCCESS ? (a) : ((b) != GSL_SUCCESS ? (b) : GSL_SUCCESS))
22658#define GSL_ERROR_SELECT_3(a,b,c) ((a) != GSL_SUCCESS ? (a) : GSL_ERROR_SELECT_2(b,c))
22659#define GSL_ERROR_SELECT_4(a,b,c,d) ((a) != GSL_SUCCESS ? (a) : GSL_ERROR_SELECT_3(b,c,d))
22660#define GSL_ERROR_SELECT_5(a,b,c,d,e) ((a) != GSL_SUCCESS ? (a) : GSL_ERROR_SELECT_4(b,c,d,e))
22661
22662#define GSL_STATUS_UPDATE(sp, s) do { if ((s) != GSL_SUCCESS) *(sp) = (s);} while(0)
22663
22664__END_DECLS
22665
22666#endif /* __GSL_ERRNO_H__ */
22667
22668/* end inlined header: gsl/gsl_errno.h */
22669/* begin inlined header: gsl/gsl_sf_trig.h */
22670/* specfunc/gsl_sf_trig.h
22671 *
22672 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
22673 *
22674 * This program is free software; you can redistribute it and/or modify
22675 * it under the terms of the GNU General Public License as published by
22676 * the Free Software Foundation; either version 3 of the License, or (at
22677 * your option) any later version.
22678 *
22679 * This program is distributed in the hope that it will be useful, but
22680 * WITHOUT ANY WARRANTY; without even the implied warranty of
22681 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22682 * General Public License for more details.
22683 *
22684 * You should have received a copy of the GNU General Public License
22685 * along with this program; if not, write to the Free Software
22686 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22687 */
22688
22689/* Author: G. Jungman */
22690
22691#ifndef __GSL_SF_TRIG_H__
22692#define __GSL_SF_TRIG_H__
22693/* begin inlined header: gsl/gsl_sf_result.h */
22694/* specfunc/gsl_sf_result.h
22695 *
22696 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
22697 *
22698 * This program is free software; you can redistribute it and/or modify
22699 * it under the terms of the GNU General Public License as published by
22700 * the Free Software Foundation; either version 3 of the License, or (at
22701 * your option) any later version.
22702 *
22703 * This program is distributed in the hope that it will be useful, but
22704 * WITHOUT ANY WARRANTY; without even the implied warranty of
22705 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22706 * General Public License for more details.
22707 *
22708 * You should have received a copy of the GNU General Public License
22709 * along with this program; if not, write to the Free Software
22710 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22711 */
22712
22713/* Author: G. Jungman */
22714
22715#ifndef __GSL_SF_RESULT_H__
22716#define __GSL_SF_RESULT_H__
22717
22718
22719
22720__BEGIN_DECLS
22721
22722struct gsl_sf_result_struct {
22723 double val;
22724 double err;
22725};
22726typedef struct gsl_sf_result_struct gsl_sf_result;
22727
22728#define GSL_SF_RESULT_SET(r,v,e) do { (r)->val=(v); (r)->err=(e); } while(0)
22729
22730
22732 double val;
22733 double err;
22734 int e10;
22735};
22736typedef struct gsl_sf_result_e10_struct gsl_sf_result_e10;
22737
22738
22739int gsl_sf_result_smash_e(const gsl_sf_result_e10 * re, gsl_sf_result * r);
22740
22741
22742__END_DECLS
22743
22744#endif /* __GSL_SF_RESULT_H__ */
22745
22746/* end inlined header: gsl/gsl_sf_result.h */
22747
22748
22749__BEGIN_DECLS
22750
22751
22752/* Sin(x) with GSL semantics. This is actually important
22753 * because we want to control the error estimate, and trying
22754 * to guess the error for the standard library implementation
22755 * every time it is used would be a little goofy.
22756 */
22757int gsl_sf_sin_e(double x, gsl_sf_result * result);
22758double gsl_sf_sin(const double x);
22759
22760
22761/* Cos(x) with GSL semantics.
22762 */
22763int gsl_sf_cos_e(double x, gsl_sf_result * result);
22764double gsl_sf_cos(const double x);
22765
22766
22767/* Hypot(x,y) with GSL semantics.
22768 */
22769int gsl_sf_hypot_e(const double x, const double y, gsl_sf_result * result);
22770double gsl_sf_hypot(const double x, const double y);
22771
22772
22773/* Sin(z) for complex z
22774 *
22775 * exceptions: GSL_EOVRFLW
22776 */
22777int gsl_sf_complex_sin_e(const double zr, const double zi, gsl_sf_result * szr, gsl_sf_result * szi);
22778
22779
22780/* Cos(z) for complex z
22781 *
22782 * exceptions: GSL_EOVRFLW
22783 */
22784int gsl_sf_complex_cos_e(const double zr, const double zi, gsl_sf_result * czr, gsl_sf_result * czi);
22785
22786
22787/* Log(Sin(z)) for complex z
22788 *
22789 * exceptions: GSL_EDOM, GSL_ELOSS
22790 */
22791int gsl_sf_complex_logsin_e(const double zr, const double zi, gsl_sf_result * lszr, gsl_sf_result * lszi);
22792
22793
22794/* Sinc(x) = sin(pi x) / (pi x)
22795 *
22796 * exceptions: none
22797 */
22798int gsl_sf_sinc_e(double x, gsl_sf_result * result);
22799double gsl_sf_sinc(const double x);
22800
22801
22802/* Log(Sinh(x)), x > 0
22803 *
22804 * exceptions: GSL_EDOM
22805 */
22806int gsl_sf_lnsinh_e(const double x, gsl_sf_result * result);
22807double gsl_sf_lnsinh(const double x);
22808
22809
22810/* Log(Cosh(x))
22811 *
22812 * exceptions: none
22813 */
22814int gsl_sf_lncosh_e(const double x, gsl_sf_result * result);
22815double gsl_sf_lncosh(const double x);
22816
22817
22818/* Convert polar to rectlinear coordinates.
22819 *
22820 * exceptions: GSL_ELOSS
22821 */
22822int gsl_sf_polar_to_rect(const double r, const double theta, gsl_sf_result * x, gsl_sf_result * y);
22823
22824/* Convert rectilinear to polar coordinates.
22825 * return argument in range [-pi, pi]
22826 *
22827 * exceptions: GSL_EDOM
22828 */
22829int gsl_sf_rect_to_polar(const double x, const double y, gsl_sf_result * r, gsl_sf_result * theta);
22830
22831/* Sin(x) for quantity with an associated error.
22832 */
22833int gsl_sf_sin_err_e(const double x, const double dx, gsl_sf_result * result);
22834
22835
22836/* Cos(x) for quantity with an associated error.
22837 */
22838int gsl_sf_cos_err_e(const double x, const double dx, gsl_sf_result * result);
22839
22840
22841/* Force an angle to lie in the range (-pi,pi].
22842 *
22843 * exceptions: GSL_ELOSS
22844 */
22845int gsl_sf_angle_restrict_symm_e(double * theta);
22846double gsl_sf_angle_restrict_symm(const double theta);
22847
22848
22849/* Force an angle to lie in the range [0, 2pi)
22850 *
22851 * exceptions: GSL_ELOSS
22852 */
22853int gsl_sf_angle_restrict_pos_e(double * theta);
22854double gsl_sf_angle_restrict_pos(const double theta);
22855
22856
22857int gsl_sf_angle_restrict_symm_err_e(const double theta, gsl_sf_result * result);
22858
22859int gsl_sf_angle_restrict_pos_err_e(const double theta, gsl_sf_result * result);
22860
22861
22862__END_DECLS
22863
22864#endif /* __GSL_SF_TRIG_H__ */
22865
22866/* end inlined header: gsl/gsl_sf_trig.h */
22867/* begin inlined header: gsl/gsl_sf_airy.h */
22868/* specfunc/gsl_sf_airy.h
22869 *
22870 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
22871 *
22872 * This program is free software; you can redistribute it and/or modify
22873 * it under the terms of the GNU General Public License as published by
22874 * the Free Software Foundation; either version 3 of the License, or (at
22875 * your option) any later version.
22876 *
22877 * This program is distributed in the hope that it will be useful, but
22878 * WITHOUT ANY WARRANTY; without even the implied warranty of
22879 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22880 * General Public License for more details.
22881 *
22882 * You should have received a copy of the GNU General Public License
22883 * along with this program; if not, write to the Free Software
22884 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22885 */
22886
22887/* Author: G. Jungman */
22888
22889#ifndef __GSL_SF_AIRY_H__
22890#define __GSL_SF_AIRY_H__
22891/* begin inlined header: gsl/gsl_mode.h */
22892/* gsl_mode.h
22893 *
22894 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2004 Gerard Jungman
22895 *
22896 * This program is free software; you can redistribute it and/or modify
22897 * it under the terms of the GNU General Public License as published by
22898 * the Free Software Foundation; either version 3 of the License, or (at
22899 * your option) any later version.
22900 *
22901 * This program is distributed in the hope that it will be useful, but
22902 * WITHOUT ANY WARRANTY; without even the implied warranty of
22903 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22904 * General Public License for more details.
22905 *
22906 * You should have received a copy of the GNU General Public License
22907 * along with this program; if not, write to the Free Software
22908 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22909 */
22910
22911/* Author: B. Gough and G. Jungman */
22912
22913#ifndef __GSL_MODE_H__
22914#define __GSL_MODE_H__
22915/* begin inlined header: gsl/gsl_inline.h */
22916/* gsl_inline.h
22917 *
22918 * Copyright (C) 2008, 2009 Brian Gough
22919 *
22920 * This program is free software; you can redistribute it and/or modify
22921 * it under the terms of the GNU General Public License as published by
22922 * the Free Software Foundation; either version 3 of the License, or (at
22923 * your option) any later version.
22924 *
22925 * This program is distributed in the hope that it will be useful, but
22926 * WITHOUT ANY WARRANTY; without even the implied warranty of
22927 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22928 * General Public License for more details.
22929 *
22930 * You should have received a copy of the GNU General Public License
22931 * along with this program; if not, write to the Free Software
22932 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22933 */
22934
22935#ifndef __GSL_INLINE_H__
22936#define __GSL_INLINE_H__
22937
22938/* In recent versiions of GCC, the inline keyword has two different
22939 forms: GNU and C99.
22940
22941 In GNU mode we can use 'extern inline' to make inline functions
22942 work like macros. The function is only inlined--it is never output
22943 as a definition in an object file.
22944
22945 In the new C99 mode 'extern inline' has a different meaning--it
22946 causes the definition of the function to be output in each object
22947 file where it is used. This will result in multiple-definition
22948 errors on linking. The 'inline' keyword on its own (without
22949 extern) has the same behavior as the original GNU 'extern inline'.
22950
22951 The C99 style is the default with -std=c99 in GCC 4.3.
22952
22953 This header file allows either form of inline to be used by
22954 redefining the macros INLINE_DECL and INLINE_FUN. These are used
22955 in the public header files as
22956
22957 INLINE_DECL double gsl_foo (double x);
22958 #ifdef HAVE_INLINE
22959 INLINE_FUN double gsl_foo (double x) { return x+1.0; } ;
22960 #endif
22961
22962*/
22963
22964#ifdef HAVE_INLINE
22965# if defined(__GNUC_STDC_INLINE__) || defined(GSL_C99_INLINE) || defined(HAVE_C99_INLINE)
22966# define INLINE_DECL inline /* use C99 inline */
22967# define INLINE_FUN inline
22968# else
22969# define INLINE_DECL /* use GNU extern inline */
22970# define INLINE_FUN extern inline
22971# endif
22972#else
22973# define INLINE_DECL /* */
22974#endif
22975
22976/* Range checking conditions in headers do not require any run-time
22977 tests of the global variable gsl_check_range. They are enabled or
22978 disabled in user code at compile time with GSL_RANGE_CHECK macro.
22979 See also build.h. */
22980#define GSL_RANGE_COND(x) (x)
22981
22982#endif /* __GSL_INLINE_H__ */
22983
22984/* end inlined header: gsl/gsl_inline.h */
22985
22986
22987__BEGIN_DECLS
22988
22989
22990/* Some functions can take a mode argument. This
22991 * is a rough method to do things like control
22992 * the precision of the algorithm. This mainly
22993 * occurs in special functions, but we figured
22994 * it was ok to have a general facility.
22995 *
22996 * The mode type is 32-bit field. Most of
22997 * the fields are currently unused. Users
22998 * '|' various predefined constants to get
22999 * a desired mode.
23000 */
23001typedef unsigned int gsl_mode_t;
23002
23003
23004/* Here are the predefined constants.
23005 * Note that the precision constants
23006 * are special because they are used
23007 * to index arrays, so do not change
23008 * them. The precision information is
23009 * in the low order 3 bits of gsl_mode_t
23010 * (the third bit is currently unused).
23011 */
23012
23013/* Note that "0" is double precision,
23014 * so that you get that by default if
23015 * you forget a flag.
23016 */
23017#define GSL_PREC_DOUBLE 0
23018#define GSL_PREC_SINGLE 1
23019#define GSL_PREC_APPROX 2
23020
23021#ifdef HAVE_INLINE
23022INLINE_FUN unsigned int GSL_MODE_PREC(gsl_mode_t mt);
23023
23024INLINE_FUN unsigned int
23025GSL_MODE_PREC(gsl_mode_t mt)
23026{ return (mt & (unsigned int)7); }
23027#else /* HAVE_INLINE */
23028#define GSL_MODE_PREC(mt) ((mt) & (unsigned int)7)
23029#endif /* HAVE_INLINE */
23030
23031
23032/* Here are some predefined generic modes.
23033 */
23034#define GSL_MODE_DEFAULT 0
23035
23036
23037__END_DECLS
23038
23039#endif /* __GSL_MODE_H__ */
23040
23041/* end inlined header: gsl/gsl_mode.h */
23042/* begin inlined header: gsl/gsl_sf_result.h */
23043/* specfunc/gsl_sf_result.h
23044 *
23045 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
23046 *
23047 * This program is free software; you can redistribute it and/or modify
23048 * it under the terms of the GNU General Public License as published by
23049 * the Free Software Foundation; either version 3 of the License, or (at
23050 * your option) any later version.
23051 *
23052 * This program is distributed in the hope that it will be useful, but
23053 * WITHOUT ANY WARRANTY; without even the implied warranty of
23054 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23055 * General Public License for more details.
23056 *
23057 * You should have received a copy of the GNU General Public License
23058 * along with this program; if not, write to the Free Software
23059 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23060 */
23061
23062/* Author: G. Jungman */
23063
23064#ifndef __GSL_SF_RESULT_H__
23065#define __GSL_SF_RESULT_H__
23066
23067
23068
23069__BEGIN_DECLS
23070
23071struct gsl_sf_result_struct {
23072 double val;
23073 double err;
23074};
23075typedef struct gsl_sf_result_struct gsl_sf_result;
23076
23077#define GSL_SF_RESULT_SET(r,v,e) do { (r)->val=(v); (r)->err=(e); } while(0)
23078
23079
23081 double val;
23082 double err;
23083 int e10;
23084};
23085typedef struct gsl_sf_result_e10_struct gsl_sf_result_e10;
23086
23087
23088int gsl_sf_result_smash_e(const gsl_sf_result_e10 * re, gsl_sf_result * r);
23089
23090
23091__END_DECLS
23092
23093#endif /* __GSL_SF_RESULT_H__ */
23094
23095/* end inlined header: gsl/gsl_sf_result.h */
23096
23097
23098__BEGIN_DECLS
23099
23100
23101/* Airy function Ai(x)
23102 *
23103 * exceptions: GSL_EUNDRFLW
23104 */
23105int gsl_sf_airy_Ai_e(const double x, const gsl_mode_t mode, gsl_sf_result * result);
23106double gsl_sf_airy_Ai(const double x, gsl_mode_t mode);
23107
23108
23109/* Airy function Bi(x)
23110 *
23111 * exceptions: GSL_EOVRFLW
23112 */
23113int gsl_sf_airy_Bi_e(const double x, gsl_mode_t mode, gsl_sf_result * result);
23114double gsl_sf_airy_Bi(const double x, gsl_mode_t mode);
23115
23116
23117/* scaled Ai(x):
23118 * Ai(x) x < 0
23119 * exp(+2/3 x^{3/2}) Ai(x) x > 0
23120 *
23121 * exceptions: none
23122 */
23123int gsl_sf_airy_Ai_scaled_e(const double x, gsl_mode_t mode, gsl_sf_result * result);
23124double gsl_sf_airy_Ai_scaled(const double x, gsl_mode_t mode);
23125
23126
23127/* scaled Bi(x):
23128 * Bi(x) x < 0
23129 * exp(-2/3 x^{3/2}) Bi(x) x > 0
23130 *
23131 * exceptions: none
23132 */
23133int gsl_sf_airy_Bi_scaled_e(const double x, gsl_mode_t mode, gsl_sf_result * result);
23134double gsl_sf_airy_Bi_scaled(const double x, gsl_mode_t mode);
23135
23136
23137/* derivative Ai'(x)
23138 *
23139 * exceptions: GSL_EUNDRFLW
23140 */
23141int gsl_sf_airy_Ai_deriv_e(const double x, gsl_mode_t mode, gsl_sf_result * result);
23142double gsl_sf_airy_Ai_deriv(const double x, gsl_mode_t mode);
23143
23144
23145/* derivative Bi'(x)
23146 *
23147 * exceptions: GSL_EOVRFLW
23148 */
23149int gsl_sf_airy_Bi_deriv_e(const double x, gsl_mode_t mode, gsl_sf_result * result);
23150double gsl_sf_airy_Bi_deriv(const double x, gsl_mode_t mode);
23151
23152
23153/* scaled derivative Ai'(x):
23154 * Ai'(x) x < 0
23155 * exp(+2/3 x^{3/2}) Ai'(x) x > 0
23156 *
23157 * exceptions: none
23158 */
23159int gsl_sf_airy_Ai_deriv_scaled_e(const double x, gsl_mode_t mode, gsl_sf_result * result);
23160double gsl_sf_airy_Ai_deriv_scaled(const double x, gsl_mode_t mode);
23161
23162
23163/* scaled derivative:
23164 * Bi'(x) x < 0
23165 * exp(-2/3 x^{3/2}) Bi'(x) x > 0
23166 *
23167 * exceptions: none
23168 */
23169int gsl_sf_airy_Bi_deriv_scaled_e(const double x, gsl_mode_t mode, gsl_sf_result * result);
23170double gsl_sf_airy_Bi_deriv_scaled(const double x, gsl_mode_t mode);
23171
23172
23173/* Zeros of Ai(x)
23174 */
23175int gsl_sf_airy_zero_Ai_e(unsigned int s, gsl_sf_result * result);
23176double gsl_sf_airy_zero_Ai(unsigned int s);
23177
23178
23179/* Zeros of Bi(x)
23180 */
23181int gsl_sf_airy_zero_Bi_e(unsigned int s, gsl_sf_result * result);
23182double gsl_sf_airy_zero_Bi(unsigned int s);
23183
23184
23185/* Zeros of Ai'(x)
23186 */
23187int gsl_sf_airy_zero_Ai_deriv_e(unsigned int s, gsl_sf_result * result);
23188double gsl_sf_airy_zero_Ai_deriv(unsigned int s);
23189
23190
23191/* Zeros of Bi'(x)
23192 */
23193int gsl_sf_airy_zero_Bi_deriv_e(unsigned int s, gsl_sf_result * result);
23194double gsl_sf_airy_zero_Bi_deriv(unsigned int s);
23195
23196
23197__END_DECLS
23198
23199#endif /* __GSL_SF_AIRY_H__ */
23200
23201/* end inlined header: gsl/gsl_sf_airy.h */
23202/* inlined: error.h */
23203/* inlined: check.h */
23204
23205/* inlined: chebyshev.h */
23206/* begin inlined source: specfunc/cheb_eval_mode.c */
23207#ifndef MARLEY_BUILTIN_GSL_CHEB_EVAL_MODE_C
23208#define MARLEY_BUILTIN_GSL_CHEB_EVAL_MODE_C
23209
23210static inline int
23211cheb_eval_mode_e(const cheb_series * cs,
23212 const double x,
23213 gsl_mode_t mode,
23214 gsl_sf_result * result)
23215{
23216 int j;
23217 double d = 0.0;
23218 double dd = 0.0;
23219
23220 double y = (2.*x - cs->a - cs->b) / (cs->b - cs->a);
23221 double y2 = 2.0 * y;
23222
23223 int eval_order;
23224
23225 if(GSL_MODE_PREC(mode) == GSL_PREC_DOUBLE)
23226 eval_order = cs->order;
23227 else
23228 eval_order = cs->order_sp;
23229
23230 for(j = eval_order; j>=1; j--) {
23231 double temp = d;
23232 d = y2*d - dd + cs->c[j];
23233 dd = temp;
23234 }
23235
23236 result->val = y*d - dd + 0.5 * cs->c[0];
23237 result->err = GSL_DBL_EPSILON * fabs(result->val) + fabs(cs->c[eval_order]);
23238 return GSL_SUCCESS;
23239}
23240
23241#endif /* MARLEY_BUILTIN_GSL_CHEB_EVAL_MODE_C */
23242/* end inlined source: specfunc/cheb_eval_mode.c */
23243
23244/*-*-*-*-*-*-*-*-*-*-*-* Private Section *-*-*-*-*-*-*-*-*-*-*-*/
23245
23246
23247/* chebyshev expansions for Airy modulus and phase
23248 based on SLATEC r9aimp()
23249
23250 Series for AM21 on the interval -1.25000D-01 to 0.
23251 with weighted error 2.89E-17
23252 log weighted error 16.54
23253 significant figures required 14.15
23254 decimal places required 17.34
23255
23256 Series for ATH1 on the interval -1.25000D-01 to 0.
23257 with weighted error 2.53E-17
23258 log weighted error 16.60
23259 significant figures required 15.15
23260 decimal places required 17.38
23261
23262 Series for AM22 on the interval -1.00000D+00 to -1.25000D-01
23263 with weighted error 2.99E-17
23264 log weighted error 16.52
23265 significant figures required 14.57
23266 decimal places required 17.28
23267
23268 Series for ATH2 on the interval -1.00000D+00 to -1.25000D-01
23269 with weighted error 2.57E-17
23270 log weighted error 16.59
23271 significant figures required 15.07
23272 decimal places required 17.34
23273*/
23274
23275static double am21_data[37] = {
23276 0.0065809191761485,
23277 0.0023675984685722,
23278 0.0001324741670371,
23279 0.0000157600904043,
23280 0.0000027529702663,
23281 0.0000006102679017,
23282 0.0000001595088468,
23283 0.0000000471033947,
23284 0.0000000152933871,
23285 0.0000000053590722,
23286 0.0000000020000910,
23287 0.0000000007872292,
23288 0.0000000003243103,
23289 0.0000000001390106,
23290 0.0000000000617011,
23291 0.0000000000282491,
23292 0.0000000000132979,
23293 0.0000000000064188,
23294 0.0000000000031697,
23295 0.0000000000015981,
23296 0.0000000000008213,
23297 0.0000000000004296,
23298 0.0000000000002284,
23299 0.0000000000001232,
23300 0.0000000000000675,
23301 0.0000000000000374,
23302 0.0000000000000210,
23303 0.0000000000000119,
23304 0.0000000000000068,
23305 0.0000000000000039,
23306 0.0000000000000023,
23307 0.0000000000000013,
23308 0.0000000000000008,
23309 0.0000000000000005,
23310 0.0000000000000003,
23311 0.0000000000000001,
23312 0.0000000000000001
23313};
23314static cheb_series am21_cs = {
23315 am21_data,
23316 36,
23317 -1, 1,
23318 20
23319};
23320
23321static double ath1_data[36] = {
23322 -0.07125837815669365,
23323 -0.00590471979831451,
23324 -0.00012114544069499,
23325 -0.00000988608542270,
23326 -0.00000138084097352,
23327 -0.00000026142640172,
23328 -0.00000006050432589,
23329 -0.00000001618436223,
23330 -0.00000000483464911,
23331 -0.00000000157655272,
23332 -0.00000000055231518,
23333 -0.00000000020545441,
23334 -0.00000000008043412,
23335 -0.00000000003291252,
23336 -0.00000000001399875,
23337 -0.00000000000616151,
23338 -0.00000000000279614,
23339 -0.00000000000130428,
23340 -0.00000000000062373,
23341 -0.00000000000030512,
23342 -0.00000000000015239,
23343 -0.00000000000007758,
23344 -0.00000000000004020,
23345 -0.00000000000002117,
23346 -0.00000000000001132,
23347 -0.00000000000000614,
23348 -0.00000000000000337,
23349 -0.00000000000000188,
23350 -0.00000000000000105,
23351 -0.00000000000000060,
23352 -0.00000000000000034,
23353 -0.00000000000000020,
23354 -0.00000000000000011,
23355 -0.00000000000000007,
23356 -0.00000000000000004,
23357 -0.00000000000000002
23358};
23359static cheb_series ath1_cs = {
23360 ath1_data,
23361 35,
23362 -1, 1,
23363 15
23364};
23365
23366static double am22_data[33] = {
23367 -0.01562844480625341,
23368 0.00778336445239681,
23369 0.00086705777047718,
23370 0.00015696627315611,
23371 0.00003563962571432,
23372 0.00000924598335425,
23373 0.00000262110161850,
23374 0.00000079188221651,
23375 0.00000025104152792,
23376 0.00000008265223206,
23377 0.00000002805711662,
23378 0.00000000976821090,
23379 0.00000000347407923,
23380 0.00000000125828132,
23381 0.00000000046298826,
23382 0.00000000017272825,
23383 0.00000000006523192,
23384 0.00000000002490471,
23385 0.00000000000960156,
23386 0.00000000000373448,
23387 0.00000000000146417,
23388 0.00000000000057826,
23389 0.00000000000022991,
23390 0.00000000000009197,
23391 0.00000000000003700,
23392 0.00000000000001496,
23393 0.00000000000000608,
23394 0.00000000000000248,
23395 0.00000000000000101,
23396 0.00000000000000041,
23397 0.00000000000000017,
23398 0.00000000000000007,
23399 0.00000000000000002
23400};
23401static cheb_series am22_cs = {
23402 am22_data,
23403 32,
23404 -1, 1,
23405 15
23406};
23407
23408static double ath2_data[32] = {
23409 0.00440527345871877,
23410 -0.03042919452318455,
23411 -0.00138565328377179,
23412 -0.00018044439089549,
23413 -0.00003380847108327,
23414 -0.00000767818353522,
23415 -0.00000196783944371,
23416 -0.00000054837271158,
23417 -0.00000016254615505,
23418 -0.00000005053049981,
23419 -0.00000001631580701,
23420 -0.00000000543420411,
23421 -0.00000000185739855,
23422 -0.00000000064895120,
23423 -0.00000000023105948,
23424 -0.00000000008363282,
23425 -0.00000000003071196,
23426 -0.00000000001142367,
23427 -0.00000000000429811,
23428 -0.00000000000163389,
23429 -0.00000000000062693,
23430 -0.00000000000024260,
23431 -0.00000000000009461,
23432 -0.00000000000003716,
23433 -0.00000000000001469,
23434 -0.00000000000000584,
23435 -0.00000000000000233,
23436 -0.00000000000000093,
23437 -0.00000000000000037,
23438 -0.00000000000000015,
23439 -0.00000000000000006,
23440 -0.00000000000000002
23441};
23442static cheb_series ath2_cs = {
23443 ath2_data,
23444 31,
23445 -1, 1,
23446 16
23447};
23448
23449
23450/* Airy modulus and phase for x < -1 */
23451static
23452int
23453airy_mod_phase(const double x, gsl_mode_t mode, gsl_sf_result * mod, gsl_sf_result * phase)
23454{
23455 gsl_sf_result result_m;
23456 gsl_sf_result result_p;
23457 double m, p;
23458 double sqx;
23459
23460 if(x < -2.0) {
23461 double z = 16.0/(x*x*x) + 1.0;
23462 cheb_eval_mode_e(&am21_cs, z, mode, &result_m);
23463 cheb_eval_mode_e(&ath1_cs, z, mode, &result_p);
23464 }
23465 else if(x <= -1.0) {
23466 double z = (16.0/(x*x*x) + 9.0)/7.0;
23467 cheb_eval_mode_e(&am22_cs, z, mode, &result_m);
23468 cheb_eval_mode_e(&ath2_cs, z, mode, &result_p);
23469 }
23470 else {
23471 mod->val = 0.0;
23472 mod->err = 0.0;
23473 phase->val = 0.0;
23474 phase->err = 0.0;
23475 GSL_ERROR ("x is greater than 1.0", GSL_EDOM);
23476 }
23477
23478 m = 0.3125 + result_m.val;
23479 p = -0.625 + result_p.val;
23480
23481 sqx = sqrt(-x);
23482
23483 mod->val = sqrt(m/sqx);
23484 mod->err = fabs(mod->val) * (GSL_DBL_EPSILON + fabs(result_m.err/result_m.val));
23485 phase->val = M_PI_4 - x*sqx * p;
23486 phase->err = fabs(phase->val) * (GSL_DBL_EPSILON + fabs(result_p.err/result_p.val));
23487
23488 return GSL_SUCCESS;
23489}
23490
23491
23492
23493/* Chebyshev series for Ai(x) with x in [-1,1]
23494 based on SLATEC ai(x)
23495
23496 series for aif on the interval -1.00000d+00 to 1.00000d+00
23497 with weighted error 1.09e-19
23498 log weighted error 18.96
23499 significant figures required 17.76
23500 decimal places required 19.44
23501
23502 series for aig on the interval -1.00000d+00 to 1.00000d+00
23503 with weighted error 1.51e-17
23504 log weighted error 16.82
23505 significant figures required 15.19
23506 decimal places required 17.27
23507 */
23508static double ai_data_f[9] = {
23509 -0.03797135849666999750,
23510 0.05919188853726363857,
23511 0.00098629280577279975,
23512 0.00000684884381907656,
23513 0.00000002594202596219,
23514 0.00000000006176612774,
23515 0.00000000000010092454,
23516 0.00000000000000012014,
23517 0.00000000000000000010
23518};
23519static cheb_series aif_cs = {
23520 ai_data_f,
23521 8,
23522 -1, 1,
23523 8
23524};
23525
23526static double ai_data_g[8] = {
23527 0.01815236558116127,
23528 0.02157256316601076,
23529 0.00025678356987483,
23530 0.00000142652141197,
23531 0.00000000457211492,
23532 0.00000000000952517,
23533 0.00000000000001392,
23534 0.00000000000000001
23535};
23536static cheb_series aig_cs = {
23537 ai_data_g,
23538 7,
23539 -1, 1,
23540 7
23541};
23542
23543
23544/* Chebvyshev series for Bi(x) with x in [-1,1]
23545 based on SLATEC bi(x)
23546
23547 series for bif on the interval -1.00000d+00 to 1.00000d+00
23548 with weighted error 1.88e-19
23549 log weighted error 18.72
23550 significant figures required 17.74
23551 decimal places required 19.20
23552
23553 series for big on the interval -1.00000d+00 to 1.00000d+00
23554 with weighted error 2.61e-17
23555 log weighted error 16.58
23556 significant figures required 15.17
23557 decimal places required 17.03
23558 */
23559static double data_bif[9] = {
23560 -0.01673021647198664948,
23561 0.10252335834249445610,
23562 0.00170830925073815165,
23563 0.00001186254546774468,
23564 0.00000004493290701779,
23565 0.00000000010698207143,
23566 0.00000000000017480643,
23567 0.00000000000000020810,
23568 0.00000000000000000018
23569};
23570static cheb_series bif_cs = {
23571 data_bif,
23572 8,
23573 -1, 1,
23574 8
23575};
23576
23577static double data_big[8] = {
23578 0.02246622324857452,
23579 0.03736477545301955,
23580 0.00044476218957212,
23581 0.00000247080756363,
23582 0.00000000791913533,
23583 0.00000000001649807,
23584 0.00000000000002411,
23585 0.00000000000000002
23586};
23587static cheb_series big_cs = {
23588 data_big,
23589 7,
23590 -1, 1,
23591 7
23592};
23593
23594
23595/* Chebyshev series for Bi(x) with x in [1,8]
23596 based on SLATEC bi(x)
23597 */
23598static double data_bif2[10] = {
23599 0.0998457269381604100,
23600 0.4786249778630055380,
23601 0.0251552119604330118,
23602 0.0005820693885232645,
23603 0.0000074997659644377,
23604 0.0000000613460287034,
23605 0.0000000003462753885,
23606 0.0000000000014288910,
23607 0.0000000000000044962,
23608 0.0000000000000000111
23609};
23610static cheb_series bif2_cs = {
23611 data_bif2,
23612 9,
23613 -1, 1,
23614 9
23615};
23616
23617static double data_big2[10] = {
23618 0.033305662145514340,
23619 0.161309215123197068,
23620 0.0063190073096134286,
23621 0.0001187904568162517,
23622 0.0000013045345886200,
23623 0.0000000093741259955,
23624 0.0000000000474580188,
23625 0.0000000000001783107,
23626 0.0000000000000005167,
23627 0.0000000000000000011
23628};
23629static cheb_series big2_cs = {
23630 data_big2,
23631 9,
23632 -1, 1,
23633 9
23634};
23635
23636
23637/* chebyshev for Ai(x) asymptotic factor
23638 based on SLATEC aie()
23639
23640 Series for AIP on the interval 0. to 1.00000D+00
23641 with weighted error 5.10E-17
23642 log weighted error 16.29
23643 significant figures required 14.41
23644 decimal places required 17.06
23645
23646 [GJ] Sun Apr 19 18:14:31 EDT 1998
23647 There was something wrong with these coefficients. I was getting
23648 errors after 3 or 4 digits. So I recomputed this table. Now I get
23649 double precision agreement with Mathematica. But it does not seem
23650 possible that the small differences here would account for the
23651 original discrepancy. There must have been something wrong with my
23652 original usage...
23653*/
23654static double data_aip[36] = {
23655 -0.0187519297793867540198,
23656 -0.0091443848250055004725,
23657 0.0009010457337825074652,
23658 -0.0001394184127221491507,
23659 0.0000273815815785209370,
23660 -0.0000062750421119959424,
23661 0.0000016064844184831521,
23662 -0.0000004476392158510354,
23663 0.0000001334635874651668,
23664 -0.0000000420735334263215,
23665 0.0000000139021990246364,
23666 -0.0000000047831848068048,
23667 0.0000000017047897907465,
23668 -0.0000000006268389576018,
23669 0.0000000002369824276612,
23670 -0.0000000000918641139267,
23671 0.0000000000364278543037,
23672 -0.0000000000147475551725,
23673 0.0000000000060851006556,
23674 -0.0000000000025552772234,
23675 0.0000000000010906187250,
23676 -0.0000000000004725870319,
23677 0.0000000000002076969064,
23678 -0.0000000000000924976214,
23679 0.0000000000000417096723,
23680 -0.0000000000000190299093,
23681 0.0000000000000087790676,
23682 -0.0000000000000040927557,
23683 0.0000000000000019271068,
23684 -0.0000000000000009160199,
23685 0.0000000000000004393567,
23686 -0.0000000000000002125503,
23687 0.0000000000000001036735,
23688 -0.0000000000000000509642,
23689 0.0000000000000000252377,
23690 -0.0000000000000000125793
23691/*
23692 -.0187519297793868
23693 -.0091443848250055,
23694 .0009010457337825,
23695 -.0001394184127221,
23696 .0000273815815785,
23697 -.0000062750421119,
23698 .0000016064844184,
23699 -.0000004476392158,
23700 .0000001334635874,
23701 -.0000000420735334,
23702 .0000000139021990,
23703 -.0000000047831848,
23704 .0000000017047897,
23705 -.0000000006268389,
23706 .0000000002369824,
23707 -.0000000000918641,
23708 .0000000000364278,
23709 -.0000000000147475,
23710 .0000000000060851,
23711 -.0000000000025552,
23712 .0000000000010906,
23713 -.0000000000004725,
23714 .0000000000002076,
23715 -.0000000000000924,
23716 .0000000000000417,
23717 -.0000000000000190,
23718 .0000000000000087,
23719 -.0000000000000040,
23720 .0000000000000019,
23721 -.0000000000000009,
23722 .0000000000000004,
23723 -.0000000000000002,
23724 .0000000000000001,
23725 -.0000000000000000
23726*/
23727};
23728static cheb_series aip_cs = {
23729 data_aip,
23730 35,
23731 -1, 1,
23732 17
23733};
23734
23735
23736/* chebyshev for Bi(x) asymptotic factor
23737 based on SLATEC bie()
23738
23739 Series for BIP on the interval 1.25000D-01 to 3.53553D-01
23740 with weighted error 1.91E-17
23741 log weighted error 16.72
23742 significant figures required 15.35
23743 decimal places required 17.41
23744
23745 Series for BIP2 on the interval 0. to 1.25000D-01
23746 with weighted error 1.05E-18
23747 log weighted error 17.98
23748 significant figures required 16.74
23749 decimal places required 18.71
23750*/
23751static double data_bip[24] = {
23752 -0.08322047477943447,
23753 0.01146118927371174,
23754 0.00042896440718911,
23755 -0.00014906639379950,
23756 -0.00001307659726787,
23757 0.00000632759839610,
23758 -0.00000042226696982,
23759 -0.00000019147186298,
23760 0.00000006453106284,
23761 -0.00000000784485467,
23762 -0.00000000096077216,
23763 0.00000000070004713,
23764 -0.00000000017731789,
23765 0.00000000002272089,
23766 0.00000000000165404,
23767 -0.00000000000185171,
23768 0.00000000000059576,
23769 -0.00000000000012194,
23770 0.00000000000001334,
23771 0.00000000000000172,
23772 -0.00000000000000145,
23773 0.00000000000000049,
23774 -0.00000000000000011,
23775 0.00000000000000001
23776};
23777static cheb_series bip_cs = {
23778 data_bip,
23779 23,
23780 -1, 1,
23781 14
23782};
23783
23784static double data_bip2[29] = {
23785 -0.113596737585988679,
23786 0.0041381473947881595,
23787 0.0001353470622119332,
23788 0.0000104273166530153,
23789 0.0000013474954767849,
23790 0.0000001696537405438,
23791 -0.0000000100965008656,
23792 -0.0000000167291194937,
23793 -0.0000000045815364485,
23794 0.0000000003736681366,
23795 0.0000000005766930320,
23796 0.0000000000621812650,
23797 -0.0000000000632941202,
23798 -0.0000000000149150479,
23799 0.0000000000078896213,
23800 0.0000000000024960513,
23801 -0.0000000000012130075,
23802 -0.0000000000003740493,
23803 0.0000000000002237727,
23804 0.0000000000000474902,
23805 -0.0000000000000452616,
23806 -0.0000000000000030172,
23807 0.0000000000000091058,
23808 -0.0000000000000009814,
23809 -0.0000000000000016429,
23810 0.0000000000000005533,
23811 0.0000000000000002175,
23812 -0.0000000000000001737,
23813 -0.0000000000000000010
23814};
23815static cheb_series bip2_cs = {
23816 data_bip2,
23817 28,
23818 -1, 1,
23819 10
23820};
23821
23822
23823/* assumes x >= 1.0 */
23824inline static int
23825airy_aie(const double x, gsl_mode_t mode, gsl_sf_result * result)
23826{
23827 double sqx = sqrt(x);
23828 double z = 2.0/(x*sqx) - 1.0;
23829 double y = sqrt(sqx);
23830 gsl_sf_result result_c;
23831 cheb_eval_mode_e(&aip_cs, z, mode, &result_c);
23832 result->val = (0.28125 + result_c.val)/y;
23833 result->err = result_c.err/y + GSL_DBL_EPSILON * fabs(result->val);
23834 return GSL_SUCCESS;
23835}
23836
23837/* assumes x >= 2.0 */
23838static int airy_bie(const double x, gsl_mode_t mode, gsl_sf_result * result)
23839{
23840 const double ATR = 8.7506905708484345;
23841 const double BTR = -2.0938363213560543;
23842
23843 if(x < 4.0) {
23844 double sqx = sqrt(x);
23845 double z = ATR/(x*sqx) + BTR;
23846 double y = sqrt(sqx);
23847 gsl_sf_result result_c;
23848 cheb_eval_mode_e(&bip_cs, z, mode, &result_c);
23849 result->val = (0.625 + result_c.val)/y;
23850 result->err = result_c.err/y + GSL_DBL_EPSILON * fabs(result->val);
23851 }
23852 else {
23853 double sqx = sqrt(x);
23854 double z = 16.0/(x*sqx) - 1.0;
23855 double y = sqrt(sqx);
23856 gsl_sf_result result_c;
23857 cheb_eval_mode_e(&bip2_cs, z, mode, &result_c);
23858 result->val = (0.625 + result_c.val)/y;
23859 result->err = result_c.err/y + GSL_DBL_EPSILON * fabs(result->val);
23860 }
23861
23862 return GSL_SUCCESS;
23863}
23864
23865
23866/*-*-*-*-*-*-*-*-*-*-*-* Functions with Error Codes *-*-*-*-*-*-*-*-*-*-*-*/
23867
23868int
23869gsl_sf_airy_Ai_e(const double x, const gsl_mode_t mode, gsl_sf_result * result)
23870{
23871 /* CHECK_POINTER(result) */
23872
23873 if(x < -1.0) {
23874 gsl_sf_result mod;
23875 gsl_sf_result theta;
23876 gsl_sf_result cos_result;
23877 int stat_mp = airy_mod_phase(x, mode, &mod, &theta);
23878 int stat_cos = gsl_sf_cos_err_e(theta.val, theta.err, &cos_result);
23879 result->val = mod.val * cos_result.val;
23880 result->err = fabs(mod.val * cos_result.err) + fabs(cos_result.val * mod.err);
23881 result->err += GSL_DBL_EPSILON * fabs(result->val);
23882 return GSL_ERROR_SELECT_2(stat_mp, stat_cos);
23883 }
23884 else if(x <= 1.0) {
23885 const double z = x*x*x;
23886 gsl_sf_result result_c0;
23887 gsl_sf_result result_c1;
23888 cheb_eval_mode_e(&aif_cs, z, mode, &result_c0);
23889 cheb_eval_mode_e(&aig_cs, z, mode, &result_c1);
23890 result->val = 0.375 + (result_c0.val - x*(0.25 + result_c1.val));
23891 result->err = result_c0.err + fabs(x*result_c1.err);
23892 result->err += GSL_DBL_EPSILON * fabs(result->val);
23893 return GSL_SUCCESS;
23894 }
23895 else {
23896 double x32 = x * sqrt(x);
23897 double s = exp(-2.0*x32/3.0);
23898 gsl_sf_result result_aie;
23899 int stat_aie = airy_aie(x, mode, &result_aie);
23900 result->val = result_aie.val * s;
23901 result->err = result_aie.err * s + result->val * x32 * GSL_DBL_EPSILON;
23902 result->err += GSL_DBL_EPSILON * fabs(result->val);
23903 CHECK_UNDERFLOW(result);
23904 return stat_aie;
23905 }
23906}
23907
23908
23909int
23910gsl_sf_airy_Ai_scaled_e(const double x, gsl_mode_t mode, gsl_sf_result * result)
23911{
23912 /* CHECK_POINTER(result) */
23913
23914 if(x < -1.0) {
23915 gsl_sf_result mod;
23916 gsl_sf_result theta;
23917 gsl_sf_result cos_result;
23918 int stat_mp = airy_mod_phase(x, mode, &mod, &theta);
23919 int stat_cos = gsl_sf_cos_err_e(theta.val, theta.err, &cos_result);
23920 result->val = mod.val * cos_result.val;
23921 result->err = fabs(mod.val * cos_result.err) + fabs(cos_result.val * mod.err);
23922 result->err += GSL_DBL_EPSILON * fabs(result->val);
23923 return GSL_ERROR_SELECT_2(stat_mp, stat_cos);
23924 }
23925 else if(x <= 1.0) {
23926 const double z = x*x*x;
23927 gsl_sf_result result_c0;
23928 gsl_sf_result result_c1;
23929 cheb_eval_mode_e(&aif_cs, z, mode, &result_c0);
23930 cheb_eval_mode_e(&aig_cs, z, mode, &result_c1);
23931 result->val = 0.375 + (result_c0.val - x*(0.25 + result_c1.val));
23932 result->err = result_c0.err + fabs(x*result_c1.err);
23933 result->err += GSL_DBL_EPSILON * fabs(result->val);
23934
23935 if(x > 0.0) {
23936 const double scale = exp(2.0/3.0 * sqrt(z));
23937 result->val *= scale;
23938 result->err *= scale;
23939 }
23940
23941 return GSL_SUCCESS;
23942 }
23943 else {
23944 return airy_aie(x, mode, result);
23945 }
23946}
23947
23948
23949int gsl_sf_airy_Bi_e(const double x, gsl_mode_t mode, gsl_sf_result * result)
23950{
23951 /* CHECK_POINTER(result) */
23952 if(x < -1.0) {
23953 gsl_sf_result mod;
23954 gsl_sf_result theta;
23955 gsl_sf_result sin_result;
23956 int stat_mp = airy_mod_phase(x, mode, &mod, &theta);
23957 int stat_sin = gsl_sf_sin_err_e(theta.val, theta.err, &sin_result);
23958 result->val = mod.val * sin_result.val;
23959 result->err = fabs(mod.val * sin_result.err) + fabs(sin_result.val * mod.err);
23960 result->err += GSL_DBL_EPSILON * fabs(result->val);
23961 return GSL_ERROR_SELECT_2(stat_mp, stat_sin);
23962 }
23963 else if(x < 1.0) {
23964 const double z = x*x*x;
23965 gsl_sf_result result_c0;
23966 gsl_sf_result result_c1;
23967 cheb_eval_mode_e(&bif_cs, z, mode, &result_c0);
23968 cheb_eval_mode_e(&big_cs, z, mode, &result_c1);
23969 result->val = 0.625 + result_c0.val + x*(0.4375 + result_c1.val);
23970 result->err = result_c0.err + fabs(x * result_c1.err);
23971 result->err += GSL_DBL_EPSILON * fabs(result->val);
23972 return GSL_SUCCESS;
23973 }
23974 else if(x <= 2.0) {
23975 const double z = (2.0*x*x*x - 9.0)/7.0;
23976 gsl_sf_result result_c0;
23977 gsl_sf_result result_c1;
23978 cheb_eval_mode_e(&bif2_cs, z, mode, &result_c0);
23979 cheb_eval_mode_e(&big2_cs, z, mode, &result_c1);
23980 result->val = 1.125 + result_c0.val + x*(0.625 + result_c1.val);
23981 result->err = result_c0.err + fabs(x * result_c1.err);
23982 result->err += GSL_DBL_EPSILON * fabs(result->val);
23983 return GSL_SUCCESS;
23984 }
23985 else {
23986 const double y = 2.0*x*sqrt(x)/3.0;
23987 const double s = exp(y);
23988
23989 if(y > GSL_LOG_DBL_MAX - 1.0) {
23990 OVERFLOW_ERROR(result);
23991 }
23992 else {
23993 gsl_sf_result result_bie;
23994 int stat_bie = airy_bie(x, mode, &result_bie);
23995 result->val = result_bie.val * s;
23996 result->err = result_bie.err * s + fabs(1.5*y * (GSL_DBL_EPSILON * result->val));
23997 result->err += GSL_DBL_EPSILON * fabs(result->val);
23998 return stat_bie;
23999 }
24000 }
24001}
24002
24003
24004int
24005gsl_sf_airy_Bi_scaled_e(const double x, gsl_mode_t mode, gsl_sf_result * result)
24006{
24007 /* CHECK_POINTER(result) */
24008
24009 if(x < -1.0) {
24010 gsl_sf_result mod;
24011 gsl_sf_result theta;
24012 gsl_sf_result sin_result;
24013 int stat_mp = airy_mod_phase(x, mode, &mod, &theta);
24014 int stat_sin = gsl_sf_sin_err_e(theta.val, theta.err, &sin_result);
24015 result->val = mod.val * sin_result.val;
24016 result->err = fabs(mod.val * sin_result.err) + fabs(sin_result.val * mod.err);
24017 result->err += GSL_DBL_EPSILON * fabs(result->val);
24018 return GSL_ERROR_SELECT_2(stat_mp, stat_sin);
24019 }
24020 else if(x < 1.0) {
24021 const double z = x*x*x;
24022 gsl_sf_result result_c0;
24023 gsl_sf_result result_c1;
24024 cheb_eval_mode_e(&bif_cs, z, mode, &result_c0);
24025 cheb_eval_mode_e(&big_cs, z, mode, &result_c1);
24026 result->val = 0.625 + result_c0.val + x*(0.4375 + result_c1.val);
24027 result->err = result_c0.err + fabs(x * result_c1.err);
24028 result->err += GSL_DBL_EPSILON * fabs(result->val);
24029 if(x > 0.0) {
24030 const double scale = exp(-2.0/3.0 * sqrt(z));
24031 result->val *= scale;
24032 result->err *= scale;
24033 }
24034 return GSL_SUCCESS;
24035 }
24036 else if(x <= 2.0) {
24037 const double x3 = x*x*x;
24038 const double z = (2.0*x3 - 9.0)/7.0;
24039 const double s = exp(-2.0/3.0 * sqrt(x3));
24040 gsl_sf_result result_c0;
24041 gsl_sf_result result_c1;
24042 cheb_eval_mode_e(&bif2_cs, z, mode, &result_c0);
24043 cheb_eval_mode_e(&big2_cs, z, mode, &result_c1);
24044 result->val = s * (1.125 + result_c0.val + x*(0.625 + result_c1.val));
24045 result->err = s * (result_c0.err + fabs(x * result_c1.err));
24046 result->err += GSL_DBL_EPSILON * fabs(result->val);
24047 return GSL_SUCCESS;
24048 }
24049 else {
24050 return airy_bie(x, mode, result);
24051 }
24052}
24053
24054
24055/*-*-*-*-*-*-*-*-*-* Functions w/ Natural Prototypes *-*-*-*-*-*-*-*-*-*-*/
24056
24057/* inlined: eval.h */
24058
24059double gsl_sf_airy_Ai(const double x, gsl_mode_t mode)
24060{
24061 EVAL_RESULT(gsl_sf_airy_Ai_e(x, mode, &result));
24062}
24063
24064double gsl_sf_airy_Ai_scaled(const double x, gsl_mode_t mode)
24065{
24066 EVAL_RESULT(gsl_sf_airy_Ai_scaled_e(x, mode, &result));
24067}
24068
24069double gsl_sf_airy_Bi(const double x, gsl_mode_t mode)
24070{
24071 EVAL_RESULT(gsl_sf_airy_Bi_e(x, mode, &result));
24072}
24073
24074double gsl_sf_airy_Bi_scaled(const double x, gsl_mode_t mode)
24075{
24076 EVAL_RESULT(gsl_sf_airy_Bi_scaled_e(x, mode, &result));
24077}
24078
24079
24080/* end inlined source: specfunc/airy.c */
24081/* begin inlined source: specfunc/coulomb.c */
24082/* specfunc/coulomb.c
24083 *
24084 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
24085 *
24086 * This program is free software; you can redistribute it and/or modify
24087 * it under the terms of the GNU General Public License as published by
24088 * the Free Software Foundation; either version 3 of the License, or (at
24089 * your option) any later version.
24090 *
24091 * This program is distributed in the hope that it will be useful, but
24092 * WITHOUT ANY WARRANTY; without even the implied warranty of
24093 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24094 * General Public License for more details.
24095 *
24096 * You should have received a copy of the GNU General Public License
24097 * along with this program; if not, write to the Free Software
24098 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24099 */
24100
24101/* Author: G. Jungman */
24102
24103/* Evaluation of Coulomb wave functions F_L(eta, x), G_L(eta, x),
24104 * and their derivatives. A combination of Steed's method, asymptotic
24105 * results, and power series.
24106 *
24107 * Steed's method:
24108 * [Barnett, CPC 21, 297 (1981)]
24109 * Power series and other methods:
24110 * [Biedenharn et al., PR 97, 542 (1954)]
24111 * [Bardin et al., CPC 3, 73 (1972)]
24112 * [Abad+Sesma, CPC 71, 110 (1992)]
24113 */
24114/* begin inlined header: config.h */
24115#ifndef MARLEY_BUILTIN_GSL_CONFIG_WRAPPER_H
24116#define MARLEY_BUILTIN_GSL_CONFIG_WRAPPER_H
24117/* begin inlined header: gsl_config.h */
24118#ifndef MARLEY_BUILTIN_GSL_CONFIG_H
24119#define MARLEY_BUILTIN_GSL_CONFIG_H
24120
24121#define HAVE_INLINE 1
24122#define HAVE_DECL_ISFINITE 1
24123#define HAVE_DECL_ISNAN 1
24124#define HAVE_DECL_ISINF 1
24125#define GSL_COERCE_DBL(x) (x)
24126
24127#define GSL_DISABLE_DEPRECATED 0
24128#define PACKAGE_VERSION "2.8"
24129#define VERSION "2.8"
24130
24131#endif
24132
24133/* end inlined header: gsl_config.h */
24134#endif
24135
24136/* end inlined header: config.h */
24137/* begin inlined header: gsl/gsl_math.h */
24138/* gsl_math.h
24139 *
24140 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2004, 2007 Gerard Jungman, Brian Gough
24141 *
24142 * This program is free software; you can redistribute it and/or modify
24143 * it under the terms of the GNU General Public License as published by
24144 * the Free Software Foundation; either version 3 of the License, or (at
24145 * your option) any later version.
24146 *
24147 * This program is distributed in the hope that it will be useful, but
24148 * WITHOUT ANY WARRANTY; without even the implied warranty of
24149 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24150 * General Public License for more details.
24151 *
24152 * You should have received a copy of the GNU General Public License
24153 * along with this program; if not, write to the Free Software
24154 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24155 */
24156
24157#ifndef __GSL_MATH_H__
24158#define __GSL_MATH_H__
24159#include <math.h>
24160/* begin inlined header: gsl/gsl_sys.h */
24161/* sys/gsl_sys.h
24162 *
24163 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, Brian Gough
24164 *
24165 * This program is free software; you can redistribute it and/or modify
24166 * it under the terms of the GNU General Public License as published by
24167 * the Free Software Foundation; either version 3 of the License, or (at
24168 * your option) any later version.
24169 *
24170 * This program is distributed in the hope that it will be useful, but
24171 * WITHOUT ANY WARRANTY; without even the implied warranty of
24172 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24173 * General Public License for more details.
24174 *
24175 * You should have received a copy of the GNU General Public License
24176 * along with this program; if not, write to the Free Software
24177 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24178 */
24179
24180#ifndef __GSL_SYS_H__
24181#define __GSL_SYS_H__
24182
24183
24184
24185__BEGIN_DECLS
24186
24187double gsl_log1p (const double x);
24188double gsl_expm1 (const double x);
24189double gsl_hypot (const double x, const double y);
24190double gsl_hypot3 (const double x, const double y, const double z);
24191double gsl_acosh (const double x);
24192double gsl_asinh (const double x);
24193double gsl_atanh (const double x);
24194
24195int gsl_isnan (const double x);
24196int gsl_isinf (const double x);
24197int gsl_finite (const double x);
24198
24199double gsl_nan (void);
24200double gsl_posinf (void);
24201double gsl_neginf (void);
24202double gsl_fdiv (const double x, const double y);
24203
24204double gsl_coerce_double (const double x);
24205float gsl_coerce_float (const float x);
24206long double gsl_coerce_long_double (const long double x);
24207
24208double gsl_ldexp(const double x, const int e);
24209double gsl_frexp(const double x, int * e);
24210
24211int gsl_fcmp (const double x1, const double x2, const double epsilon);
24212
24213__END_DECLS
24214
24215#endif /* __GSL_SYS_H__ */
24216
24217/* end inlined header: gsl/gsl_sys.h */
24218/* begin inlined header: gsl/gsl_inline.h */
24219/* gsl_inline.h
24220 *
24221 * Copyright (C) 2008, 2009 Brian Gough
24222 *
24223 * This program is free software; you can redistribute it and/or modify
24224 * it under the terms of the GNU General Public License as published by
24225 * the Free Software Foundation; either version 3 of the License, or (at
24226 * your option) any later version.
24227 *
24228 * This program is distributed in the hope that it will be useful, but
24229 * WITHOUT ANY WARRANTY; without even the implied warranty of
24230 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24231 * General Public License for more details.
24232 *
24233 * You should have received a copy of the GNU General Public License
24234 * along with this program; if not, write to the Free Software
24235 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24236 */
24237
24238#ifndef __GSL_INLINE_H__
24239#define __GSL_INLINE_H__
24240
24241/* In recent versiions of GCC, the inline keyword has two different
24242 forms: GNU and C99.
24243
24244 In GNU mode we can use 'extern inline' to make inline functions
24245 work like macros. The function is only inlined--it is never output
24246 as a definition in an object file.
24247
24248 In the new C99 mode 'extern inline' has a different meaning--it
24249 causes the definition of the function to be output in each object
24250 file where it is used. This will result in multiple-definition
24251 errors on linking. The 'inline' keyword on its own (without
24252 extern) has the same behavior as the original GNU 'extern inline'.
24253
24254 The C99 style is the default with -std=c99 in GCC 4.3.
24255
24256 This header file allows either form of inline to be used by
24257 redefining the macros INLINE_DECL and INLINE_FUN. These are used
24258 in the public header files as
24259
24260 INLINE_DECL double gsl_foo (double x);
24261 #ifdef HAVE_INLINE
24262 INLINE_FUN double gsl_foo (double x) { return x+1.0; } ;
24263 #endif
24264
24265*/
24266
24267#ifdef HAVE_INLINE
24268# if defined(__GNUC_STDC_INLINE__) || defined(GSL_C99_INLINE) || defined(HAVE_C99_INLINE)
24269# define INLINE_DECL inline /* use C99 inline */
24270# define INLINE_FUN inline
24271# else
24272# define INLINE_DECL /* use GNU extern inline */
24273# define INLINE_FUN extern inline
24274# endif
24275#else
24276# define INLINE_DECL /* */
24277#endif
24278
24279/* Range checking conditions in headers do not require any run-time
24280 tests of the global variable gsl_check_range. They are enabled or
24281 disabled in user code at compile time with GSL_RANGE_CHECK macro.
24282 See also build.h. */
24283#define GSL_RANGE_COND(x) (x)
24284
24285#endif /* __GSL_INLINE_H__ */
24286
24287/* end inlined header: gsl/gsl_inline.h */
24288/* begin inlined header: gsl/gsl_machine.h */
24289/* Author: B. Gough and G. Jungman */
24290#ifndef __GSL_MACHINE_H__
24291#define __GSL_MACHINE_H__
24292
24293#include <limits.h>
24294#include <float.h>
24295
24296/* magic constants; mostly for the benefit of the implementation */
24297
24298/* -*-MACHINE CONSTANTS-*-
24299 *
24300 * PLATFORM: Whiz-O-Matic 9000
24301 * FP_PLATFORM: IEEE-Virtual
24302 * HOSTNAME: nnn.lanl.gov
24303 * DATE: Fri Nov 20 17:53:26 MST 1998
24304 */
24305#define GSL_DBL_EPSILON 2.2204460492503131e-16
24306#define GSL_SQRT_DBL_EPSILON 1.4901161193847656e-08
24307#define GSL_ROOT3_DBL_EPSILON 6.0554544523933429e-06
24308#define GSL_ROOT4_DBL_EPSILON 1.2207031250000000e-04
24309#define GSL_ROOT5_DBL_EPSILON 7.4009597974140505e-04
24310#define GSL_ROOT6_DBL_EPSILON 2.4607833005759251e-03
24311#define GSL_LOG_DBL_EPSILON (-3.6043653389117154e+01)
24312
24313#define GSL_DBL_MIN 2.2250738585072014e-308
24314#define GSL_SQRT_DBL_MIN 1.4916681462400413e-154
24315#define GSL_ROOT3_DBL_MIN 2.8126442852362996e-103
24316#define GSL_ROOT4_DBL_MIN 1.2213386697554620e-77
24317#define GSL_ROOT5_DBL_MIN 2.9476022969691763e-62
24318#define GSL_ROOT6_DBL_MIN 5.3034368905798218e-52
24319#define GSL_LOG_DBL_MIN (-7.0839641853226408e+02)
24320
24321#define GSL_DBL_MAX 1.7976931348623157e+308
24322#define GSL_SQRT_DBL_MAX 1.3407807929942596e+154
24323#define GSL_ROOT3_DBL_MAX 5.6438030941222897e+102
24324#define GSL_ROOT4_DBL_MAX 1.1579208923731620e+77
24325#define GSL_ROOT5_DBL_MAX 4.4765466227572707e+61
24326#define GSL_ROOT6_DBL_MAX 2.3756689782295612e+51
24327#define GSL_LOG_DBL_MAX 7.0978271289338397e+02
24328
24329#define GSL_FLT_EPSILON 1.1920928955078125e-07
24330#define GSL_SQRT_FLT_EPSILON 3.4526698300124393e-04
24331#define GSL_ROOT3_FLT_EPSILON 4.9215666011518501e-03
24332#define GSL_ROOT4_FLT_EPSILON 1.8581361171917516e-02
24333#define GSL_ROOT5_FLT_EPSILON 4.1234622211652937e-02
24334#define GSL_ROOT6_FLT_EPSILON 7.0153878019335827e-02
24335#define GSL_LOG_FLT_EPSILON (-1.5942385152878742e+01)
24336
24337#define GSL_FLT_MIN 1.1754943508222875e-38
24338#define GSL_SQRT_FLT_MIN 1.0842021724855044e-19
24339#define GSL_ROOT3_FLT_MIN 2.2737367544323241e-13
24340#define GSL_ROOT4_FLT_MIN 3.2927225399135965e-10
24341#define GSL_ROOT5_FLT_MIN 2.5944428542140822e-08
24342#define GSL_ROOT6_FLT_MIN 4.7683715820312542e-07
24343#define GSL_LOG_FLT_MIN (-8.7336544750553102e+01)
24344
24345#define GSL_FLT_MAX 3.4028234663852886e+38
24346#define GSL_SQRT_FLT_MAX 1.8446743523953730e+19
24347#define GSL_ROOT3_FLT_MAX 6.9814635196223242e+12
24348#define GSL_ROOT4_FLT_MAX 4.2949672319999986e+09
24349#define GSL_ROOT5_FLT_MAX 5.0859007855960041e+07
24350#define GSL_ROOT6_FLT_MAX 2.6422459233807749e+06
24351#define GSL_LOG_FLT_MAX 8.8722839052068352e+01
24352
24353#define GSL_SFLT_EPSILON 4.8828125000000000e-04
24354#define GSL_SQRT_SFLT_EPSILON 2.2097086912079612e-02
24355#define GSL_ROOT3_SFLT_EPSILON 7.8745065618429588e-02
24356#define GSL_ROOT4_SFLT_EPSILON 1.4865088937534013e-01
24357#define GSL_ROOT5_SFLT_EPSILON 2.1763764082403100e-01
24358#define GSL_ROOT6_SFLT_EPSILON 2.8061551207734325e-01
24359#define GSL_LOG_SFLT_EPSILON (-7.6246189861593985e+00)
24360
24361/* !MACHINE CONSTANTS! */
24362
24363
24364/* a little internal backwards compatibility */
24365#define GSL_MACH_EPS GSL_DBL_EPSILON
24366
24367
24368
24369/* Here are the constants related to or derived from
24370 * machine constants. These are not to be confused with
24371 * the constants that define various precision levels
24372 * for the precision/error system.
24373 *
24374 * This information is determined at configure time
24375 * and is platform dependent. Edit at your own risk.
24376 *
24377 * PLATFORM: WHIZ-O-MATIC
24378 * CONFIG-DATE: Thu Nov 19 19:27:18 MST 1998
24379 * CONFIG-HOST: nnn.lanl.gov
24380 */
24381
24382/* machine precision constants */
24383/* #define GSL_MACH_EPS 1.0e-15 */
24384#define GSL_SQRT_MACH_EPS 3.2e-08
24385#define GSL_ROOT3_MACH_EPS 1.0e-05
24386#define GSL_ROOT4_MACH_EPS 0.000178
24387#define GSL_ROOT5_MACH_EPS 0.00100
24388#define GSL_ROOT6_MACH_EPS 0.00316
24389#define GSL_LOG_MACH_EPS (-34.54)
24390
24391
24392#endif /* __GSL_MACHINE_H__ */
24393
24394/* end inlined header: gsl/gsl_machine.h */
24395/* begin inlined header: gsl/gsl_precision.h */
24396/* gsl_precision.h
24397 *
24398 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
24399 *
24400 * This program is free software; you can redistribute it and/or modify
24401 * it under the terms of the GNU General Public License as published by
24402 * the Free Software Foundation; either version 3 of the License, or (at
24403 * your option) any later version.
24404 *
24405 * This program is distributed in the hope that it will be useful, but
24406 * WITHOUT ANY WARRANTY; without even the implied warranty of
24407 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24408 * General Public License for more details.
24409 *
24410 * You should have received a copy of the GNU General Public License
24411 * along with this program; if not, write to the Free Software
24412 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24413 */
24414
24415/* Author: B. Gough and G. Jungman */
24416
24417#ifndef __GSL_PRECISION_H__
24418#define __GSL_PRECISION_H__
24419/* begin inlined header: gsl/gsl_types.h */
24420/* gsl_types.h
24421 *
24422 * Copyright (C) 2001, 2007 Brian Gough
24423 *
24424 * This program is free software; you can redistribute it and/or modify
24425 * it under the terms of the GNU General Public License as published by
24426 * the Free Software Foundation; either version 3 of the License, or (at
24427 * your option) any later version.
24428 *
24429 * This program is distributed in the hope that it will be useful, but
24430 * WITHOUT ANY WARRANTY; without even the implied warranty of
24431 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24432 * General Public License for more details.
24433 *
24434 * You should have received a copy of the GNU General Public License
24435 * along with this program; if not, write to the Free Software
24436 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24437 */
24438
24439#ifndef __GSL_TYPES_H__
24440#define __GSL_TYPES_H__
24441
24442#ifndef GSL_VAR
24443
24444#ifdef WIN32
24445# ifdef GSL_DLL
24446# ifdef DLL_EXPORT
24447# define GSL_VAR extern __declspec(dllexport)
24448# else
24449# define GSL_VAR extern __declspec(dllimport)
24450# endif
24451# else
24452# define GSL_VAR extern
24453# endif
24454#else
24455# define GSL_VAR extern
24456#endif
24457
24458#endif
24459
24460#endif /* __GSL_TYPES_H__ */
24461
24462/* end inlined header: gsl/gsl_types.h */
24463
24464
24465__BEGIN_DECLS
24466
24467
24468/* A type for the precision indicator.
24469 * This is mainly for pedagogy.
24470 */
24471typedef unsigned int gsl_prec_t;
24472
24473
24474/* The number of precision types.
24475 * Remember that precision-mode
24476 * can index an array.
24477 */
24478#define _GSL_PREC_T_NUM 3
24479
24480
24481/* Arrays containing derived
24482 * precision constants for the
24483 * different precision levels.
24484 */
24485GSL_VAR const double gsl_prec_eps[];
24486GSL_VAR const double gsl_prec_sqrt_eps[];
24487GSL_VAR const double gsl_prec_root3_eps[];
24488GSL_VAR const double gsl_prec_root4_eps[];
24489GSL_VAR const double gsl_prec_root5_eps[];
24490GSL_VAR const double gsl_prec_root6_eps[];
24491
24492
24493__END_DECLS
24494
24495#endif /* __GSL_PRECISION_H__ */
24496
24497/* end inlined header: gsl/gsl_precision.h */
24498/* begin inlined header: gsl/gsl_nan.h */
24499/* gsl_nan.h
24500 *
24501 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, Brian Gough
24502 *
24503 * This program is free software; you can redistribute it and/or modify
24504 * it under the terms of the GNU General Public License as published by
24505 * the Free Software Foundation; either version 3 of the License, or (at
24506 * your option) any later version.
24507 *
24508 * This program is distributed in the hope that it will be useful, but
24509 * WITHOUT ANY WARRANTY; without even the implied warranty of
24510 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24511 * General Public License for more details.
24512 *
24513 * You should have received a copy of the GNU General Public License
24514 * along with this program; if not, write to the Free Software
24515 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24516 */
24517
24518#ifndef __GSL_NAN_H__
24519#define __GSL_NAN_H__
24520
24521#ifdef INFINITY
24522# define GSL_POSINF INFINITY
24523# define GSL_NEGINF (-INFINITY)
24524#elif defined(HUGE_VAL)
24525# define GSL_POSINF HUGE_VAL
24526# define GSL_NEGINF (-HUGE_VAL)
24527#else
24528# define GSL_POSINF (gsl_posinf())
24529# define GSL_NEGINF (gsl_neginf())
24530#endif
24531
24532#ifdef NAN
24533# define GSL_NAN NAN
24534#elif defined(INFINITY)
24535# define GSL_NAN (INFINITY/INFINITY)
24536#else
24537# define GSL_NAN (gsl_nan())
24538#endif
24539
24540#define GSL_POSZERO (+0.0)
24541#define GSL_NEGZERO (-0.0)
24542
24543#endif /* __GSL_NAN_H__ */
24544
24545/* end inlined header: gsl/gsl_nan.h */
24546/* begin inlined header: gsl/gsl_pow_int.h */
24547/* gsl_pow_int.h
24548 *
24549 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2004, 2007 Gerard Jungman, Brian Gough
24550 *
24551 * This program is free software; you can redistribute it and/or modify
24552 * it under the terms of the GNU General Public License as published by
24553 * the Free Software Foundation; either version 3 of the License, or (at
24554 * your option) any later version.
24555 *
24556 * This program is distributed in the hope that it will be useful, but
24557 * WITHOUT ANY WARRANTY; without even the implied warranty of
24558 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24559 * General Public License for more details.
24560 *
24561 * You should have received a copy of the GNU General Public License
24562 * along with this program; if not, write to the Free Software
24563 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24564 */
24565
24566#ifndef __GSL_POW_INT_H__
24567#define __GSL_POW_INT_H__
24568/* begin inlined header: gsl/gsl_inline.h */
24569/* gsl_inline.h
24570 *
24571 * Copyright (C) 2008, 2009 Brian Gough
24572 *
24573 * This program is free software; you can redistribute it and/or modify
24574 * it under the terms of the GNU General Public License as published by
24575 * the Free Software Foundation; either version 3 of the License, or (at
24576 * your option) any later version.
24577 *
24578 * This program is distributed in the hope that it will be useful, but
24579 * WITHOUT ANY WARRANTY; without even the implied warranty of
24580 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24581 * General Public License for more details.
24582 *
24583 * You should have received a copy of the GNU General Public License
24584 * along with this program; if not, write to the Free Software
24585 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24586 */
24587
24588#ifndef __GSL_INLINE_H__
24589#define __GSL_INLINE_H__
24590
24591/* In recent versiions of GCC, the inline keyword has two different
24592 forms: GNU and C99.
24593
24594 In GNU mode we can use 'extern inline' to make inline functions
24595 work like macros. The function is only inlined--it is never output
24596 as a definition in an object file.
24597
24598 In the new C99 mode 'extern inline' has a different meaning--it
24599 causes the definition of the function to be output in each object
24600 file where it is used. This will result in multiple-definition
24601 errors on linking. The 'inline' keyword on its own (without
24602 extern) has the same behavior as the original GNU 'extern inline'.
24603
24604 The C99 style is the default with -std=c99 in GCC 4.3.
24605
24606 This header file allows either form of inline to be used by
24607 redefining the macros INLINE_DECL and INLINE_FUN. These are used
24608 in the public header files as
24609
24610 INLINE_DECL double gsl_foo (double x);
24611 #ifdef HAVE_INLINE
24612 INLINE_FUN double gsl_foo (double x) { return x+1.0; } ;
24613 #endif
24614
24615*/
24616
24617#ifdef HAVE_INLINE
24618# if defined(__GNUC_STDC_INLINE__) || defined(GSL_C99_INLINE) || defined(HAVE_C99_INLINE)
24619# define INLINE_DECL inline /* use C99 inline */
24620# define INLINE_FUN inline
24621# else
24622# define INLINE_DECL /* use GNU extern inline */
24623# define INLINE_FUN extern inline
24624# endif
24625#else
24626# define INLINE_DECL /* */
24627#endif
24628
24629/* Range checking conditions in headers do not require any run-time
24630 tests of the global variable gsl_check_range. They are enabled or
24631 disabled in user code at compile time with GSL_RANGE_CHECK macro.
24632 See also build.h. */
24633#define GSL_RANGE_COND(x) (x)
24634
24635#endif /* __GSL_INLINE_H__ */
24636
24637/* end inlined header: gsl/gsl_inline.h */
24638
24639
24640__BEGIN_DECLS
24641
24642INLINE_DECL double gsl_pow_2(const double x);
24643INLINE_DECL double gsl_pow_3(const double x);
24644INLINE_DECL double gsl_pow_4(const double x);
24645INLINE_DECL double gsl_pow_5(const double x);
24646INLINE_DECL double gsl_pow_6(const double x);
24647INLINE_DECL double gsl_pow_7(const double x);
24648INLINE_DECL double gsl_pow_8(const double x);
24649INLINE_DECL double gsl_pow_9(const double x);
24650
24651#ifdef HAVE_INLINE
24652INLINE_FUN double gsl_pow_2(const double x) { return x*x; }
24653INLINE_FUN double gsl_pow_3(const double x) { return x*x*x; }
24654INLINE_FUN double gsl_pow_4(const double x) { double x2 = x*x; return x2*x2; }
24655INLINE_FUN double gsl_pow_5(const double x) { double x2 = x*x; return x2*x2*x; }
24656INLINE_FUN double gsl_pow_6(const double x) { double x2 = x*x; return x2*x2*x2; }
24657INLINE_FUN double gsl_pow_7(const double x) { double x3 = x*x*x; return x3*x3*x; }
24658INLINE_FUN double gsl_pow_8(const double x) { double x2 = x*x; double x4 = x2*x2; return x4*x4; }
24659INLINE_FUN double gsl_pow_9(const double x) { double x3 = x*x*x; return x3*x3*x3; }
24660#endif
24661
24662double gsl_pow_int(double x, int n);
24663double gsl_pow_uint(double x, unsigned int n);
24664
24665__END_DECLS
24666
24667#endif /* __GSL_POW_INT_H__ */
24668
24669/* end inlined header: gsl/gsl_pow_int.h */
24670/* begin inlined header: gsl/gsl_minmax.h */
24671/* gsl_minmax.h
24672 *
24673 * Copyright (C) 2008 Gerard Jungman, Brian Gough
24674 *
24675 * This program is free software; you can redistribute it and/or modify
24676 * it under the terms of the GNU General Public License as published by
24677 * the Free Software Foundation; either version 3 of the License, or (at
24678 * your option) any later version.
24679 *
24680 * This program is distributed in the hope that it will be useful, but
24681 * WITHOUT ANY WARRANTY; without even the implied warranty of
24682 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24683 * General Public License for more details.
24684 *
24685 * You should have received a copy of the GNU General Public License
24686 * along with this program; if not, write to the Free Software
24687 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24688 */
24689
24690#ifndef __GSL_MINMAX_H__
24691#define __GSL_MINMAX_H__
24692/* begin inlined header: gsl/gsl_inline.h */
24693/* gsl_inline.h
24694 *
24695 * Copyright (C) 2008, 2009 Brian Gough
24696 *
24697 * This program is free software; you can redistribute it and/or modify
24698 * it under the terms of the GNU General Public License as published by
24699 * the Free Software Foundation; either version 3 of the License, or (at
24700 * your option) any later version.
24701 *
24702 * This program is distributed in the hope that it will be useful, but
24703 * WITHOUT ANY WARRANTY; without even the implied warranty of
24704 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24705 * General Public License for more details.
24706 *
24707 * You should have received a copy of the GNU General Public License
24708 * along with this program; if not, write to the Free Software
24709 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24710 */
24711
24712#ifndef __GSL_INLINE_H__
24713#define __GSL_INLINE_H__
24714
24715/* In recent versiions of GCC, the inline keyword has two different
24716 forms: GNU and C99.
24717
24718 In GNU mode we can use 'extern inline' to make inline functions
24719 work like macros. The function is only inlined--it is never output
24720 as a definition in an object file.
24721
24722 In the new C99 mode 'extern inline' has a different meaning--it
24723 causes the definition of the function to be output in each object
24724 file where it is used. This will result in multiple-definition
24725 errors on linking. The 'inline' keyword on its own (without
24726 extern) has the same behavior as the original GNU 'extern inline'.
24727
24728 The C99 style is the default with -std=c99 in GCC 4.3.
24729
24730 This header file allows either form of inline to be used by
24731 redefining the macros INLINE_DECL and INLINE_FUN. These are used
24732 in the public header files as
24733
24734 INLINE_DECL double gsl_foo (double x);
24735 #ifdef HAVE_INLINE
24736 INLINE_FUN double gsl_foo (double x) { return x+1.0; } ;
24737 #endif
24738
24739*/
24740
24741#ifdef HAVE_INLINE
24742# if defined(__GNUC_STDC_INLINE__) || defined(GSL_C99_INLINE) || defined(HAVE_C99_INLINE)
24743# define INLINE_DECL inline /* use C99 inline */
24744# define INLINE_FUN inline
24745# else
24746# define INLINE_DECL /* use GNU extern inline */
24747# define INLINE_FUN extern inline
24748# endif
24749#else
24750# define INLINE_DECL /* */
24751#endif
24752
24753/* Range checking conditions in headers do not require any run-time
24754 tests of the global variable gsl_check_range. They are enabled or
24755 disabled in user code at compile time with GSL_RANGE_CHECK macro.
24756 See also build.h. */
24757#define GSL_RANGE_COND(x) (x)
24758
24759#endif /* __GSL_INLINE_H__ */
24760
24761/* end inlined header: gsl/gsl_inline.h */
24762
24763
24764__BEGIN_DECLS
24765
24766/* Define MAX and MIN macros/functions if they don't exist. */
24767
24768/* plain old macros for general use */
24769#define GSL_MAX(a,b) ((a) > (b) ? (a) : (b))
24770#define GSL_MIN(a,b) ((a) < (b) ? (a) : (b))
24771
24772/* function versions of the above, in case they are needed */
24773double gsl_max (double a, double b);
24774double gsl_min (double a, double b);
24775
24776/* inline-friendly strongly typed versions */
24777#ifdef HAVE_INLINE
24778
24779INLINE_FUN int GSL_MAX_INT (int a, int b);
24780INLINE_FUN int GSL_MIN_INT (int a, int b);
24781INLINE_FUN double GSL_MAX_DBL (double a, double b);
24782INLINE_FUN double GSL_MIN_DBL (double a, double b);
24783INLINE_FUN long double GSL_MAX_LDBL (long double a, long double b);
24784INLINE_FUN long double GSL_MIN_LDBL (long double a, long double b);
24785
24786INLINE_FUN int
24787GSL_MAX_INT (int a, int b)
24788{
24789 return GSL_MAX (a, b);
24790}
24791
24792INLINE_FUN int
24793GSL_MIN_INT (int a, int b)
24794{
24795 return GSL_MIN (a, b);
24796}
24797
24798INLINE_FUN double
24799GSL_MAX_DBL (double a, double b)
24800{
24801 return GSL_MAX (a, b);
24802}
24803
24804INLINE_FUN double
24805GSL_MIN_DBL (double a, double b)
24806{
24807 return GSL_MIN (a, b);
24808}
24809
24810INLINE_FUN long double
24811GSL_MAX_LDBL (long double a, long double b)
24812{
24813 return GSL_MAX (a, b);
24814}
24815
24816INLINE_FUN long double
24817GSL_MIN_LDBL (long double a, long double b)
24818{
24819 return GSL_MIN (a, b);
24820}
24821#else
24822#define GSL_MAX_INT(a,b) GSL_MAX(a,b)
24823#define GSL_MIN_INT(a,b) GSL_MIN(a,b)
24824#define GSL_MAX_DBL(a,b) GSL_MAX(a,b)
24825#define GSL_MIN_DBL(a,b) GSL_MIN(a,b)
24826#define GSL_MAX_LDBL(a,b) GSL_MAX(a,b)
24827#define GSL_MIN_LDBL(a,b) GSL_MIN(a,b)
24828#endif /* HAVE_INLINE */
24829
24830__END_DECLS
24831
24832#endif /* __GSL_POW_INT_H__ */
24833
24834/* end inlined header: gsl/gsl_minmax.h */
24835#ifndef M_E
24836#define M_E 2.71828182845904523536028747135 /* e */
24837#endif
24838
24839#ifndef M_LOG2E
24840#define M_LOG2E 1.44269504088896340735992468100 /* log_2 (e) */
24841#endif
24842
24843#ifndef M_LOG10E
24844#define M_LOG10E 0.43429448190325182765112891892 /* log_10 (e) */
24845#endif
24846
24847#ifndef M_SQRT2
24848#define M_SQRT2 1.41421356237309504880168872421 /* sqrt(2) */
24849#endif
24850
24851#ifndef M_SQRT1_2
24852#define M_SQRT1_2 0.70710678118654752440084436210 /* sqrt(1/2) */
24853#endif
24854
24855
24856#ifndef M_SQRT3
24857#define M_SQRT3 1.73205080756887729352744634151 /* sqrt(3) */
24858#endif
24859
24860#ifndef M_PI
24861#define M_PI 3.14159265358979323846264338328 /* pi */
24862#endif
24863
24864#ifndef M_PI_2
24865#define M_PI_2 1.57079632679489661923132169164 /* pi/2 */
24866#endif
24867
24868#ifndef M_PI_4
24869#define M_PI_4 0.78539816339744830961566084582 /* pi/4 */
24870#endif
24871
24872#ifndef M_SQRTPI
24873#define M_SQRTPI 1.77245385090551602729816748334 /* sqrt(pi) */
24874#endif
24875
24876#ifndef M_2_SQRTPI
24877#define M_2_SQRTPI 1.12837916709551257389615890312 /* 2/sqrt(pi) */
24878#endif
24879
24880#ifndef M_1_PI
24881#define M_1_PI 0.31830988618379067153776752675 /* 1/pi */
24882#endif
24883
24884#ifndef M_2_PI
24885#define M_2_PI 0.63661977236758134307553505349 /* 2/pi */
24886#endif
24887
24888#ifndef M_LN10
24889#define M_LN10 2.30258509299404568401799145468 /* ln(10) */
24890#endif
24891
24892#ifndef M_LN2
24893#define M_LN2 0.69314718055994530941723212146 /* ln(2) */
24894#endif
24895
24896#ifndef M_LNPI
24897#define M_LNPI 1.14472988584940017414342735135 /* ln(pi) */
24898#endif
24899
24900#ifndef M_EULER
24901#define M_EULER 0.57721566490153286060651209008 /* Euler constant */
24902#endif
24903
24904
24905
24906__BEGIN_DECLS
24907
24908/* other needlessly compulsive abstractions */
24909
24910#define GSL_IS_ODD(n) ((n) & 1)
24911#define GSL_IS_EVEN(n) (!(GSL_IS_ODD(n)))
24912#define GSL_SIGN(x) ((x) >= 0.0 ? 1 : -1)
24913
24914/* Return nonzero if x is a real number, i.e. non NaN or infinite. */
24915#define GSL_IS_REAL(x) (gsl_finite(x))
24916
24917/* Definition of an arbitrary function with parameters */
24918
24920{
24921 double (* function) (double x, void * params);
24922 void * params;
24923};
24924
24925typedef struct gsl_function_struct gsl_function ;
24926
24927#define GSL_FN_EVAL(F,x) (*((F)->function))(x,(F)->params)
24928
24929/* Definition of an arbitrary function returning two values, r1, r2 */
24930
24932{
24933 double (* f) (double x, void * params);
24934 double (* df) (double x, void * params);
24935 void (* fdf) (double x, void * params, double * f, double * df);
24936 void * params;
24937};
24938
24939typedef struct gsl_function_fdf_struct gsl_function_fdf ;
24940
24941#define GSL_FN_FDF_EVAL_F(FDF,x) (*((FDF)->f))(x,(FDF)->params)
24942#define GSL_FN_FDF_EVAL_DF(FDF,x) (*((FDF)->df))(x,(FDF)->params)
24943#define GSL_FN_FDF_EVAL_F_DF(FDF,x,y,dy) (*((FDF)->fdf))(x,(FDF)->params,(y),(dy))
24944
24945
24946/* Definition of an arbitrary vector-valued function with parameters */
24947
24949{
24950 int (* function) (double x, double y[], void * params);
24951 void * params;
24952};
24953
24954typedef struct gsl_function_vec_struct gsl_function_vec ;
24955
24956#define GSL_FN_VEC_EVAL(F,x,y) (*((F)->function))(x,y,(F)->params)
24957
24958__END_DECLS
24959
24960#endif /* __GSL_MATH_H__ */
24961
24962/* end inlined header: gsl/gsl_math.h */
24963/* begin inlined header: gsl/gsl_errno.h */
24964/* err/gsl_errno.h
24965 *
24966 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, Brian Gough
24967 *
24968 * This program is free software; you can redistribute it and/or modify
24969 * it under the terms of the GNU General Public License as published by
24970 * the Free Software Foundation; either version 3 of the License, or (at
24971 * your option) any later version.
24972 *
24973 * This program is distributed in the hope that it will be useful, but
24974 * WITHOUT ANY WARRANTY; without even the implied warranty of
24975 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24976 * General Public License for more details.
24977 *
24978 * You should have received a copy of the GNU General Public License
24979 * along with this program; if not, write to the Free Software
24980 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24981 */
24982
24983#ifndef __GSL_ERRNO_H__
24984#define __GSL_ERRNO_H__
24985
24986#include <stdio.h>
24987#include <errno.h>
24988/* begin inlined header: gsl/gsl_types.h */
24989/* gsl_types.h
24990 *
24991 * Copyright (C) 2001, 2007 Brian Gough
24992 *
24993 * This program is free software; you can redistribute it and/or modify
24994 * it under the terms of the GNU General Public License as published by
24995 * the Free Software Foundation; either version 3 of the License, or (at
24996 * your option) any later version.
24997 *
24998 * This program is distributed in the hope that it will be useful, but
24999 * WITHOUT ANY WARRANTY; without even the implied warranty of
25000 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25001 * General Public License for more details.
25002 *
25003 * You should have received a copy of the GNU General Public License
25004 * along with this program; if not, write to the Free Software
25005 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25006 */
25007
25008#ifndef __GSL_TYPES_H__
25009#define __GSL_TYPES_H__
25010
25011#ifndef GSL_VAR
25012
25013#ifdef WIN32
25014# ifdef GSL_DLL
25015# ifdef DLL_EXPORT
25016# define GSL_VAR extern __declspec(dllexport)
25017# else
25018# define GSL_VAR extern __declspec(dllimport)
25019# endif
25020# else
25021# define GSL_VAR extern
25022# endif
25023#else
25024# define GSL_VAR extern
25025#endif
25026
25027#endif
25028
25029#endif /* __GSL_TYPES_H__ */
25030
25031/* end inlined header: gsl/gsl_types.h */
25032
25033
25034__BEGIN_DECLS
25035
25036enum {
25037 GSL_SUCCESS = 0,
25038 GSL_FAILURE = -1,
25039 GSL_CONTINUE = -2, /* iteration has not converged */
25040 GSL_EDOM = 1, /* input domain error, e.g sqrt(-1) */
25041 GSL_ERANGE = 2, /* output range error, e.g. exp(1e100) */
25042 GSL_EFAULT = 3, /* invalid pointer */
25043 GSL_EINVAL = 4, /* invalid argument supplied by user */
25044 GSL_EFAILED = 5, /* generic failure */
25045 GSL_EFACTOR = 6, /* factorization failed */
25046 GSL_ESANITY = 7, /* sanity check failed - shouldn't happen */
25047 GSL_ENOMEM = 8, /* malloc failed */
25048 GSL_EBADFUNC = 9, /* problem with user-supplied function */
25049 GSL_ERUNAWAY = 10, /* iterative process is out of control */
25050 GSL_EMAXITER = 11, /* exceeded max number of iterations */
25051 GSL_EZERODIV = 12, /* tried to divide by zero */
25052 GSL_EBADTOL = 13, /* user specified an invalid tolerance */
25053 GSL_ETOL = 14, /* failed to reach the specified tolerance */
25054 GSL_EUNDRFLW = 15, /* underflow */
25055 GSL_EOVRFLW = 16, /* overflow */
25056 GSL_ELOSS = 17, /* loss of accuracy */
25057 GSL_EROUND = 18, /* failed because of roundoff error */
25058 GSL_EBADLEN = 19, /* matrix, vector lengths are not conformant */
25059 GSL_ENOTSQR = 20, /* matrix not square */
25060 GSL_ESING = 21, /* apparent singularity detected */
25061 GSL_EDIVERGE = 22, /* integral or series is divergent */
25062 GSL_EUNSUP = 23, /* requested feature is not supported by the hardware */
25063 GSL_EUNIMPL = 24, /* requested feature not (yet) implemented */
25064 GSL_ECACHE = 25, /* cache limit exceeded */
25065 GSL_ETABLE = 26, /* table limit exceeded */
25066 GSL_ENOPROG = 27, /* iteration is not making progress towards solution */
25067 GSL_ENOPROGJ = 28, /* jacobian evaluations are not improving the solution */
25068 GSL_ETOLF = 29, /* cannot reach the specified tolerance in F */
25069 GSL_ETOLX = 30, /* cannot reach the specified tolerance in X */
25070 GSL_ETOLG = 31, /* cannot reach the specified tolerance in gradient */
25071 GSL_EOF = 32 /* end of file */
25072} ;
25073
25074void gsl_error (const char * reason, const char * file, int line,
25075 int gsl_errno);
25076
25077void gsl_stream_printf (const char *label, const char *file,
25078 int line, const char *reason);
25079
25080typedef void gsl_error_handler_t (const char * reason, const char * file,
25081 int line, int gsl_errno);
25082
25083gsl_error_handler_t *
25084gsl_set_error_handler (gsl_error_handler_t * new_handler);
25085
25086/* GSL_ERROR: call the error handler, and return the error code */
25087
25088#define GSL_ERROR(reason, gsl_errno) \
25089 do { \
25090 gsl_error (reason, __FILE__, __LINE__, gsl_errno) ; \
25091 return gsl_errno ; \
25092 } while (0)
25093
25094/* GSL_ERROR_VAL: call the error handler, and return the given value */
25095
25096#define GSL_ERROR_VAL(reason, gsl_errno, value) \
25097 do { \
25098 gsl_error (reason, __FILE__, __LINE__, gsl_errno) ; \
25099 return value ; \
25100 } while (0)
25101
25102/* GSL_ERROR_VOID: call the error handler, and then return
25103 (for void functions which still need to generate an error) */
25104
25105#define GSL_ERROR_VOID(reason, gsl_errno) \
25106 do { \
25107 gsl_error (reason, __FILE__, __LINE__, gsl_errno) ; \
25108 return ; \
25109 } while (0)
25110
25111/* GSL_ERROR_NULL suitable for out-of-memory conditions */
25112
25113#define GSL_ERROR_NULL(reason, gsl_errno) GSL_ERROR_VAL(reason, gsl_errno, 0)
25114
25115/* Sometimes you have several status results returned from
25116 * function calls and you want to combine them in some sensible
25117 * way. You cannot produce a "total" status condition, but you can
25118 * pick one from a set of conditions based on an implied hierarchy.
25119 *
25120 * In other words:
25121 * you have: status_a, status_b, ...
25122 * you want: status = (status_a if it is bad, or status_b if it is bad,...)
25123 *
25124 * In this example you consider status_a to be more important and
25125 * it is checked first, followed by the others in the order specified.
25126 *
25127 * Here are some dumb macros to do this.
25128 */
25129#define GSL_ERROR_SELECT_2(a,b) ((a) != GSL_SUCCESS ? (a) : ((b) != GSL_SUCCESS ? (b) : GSL_SUCCESS))
25130#define GSL_ERROR_SELECT_3(a,b,c) ((a) != GSL_SUCCESS ? (a) : GSL_ERROR_SELECT_2(b,c))
25131#define GSL_ERROR_SELECT_4(a,b,c,d) ((a) != GSL_SUCCESS ? (a) : GSL_ERROR_SELECT_3(b,c,d))
25132#define GSL_ERROR_SELECT_5(a,b,c,d,e) ((a) != GSL_SUCCESS ? (a) : GSL_ERROR_SELECT_4(b,c,d,e))
25133
25134#define GSL_STATUS_UPDATE(sp, s) do { if ((s) != GSL_SUCCESS) *(sp) = (s);} while(0)
25135
25136__END_DECLS
25137
25138#endif /* __GSL_ERRNO_H__ */
25139
25140/* end inlined header: gsl/gsl_errno.h */
25141/* begin inlined header: gsl/gsl_sf_exp.h */
25142/* specfunc/gsl_sf_exp.h
25143 *
25144 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2004 Gerard Jungman
25145 *
25146 * This program is free software; you can redistribute it and/or modify
25147 * it under the terms of the GNU General Public License as published by
25148 * the Free Software Foundation; either version 3 of the License, or (at
25149 * your option) any later version.
25150 *
25151 * This program is distributed in the hope that it will be useful, but
25152 * WITHOUT ANY WARRANTY; without even the implied warranty of
25153 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25154 * General Public License for more details.
25155 *
25156 * You should have received a copy of the GNU General Public License
25157 * along with this program; if not, write to the Free Software
25158 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25159 */
25160
25161/* Author: G. Jungman */
25162
25163#ifndef __GSL_SF_EXP_H__
25164#define __GSL_SF_EXP_H__
25165/* begin inlined header: gsl/gsl_sf_result.h */
25166/* specfunc/gsl_sf_result.h
25167 *
25168 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
25169 *
25170 * This program is free software; you can redistribute it and/or modify
25171 * it under the terms of the GNU General Public License as published by
25172 * the Free Software Foundation; either version 3 of the License, or (at
25173 * your option) any later version.
25174 *
25175 * This program is distributed in the hope that it will be useful, but
25176 * WITHOUT ANY WARRANTY; without even the implied warranty of
25177 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25178 * General Public License for more details.
25179 *
25180 * You should have received a copy of the GNU General Public License
25181 * along with this program; if not, write to the Free Software
25182 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25183 */
25184
25185/* Author: G. Jungman */
25186
25187#ifndef __GSL_SF_RESULT_H__
25188#define __GSL_SF_RESULT_H__
25189
25190
25191
25192__BEGIN_DECLS
25193
25194struct gsl_sf_result_struct {
25195 double val;
25196 double err;
25197};
25198typedef struct gsl_sf_result_struct gsl_sf_result;
25199
25200#define GSL_SF_RESULT_SET(r,v,e) do { (r)->val=(v); (r)->err=(e); } while(0)
25201
25202
25204 double val;
25205 double err;
25206 int e10;
25207};
25208typedef struct gsl_sf_result_e10_struct gsl_sf_result_e10;
25209
25210
25211int gsl_sf_result_smash_e(const gsl_sf_result_e10 * re, gsl_sf_result * r);
25212
25213
25214__END_DECLS
25215
25216#endif /* __GSL_SF_RESULT_H__ */
25217
25218/* end inlined header: gsl/gsl_sf_result.h */
25219/* begin inlined header: gsl/gsl_precision.h */
25220/* gsl_precision.h
25221 *
25222 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
25223 *
25224 * This program is free software; you can redistribute it and/or modify
25225 * it under the terms of the GNU General Public License as published by
25226 * the Free Software Foundation; either version 3 of the License, or (at
25227 * your option) any later version.
25228 *
25229 * This program is distributed in the hope that it will be useful, but
25230 * WITHOUT ANY WARRANTY; without even the implied warranty of
25231 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25232 * General Public License for more details.
25233 *
25234 * You should have received a copy of the GNU General Public License
25235 * along with this program; if not, write to the Free Software
25236 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25237 */
25238
25239/* Author: B. Gough and G. Jungman */
25240
25241#ifndef __GSL_PRECISION_H__
25242#define __GSL_PRECISION_H__
25243/* begin inlined header: gsl/gsl_types.h */
25244/* gsl_types.h
25245 *
25246 * Copyright (C) 2001, 2007 Brian Gough
25247 *
25248 * This program is free software; you can redistribute it and/or modify
25249 * it under the terms of the GNU General Public License as published by
25250 * the Free Software Foundation; either version 3 of the License, or (at
25251 * your option) any later version.
25252 *
25253 * This program is distributed in the hope that it will be useful, but
25254 * WITHOUT ANY WARRANTY; without even the implied warranty of
25255 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25256 * General Public License for more details.
25257 *
25258 * You should have received a copy of the GNU General Public License
25259 * along with this program; if not, write to the Free Software
25260 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25261 */
25262
25263#ifndef __GSL_TYPES_H__
25264#define __GSL_TYPES_H__
25265
25266#ifndef GSL_VAR
25267
25268#ifdef WIN32
25269# ifdef GSL_DLL
25270# ifdef DLL_EXPORT
25271# define GSL_VAR extern __declspec(dllexport)
25272# else
25273# define GSL_VAR extern __declspec(dllimport)
25274# endif
25275# else
25276# define GSL_VAR extern
25277# endif
25278#else
25279# define GSL_VAR extern
25280#endif
25281
25282#endif
25283
25284#endif /* __GSL_TYPES_H__ */
25285
25286/* end inlined header: gsl/gsl_types.h */
25287
25288
25289__BEGIN_DECLS
25290
25291
25292/* A type for the precision indicator.
25293 * This is mainly for pedagogy.
25294 */
25295typedef unsigned int gsl_prec_t;
25296
25297
25298/* The number of precision types.
25299 * Remember that precision-mode
25300 * can index an array.
25301 */
25302#define _GSL_PREC_T_NUM 3
25303
25304
25305/* Arrays containing derived
25306 * precision constants for the
25307 * different precision levels.
25308 */
25309GSL_VAR const double gsl_prec_eps[];
25310GSL_VAR const double gsl_prec_sqrt_eps[];
25311GSL_VAR const double gsl_prec_root3_eps[];
25312GSL_VAR const double gsl_prec_root4_eps[];
25313GSL_VAR const double gsl_prec_root5_eps[];
25314GSL_VAR const double gsl_prec_root6_eps[];
25315
25316
25317__END_DECLS
25318
25319#endif /* __GSL_PRECISION_H__ */
25320
25321/* end inlined header: gsl/gsl_precision.h */
25322
25323
25324__BEGIN_DECLS
25325
25326/* Provide an exp() function with GSL semantics,
25327 * i.e. with proper error checking, etc.
25328 *
25329 * exceptions: GSL_EOVRFLW, GSL_EUNDRFLW
25330 */
25331int gsl_sf_exp_e(const double x, gsl_sf_result * result);
25332double gsl_sf_exp(const double x);
25333
25334
25335/* Exp(x)
25336 *
25337 * exceptions: GSL_EOVRFLW, GSL_EUNDRFLW
25338 */
25339int gsl_sf_exp_e10_e(const double x, gsl_sf_result_e10 * result);
25340
25341
25342/* Exponentiate and multiply by a given factor: y * Exp(x)
25343 *
25344 * exceptions: GSL_EOVRFLW, GSL_EUNDRFLW
25345 */
25346int gsl_sf_exp_mult_e(const double x, const double y, gsl_sf_result * result);
25347double gsl_sf_exp_mult(const double x, const double y);
25348
25349
25350/* Exponentiate and multiply by a given factor: y * Exp(x)
25351 *
25352 * exceptions: GSL_EOVRFLW, GSL_EUNDRFLW
25353 */
25354int gsl_sf_exp_mult_e10_e(const double x, const double y, gsl_sf_result_e10 * result);
25355
25356
25357/* exp(x)-1
25358 *
25359 * exceptions: GSL_EOVRFLW
25360 */
25361int gsl_sf_expm1_e(const double x, gsl_sf_result * result);
25362double gsl_sf_expm1(const double x);
25363
25364
25365/* (exp(x)-1)/x = 1 + x/2 + x^2/(2*3) + x^3/(2*3*4) + ...
25366 *
25367 * exceptions: GSL_EOVRFLW
25368 */
25369int gsl_sf_exprel_e(const double x, gsl_sf_result * result);
25370double gsl_sf_exprel(const double x);
25371
25372
25373/* 2(exp(x)-1-x)/x^2 = 1 + x/3 + x^2/(3*4) + x^3/(3*4*5) + ...
25374 *
25375 * exceptions: GSL_EOVRFLW
25376 */
25377int gsl_sf_exprel_2_e(double x, gsl_sf_result * result);
25378double gsl_sf_exprel_2(const double x);
25379
25380
25381/* Similarly for the N-th generalization of
25382 * the above. The so-called N-relative exponential
25383 *
25384 * exprel_N(x) = N!/x^N (exp(x) - Sum[x^k/k!, {k,0,N-1}])
25385 * = 1 + x/(N+1) + x^2/((N+1)(N+2)) + ...
25386 * = 1F1(1,1+N,x)
25387 */
25388int gsl_sf_exprel_n_e(const int n, const double x, gsl_sf_result * result);
25389double gsl_sf_exprel_n(const int n, const double x);
25390
25391int gsl_sf_exprel_n_CF_e(const double n, const double x, gsl_sf_result * result);
25392
25393
25394/* Exponentiate a quantity with an associated error.
25395 */
25396int gsl_sf_exp_err_e(const double x, const double dx, gsl_sf_result * result);
25397
25398/* Exponentiate a quantity with an associated error.
25399 */
25400int gsl_sf_exp_err_e10_e(const double x, const double dx, gsl_sf_result_e10 * result);
25401
25402
25403/* Exponentiate and multiply by a given factor: y * Exp(x),
25404 * for quantities with associated errors.
25405 *
25406 * exceptions: GSL_EOVRFLW, GSL_EUNDRFLW
25407 */
25408int gsl_sf_exp_mult_err_e(const double x, const double dx, const double y, const double dy, gsl_sf_result * result);
25409
25410
25411/* Exponentiate and multiply by a given factor: y * Exp(x),
25412 * for quantities with associated errors.
25413 *
25414 * exceptions: GSL_EOVRFLW, GSL_EUNDRFLW
25415 */
25416int gsl_sf_exp_mult_err_e10_e(const double x, const double dx, const double y, const double dy, gsl_sf_result_e10 * result);
25417
25418__END_DECLS
25419
25420#endif /* __GSL_SF_EXP_H__ */
25421
25422/* end inlined header: gsl/gsl_sf_exp.h */
25423/* begin inlined header: gsl/gsl_sf_psi.h */
25424/* specfunc/gsl_sf_psi.h
25425 *
25426 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2004 Gerard Jungman
25427 *
25428 * This program is free software; you can redistribute it and/or modify
25429 * it under the terms of the GNU General Public License as published by
25430 * the Free Software Foundation; either version 3 of the License, or (at
25431 * your option) any later version.
25432 *
25433 * This program is distributed in the hope that it will be useful, but
25434 * WITHOUT ANY WARRANTY; without even the implied warranty of
25435 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25436 * General Public License for more details.
25437 *
25438 * You should have received a copy of the GNU General Public License
25439 * along with this program; if not, write to the Free Software
25440 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25441 */
25442
25443/* Author: G. Jungman */
25444
25445#ifndef __GSL_SF_PSI_H__
25446#define __GSL_SF_PSI_H__
25447/* begin inlined header: gsl/gsl_sf_result.h */
25448/* specfunc/gsl_sf_result.h
25449 *
25450 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
25451 *
25452 * This program is free software; you can redistribute it and/or modify
25453 * it under the terms of the GNU General Public License as published by
25454 * the Free Software Foundation; either version 3 of the License, or (at
25455 * your option) any later version.
25456 *
25457 * This program is distributed in the hope that it will be useful, but
25458 * WITHOUT ANY WARRANTY; without even the implied warranty of
25459 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25460 * General Public License for more details.
25461 *
25462 * You should have received a copy of the GNU General Public License
25463 * along with this program; if not, write to the Free Software
25464 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25465 */
25466
25467/* Author: G. Jungman */
25468
25469#ifndef __GSL_SF_RESULT_H__
25470#define __GSL_SF_RESULT_H__
25471
25472
25473
25474__BEGIN_DECLS
25475
25476struct gsl_sf_result_struct {
25477 double val;
25478 double err;
25479};
25480typedef struct gsl_sf_result_struct gsl_sf_result;
25481
25482#define GSL_SF_RESULT_SET(r,v,e) do { (r)->val=(v); (r)->err=(e); } while(0)
25483
25484
25486 double val;
25487 double err;
25488 int e10;
25489};
25490typedef struct gsl_sf_result_e10_struct gsl_sf_result_e10;
25491
25492
25493int gsl_sf_result_smash_e(const gsl_sf_result_e10 * re, gsl_sf_result * r);
25494
25495
25496__END_DECLS
25497
25498#endif /* __GSL_SF_RESULT_H__ */
25499
25500/* end inlined header: gsl/gsl_sf_result.h */
25501
25502
25503__BEGIN_DECLS
25504
25505
25506/* Poly-Gamma Functions
25507 *
25508 * psi(m,x) := (d/dx)^m psi(0,x) = (d/dx)^{m+1} log(gamma(x))
25509 */
25510
25511
25512/* Di-Gamma Function psi(n) = psi(0,n)
25513 *
25514 * n > 0
25515 * exceptions: GSL_EDOM
25516 */
25517int gsl_sf_psi_int_e(const int n, gsl_sf_result * result);
25518double gsl_sf_psi_int(const int n);
25519
25520
25521/* Di-Gamma Function psi(x) = psi(0, x)
25522 *
25523 * x != 0.0, -1.0, -2.0, ...
25524 * exceptions: GSL_EDOM, GSL_ELOSS
25525 */
25526int gsl_sf_psi_e(const double x, gsl_sf_result * result);
25527double gsl_sf_psi(const double x);
25528
25529
25530/* Di-Gamma Function Re[psi(1 + I y)]
25531 *
25532 * exceptions: none
25533 */
25534int gsl_sf_psi_1piy_e(const double y, gsl_sf_result * result);
25535double gsl_sf_psi_1piy(const double y);
25536
25537
25538/* Di-Gamma Function psi(z) for general complex argument z = x + iy
25539 *
25540 * exceptions: GSL_EDOM
25541 */
25542int gsl_sf_complex_psi_e(
25543 const double x,
25544 const double y,
25545 gsl_sf_result * result_re,
25546 gsl_sf_result * result_im
25547 );
25548
25549
25550/* Tri-Gamma Function psi^(1)(n)
25551 *
25552 * n > 0
25553 * exceptions: GSL_EDOM
25554 */
25555int gsl_sf_psi_1_int_e(const int n, gsl_sf_result * result);
25556double gsl_sf_psi_1_int(const int n);
25557
25558
25559/* Tri-Gamma Function psi^(1)(x)
25560 *
25561 * x != 0.0, -1.0, -2.0, ...
25562 * exceptions: GSL_EDOM, GSL_ELOSS
25563 */
25564int gsl_sf_psi_1_e(const double x, gsl_sf_result * result);
25565double gsl_sf_psi_1(const double x);
25566
25567
25568/* Poly-Gamma Function psi^(n)(x)
25569 *
25570 * n >= 0, x > 0.0
25571 * exceptions: GSL_EDOM
25572 */
25573int gsl_sf_psi_n_e(const int n, const double x, gsl_sf_result * result);
25574double gsl_sf_psi_n(const int n, const double x);
25575
25576
25577__END_DECLS
25578
25579#endif /* __GSL_SF_PSI_H__ */
25580
25581/* end inlined header: gsl/gsl_sf_psi.h */
25582/* begin inlined header: gsl/gsl_sf_airy.h */
25583/* specfunc/gsl_sf_airy.h
25584 *
25585 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
25586 *
25587 * This program is free software; you can redistribute it and/or modify
25588 * it under the terms of the GNU General Public License as published by
25589 * the Free Software Foundation; either version 3 of the License, or (at
25590 * your option) any later version.
25591 *
25592 * This program is distributed in the hope that it will be useful, but
25593 * WITHOUT ANY WARRANTY; without even the implied warranty of
25594 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25595 * General Public License for more details.
25596 *
25597 * You should have received a copy of the GNU General Public License
25598 * along with this program; if not, write to the Free Software
25599 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25600 */
25601
25602/* Author: G. Jungman */
25603
25604#ifndef __GSL_SF_AIRY_H__
25605#define __GSL_SF_AIRY_H__
25606/* begin inlined header: gsl/gsl_mode.h */
25607/* gsl_mode.h
25608 *
25609 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2004 Gerard Jungman
25610 *
25611 * This program is free software; you can redistribute it and/or modify
25612 * it under the terms of the GNU General Public License as published by
25613 * the Free Software Foundation; either version 3 of the License, or (at
25614 * your option) any later version.
25615 *
25616 * This program is distributed in the hope that it will be useful, but
25617 * WITHOUT ANY WARRANTY; without even the implied warranty of
25618 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25619 * General Public License for more details.
25620 *
25621 * You should have received a copy of the GNU General Public License
25622 * along with this program; if not, write to the Free Software
25623 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25624 */
25625
25626/* Author: B. Gough and G. Jungman */
25627
25628#ifndef __GSL_MODE_H__
25629#define __GSL_MODE_H__
25630/* begin inlined header: gsl/gsl_inline.h */
25631/* gsl_inline.h
25632 *
25633 * Copyright (C) 2008, 2009 Brian Gough
25634 *
25635 * This program is free software; you can redistribute it and/or modify
25636 * it under the terms of the GNU General Public License as published by
25637 * the Free Software Foundation; either version 3 of the License, or (at
25638 * your option) any later version.
25639 *
25640 * This program is distributed in the hope that it will be useful, but
25641 * WITHOUT ANY WARRANTY; without even the implied warranty of
25642 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25643 * General Public License for more details.
25644 *
25645 * You should have received a copy of the GNU General Public License
25646 * along with this program; if not, write to the Free Software
25647 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25648 */
25649
25650#ifndef __GSL_INLINE_H__
25651#define __GSL_INLINE_H__
25652
25653/* In recent versiions of GCC, the inline keyword has two different
25654 forms: GNU and C99.
25655
25656 In GNU mode we can use 'extern inline' to make inline functions
25657 work like macros. The function is only inlined--it is never output
25658 as a definition in an object file.
25659
25660 In the new C99 mode 'extern inline' has a different meaning--it
25661 causes the definition of the function to be output in each object
25662 file where it is used. This will result in multiple-definition
25663 errors on linking. The 'inline' keyword on its own (without
25664 extern) has the same behavior as the original GNU 'extern inline'.
25665
25666 The C99 style is the default with -std=c99 in GCC 4.3.
25667
25668 This header file allows either form of inline to be used by
25669 redefining the macros INLINE_DECL and INLINE_FUN. These are used
25670 in the public header files as
25671
25672 INLINE_DECL double gsl_foo (double x);
25673 #ifdef HAVE_INLINE
25674 INLINE_FUN double gsl_foo (double x) { return x+1.0; } ;
25675 #endif
25676
25677*/
25678
25679#ifdef HAVE_INLINE
25680# if defined(__GNUC_STDC_INLINE__) || defined(GSL_C99_INLINE) || defined(HAVE_C99_INLINE)
25681# define INLINE_DECL inline /* use C99 inline */
25682# define INLINE_FUN inline
25683# else
25684# define INLINE_DECL /* use GNU extern inline */
25685# define INLINE_FUN extern inline
25686# endif
25687#else
25688# define INLINE_DECL /* */
25689#endif
25690
25691/* Range checking conditions in headers do not require any run-time
25692 tests of the global variable gsl_check_range. They are enabled or
25693 disabled in user code at compile time with GSL_RANGE_CHECK macro.
25694 See also build.h. */
25695#define GSL_RANGE_COND(x) (x)
25696
25697#endif /* __GSL_INLINE_H__ */
25698
25699/* end inlined header: gsl/gsl_inline.h */
25700
25701
25702__BEGIN_DECLS
25703
25704
25705/* Some functions can take a mode argument. This
25706 * is a rough method to do things like control
25707 * the precision of the algorithm. This mainly
25708 * occurs in special functions, but we figured
25709 * it was ok to have a general facility.
25710 *
25711 * The mode type is 32-bit field. Most of
25712 * the fields are currently unused. Users
25713 * '|' various predefined constants to get
25714 * a desired mode.
25715 */
25716typedef unsigned int gsl_mode_t;
25717
25718
25719/* Here are the predefined constants.
25720 * Note that the precision constants
25721 * are special because they are used
25722 * to index arrays, so do not change
25723 * them. The precision information is
25724 * in the low order 3 bits of gsl_mode_t
25725 * (the third bit is currently unused).
25726 */
25727
25728/* Note that "0" is double precision,
25729 * so that you get that by default if
25730 * you forget a flag.
25731 */
25732#define GSL_PREC_DOUBLE 0
25733#define GSL_PREC_SINGLE 1
25734#define GSL_PREC_APPROX 2
25735
25736#ifdef HAVE_INLINE
25737INLINE_FUN unsigned int GSL_MODE_PREC(gsl_mode_t mt);
25738
25739INLINE_FUN unsigned int
25740GSL_MODE_PREC(gsl_mode_t mt)
25741{ return (mt & (unsigned int)7); }
25742#else /* HAVE_INLINE */
25743#define GSL_MODE_PREC(mt) ((mt) & (unsigned int)7)
25744#endif /* HAVE_INLINE */
25745
25746
25747/* Here are some predefined generic modes.
25748 */
25749#define GSL_MODE_DEFAULT 0
25750
25751
25752__END_DECLS
25753
25754#endif /* __GSL_MODE_H__ */
25755
25756/* end inlined header: gsl/gsl_mode.h */
25757/* begin inlined header: gsl/gsl_sf_result.h */
25758/* specfunc/gsl_sf_result.h
25759 *
25760 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
25761 *
25762 * This program is free software; you can redistribute it and/or modify
25763 * it under the terms of the GNU General Public License as published by
25764 * the Free Software Foundation; either version 3 of the License, or (at
25765 * your option) any later version.
25766 *
25767 * This program is distributed in the hope that it will be useful, but
25768 * WITHOUT ANY WARRANTY; without even the implied warranty of
25769 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25770 * General Public License for more details.
25771 *
25772 * You should have received a copy of the GNU General Public License
25773 * along with this program; if not, write to the Free Software
25774 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25775 */
25776
25777/* Author: G. Jungman */
25778
25779#ifndef __GSL_SF_RESULT_H__
25780#define __GSL_SF_RESULT_H__
25781
25782
25783
25784__BEGIN_DECLS
25785
25786struct gsl_sf_result_struct {
25787 double val;
25788 double err;
25789};
25790typedef struct gsl_sf_result_struct gsl_sf_result;
25791
25792#define GSL_SF_RESULT_SET(r,v,e) do { (r)->val=(v); (r)->err=(e); } while(0)
25793
25794
25796 double val;
25797 double err;
25798 int e10;
25799};
25800typedef struct gsl_sf_result_e10_struct gsl_sf_result_e10;
25801
25802
25803int gsl_sf_result_smash_e(const gsl_sf_result_e10 * re, gsl_sf_result * r);
25804
25805
25806__END_DECLS
25807
25808#endif /* __GSL_SF_RESULT_H__ */
25809
25810/* end inlined header: gsl/gsl_sf_result.h */
25811
25812
25813__BEGIN_DECLS
25814
25815
25816/* Airy function Ai(x)
25817 *
25818 * exceptions: GSL_EUNDRFLW
25819 */
25820int gsl_sf_airy_Ai_e(const double x, const gsl_mode_t mode, gsl_sf_result * result);
25821double gsl_sf_airy_Ai(const double x, gsl_mode_t mode);
25822
25823
25824/* Airy function Bi(x)
25825 *
25826 * exceptions: GSL_EOVRFLW
25827 */
25828int gsl_sf_airy_Bi_e(const double x, gsl_mode_t mode, gsl_sf_result * result);
25829double gsl_sf_airy_Bi(const double x, gsl_mode_t mode);
25830
25831
25832/* scaled Ai(x):
25833 * Ai(x) x < 0
25834 * exp(+2/3 x^{3/2}) Ai(x) x > 0
25835 *
25836 * exceptions: none
25837 */
25838int gsl_sf_airy_Ai_scaled_e(const double x, gsl_mode_t mode, gsl_sf_result * result);
25839double gsl_sf_airy_Ai_scaled(const double x, gsl_mode_t mode);
25840
25841
25842/* scaled Bi(x):
25843 * Bi(x) x < 0
25844 * exp(-2/3 x^{3/2}) Bi(x) x > 0
25845 *
25846 * exceptions: none
25847 */
25848int gsl_sf_airy_Bi_scaled_e(const double x, gsl_mode_t mode, gsl_sf_result * result);
25849double gsl_sf_airy_Bi_scaled(const double x, gsl_mode_t mode);
25850
25851
25852/* derivative Ai'(x)
25853 *
25854 * exceptions: GSL_EUNDRFLW
25855 */
25856int gsl_sf_airy_Ai_deriv_e(const double x, gsl_mode_t mode, gsl_sf_result * result);
25857double gsl_sf_airy_Ai_deriv(const double x, gsl_mode_t mode);
25858
25859
25860/* derivative Bi'(x)
25861 *
25862 * exceptions: GSL_EOVRFLW
25863 */
25864int gsl_sf_airy_Bi_deriv_e(const double x, gsl_mode_t mode, gsl_sf_result * result);
25865double gsl_sf_airy_Bi_deriv(const double x, gsl_mode_t mode);
25866
25867
25868/* scaled derivative Ai'(x):
25869 * Ai'(x) x < 0
25870 * exp(+2/3 x^{3/2}) Ai'(x) x > 0
25871 *
25872 * exceptions: none
25873 */
25874int gsl_sf_airy_Ai_deriv_scaled_e(const double x, gsl_mode_t mode, gsl_sf_result * result);
25875double gsl_sf_airy_Ai_deriv_scaled(const double x, gsl_mode_t mode);
25876
25877
25878/* scaled derivative:
25879 * Bi'(x) x < 0
25880 * exp(-2/3 x^{3/2}) Bi'(x) x > 0
25881 *
25882 * exceptions: none
25883 */
25884int gsl_sf_airy_Bi_deriv_scaled_e(const double x, gsl_mode_t mode, gsl_sf_result * result);
25885double gsl_sf_airy_Bi_deriv_scaled(const double x, gsl_mode_t mode);
25886
25887
25888/* Zeros of Ai(x)
25889 */
25890int gsl_sf_airy_zero_Ai_e(unsigned int s, gsl_sf_result * result);
25891double gsl_sf_airy_zero_Ai(unsigned int s);
25892
25893
25894/* Zeros of Bi(x)
25895 */
25896int gsl_sf_airy_zero_Bi_e(unsigned int s, gsl_sf_result * result);
25897double gsl_sf_airy_zero_Bi(unsigned int s);
25898
25899
25900/* Zeros of Ai'(x)
25901 */
25902int gsl_sf_airy_zero_Ai_deriv_e(unsigned int s, gsl_sf_result * result);
25903double gsl_sf_airy_zero_Ai_deriv(unsigned int s);
25904
25905
25906/* Zeros of Bi'(x)
25907 */
25908int gsl_sf_airy_zero_Bi_deriv_e(unsigned int s, gsl_sf_result * result);
25909double gsl_sf_airy_zero_Bi_deriv(unsigned int s);
25910
25911
25912__END_DECLS
25913
25914#endif /* __GSL_SF_AIRY_H__ */
25915
25916/* end inlined header: gsl/gsl_sf_airy.h */
25917/* begin inlined header: gsl/gsl_sf_pow_int.h */
25918/* specfunc/gsl_sf_pow_int.h
25919 *
25920 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
25921 *
25922 * This program is free software; you can redistribute it and/or modify
25923 * it under the terms of the GNU General Public License as published by
25924 * the Free Software Foundation; either version 3 of the License, or (at
25925 * your option) any later version.
25926 *
25927 * This program is distributed in the hope that it will be useful, but
25928 * WITHOUT ANY WARRANTY; without even the implied warranty of
25929 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25930 * General Public License for more details.
25931 *
25932 * You should have received a copy of the GNU General Public License
25933 * along with this program; if not, write to the Free Software
25934 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25935 */
25936
25937/* Author: G. Jungman */
25938
25939#ifndef __GSL_SF_POW_INT_H__
25940#define __GSL_SF_POW_INT_H__
25941/* begin inlined header: gsl/gsl_sf_result.h */
25942/* specfunc/gsl_sf_result.h
25943 *
25944 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
25945 *
25946 * This program is free software; you can redistribute it and/or modify
25947 * it under the terms of the GNU General Public License as published by
25948 * the Free Software Foundation; either version 3 of the License, or (at
25949 * your option) any later version.
25950 *
25951 * This program is distributed in the hope that it will be useful, but
25952 * WITHOUT ANY WARRANTY; without even the implied warranty of
25953 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25954 * General Public License for more details.
25955 *
25956 * You should have received a copy of the GNU General Public License
25957 * along with this program; if not, write to the Free Software
25958 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25959 */
25960
25961/* Author: G. Jungman */
25962
25963#ifndef __GSL_SF_RESULT_H__
25964#define __GSL_SF_RESULT_H__
25965
25966
25967
25968__BEGIN_DECLS
25969
25970struct gsl_sf_result_struct {
25971 double val;
25972 double err;
25973};
25974typedef struct gsl_sf_result_struct gsl_sf_result;
25975
25976#define GSL_SF_RESULT_SET(r,v,e) do { (r)->val=(v); (r)->err=(e); } while(0)
25977
25978
25980 double val;
25981 double err;
25982 int e10;
25983};
25984typedef struct gsl_sf_result_e10_struct gsl_sf_result_e10;
25985
25986
25987int gsl_sf_result_smash_e(const gsl_sf_result_e10 * re, gsl_sf_result * r);
25988
25989
25990__END_DECLS
25991
25992#endif /* __GSL_SF_RESULT_H__ */
25993
25994/* end inlined header: gsl/gsl_sf_result.h */
25995
25996
25997__BEGIN_DECLS
25998
25999
26000/* Calculate x^n.
26001 * Does not check for overflow/underflow.
26002 */
26003int gsl_sf_pow_int_e(double x, int n, gsl_sf_result * result);
26004double gsl_sf_pow_int(const double x, const int n);
26005
26006
26007__END_DECLS
26008
26009#endif /* __GSL_SF_POW_INT_H__ */
26010
26011/* end inlined header: gsl/gsl_sf_pow_int.h */
26012/* begin inlined header: gsl/gsl_sf_gamma.h */
26013/* specfunc/gsl_sf_gamma.h
26014 *
26015 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
26016 *
26017 * This program is free software; you can redistribute it and/or modify
26018 * it under the terms of the GNU General Public License as published by
26019 * the Free Software Foundation; either version 3 of the License, or (at
26020 * your option) any later version.
26021 *
26022 * This program is distributed in the hope that it will be useful, but
26023 * WITHOUT ANY WARRANTY; without even the implied warranty of
26024 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
26025 * General Public License for more details.
26026 *
26027 * You should have received a copy of the GNU General Public License
26028 * along with this program; if not, write to the Free Software
26029 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26030 */
26031
26032/* Author: G. Jungman */
26033
26034#ifndef __GSL_SF_GAMMA_H__
26035#define __GSL_SF_GAMMA_H__
26036/* begin inlined header: gsl/gsl_sf_result.h */
26037/* specfunc/gsl_sf_result.h
26038 *
26039 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
26040 *
26041 * This program is free software; you can redistribute it and/or modify
26042 * it under the terms of the GNU General Public License as published by
26043 * the Free Software Foundation; either version 3 of the License, or (at
26044 * your option) any later version.
26045 *
26046 * This program is distributed in the hope that it will be useful, but
26047 * WITHOUT ANY WARRANTY; without even the implied warranty of
26048 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
26049 * General Public License for more details.
26050 *
26051 * You should have received a copy of the GNU General Public License
26052 * along with this program; if not, write to the Free Software
26053 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26054 */
26055
26056/* Author: G. Jungman */
26057
26058#ifndef __GSL_SF_RESULT_H__
26059#define __GSL_SF_RESULT_H__
26060
26061
26062
26063__BEGIN_DECLS
26064
26065struct gsl_sf_result_struct {
26066 double val;
26067 double err;
26068};
26069typedef struct gsl_sf_result_struct gsl_sf_result;
26070
26071#define GSL_SF_RESULT_SET(r,v,e) do { (r)->val=(v); (r)->err=(e); } while(0)
26072
26073
26075 double val;
26076 double err;
26077 int e10;
26078};
26079typedef struct gsl_sf_result_e10_struct gsl_sf_result_e10;
26080
26081
26082int gsl_sf_result_smash_e(const gsl_sf_result_e10 * re, gsl_sf_result * r);
26083
26084
26085__END_DECLS
26086
26087#endif /* __GSL_SF_RESULT_H__ */
26088
26089/* end inlined header: gsl/gsl_sf_result.h */
26090
26091
26092__BEGIN_DECLS
26093
26094
26095/* Log[Gamma(x)], x not a negative integer
26096 * Uses real Lanczos method.
26097 * Returns the real part of Log[Gamma[x]] when x < 0,
26098 * i.e. Log[|Gamma[x]|].
26099 *
26100 * exceptions: GSL_EDOM, GSL_EROUND
26101 */
26102int gsl_sf_lngamma_e(double x, gsl_sf_result * result);
26103double gsl_sf_lngamma(const double x);
26104
26105
26106/* Log[Gamma(x)], x not a negative integer
26107 * Uses real Lanczos method. Determines
26108 * the sign of Gamma[x] as well as Log[|Gamma[x]|] for x < 0.
26109 * So Gamma[x] = sgn * Exp[result_lg].
26110 *
26111 * exceptions: GSL_EDOM, GSL_EROUND
26112 */
26113int gsl_sf_lngamma_sgn_e(double x, gsl_sf_result * result_lg, double *sgn);
26114
26115
26116/* Gamma(x), x not a negative integer
26117 * Uses real Lanczos method.
26118 *
26119 * exceptions: GSL_EDOM, GSL_EOVRFLW, GSL_EROUND
26120 */
26121int gsl_sf_gamma_e(const double x, gsl_sf_result * result);
26122double gsl_sf_gamma(const double x);
26123
26124
26125/* Regulated Gamma Function, x > 0
26126 * Gamma^*(x) = Gamma(x)/(Sqrt[2Pi] x^(x-1/2) exp(-x))
26127 * = (1 + 1/(12x) + ...), x->Inf
26128 * A useful suggestion of Temme.
26129 *
26130 * exceptions: GSL_EDOM
26131 */
26132int gsl_sf_gammastar_e(const double x, gsl_sf_result * result);
26133double gsl_sf_gammastar(const double x);
26134
26135
26136/* 1/Gamma(x)
26137 * Uses real Lanczos method.
26138 *
26139 * exceptions: GSL_EUNDRFLW, GSL_EROUND
26140 */
26141int gsl_sf_gammainv_e(const double x, gsl_sf_result * result);
26142double gsl_sf_gammainv(const double x);
26143
26144
26145/* Log[Gamma(z)] for z complex, z not a negative integer
26146 * Uses complex Lanczos method. Note that the phase part (arg)
26147 * is not well-determined when |z| is very large, due
26148 * to inevitable roundoff in restricting to (-Pi,Pi].
26149 * This will raise the GSL_ELOSS exception when it occurs.
26150 * The absolute value part (lnr), however, never suffers.
26151 *
26152 * Calculates:
26153 * lnr = log|Gamma(z)|
26154 * arg = arg(Gamma(z)) in (-Pi, Pi]
26155 *
26156 * exceptions: GSL_EDOM, GSL_ELOSS
26157 */
26158int gsl_sf_lngamma_complex_e(double zr, double zi, gsl_sf_result * lnr, gsl_sf_result * arg);
26159
26160
26161/* x^n / n!
26162 *
26163 * x >= 0.0, n >= 0
26164 * exceptions: GSL_EDOM, GSL_EOVRFLW, GSL_EUNDRFLW
26165 */
26166int gsl_sf_taylorcoeff_e(const int n, const double x, gsl_sf_result * result);
26167double gsl_sf_taylorcoeff(const int n, const double x);
26168
26169
26170/* n!
26171 *
26172 * exceptions: GSL_EDOM, GSL_EOVRFLW
26173 */
26174int gsl_sf_fact_e(const unsigned int n, gsl_sf_result * result);
26175double gsl_sf_fact(const unsigned int n);
26176
26177
26178/* n!! = n(n-2)(n-4) ...
26179 *
26180 * exceptions: GSL_EDOM, GSL_EOVRFLW
26181 */
26182int gsl_sf_doublefact_e(const unsigned int n, gsl_sf_result * result);
26183double gsl_sf_doublefact(const unsigned int n);
26184
26185
26186/* log(n!)
26187 * Faster than ln(Gamma(n+1)) for n < 170; defers for larger n.
26188 *
26189 * exceptions: none
26190 */
26191int gsl_sf_lnfact_e(const unsigned int n, gsl_sf_result * result);
26192double gsl_sf_lnfact(const unsigned int n);
26193
26194
26195/* log(n!!)
26196 *
26197 * exceptions: none
26198 */
26199int gsl_sf_lndoublefact_e(const unsigned int n, gsl_sf_result * result);
26200double gsl_sf_lndoublefact(const unsigned int n);
26201
26202
26203/* log(n choose m)
26204 *
26205 * exceptions: GSL_EDOM
26206 */
26207int gsl_sf_lnchoose_e(unsigned int n, unsigned int m, gsl_sf_result * result);
26208double gsl_sf_lnchoose(unsigned int n, unsigned int m);
26209
26210
26211/* n choose m
26212 *
26213 * exceptions: GSL_EDOM, GSL_EOVRFLW
26214 */
26215int gsl_sf_choose_e(unsigned int n, unsigned int m, gsl_sf_result * result);
26216double gsl_sf_choose(unsigned int n, unsigned int m);
26217
26218
26219/* Logarithm of Pochhammer (Apell) symbol
26220 * log( (a)_x )
26221 * where (a)_x := Gamma[a + x]/Gamma[a]
26222 *
26223 * a > 0, a+x > 0
26224 *
26225 * exceptions: GSL_EDOM
26226 */
26227int gsl_sf_lnpoch_e(const double a, const double x, gsl_sf_result * result);
26228double gsl_sf_lnpoch(const double a, const double x);
26229
26230
26231/* Logarithm of Pochhammer (Apell) symbol, with sign information.
26232 * result = log( |(a)_x| )
26233 * sgn = sgn( (a)_x )
26234 * where (a)_x := Gamma[a + x]/Gamma[a]
26235 *
26236 * a != neg integer, a+x != neg integer
26237 *
26238 * exceptions: GSL_EDOM
26239 */
26240int gsl_sf_lnpoch_sgn_e(const double a, const double x, gsl_sf_result * result, double * sgn);
26241
26242
26243/* Pochhammer (Apell) symbol
26244 * (a)_x := Gamma[a + x]/Gamma[x]
26245 *
26246 * a != neg integer, a+x != neg integer
26247 *
26248 * exceptions: GSL_EDOM, GSL_EOVRFLW
26249 */
26250int gsl_sf_poch_e(const double a, const double x, gsl_sf_result * result);
26251double gsl_sf_poch(const double a, const double x);
26252
26253
26254/* Relative Pochhammer (Apell) symbol
26255 * ((a,x) - 1)/x
26256 * where (a,x) = (a)_x := Gamma[a + x]/Gamma[a]
26257 *
26258 * exceptions: GSL_EDOM
26259 */
26260int gsl_sf_pochrel_e(const double a, const double x, gsl_sf_result * result);
26261double gsl_sf_pochrel(const double a, const double x);
26262
26263
26264/* Normalized Incomplete Gamma Function
26265 *
26266 * Q(a,x) = 1/Gamma(a) Integral[ t^(a-1) e^(-t), {t,x,Infinity} ]
26267 *
26268 * a >= 0, x >= 0
26269 * Q(a,0) := 1
26270 * Q(0,x) := 0, x != 0
26271 *
26272 * exceptions: GSL_EDOM
26273 */
26274int gsl_sf_gamma_inc_Q_e(const double a, const double x, gsl_sf_result * result);
26275double gsl_sf_gamma_inc_Q(const double a, const double x);
26276
26277
26278/* Complementary Normalized Incomplete Gamma Function
26279 *
26280 * P(a,x) = 1/Gamma(a) Integral[ t^(a-1) e^(-t), {t,0,x} ]
26281 *
26282 * a > 0, x >= 0
26283 *
26284 * exceptions: GSL_EDOM
26285 */
26286int gsl_sf_gamma_inc_P_e(const double a, const double x, gsl_sf_result * result);
26287double gsl_sf_gamma_inc_P(const double a, const double x);
26288
26289
26290/* Non-normalized Incomplete Gamma Function
26291 *
26292 * Gamma(a,x) := Integral[ t^(a-1) e^(-t), {t,x,Infinity} ]
26293 *
26294 * x >= 0.0
26295 * Gamma(a, 0) := Gamma(a)
26296 *
26297 * exceptions: GSL_EDOM
26298 */
26299int gsl_sf_gamma_inc_e(const double a, const double x, gsl_sf_result * result);
26300double gsl_sf_gamma_inc(const double a, const double x);
26301
26302
26303/* Logarithm of Beta Function
26304 * Log[B(a,b)]
26305 *
26306 * a > 0, b > 0
26307 * exceptions: GSL_EDOM
26308 */
26309int gsl_sf_lnbeta_e(const double a, const double b, gsl_sf_result * result);
26310double gsl_sf_lnbeta(const double a, const double b);
26311
26312int gsl_sf_lnbeta_sgn_e(const double x, const double y, gsl_sf_result * result, double * sgn);
26313
26314
26315/* Beta Function
26316 * B(a,b)
26317 *
26318 * a > 0, b > 0
26319 * exceptions: GSL_EDOM, GSL_EOVRFLW, GSL_EUNDRFLW
26320 */
26321int gsl_sf_beta_e(const double a, const double b, gsl_sf_result * result);
26322double gsl_sf_beta(const double a, const double b);
26323
26324
26325/* Normalized Incomplete Beta Function
26326 * B_x(a,b)/B(a,b)
26327 *
26328 * a > 0, b > 0, 0 <= x <= 1
26329 * exceptions: GSL_EDOM, GSL_EUNDRFLW
26330 */
26331int gsl_sf_beta_inc_e(const double a, const double b, const double x, gsl_sf_result * result);
26332double gsl_sf_beta_inc(const double a, const double b, const double x);
26333
26334
26335/* The maximum x such that gamma(x) is not
26336 * considered an overflow.
26337 */
26338#define GSL_SF_GAMMA_XMAX 171.0
26339
26340/* The maximum n such that gsl_sf_fact(n) does not give an overflow. */
26341#define GSL_SF_FACT_NMAX 170
26342
26343/* The maximum n such that gsl_sf_doublefact(n) does not give an overflow. */
26344#define GSL_SF_DOUBLEFACT_NMAX 297
26345
26346__END_DECLS
26347
26348#endif /* __GSL_SF_GAMMA_H__ */
26349
26350/* end inlined header: gsl/gsl_sf_gamma.h */
26351/* begin inlined header: gsl/gsl_sf_coulomb.h */
26352/* specfunc/gsl_sf_coulomb.h
26353 *
26354 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
26355 *
26356 * This program is free software; you can redistribute it and/or modify
26357 * it under the terms of the GNU General Public License as published by
26358 * the Free Software Foundation; either version 3 of the License, or (at
26359 * your option) any later version.
26360 *
26361 * This program is distributed in the hope that it will be useful, but
26362 * WITHOUT ANY WARRANTY; without even the implied warranty of
26363 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
26364 * General Public License for more details.
26365 *
26366 * You should have received a copy of the GNU General Public License
26367 * along with this program; if not, write to the Free Software
26368 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26369 */
26370
26371/* Author: G. Jungman */
26372
26373#ifndef __GSL_SF_COULOMB_H__
26374#define __GSL_SF_COULOMB_H__
26375/* begin inlined header: gsl/gsl_mode.h */
26376/* gsl_mode.h
26377 *
26378 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2004 Gerard Jungman
26379 *
26380 * This program is free software; you can redistribute it and/or modify
26381 * it under the terms of the GNU General Public License as published by
26382 * the Free Software Foundation; either version 3 of the License, or (at
26383 * your option) any later version.
26384 *
26385 * This program is distributed in the hope that it will be useful, but
26386 * WITHOUT ANY WARRANTY; without even the implied warranty of
26387 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
26388 * General Public License for more details.
26389 *
26390 * You should have received a copy of the GNU General Public License
26391 * along with this program; if not, write to the Free Software
26392 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26393 */
26394
26395/* Author: B. Gough and G. Jungman */
26396
26397#ifndef __GSL_MODE_H__
26398#define __GSL_MODE_H__
26399/* begin inlined header: gsl/gsl_inline.h */
26400/* gsl_inline.h
26401 *
26402 * Copyright (C) 2008, 2009 Brian Gough
26403 *
26404 * This program is free software; you can redistribute it and/or modify
26405 * it under the terms of the GNU General Public License as published by
26406 * the Free Software Foundation; either version 3 of the License, or (at
26407 * your option) any later version.
26408 *
26409 * This program is distributed in the hope that it will be useful, but
26410 * WITHOUT ANY WARRANTY; without even the implied warranty of
26411 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
26412 * General Public License for more details.
26413 *
26414 * You should have received a copy of the GNU General Public License
26415 * along with this program; if not, write to the Free Software
26416 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26417 */
26418
26419#ifndef __GSL_INLINE_H__
26420#define __GSL_INLINE_H__
26421
26422/* In recent versiions of GCC, the inline keyword has two different
26423 forms: GNU and C99.
26424
26425 In GNU mode we can use 'extern inline' to make inline functions
26426 work like macros. The function is only inlined--it is never output
26427 as a definition in an object file.
26428
26429 In the new C99 mode 'extern inline' has a different meaning--it
26430 causes the definition of the function to be output in each object
26431 file where it is used. This will result in multiple-definition
26432 errors on linking. The 'inline' keyword on its own (without
26433 extern) has the same behavior as the original GNU 'extern inline'.
26434
26435 The C99 style is the default with -std=c99 in GCC 4.3.
26436
26437 This header file allows either form of inline to be used by
26438 redefining the macros INLINE_DECL and INLINE_FUN. These are used
26439 in the public header files as
26440
26441 INLINE_DECL double gsl_foo (double x);
26442 #ifdef HAVE_INLINE
26443 INLINE_FUN double gsl_foo (double x) { return x+1.0; } ;
26444 #endif
26445
26446*/
26447
26448#ifdef HAVE_INLINE
26449# if defined(__GNUC_STDC_INLINE__) || defined(GSL_C99_INLINE) || defined(HAVE_C99_INLINE)
26450# define INLINE_DECL inline /* use C99 inline */
26451# define INLINE_FUN inline
26452# else
26453# define INLINE_DECL /* use GNU extern inline */
26454# define INLINE_FUN extern inline
26455# endif
26456#else
26457# define INLINE_DECL /* */
26458#endif
26459
26460/* Range checking conditions in headers do not require any run-time
26461 tests of the global variable gsl_check_range. They are enabled or
26462 disabled in user code at compile time with GSL_RANGE_CHECK macro.
26463 See also build.h. */
26464#define GSL_RANGE_COND(x) (x)
26465
26466#endif /* __GSL_INLINE_H__ */
26467
26468/* end inlined header: gsl/gsl_inline.h */
26469
26470
26471__BEGIN_DECLS
26472
26473
26474/* Some functions can take a mode argument. This
26475 * is a rough method to do things like control
26476 * the precision of the algorithm. This mainly
26477 * occurs in special functions, but we figured
26478 * it was ok to have a general facility.
26479 *
26480 * The mode type is 32-bit field. Most of
26481 * the fields are currently unused. Users
26482 * '|' various predefined constants to get
26483 * a desired mode.
26484 */
26485typedef unsigned int gsl_mode_t;
26486
26487
26488/* Here are the predefined constants.
26489 * Note that the precision constants
26490 * are special because they are used
26491 * to index arrays, so do not change
26492 * them. The precision information is
26493 * in the low order 3 bits of gsl_mode_t
26494 * (the third bit is currently unused).
26495 */
26496
26497/* Note that "0" is double precision,
26498 * so that you get that by default if
26499 * you forget a flag.
26500 */
26501#define GSL_PREC_DOUBLE 0
26502#define GSL_PREC_SINGLE 1
26503#define GSL_PREC_APPROX 2
26504
26505#ifdef HAVE_INLINE
26506INLINE_FUN unsigned int GSL_MODE_PREC(gsl_mode_t mt);
26507
26508INLINE_FUN unsigned int
26509GSL_MODE_PREC(gsl_mode_t mt)
26510{ return (mt & (unsigned int)7); }
26511#else /* HAVE_INLINE */
26512#define GSL_MODE_PREC(mt) ((mt) & (unsigned int)7)
26513#endif /* HAVE_INLINE */
26514
26515
26516/* Here are some predefined generic modes.
26517 */
26518#define GSL_MODE_DEFAULT 0
26519
26520
26521__END_DECLS
26522
26523#endif /* __GSL_MODE_H__ */
26524
26525/* end inlined header: gsl/gsl_mode.h */
26526/* begin inlined header: gsl/gsl_sf_result.h */
26527/* specfunc/gsl_sf_result.h
26528 *
26529 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
26530 *
26531 * This program is free software; you can redistribute it and/or modify
26532 * it under the terms of the GNU General Public License as published by
26533 * the Free Software Foundation; either version 3 of the License, or (at
26534 * your option) any later version.
26535 *
26536 * This program is distributed in the hope that it will be useful, but
26537 * WITHOUT ANY WARRANTY; without even the implied warranty of
26538 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
26539 * General Public License for more details.
26540 *
26541 * You should have received a copy of the GNU General Public License
26542 * along with this program; if not, write to the Free Software
26543 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26544 */
26545
26546/* Author: G. Jungman */
26547
26548#ifndef __GSL_SF_RESULT_H__
26549#define __GSL_SF_RESULT_H__
26550
26551
26552
26553__BEGIN_DECLS
26554
26555struct gsl_sf_result_struct {
26556 double val;
26557 double err;
26558};
26559typedef struct gsl_sf_result_struct gsl_sf_result;
26560
26561#define GSL_SF_RESULT_SET(r,v,e) do { (r)->val=(v); (r)->err=(e); } while(0)
26562
26563
26565 double val;
26566 double err;
26567 int e10;
26568};
26569typedef struct gsl_sf_result_e10_struct gsl_sf_result_e10;
26570
26571
26572int gsl_sf_result_smash_e(const gsl_sf_result_e10 * re, gsl_sf_result * r);
26573
26574
26575__END_DECLS
26576
26577#endif /* __GSL_SF_RESULT_H__ */
26578
26579/* end inlined header: gsl/gsl_sf_result.h */
26580
26581
26582__BEGIN_DECLS
26583
26584
26585/* Normalized hydrogenic bound states, radial dependence. */
26586
26587/* R_1 := 2Z sqrt(Z) exp(-Z r)
26588 */
26589int gsl_sf_hydrogenicR_1_e(const double Z, const double r, gsl_sf_result * result);
26590double gsl_sf_hydrogenicR_1(const double Z, const double r);
26591
26592/* R_n := norm exp(-Z r/n) (2Z/n)^l Laguerre[n-l-1, 2l+1, 2Z/n r]
26593 *
26594 * normalization such that psi(n,l,r) = R_n Y_{lm}
26595 */
26596int gsl_sf_hydrogenicR_e(const int n, const int l, const double Z, const double r, gsl_sf_result * result);
26597double gsl_sf_hydrogenicR(const int n, const int l, const double Z, const double r);
26598
26599
26600/* Coulomb wave functions F_{lam_F}(eta,x), G_{lam_G}(eta,x)
26601 * and their derivatives; lam_G := lam_F - k_lam_G
26602 *
26603 * lam_F, lam_G > -0.5
26604 * x > 0.0
26605 *
26606 * Conventions of Abramowitz+Stegun.
26607 *
26608 * Because there can be a large dynamic range of values,
26609 * overflows are handled gracefully. If an overflow occurs,
26610 * GSL_EOVRFLW is signalled and exponent(s) are returned
26611 * through exp_F, exp_G. These are such that
26612 *
26613 * F_L(eta,x) = fc[k_L] * exp(exp_F)
26614 * G_L(eta,x) = gc[k_L] * exp(exp_G)
26615 * F_L'(eta,x) = fcp[k_L] * exp(exp_F)
26616 * G_L'(eta,x) = gcp[k_L] * exp(exp_G)
26617 */
26618int
26619gsl_sf_coulomb_wave_FG_e(const double eta, const double x,
26620 const double lam_F,
26621 const int k_lam_G,
26622 gsl_sf_result * F, gsl_sf_result * Fp,
26623 gsl_sf_result * G, gsl_sf_result * Gp,
26624 double * exp_F, double * exp_G);
26625
26626
26627/* F_L(eta,x), G_L(eta,x) as arrays */
26628int gsl_sf_coulomb_wave_FG_array(double lam_min, int kmax,
26629 double eta, double x,
26630 double * fc_array, double * gc_array,
26631 double * F_exponent,
26632 double * G_exponent
26633 );
26634
26635
26636__END_DECLS
26637
26638#endif /* __GSL_SF_COULOMB_H__ */
26639
26640/* end inlined header: gsl/gsl_sf_coulomb.h */
26641/* inlined: error.h */
26642
26643/* the full definition of C_L(eta) for any valid L and eta
26644 * [Abramowitz and Stegun 14.1.7]
26645 * This depends on the complex gamma function. For large
26646 * arguments the phase of the complex gamma function is not
26647 * very accurately determined. However the modulus is, and that
26648 * is all that we need to calculate C_L.
26649 *
26650 * This is not valid for L <= -3/2 or L = -1.
26651 */
26652static
26653int
26654CLeta(double L, double eta, gsl_sf_result * result)
26655{
26656 gsl_sf_result ln1; /* log of numerator Gamma function */
26657 gsl_sf_result ln2; /* log of denominator Gamma function */
26658 double sgn = 1.0;
26659 double arg_val, arg_err;
26660
26661 if(fabs(eta/(L+1.0)) < GSL_DBL_EPSILON) {
26662 gsl_sf_lngamma_e(L+1.0, &ln1);
26663 }
26664 else {
26665 gsl_sf_result p1; /* phase of numerator Gamma -- not used */
26666 gsl_sf_lngamma_complex_e(L+1.0, eta, &ln1, &p1); /* should be ok */
26667 }
26668
26669 gsl_sf_lngamma_e(2.0*(L+1.0), &ln2);
26670 if(L < -1.0) sgn = -sgn;
26671
26672 arg_val = L*M_LN2 - 0.5*eta*M_PI + ln1.val - ln2.val;
26673 arg_err = ln1.err + ln2.err;
26674 arg_err += GSL_DBL_EPSILON * (fabs(L*M_LN2) + fabs(0.5*eta*M_PI));
26675 return gsl_sf_exp_err_e(arg_val, arg_err, result);
26676}
26677
26678
26679/* Evaluate the series for Phi_L(eta,x) and Phi_L*(eta,x)
26680 * [Abramowitz+Stegun 14.1.5]
26681 * [Abramowitz+Stegun 14.1.13]
26682 *
26683 * The sequence of coefficients A_k^L is
26684 * manifestly well-controlled for L >= -1/2
26685 * and eta < 10.
26686 *
26687 * This makes sense since this is the region
26688 * away from threshold, and you expect
26689 * the evaluation to become easier as you
26690 * get farther from threshold.
26691 *
26692 * Empirically, this is quite well-behaved for
26693 * L >= -1/2
26694 * eta < 10
26695 * x < 10
26696 */
26697#if 0
26698static
26699int
26700coulomb_Phi_series(const double lam, const double eta, const double x,
26701 double * result, double * result_star)
26702{
26703 int kmin = 5;
26704 int kmax = 200;
26705 int k;
26706 double Akm2 = 1.0;
26707 double Akm1 = eta/(lam+1.0);
26708 double Ak;
26709
26710 double xpow = x;
26711 double sum = Akm2 + Akm1*x;
26712 double sump = (lam+1.0)*Akm2 + (lam+2.0)*Akm1*x;
26713 double prev_abs_del = fabs(Akm1*x);
26714 double prev_abs_del_p = (lam+2.0) * prev_abs_del;
26715
26716 for(k=2; k<kmax; k++) {
26717 double del;
26718 double del_p;
26719 double abs_del;
26720 double abs_del_p;
26721
26722 Ak = (2.0*eta*Akm1 - Akm2)/(k*(2.0*lam + 1.0 + k));
26723
26724 xpow *= x;
26725 del = Ak*xpow;
26726 del_p = (k+lam+1.0)*del;
26727 sum += del;
26728 sump += del_p;
26729
26730 abs_del = fabs(del);
26731 abs_del_p = fabs(del_p);
26732
26733 if( abs_del/(fabs(sum)+abs_del) < GSL_DBL_EPSILON
26734 && prev_abs_del/(fabs(sum)+prev_abs_del) < GSL_DBL_EPSILON
26735 && abs_del_p/(fabs(sump)+abs_del_p) < GSL_DBL_EPSILON
26736 && prev_abs_del_p/(fabs(sump)+prev_abs_del_p) < GSL_DBL_EPSILON
26737 && k > kmin
26738 ) break;
26739
26740 /* We need to keep track of the previous delta because when
26741 * eta is near zero the odd terms of the sum are very small
26742 * and this could lead to premature termination.
26743 */
26744 prev_abs_del = abs_del;
26745 prev_abs_del_p = abs_del_p;
26746
26747 Akm2 = Akm1;
26748 Akm1 = Ak;
26749 }
26750
26751 *result = sum;
26752 *result_star = sump;
26753
26754 if(k==kmax) {
26755 GSL_ERROR ("error", GSL_EMAXITER);
26756 }
26757 else {
26758 return GSL_SUCCESS;
26759 }
26760}
26761#endif /* 0 */
26762
26763
26764/* Determine the connection phase, phi_lambda.
26765 * See coulomb_FG_series() below. We have
26766 * to be careful about sin(phi)->0. Note that
26767 * there is an underflow condition for large
26768 * positive eta in any case.
26769 */
26770static
26771int
26772coulomb_connection(const double lam, const double eta,
26773 double * cos_phi, double * sin_phi)
26774{
26775 if(eta > -GSL_LOG_DBL_MIN/2.0*M_PI-1.0) {
26776 *cos_phi = 1.0;
26777 *sin_phi = 0.0;
26778 GSL_ERROR ("error", GSL_EUNDRFLW);
26779 }
26780 else if(eta > -GSL_LOG_DBL_EPSILON/(4.0*M_PI)) {
26781 const double eps = 2.0 * exp(-2.0*M_PI*eta);
26782 const double tpl = tan(M_PI * lam);
26783 const double dth = eps * tpl / (tpl*tpl + 1.0);
26784 *cos_phi = -1.0 + 0.5 * dth*dth;
26785 *sin_phi = -dth;
26786 return GSL_SUCCESS;
26787 }
26788 else {
26789 double X = tanh(M_PI * eta) / tan(M_PI * lam);
26790 double phi = -atan(X) - (lam + 0.5) * M_PI;
26791 *cos_phi = cos(phi);
26792 *sin_phi = sin(phi);
26793 return GSL_SUCCESS;
26794 }
26795}
26796
26797
26798/* Evaluate the Frobenius series for F_lam(eta,x) and G_lam(eta,x).
26799 * Homegrown algebra. Evaluates the series for F_{lam} and
26800 * F_{-lam-1}, then uses
26801 * G_{lam} = (F_{lam} cos(phi) - F_{-lam-1}) / sin(phi)
26802 * where
26803 * phi = Arg[Gamma[1+lam+I eta]] - Arg[Gamma[-lam + I eta]] - (lam+1/2)Pi
26804 * = Arg[Sin[Pi(-lam+I eta)] - (lam+1/2)Pi
26805 * = atan2(-cos(lam Pi)sinh(eta Pi), -sin(lam Pi)cosh(eta Pi)) - (lam+1/2)Pi
26806 *
26807 * = -atan(X) - (lam+1/2) Pi, X = tanh(eta Pi)/tan(lam Pi)
26808 *
26809 * Not appropriate for lam <= -1/2, lam = 0, or lam >= 1/2.
26810 */
26811static
26812int
26813coulomb_FG_series(const double lam, const double eta, const double x,
26814 gsl_sf_result * F, gsl_sf_result * G)
26815{
26816 const int max_iter = 800;
26817 gsl_sf_result ClamA;
26818 gsl_sf_result ClamB;
26819 int stat_A = CLeta(lam, eta, &ClamA);
26820 int stat_B = CLeta(-lam-1.0, eta, &ClamB);
26821 const double tlp1 = 2.0*lam + 1.0;
26822 const double pow_x = pow(x, lam);
26823 double cos_phi_lam;
26824 double sin_phi_lam;
26825
26826 double uA_mm2 = 1.0; /* uA sum is for F_{lam} */
26827 double uA_mm1 = x*eta/(lam+1.0);
26828 double uA_m;
26829 double uB_mm2 = 1.0; /* uB sum is for F_{-lam-1} */
26830 double uB_mm1 = -x*eta/lam;
26831 double uB_m;
26832 double A_sum = uA_mm2 + uA_mm1;
26833 double B_sum = uB_mm2 + uB_mm1;
26834 double A_abs_del_prev = fabs(A_sum);
26835 double B_abs_del_prev = fabs(B_sum);
26836 gsl_sf_result FA, FB;
26837 int m = 2;
26838
26839 int stat_conn = coulomb_connection(lam, eta, &cos_phi_lam, &sin_phi_lam);
26840
26841 if(stat_conn == GSL_EUNDRFLW) {
26842 F->val = 0.0; /* FIXME: should this be set to Inf too like G? */
26843 F->err = 0.0;
26844 OVERFLOW_ERROR(G);
26845 }
26846
26847 while(m < max_iter) {
26848 double abs_dA;
26849 double abs_dB;
26850 uA_m = x*(2.0*eta*uA_mm1 - x*uA_mm2)/(m*(m+tlp1));
26851 uB_m = x*(2.0*eta*uB_mm1 - x*uB_mm2)/(m*(m-tlp1));
26852 A_sum += uA_m;
26853 B_sum += uB_m;
26854 abs_dA = fabs(uA_m);
26855 abs_dB = fabs(uB_m);
26856 if(m > 15) {
26857 /* Don't bother checking until we have gone out a little ways;
26858 * a minor optimization. Also make sure to check both the
26859 * current and the previous increment because the odd and even
26860 * terms of the sum can have very different behaviour, depending
26861 * on the value of eta.
26862 */
26863 double max_abs_dA = GSL_MAX(abs_dA, A_abs_del_prev);
26864 double max_abs_dB = GSL_MAX(abs_dB, B_abs_del_prev);
26865 double abs_A = fabs(A_sum);
26866 double abs_B = fabs(B_sum);
26867 if( max_abs_dA/(max_abs_dA + abs_A) < 4.0*GSL_DBL_EPSILON
26868 && max_abs_dB/(max_abs_dB + abs_B) < 4.0*GSL_DBL_EPSILON
26869 ) break;
26870 }
26871 A_abs_del_prev = abs_dA;
26872 B_abs_del_prev = abs_dB;
26873 uA_mm2 = uA_mm1;
26874 uA_mm1 = uA_m;
26875 uB_mm2 = uB_mm1;
26876 uB_mm1 = uB_m;
26877 m++;
26878 }
26879
26880 FA.val = A_sum * ClamA.val * pow_x * x;
26881 FA.err = fabs(A_sum) * ClamA.err * pow_x * x + 2.0*GSL_DBL_EPSILON*fabs(FA.val);
26882 FB.val = B_sum * ClamB.val / pow_x;
26883 FB.err = fabs(B_sum) * ClamB.err / pow_x + 2.0*GSL_DBL_EPSILON*fabs(FB.val);
26884
26885 F->val = FA.val;
26886 F->err = FA.err;
26887
26888 G->val = (FA.val * cos_phi_lam - FB.val)/sin_phi_lam;
26889 G->err = (FA.err * fabs(cos_phi_lam) + FB.err)/fabs(sin_phi_lam);
26890
26891 if(m >= max_iter)
26892 GSL_ERROR ("error", GSL_EMAXITER);
26893 else
26894 return GSL_ERROR_SELECT_2(stat_A, stat_B);
26895}
26896
26897
26898/* Evaluate the Frobenius series for F_0(eta,x) and G_0(eta,x).
26899 * See [Bardin et al., CPC 3, 73 (1972), (14)-(17)];
26900 * note the misprint in (17): nu_0=1 is correct, not nu_0=0.
26901 */
26902static
26903int
26904coulomb_FG0_series(const double eta, const double x,
26905 gsl_sf_result * F, gsl_sf_result * G)
26906{
26907 const int max_iter = 800;
26908 const double x2 = x*x;
26909 const double tex = 2.0*eta*x;
26910 gsl_sf_result C0;
26911 int stat_CL = CLeta(0.0, eta, &C0);
26912 gsl_sf_result r1pie;
26913 int psi_stat = gsl_sf_psi_1piy_e(eta, &r1pie);
26914 double u_mm2 = 0.0; /* u_0 */
26915 double u_mm1 = x; /* u_1 */
26916 double u_m;
26917 double v_mm2 = 1.0; /* nu_0 */
26918 double v_mm1 = tex*(2.0*M_EULER-1.0+r1pie.val); /* nu_1 */
26919 double v_m;
26920 double u_sum = u_mm2 + u_mm1;
26921 double v_sum = v_mm2 + v_mm1;
26922 double u_abs_del_prev = fabs(u_sum);
26923 double v_abs_del_prev = fabs(v_sum);
26924 int m = 2;
26925 double u_sum_err = 2.0 * GSL_DBL_EPSILON * fabs(u_sum);
26926 double v_sum_err = 2.0 * GSL_DBL_EPSILON * fabs(v_sum);
26927 double ln2x = log(2.0*x);
26928
26929 while(m < max_iter) {
26930 double abs_du;
26931 double abs_dv;
26932 double m_mm1 = m*(m-1.0);
26933 u_m = (tex*u_mm1 - x2*u_mm2)/m_mm1;
26934 v_m = (tex*v_mm1 - x2*v_mm2 - 2.0*eta*(2*m-1)*u_m)/m_mm1;
26935 u_sum += u_m;
26936 v_sum += v_m;
26937 abs_du = fabs(u_m);
26938 abs_dv = fabs(v_m);
26939 u_sum_err += 2.0 * GSL_DBL_EPSILON * abs_du;
26940 v_sum_err += 2.0 * GSL_DBL_EPSILON * abs_dv;
26941 if(m > 15) {
26942 /* Don't bother checking until we have gone out a little ways;
26943 * a minor optimization. Also make sure to check both the
26944 * current and the previous increment because the odd and even
26945 * terms of the sum can have very different behaviour, depending
26946 * on the value of eta.
26947 */
26948 double max_abs_du = GSL_MAX(abs_du, u_abs_del_prev);
26949 double max_abs_dv = GSL_MAX(abs_dv, v_abs_del_prev);
26950 double abs_u = fabs(u_sum);
26951 double abs_v = fabs(v_sum);
26952 if( max_abs_du/(max_abs_du + abs_u) < 40.0*GSL_DBL_EPSILON
26953 && max_abs_dv/(max_abs_dv + abs_v) < 40.0*GSL_DBL_EPSILON
26954 ) break;
26955 }
26956 u_abs_del_prev = abs_du;
26957 v_abs_del_prev = abs_dv;
26958 u_mm2 = u_mm1;
26959 u_mm1 = u_m;
26960 v_mm2 = v_mm1;
26961 v_mm1 = v_m;
26962 m++;
26963 }
26964
26965 F->val = C0.val * u_sum;
26966 F->err = C0.err * fabs(u_sum);
26967 F->err += fabs(C0.val) * u_sum_err;
26968 F->err += 2.0 * GSL_DBL_EPSILON * fabs(F->val);
26969
26970 G->val = (v_sum + 2.0*eta*u_sum * ln2x) / C0.val;
26971 G->err = (fabs(v_sum) + fabs(2.0*eta*u_sum * ln2x)) / fabs(C0.val) * fabs(C0.err/C0.val);
26972 G->err += (v_sum_err + fabs(2.0*eta*u_sum_err*ln2x)) / fabs(C0.val);
26973 G->err += 2.0 * GSL_DBL_EPSILON * fabs(G->val);
26974
26975 if(m == max_iter)
26976 GSL_ERROR ("error", GSL_EMAXITER);
26977 else
26978 return GSL_ERROR_SELECT_2(psi_stat, stat_CL);
26979}
26980
26981
26982/* Evaluate the Frobenius series for F_{-1/2}(eta,x) and G_{-1/2}(eta,x).
26983 * Homegrown algebra.
26984 */
26985static
26986int
26987coulomb_FGmhalf_series(const double eta, const double x,
26988 gsl_sf_result * F, gsl_sf_result * G)
26989{
26990 const int max_iter = 800;
26991 const double rx = sqrt(x);
26992 const double x2 = x*x;
26993 const double tex = 2.0*eta*x;
26994 gsl_sf_result Cmhalf;
26995 int stat_CL = CLeta(-0.5, eta, &Cmhalf);
26996 double u_mm2 = 1.0; /* u_0 */
26997 double u_mm1 = tex * u_mm2; /* u_1 */
26998 double u_m;
26999 double v_mm2, v_mm1, v_m;
27000 double f_sum, g_sum;
27001 double tmp1;
27002 gsl_sf_result rpsi_1pe;
27003 gsl_sf_result rpsi_1p2e;
27004 int m = 2;
27005
27006 gsl_sf_psi_1piy_e(eta, &rpsi_1pe);
27007 gsl_sf_psi_1piy_e(2.0*eta, &rpsi_1p2e);
27008
27009 v_mm2 = 2.0*M_EULER - M_LN2 - rpsi_1pe.val + 2.0*rpsi_1p2e.val;
27010 v_mm1 = tex*(v_mm2 - 2.0*u_mm2);
27011
27012 f_sum = u_mm2 + u_mm1;
27013 g_sum = v_mm2 + v_mm1;
27014
27015 while(m < max_iter) {
27016 double m2 = m*m;
27017 u_m = (tex*u_mm1 - x2*u_mm2)/m2;
27018 v_m = (tex*v_mm1 - x2*v_mm2 - 2.0*m*u_m)/m2;
27019 f_sum += u_m;
27020 g_sum += v_m;
27021 if( f_sum != 0.0
27022 && g_sum != 0.0
27023 && (fabs(u_m/f_sum) + fabs(v_m/g_sum) < 10.0*GSL_DBL_EPSILON)) break;
27024 u_mm2 = u_mm1;
27025 u_mm1 = u_m;
27026 v_mm2 = v_mm1;
27027 v_mm1 = v_m;
27028 m++;
27029 }
27030
27031 F->val = Cmhalf.val * rx * f_sum;
27032 F->err = Cmhalf.err * fabs(rx * f_sum) + 2.0*GSL_DBL_EPSILON*fabs(F->val);
27033
27034 tmp1 = f_sum*log(x);
27035 G->val = -rx*(tmp1 + g_sum)/Cmhalf.val;
27036 G->err = fabs(rx)*(fabs(tmp1) + fabs(g_sum))/fabs(Cmhalf.val) * fabs(Cmhalf.err/Cmhalf.val);
27037
27038 if(m == max_iter)
27039 GSL_ERROR ("error", GSL_EMAXITER);
27040 else
27041 return stat_CL;
27042}
27043
27044
27045/* Evolve the backwards recurrence for F,F'.
27046 *
27047 * F_{lam-1} = (S_lam F_lam + F_lam') / R_lam
27048 * F_{lam-1}' = (S_lam F_{lam-1} - R_lam F_lam)
27049 * where
27050 * R_lam = sqrt(1 + (eta/lam)^2)
27051 * S_lam = lam/x + eta/lam
27052 *
27053 */
27054static
27055int
27056coulomb_F_recur(double lam_min, int kmax,
27057 double eta, double x,
27058 double F_lam_max, double Fp_lam_max,
27059 double * F_lam_min, double * Fp_lam_min
27060 )
27061{
27062 double x_inv = 1.0/x;
27063 double fcl = F_lam_max;
27064 double fpl = Fp_lam_max;
27065 double lam_max = lam_min + kmax;
27066 double lam = lam_max;
27067 int k;
27068
27069 for(k=kmax-1; k>=0; k--) {
27070 double el = eta/lam;
27071 double rl = hypot(1.0, el);
27072 double sl = el + lam*x_inv;
27073 double fc_lm1;
27074 fc_lm1 = (fcl*sl + fpl)/rl;
27075 fpl = fc_lm1*sl - fcl*rl;
27076 fcl = fc_lm1;
27077 lam -= 1.0;
27078 }
27079
27080 *F_lam_min = fcl;
27081 *Fp_lam_min = fpl;
27082 return GSL_SUCCESS;
27083}
27084
27085
27086/* Evolve the forward recurrence for G,G'.
27087 *
27088 * G_{lam+1} = (S_lam G_lam - G_lam')/R_lam
27089 * G_{lam+1}' = R_{lam+1} G_lam - S_lam G_{lam+1}
27090 *
27091 * where S_lam and R_lam are as above in the F recursion.
27092 */
27093static
27094int
27095coulomb_G_recur(const double lam_min, const int kmax,
27096 const double eta, const double x,
27097 const double G_lam_min, const double Gp_lam_min,
27098 double * G_lam_max, double * Gp_lam_max
27099 )
27100{
27101 double x_inv = 1.0/x;
27102 double gcl = G_lam_min;
27103 double gpl = Gp_lam_min;
27104 double lam = lam_min + 1.0;
27105 int k;
27106
27107 for(k=1; k<=kmax; k++) {
27108 double el = eta/lam;
27109 double rl = hypot(1.0, el);
27110 double sl = el + lam*x_inv;
27111 double gcl1 = (sl*gcl - gpl)/rl;
27112 gpl = rl*gcl - sl*gcl1;
27113 gcl = gcl1;
27114 lam += 1.0;
27115 }
27116
27117 *G_lam_max = gcl;
27118 *Gp_lam_max = gpl;
27119 return GSL_SUCCESS;
27120}
27121
27122
27123/* Evaluate the first continued fraction, giving
27124 * the ratio F'/F at the upper lambda value.
27125 * We also determine the sign of F at that point,
27126 * since it is the sign of the last denominator
27127 * in the continued fraction.
27128 */
27129static
27130int
27131coulomb_CF1(double lambda,
27132 double eta, double x,
27133 double * fcl_sign,
27134 double * result,
27135 int * count
27136 )
27137{
27138 const double CF1_small = 1.e-30;
27139 const double CF1_abort = 1.0e+05;
27140 const double CF1_acc = 2.0*GSL_DBL_EPSILON;
27141 const double x_inv = 1.0/x;
27142 const double px = lambda + 1.0 + CF1_abort;
27143
27144 double pk = lambda + 1.0;
27145 double F = eta/pk + pk*x_inv;
27146 double D, C;
27147 double df;
27148
27149 *fcl_sign = 1.0;
27150 *count = 0;
27151
27152 if(fabs(F) < CF1_small) F = CF1_small;
27153 D = 0.0;
27154 C = F;
27155
27156 do {
27157 double pk1 = pk + 1.0;
27158 double ek = eta / pk;
27159 double rk2 = 1.0 + ek*ek;
27160 double tk = (pk + pk1)*(x_inv + ek/pk1);
27161 D = tk - rk2 * D;
27162 C = tk - rk2 / C;
27163 if(fabs(C) < CF1_small) C = CF1_small;
27164 if(fabs(D) < CF1_small) D = CF1_small;
27165 D = 1.0/D;
27166 df = D * C;
27167 F = F * df;
27168 if(D < 0.0) {
27169 /* sign of result depends on sign of denominator */
27170 *fcl_sign = - *fcl_sign;
27171 }
27172 pk = pk1;
27173 if( pk > px ) {
27174 *result = F;
27175 GSL_ERROR ("error", GSL_ERUNAWAY);
27176 }
27177 ++(*count);
27178 }
27179 while(fabs(df-1.0) > CF1_acc);
27180
27181 *result = F;
27182 return GSL_SUCCESS;
27183}
27184
27185
27186#if 0
27187static
27188int
27189old_coulomb_CF1(const double lambda,
27190 double eta, double x,
27191 double * fcl_sign,
27192 double * result
27193 )
27194{
27195 const double CF1_abort = 1.e5;
27196 const double CF1_acc = 10.0*GSL_DBL_EPSILON;
27197 const double x_inv = 1.0/x;
27198 const double px = lambda + 1.0 + CF1_abort;
27199
27200 double pk = lambda + 1.0;
27201
27202 double D;
27203 double df;
27204
27205 double F;
27206 double p;
27207 double pk1;
27208 double ek;
27209
27210 double fcl = 1.0;
27211
27212 double tk;
27213
27214 while(1) {
27215 ek = eta/pk;
27216 F = (ek + pk*x_inv)*fcl + (fcl - 1.0)*x_inv;
27217 pk1 = pk + 1.0;
27218 if(fabs(eta*x + pk*pk1) > CF1_acc) break;
27219 fcl = (1.0 + ek*ek)/(1.0 + eta*eta/(pk1*pk1));
27220 pk = 2.0 + pk;
27221 }
27222
27223 D = 1.0/((pk + pk1)*(x_inv + ek/pk1));
27224 df = -fcl*(1.0 + ek*ek)*D;
27225
27226 if(fcl != 1.0) fcl = -1.0;
27227 if(D < 0.0) fcl = -fcl;
27228
27229 F = F + df;
27230
27231 p = 1.0;
27232 do {
27233 pk = pk1;
27234 pk1 = pk + 1.0;
27235 ek = eta / pk;
27236 tk = (pk + pk1)*(x_inv + ek/pk1);
27237 D = tk - D*(1.0+ek*ek);
27238 if(fabs(D) < sqrt(CF1_acc)) {
27239 p += 1.0;
27240 if(p > 2.0) {
27241 printf("HELP............\n");
27242 }
27243 }
27244 D = 1.0/D;
27245 if(D < 0.0) {
27246 /* sign of result depends on sign of denominator */
27247 fcl = -fcl;
27248 }
27249 df = df*(D*tk - 1.0);
27250 F = F + df;
27251 if( pk > px ) {
27252 GSL_ERROR ("error", GSL_ERUNAWAY);
27253 }
27254 }
27255 while(fabs(df) > fabs(F)*CF1_acc);
27256
27257 *fcl_sign = fcl;
27258 *result = F;
27259 return GSL_SUCCESS;
27260}
27261#endif /* 0 */
27262
27263
27264/* Evaluate the second continued fraction to
27265 * obtain the ratio
27266 * (G' + i F')/(G + i F) := P + i Q
27267 * at the specified lambda value.
27268 */
27269static
27270int
27271coulomb_CF2(const double lambda, const double eta, const double x,
27272 double * result_P, double * result_Q, int * count
27273 )
27274{
27275 int status = GSL_SUCCESS;
27276
27277 const double CF2_acc = 4.0*GSL_DBL_EPSILON;
27278 const double CF2_abort = 2.0e+05;
27279
27280 const double wi = 2.0*eta;
27281 const double x_inv = 1.0/x;
27282 const double e2mm1 = eta*eta + lambda*(lambda + 1.0);
27283
27284 double ar = -e2mm1;
27285 double ai = eta;
27286
27287 double br = 2.0*(x - eta);
27288 double bi = 2.0;
27289
27290 double dr = br/(br*br + bi*bi);
27291 double di = -bi/(br*br + bi*bi);
27292
27293 double dp = -x_inv*(ar*di + ai*dr);
27294 double dq = x_inv*(ar*dr - ai*di);
27295
27296 double A, B, C, D;
27297
27298 double pk = 0.0;
27299 double P = 0.0;
27300 double Q = 1.0 - eta*x_inv;
27301
27302 *count = 0;
27303
27304 do {
27305 P += dp;
27306 Q += dq;
27307 pk += 2.0;
27308 ar += pk;
27309 ai += wi;
27310 bi += 2.0;
27311 D = ar*dr - ai*di + br;
27312 di = ai*dr + ar*di + bi;
27313 C = 1.0/(D*D + di*di);
27314 dr = C*D;
27315 di = -C*di;
27316 A = br*dr - bi*di - 1.;
27317 B = bi*dr + br*di;
27318 C = dp*A - dq*B;
27319 dq = dp*B + dq*A;
27320 dp = C;
27321 if(pk > CF2_abort) {
27322 status = GSL_ERUNAWAY;
27323 break;
27324 }
27325 ++(*count);
27326 }
27327 while(fabs(dp)+fabs(dq) > (fabs(P)+fabs(Q))*CF2_acc);
27328
27329 if(Q < CF2_abort*GSL_DBL_EPSILON*fabs(P)) {
27330 status = GSL_ELOSS;
27331 }
27332
27333 *result_P = P;
27334 *result_Q = Q;
27335 return status;
27336}
27337
27338
27339/* WKB evaluation of F, G. Assumes 0 < x < turning point.
27340 * Overflows are trapped, GSL_EOVRFLW is signalled,
27341 * and an exponent is returned such that:
27342 *
27343 * result_F = fjwkb * exp(-exponent)
27344 * result_G = gjwkb * exp( exponent)
27345 *
27346 * See [Biedenharn et al. Phys. Rev. 97, 542-554 (1955), Section IV]
27347 *
27348 * Unfortunately, this is not very accurate in general. The
27349 * test cases typically have 3-4 digits of precision. One could
27350 * argue that this is ok for general use because, for instance,
27351 * F is exponentially small in this region and so the absolute
27352 * accuracy is still roughly acceptable. But it would be better
27353 * to have a systematic method for improving the precision. See
27354 * the Abad+Sesma method discussion below.
27355 */
27356static
27357int
27358coulomb_jwkb(const double lam, const double eta, const double x,
27359 gsl_sf_result * fjwkb, gsl_sf_result * gjwkb,
27360 double * exponent)
27361{
27362 const double llp1 = lam*(lam+1.0) + 6.0/35.0;
27363 const double llp1_eff = GSL_MAX(llp1, 0.0);
27364 const double rho_ghalf = sqrt(x*(2.0*eta - x) + llp1_eff);
27365 const double sinh_arg = sqrt(llp1_eff/(eta*eta+llp1_eff)) * rho_ghalf / x;
27366 const double sinh_inv = log(sinh_arg + hypot(1.0,sinh_arg));
27367
27368 const double phi = fabs(rho_ghalf - eta*atan2(rho_ghalf,x-eta) - sqrt(llp1_eff) * sinh_inv);
27369
27370 const double zeta_half = pow(3.0*phi/2.0, 1.0/3.0);
27371 const double prefactor = sqrt(M_PI*phi*x/(6.0 * rho_ghalf));
27372
27373 double F = prefactor * 3.0/zeta_half;
27374 double G = prefactor * 3.0/zeta_half; /* Note the sqrt(3) from Bi normalization */
27375 double F_exp;
27376 double G_exp;
27377
27378 const double airy_scale_exp = phi;
27379 gsl_sf_result ai;
27380 gsl_sf_result bi;
27381 gsl_sf_airy_Ai_scaled_e(zeta_half*zeta_half, GSL_MODE_DEFAULT, &ai);
27382 gsl_sf_airy_Bi_scaled_e(zeta_half*zeta_half, GSL_MODE_DEFAULT, &bi);
27383 F *= ai.val;
27384 G *= bi.val;
27385 F_exp = log(F) - airy_scale_exp;
27386 G_exp = log(G) + airy_scale_exp;
27387
27388 if(G_exp >= GSL_LOG_DBL_MAX) {
27389 fjwkb->val = F;
27390 gjwkb->val = G;
27391 fjwkb->err = 1.0e-3 * fabs(F); /* FIXME: real error here ... could be smaller */
27392 gjwkb->err = 1.0e-3 * fabs(G);
27393 *exponent = airy_scale_exp;
27394 GSL_ERROR ("error", GSL_EOVRFLW);
27395 }
27396 else {
27397 fjwkb->val = exp(F_exp);
27398 gjwkb->val = exp(G_exp);
27399 fjwkb->err = 1.0e-3 * fabs(fjwkb->val);
27400 gjwkb->err = 1.0e-3 * fabs(gjwkb->val);
27401 *exponent = 0.0;
27402 return GSL_SUCCESS;
27403 }
27404}
27405
27406
27407/* Asymptotic evaluation of F and G below the minimal turning point.
27408 *
27409 * This is meant to be a drop-in replacement for coulomb_jwkb().
27410 * It uses the expressions in [Abad+Sesma]. This requires some
27411 * work because I am not sure where it is valid. They mumble
27412 * something about |x| < |lam|^(-1/2) or 8|eta x| > lam when |x| < 1.
27413 * This seems true, but I thought the result was based on a uniform
27414 * expansion and could be controlled by simply using more terms.
27415 */
27416#if 0
27417static
27418int
27419coulomb_AS_xlt2eta(const double lam, const double eta, const double x,
27420 gsl_sf_result * f_AS, gsl_sf_result * g_AS,
27421 double * exponent)
27422{
27423 /* no time to do this now... */
27424}
27425#endif /* 0 */
27426
27427
27428
27429/*-*-*-*-*-*-*-*-*-*-*-* Functions with Error Codes *-*-*-*-*-*-*-*-*-*-*-*/
27430
27431int
27432gsl_sf_coulomb_wave_FG_e(const double eta, const double x,
27433 const double lam_F,
27434 const int k_lam_G, /* lam_G = lam_F - k_lam_G */
27435 gsl_sf_result * F, gsl_sf_result * Fp,
27436 gsl_sf_result * G, gsl_sf_result * Gp,
27437 double * exp_F, double * exp_G)
27438{
27439 const double lam_G = lam_F - k_lam_G;
27440
27441 if(x < 0.0 || lam_F <= -0.5 || lam_G <= -0.5) {
27442 GSL_SF_RESULT_SET(F, 0.0, 0.0);
27443 GSL_SF_RESULT_SET(Fp, 0.0, 0.0);
27444 GSL_SF_RESULT_SET(G, 0.0, 0.0);
27445 GSL_SF_RESULT_SET(Gp, 0.0, 0.0);
27446 *exp_F = 0.0;
27447 *exp_G = 0.0;
27448 GSL_ERROR ("domain error", GSL_EDOM);
27449 }
27450 else if(x == 0.0) {
27451 gsl_sf_result C0;
27452 CLeta(0.0, eta, &C0);
27453 GSL_SF_RESULT_SET(F, 0.0, 0.0);
27454 GSL_SF_RESULT_SET(Fp, 0.0, 0.0);
27455 GSL_SF_RESULT_SET(G, 0.0, 0.0); /* FIXME: should be Inf */
27456 GSL_SF_RESULT_SET(Gp, 0.0, 0.0); /* FIXME: should be Inf */
27457 *exp_F = 0.0;
27458 *exp_G = 0.0;
27459 if(lam_F == 0.0){
27460 GSL_SF_RESULT_SET(Fp, C0.val, C0.err);
27461 }
27462 if(lam_G == 0.0) {
27463 GSL_SF_RESULT_SET(Gp, 1.0/C0.val, fabs(C0.err/C0.val)/fabs(C0.val));
27464 }
27465 GSL_ERROR ("domain error", GSL_EDOM);
27466 /* After all, since we are asking for G, this is a domain error... */
27467 }
27468 else if(x < 1.2 && 2.0*M_PI*eta < 0.9*(-GSL_LOG_DBL_MIN) && fabs(eta*x) < 10.0) {
27469 /* Reduce to a small lambda value and use the series
27470 * representations for F and G. We cannot allow eta to
27471 * be large and positive because the connection formula
27472 * for G_lam is badly behaved due to an underflow in sin(phi_lam)
27473 * [see coulomb_FG_series() and coulomb_connection() above].
27474 * Note that large negative eta is ok however.
27475 */
27476 const double SMALL = GSL_SQRT_DBL_EPSILON;
27477 const int N = (int)(lam_F + 0.5);
27478 const int span = GSL_MAX(k_lam_G, N);
27479 const double lam_min = lam_F - N; /* -1/2 <= lam_min < 1/2 */
27480 double F_lam_F, Fp_lam_F;
27481 double G_lam_G = 0.0, Gp_lam_G = 0.0;
27482 double F_lam_F_err, Fp_lam_F_err;
27483 double Fp_over_F_lam_F;
27484 double F_sign_lam_F;
27485 double F_lam_min_unnorm, Fp_lam_min_unnorm;
27486 double Fp_over_F_lam_min;
27487 gsl_sf_result F_lam_min;
27488 gsl_sf_result G_lam_min, Gp_lam_min;
27489 double F_scale;
27490 double Gerr_frac;
27491 double F_scale_frac_err;
27492 double F_unnorm_frac_err;
27493
27494 /* Determine F'/F at lam_F. */
27495 int CF1_count;
27496 int stat_CF1 = coulomb_CF1(lam_F, eta, x, &F_sign_lam_F, &Fp_over_F_lam_F, &CF1_count);
27497
27498 int stat_ser;
27499 int stat_Fr;
27500 int stat_Gr;
27501
27502 /* Recurse down with unnormalized F,F' values. */
27503 F_lam_F = SMALL;
27504 Fp_lam_F = Fp_over_F_lam_F * F_lam_F;
27505 if(span != 0) {
27506 stat_Fr = coulomb_F_recur(lam_min, span, eta, x,
27507 F_lam_F, Fp_lam_F,
27508 &F_lam_min_unnorm, &Fp_lam_min_unnorm
27509 );
27510 }
27511 else {
27512 F_lam_min_unnorm = F_lam_F;
27513 Fp_lam_min_unnorm = Fp_lam_F;
27514 stat_Fr = GSL_SUCCESS;
27515 }
27516
27517 /* Determine F and G at lam_min. */
27518 if(lam_min == -0.5) {
27519 stat_ser = coulomb_FGmhalf_series(eta, x, &F_lam_min, &G_lam_min);
27520 }
27521 else if(lam_min == 0.0) {
27522 stat_ser = coulomb_FG0_series(eta, x, &F_lam_min, &G_lam_min);
27523 }
27524 else if(lam_min == 0.5) {
27525 /* This cannot happen. */
27526 F->val = F_lam_F;
27527 F->err = 2.0 * GSL_DBL_EPSILON * fabs(F->val);
27528 Fp->val = Fp_lam_F;
27529 Fp->err = 2.0 * GSL_DBL_EPSILON * fabs(Fp->val);
27530 G->val = G_lam_G;
27531 G->err = 2.0 * GSL_DBL_EPSILON * fabs(G->val);
27532 Gp->val = Gp_lam_G;
27533 Gp->err = 2.0 * GSL_DBL_EPSILON * fabs(Gp->val);
27534 *exp_F = 0.0;
27535 *exp_G = 0.0;
27536 GSL_ERROR ("error", GSL_ESANITY);
27537 }
27538 else {
27539 stat_ser = coulomb_FG_series(lam_min, eta, x, &F_lam_min, &G_lam_min);
27540 }
27541
27542 /* Determine remaining quantities. */
27543 Fp_over_F_lam_min = Fp_lam_min_unnorm / F_lam_min_unnorm;
27544 Gp_lam_min.val = Fp_over_F_lam_min*G_lam_min.val - 1.0/F_lam_min.val;
27545 Gp_lam_min.err = fabs(Fp_over_F_lam_min)*G_lam_min.err;
27546 Gp_lam_min.err += fabs(1.0/F_lam_min.val) * fabs(F_lam_min.err/F_lam_min.val);
27547 F_scale = F_lam_min.val / F_lam_min_unnorm;
27548
27549 /* Apply scale to the original F,F' values. */
27550 F_scale_frac_err = fabs(F_lam_min.err/F_lam_min.val);
27551 F_unnorm_frac_err = 2.0*GSL_DBL_EPSILON*(CF1_count+span+1);
27552 F_lam_F *= F_scale;
27553 F_lam_F_err = fabs(F_lam_F) * (F_unnorm_frac_err + F_scale_frac_err);
27554 Fp_lam_F *= F_scale;
27555 Fp_lam_F_err = fabs(Fp_lam_F) * (F_unnorm_frac_err + F_scale_frac_err);
27556
27557 /* Recurse up to get the required G,G' values. */
27558 stat_Gr = coulomb_G_recur(lam_min, GSL_MAX(N-k_lam_G,0), eta, x,
27559 G_lam_min.val, Gp_lam_min.val,
27560 &G_lam_G, &Gp_lam_G
27561 );
27562
27563 F->val = F_lam_F;
27564 F->err = F_lam_F_err;
27565 F->err += 2.0 * GSL_DBL_EPSILON * fabs(F_lam_F);
27566
27567 Fp->val = Fp_lam_F;
27568 Fp->err = Fp_lam_F_err;
27569 Fp->err += 2.0 * GSL_DBL_EPSILON * fabs(Fp_lam_F);
27570
27571 Gerr_frac = fabs(G_lam_min.err/G_lam_min.val) + fabs(Gp_lam_min.err/Gp_lam_min.val);
27572
27573 G->val = G_lam_G;
27574 G->err = Gerr_frac * fabs(G_lam_G);
27575 G->err += 2.0 * (CF1_count+1) * GSL_DBL_EPSILON * fabs(G->val);
27576
27577 Gp->val = Gp_lam_G;
27578 Gp->err = Gerr_frac * fabs(Gp->val);
27579 Gp->err += 2.0 * (CF1_count+1) * GSL_DBL_EPSILON * fabs(Gp->val);
27580
27581 *exp_F = 0.0;
27582 *exp_G = 0.0;
27583
27584 return GSL_ERROR_SELECT_4(stat_ser, stat_CF1, stat_Fr, stat_Gr);
27585 }
27586 else if(x < 2.0*eta) {
27587 /* Use WKB approximation to obtain F and G at the two
27588 * lambda values, and use the Wronskian and the
27589 * continued fractions for F'/F to obtain F' and G'.
27590 */
27591 gsl_sf_result F_lam_F, G_lam_F;
27592 gsl_sf_result F_lam_G, G_lam_G;
27593 double exp_lam_F, exp_lam_G;
27594 int stat_lam_F;
27595 int stat_lam_G;
27596 int stat_CF1_lam_F;
27597 [[maybe_unused]] int stat_CF1_lam_G;
27598 int CF1_count;
27599 double Fp_over_F_lam_F;
27600 double Fp_over_F_lam_G;
27601 double F_sign_lam_F;
27602 double F_sign_lam_G;
27603
27604 stat_lam_F = coulomb_jwkb(lam_F, eta, x, &F_lam_F, &G_lam_F, &exp_lam_F);
27605 if(k_lam_G == 0) {
27606 stat_lam_G = stat_lam_F;
27607 F_lam_G = F_lam_F;
27608 G_lam_G = G_lam_F;
27609 exp_lam_G = exp_lam_F;
27610 }
27611 else {
27612 stat_lam_G = coulomb_jwkb(lam_G, eta, x, &F_lam_G, &G_lam_G, &exp_lam_G);
27613 }
27614
27615 stat_CF1_lam_F = coulomb_CF1(lam_F, eta, x, &F_sign_lam_F, &Fp_over_F_lam_F, &CF1_count);
27616 if(k_lam_G == 0) {
27617 stat_CF1_lam_G = stat_CF1_lam_F;
27618 F_sign_lam_G = F_sign_lam_F;
27619 Fp_over_F_lam_G = Fp_over_F_lam_F;
27620 }
27621 else {
27622 stat_CF1_lam_G = coulomb_CF1(lam_G, eta, x, &F_sign_lam_G, &Fp_over_F_lam_G, &CF1_count);
27623 }
27624
27625 F->val = F_lam_F.val;
27626 F->err = F_lam_F.err;
27627
27628 G->val = G_lam_G.val;
27629 G->err = G_lam_G.err;
27630
27631 Fp->val = Fp_over_F_lam_F * F_lam_F.val;
27632 Fp->err = fabs(Fp_over_F_lam_F) * F_lam_F.err;
27633 Fp->err += 2.0*GSL_DBL_EPSILON*fabs(Fp->val);
27634
27635 Gp->val = Fp_over_F_lam_G * G_lam_G.val - 1.0/F_lam_G.val;
27636 Gp->err = fabs(Fp_over_F_lam_G) * G_lam_G.err;
27637 Gp->err += fabs(1.0/F_lam_G.val) * fabs(F_lam_G.err/F_lam_G.val);
27638
27639 *exp_F = exp_lam_F;
27640 *exp_G = exp_lam_G;
27641
27642 if(stat_lam_F == GSL_EOVRFLW || stat_lam_G == GSL_EOVRFLW) {
27643 GSL_ERROR ("overflow", GSL_EOVRFLW);
27644 }
27645 else {
27646 return GSL_ERROR_SELECT_2(stat_lam_F, stat_lam_G);
27647 }
27648 }
27649 else {
27650 /* x > 2 eta, so we know that we can find a lambda value such
27651 * that x is above the turning point. We do this, evaluate
27652 * using Steed's method at that oscillatory point, then
27653 * use recursion on F and G to obtain the required values.
27654 *
27655 * lam_0 = a value of lambda such that x is below the turning point
27656 * lam_min = minimum of lam_0 and the requested lam_G, since
27657 * we must go at least as low as lam_G
27658 */
27659 const double SMALL = GSL_SQRT_DBL_EPSILON;
27660 const double C = sqrt(1.0 + 4.0*x*(x-2.0*eta));
27661 const int N = ceil(lam_F - C + 0.5);
27662 const double lam_0 = lam_F - GSL_MAX(N, 0);
27663 const double lam_min = GSL_MIN(lam_0, lam_G);
27664 double F_lam_F, Fp_lam_F;
27665 double G_lam_G, Gp_lam_G;
27666 double F_lam_min_unnorm, Fp_lam_min_unnorm;
27667 double F_lam_min;
27668 [[maybe_unused]] double Fp_lam_min;
27669 double G_lam_min, Gp_lam_min;
27670 double Fp_over_F_lam_F;
27671 double Fp_over_F_lam_min;
27672 double F_sign_lam_F, F_sign_lam_min;
27673 double P_lam_min, Q_lam_min;
27674 double alpha;
27675 double gamma;
27676 double F_scale;
27677
27678 int CF1_count;
27679 int CF2_count;
27680 int stat_CF1 = coulomb_CF1(lam_F, eta, x, &F_sign_lam_F, &Fp_over_F_lam_F, &CF1_count);
27681 int stat_CF2;
27682 int stat_Fr;
27683 int stat_Gr;
27684
27685 int F_recur_count;
27686 int G_recur_count;
27687
27688 double err_amplify;
27689
27690 F_lam_F = F_sign_lam_F * SMALL; /* unnormalized */
27691 Fp_lam_F = Fp_over_F_lam_F * F_lam_F;
27692
27693 /* Backward recurrence to get F,Fp at lam_min */
27694 F_recur_count = GSL_MAX(k_lam_G, N);
27695 stat_Fr = coulomb_F_recur(lam_min, F_recur_count, eta, x,
27696 F_lam_F, Fp_lam_F,
27697 &F_lam_min_unnorm, &Fp_lam_min_unnorm
27698 );
27699 Fp_over_F_lam_min = Fp_lam_min_unnorm / F_lam_min_unnorm;
27700
27701 /* Steed evaluation to complete evaluation of F,Fp,G,Gp at lam_min */
27702 stat_CF2 = coulomb_CF2(lam_min, eta, x, &P_lam_min, &Q_lam_min, &CF2_count);
27703 alpha = Fp_over_F_lam_min - P_lam_min;
27704 gamma = alpha/Q_lam_min;
27705
27706 F_sign_lam_min = GSL_SIGN(F_lam_min_unnorm) ;
27707
27708 F_lam_min = F_sign_lam_min / sqrt(alpha*alpha/Q_lam_min + Q_lam_min);
27709 Fp_lam_min = Fp_over_F_lam_min * F_lam_min;
27710 G_lam_min = gamma * F_lam_min;
27711 Gp_lam_min = (P_lam_min * gamma - Q_lam_min) * F_lam_min;
27712
27713 /* Apply scale to values of F,Fp at lam_F (the top). */
27714 F_scale = F_lam_min / F_lam_min_unnorm;
27715 F_lam_F *= F_scale;
27716 Fp_lam_F *= F_scale;
27717
27718 /* Forward recurrence to get G,Gp at lam_G (the top). */
27719 G_recur_count = GSL_MAX(N-k_lam_G,0);
27720 stat_Gr = coulomb_G_recur(lam_min, G_recur_count, eta, x,
27721 G_lam_min, Gp_lam_min,
27722 &G_lam_G, &Gp_lam_G
27723 );
27724
27725 err_amplify = CF1_count + CF2_count + F_recur_count + G_recur_count + 1;
27726
27727 F->val = F_lam_F;
27728 F->err = 8.0*err_amplify*GSL_DBL_EPSILON * fabs(F->val);
27729
27730 Fp->val = Fp_lam_F;
27731 Fp->err = 8.0*err_amplify*GSL_DBL_EPSILON * fabs(Fp->val);
27732
27733 G->val = G_lam_G;
27734 G->err = 8.0*err_amplify*GSL_DBL_EPSILON * fabs(G->val);
27735
27736 Gp->val = Gp_lam_G;
27737 Gp->err = 8.0*err_amplify*GSL_DBL_EPSILON * fabs(Gp->val);
27738
27739 *exp_F = 0.0;
27740 *exp_G = 0.0;
27741
27742 return GSL_ERROR_SELECT_4(stat_CF1, stat_CF2, stat_Fr, stat_Gr);
27743 }
27744}
27745
27746
27747int
27748gsl_sf_coulomb_wave_FG_array(double lam_min, int kmax,
27749 double eta, double x,
27750 double * fc_array, double * gc_array,
27751 double * F_exp, double * G_exp)
27752{
27753 const double x_inv = 1.0/x;
27754 const double lam_max = lam_min + kmax;
27755 gsl_sf_result F, Fp;
27756 gsl_sf_result G, Gp;
27757
27758 int stat_FG = gsl_sf_coulomb_wave_FG_e(eta, x, lam_max, kmax,
27759 &F, &Fp, &G, &Gp, F_exp, G_exp);
27760
27761 double fcl = F.val;
27762 double fpl = Fp.val;
27763 double lam = lam_max;
27764 int k;
27765
27766 double gcl, gpl;
27767
27768 fc_array[kmax] = F.val;
27769
27770 for(k=kmax-1; k>=0; k--) {
27771 double el = eta/lam;
27772 double rl = hypot(1.0, el);
27773 double sl = el + lam*x_inv;
27774 double fc_lm1;
27775 fc_lm1 = (fcl*sl + fpl)/rl;
27776 fc_array[k] = fc_lm1;
27777 fpl = fc_lm1*sl - fcl*rl;
27778 fcl = fc_lm1;
27779 lam -= 1.0;
27780 }
27781
27782 gcl = G.val;
27783 gpl = Gp.val;
27784 lam = lam_min + 1.0;
27785
27786 gc_array[0] = G.val;
27787
27788 for(k=1; k<=kmax; k++) {
27789 double el = eta/lam;
27790 double rl = hypot(1.0, el);
27791 double sl = el + lam*x_inv;
27792 double gcl1 = (sl*gcl - gpl)/rl;
27793 gc_array[k] = gcl1;
27794 gpl = rl*gcl - sl*gcl1;
27795 gcl = gcl1;
27796 lam += 1.0;
27797 }
27798
27799 return stat_FG;
27800}
27801
27802
27803/* end inlined source: specfunc/coulomb.c */
27804 /* gsl_sf_coulomb_wave_FG_array (future) */
27805
27806
27807/* ======================================================================== */
27808/* cdf/chi-squared support: erfc, gamma_inc, cdf/gamma, cdf/chisq */
27809/* ======================================================================== */
27810
27811/* begin inlined source: specfunc/erfc.c (gsl_sf_erfc_e only) */
27812/* specfunc/erfc.c
27813 *
27814 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 Gerard Jungman
27815 *
27816 * This program is free software; you can redistribute it and/or modify
27817 * it under the terms of the GNU General Public License as published by
27818 * the Free Software Foundation; either version 3 of the License, or (at
27819 * your option) any later version.
27820 *
27821 * This program is distributed in the hope that it will be useful, but
27822 * WITHOUT ANY WARRANTY; without even the implied warranty of
27823 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27824 * General Public License for more details.
27825 *
27826 * You should have received a copy of the GNU General Public License
27827 * along with this program; if not, write to the Free Software
27828 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27829 */
27830
27831/* Author: J. Theiler (modifications by G. Jungman) */
27832
27833
27834/* (stripped: #include directives — already handled above) */
27835/* (only gsl_sf_erfc_e is included; log_erfc, erf, erf_Z, erf_Q, hazard
27836 * are omitted as they are not needed by MARLEY) */
27837
27838#define LogRootPi_ 0.57236494292470008706
27839
27840
27841static double erfc8_sum(double x)
27842{
27843 /* estimates erfc(x) valid for 8 < x < 100 */
27844 /* This is based on index 5725 in Hart et al */
27845
27846 static double P[] = {
27847 2.97886562639399288862,
27848 7.409740605964741794425,
27849 6.1602098531096305440906,
27850 5.019049726784267463450058,
27851 1.275366644729965952479585264,
27852 0.5641895835477550741253201704
27853 };
27854 static double Q[] = {
27855 3.3690752069827527677,
27856 9.608965327192787870698,
27857 17.08144074746600431571095,
27858 12.0489519278551290360340491,
27859 9.396034016235054150430579648,
27860 2.260528520767326969591866945,
27861 1.0
27862 };
27863 double num=0.0, den=0.0;
27864 int i;
27865
27866 num = P[5];
27867 for (i=4; i>=0; --i) {
27868 num = x*num + P[i];
27869 }
27870 den = Q[6];
27871 for (i=5; i>=0; --i) {
27872 den = x*den + Q[i];
27873 }
27874
27875 return num/den;
27876}
27877
27878inline
27879static double erfc8(double x)
27880{
27881 double e;
27882 e = erfc8_sum(x);
27883 e *= exp(-x*x);
27884 return e;
27885}
27886
27887#if 0
27888/* Abramowitz+Stegun, 7.2.14 */
27889static double erfcasympsum(double x)
27890{
27891 int i;
27892 double e = 1.;
27893 double coef = 1.;
27894 for (i=1; i<5; ++i) {
27895 /* coef *= -(2*i-1)/(2*x*x); ??? [GJ] */
27896 coef *= -(2*i+1)/(i*(4*x*x*x*x));
27897 e += coef;
27898 /*
27899 if (fabs(coef) < 1.0e-15) break;
27900 if (fabs(coef) > 1.0e10) break;
27901
27902 [GJ]: These tests are not useful. This function is only
27903 used below. Took them out; they gum up the pipeline.
27904 */
27905 }
27906 return e;
27907}
27908#endif /* 0 */
27909
27910
27911/* Chebyshev fit for erfc((t+1)/2), -1 < t < 1
27912 */
27913static double erfc_xlt1_data[20] = {
27914 1.06073416421769980345174155056,
27915 -0.42582445804381043569204735291,
27916 0.04955262679620434040357683080,
27917 0.00449293488768382749558001242,
27918 -0.00129194104658496953494224761,
27919 -0.00001836389292149396270416979,
27920 0.00002211114704099526291538556,
27921 -5.23337485234257134673693179020e-7,
27922 -2.78184788833537885382530989578e-7,
27923 1.41158092748813114560316684249e-8,
27924 2.72571296330561699984539141865e-9,
27925 -2.06343904872070629406401492476e-10,
27926 -2.14273991996785367924201401812e-11,
27927 2.22990255539358204580285098119e-12,
27928 1.36250074650698280575807934155e-13,
27929 -1.95144010922293091898995913038e-14,
27930 -6.85627169231704599442806370690e-16,
27931 1.44506492869699938239521607493e-16,
27932 2.45935306460536488037576200030e-18,
27933 -9.29599561220523396007359328540e-19
27934};
27935static cheb_series erfc_xlt1_cs = {
27936 erfc_xlt1_data,
27937 19,
27938 -1, 1,
27939 12
27940};
27941
27942/* Chebyshev fit for erfc(x) exp(x^2), 1 < x < 5, x = 2t + 3, -1 < t < 1
27943 */
27944static double erfc_x15_data[25] = {
27945 0.44045832024338111077637466616,
27946 -0.143958836762168335790826895326,
27947 0.044786499817939267247056666937,
27948 -0.013343124200271211203618353102,
27949 0.003824682739750469767692372556,
27950 -0.001058699227195126547306482530,
27951 0.000283859419210073742736310108,
27952 -0.000073906170662206760483959432,
27953 0.000018725312521489179015872934,
27954 -4.62530981164919445131297264430e-6,
27955 1.11558657244432857487884006422e-6,
27956 -2.63098662650834130067808832725e-7,
27957 6.07462122724551777372119408710e-8,
27958 -1.37460865539865444777251011793e-8,
27959 3.05157051905475145520096717210e-9,
27960 -6.65174789720310713757307724790e-10,
27961 1.42483346273207784489792999706e-10,
27962 -3.00141127395323902092018744545e-11,
27963 6.22171792645348091472914001250e-12,
27964 -1.26994639225668496876152836555e-12,
27965 2.55385883033257575402681845385e-13,
27966 -5.06258237507038698392265499770e-14,
27967 9.89705409478327321641264227110e-15,
27968 -1.90685978789192181051961024995e-15,
27969 3.50826648032737849245113757340e-16
27970};
27971static cheb_series erfc_x15_cs = {
27972 erfc_x15_data,
27973 24,
27974 -1, 1,
27975 16
27976};
27977
27978/* Chebyshev fit for erfc(x) x exp(x^2), 5 < x < 10, x = (5t + 15)/2, -1 < t < 1
27979 */
27980static double erfc_x510_data[20] = {
27981 1.11684990123545698684297865808,
27982 0.003736240359381998520654927536,
27983 -0.000916623948045470238763619870,
27984 0.000199094325044940833965078819,
27985 -0.000040276384918650072591781859,
27986 7.76515264697061049477127605790e-6,
27987 -1.44464794206689070402099225301e-6,
27988 2.61311930343463958393485241947e-7,
27989 -4.61833026634844152345304095560e-8,
27990 8.00253111512943601598732144340e-9,
27991 -1.36291114862793031395712122089e-9,
27992 2.28570483090160869607683087722e-10,
27993 -3.78022521563251805044056974560e-11,
27994 6.17253683874528285729910462130e-12,
27995 -9.96019290955316888445830597430e-13,
27996 1.58953143706980770269506726000e-13,
27997 -2.51045971047162509999527428316e-14,
27998 3.92607828989125810013581287560e-15,
27999 -6.07970619384160374392535453420e-16,
28000 9.12600607264794717315507477670e-17
28001};
28002static cheb_series erfc_x510_cs = {
28003 erfc_x510_data,
28004 19,
28005 -1, 1,
28006 12
28007};
28008
28009#if 0
28010inline
28011static double
28012erfc_asymptotic(double x)
28013{
28014 return exp(-x*x)/x * erfcasympsum(x) / M_SQRTPI;
28015}
28016inline
28017static double
28018log_erfc_asymptotic(double x)
28019{
28020 return log(erfcasympsum(x)/x) - x*x - LogRootPi_;
28021}
28022#endif /* 0 */
28023
28024
28025/*-*-*-*-*-*-*-*-*-*-*-* Functions with Error Codes *-*-*-*-*-*-*-*-*-*-*-*/
28026
28027int gsl_sf_erfc_e(double x, gsl_sf_result * result)
28028{
28029 const double ax = fabs(x);
28030 double e_val, e_err;
28031
28032 /* CHECK_POINTER(result) */
28033
28034 if(ax <= 1.0) {
28035 double t = 2.0*ax - 1.0;
28036 gsl_sf_result c;
28037 cheb_eval_e(&erfc_xlt1_cs, t, &c);
28038 e_val = c.val;
28039 e_err = c.err;
28040 }
28041 else if(ax <= 5.0) {
28042 double ex2 = exp(-x*x);
28043 double t = 0.5*(ax-3.0);
28044 gsl_sf_result c;
28045 cheb_eval_e(&erfc_x15_cs, t, &c);
28046 e_val = ex2 * c.val;
28047 e_err = ex2 * (c.err + 2.0*fabs(x)*GSL_DBL_EPSILON);
28048 }
28049 else if(ax < 10.0) {
28050 double exterm = exp(-x*x) / ax;
28051 double t = (2.0*ax - 15.0)/5.0;
28052 gsl_sf_result c;
28053 cheb_eval_e(&erfc_x510_cs, t, &c);
28054 e_val = exterm * c.val;
28055 e_err = exterm * (c.err + 2.0*fabs(x)*GSL_DBL_EPSILON + GSL_DBL_EPSILON);
28056 }
28057 else {
28058 e_val = erfc8(ax);
28059 e_err = (x*x + 1.0) * GSL_DBL_EPSILON * fabs(e_val);
28060 }
28061
28062 if(x < 0.0) {
28063 result->val = 2.0 - e_val;
28064 result->err = e_err;
28065 result->err += 2.0 * GSL_DBL_EPSILON * fabs(result->val);
28066 }
28067 else {
28068 result->val = e_val;
28069 result->err = e_err;
28070 result->err += 2.0 * GSL_DBL_EPSILON * fabs(result->val);
28071 }
28072
28073 return GSL_SUCCESS;
28074}
28075
28076/* end inlined source: specfunc/erfc.c */
28077
28078/* begin inlined source: specfunc/gamma_inc.c (gsl_sf_gamma_inc_P, gsl_sf_gamma_inc_Q only) */
28079/* specfunc/gamma_inc.c
28080 *
28081 * Copyright (C) 2007 Brian Gough
28082 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
28083 *
28084 * This program is free software; you can redistribute it and/or modify
28085 * it under the terms of the GNU General Public License as published by
28086 * the Free Software Foundation; either version 3 of the License, or (at
28087 * your option) any later version.
28088 *
28089 * This program is distributed in the hope that it will be useful, but
28090 * WITHOUT ANY WARRANTY; without even the implied warranty of
28091 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28092 * General Public License for more details.
28093 *
28094 * You should have received a copy of the GNU General Public License
28095 * along with this program; if not, write to the Free Software
28096 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28097 */
28098
28099/* Author: G. Jungman */
28100
28101
28102/* (stripped: #include directives — already handled above) */
28103/* (gsl_sf_gamma_inc_e omitted: requires gsl_sf_expint_E1_e not in this subset;
28104 * that function is not called by MARLEY) */
28105
28106/* The dominant part,
28107 * D(a,x) := x^a e^(-x) / Gamma(a+1)
28108 */
28109static
28110int
28111gamma_inc_D(const double a, const double x, gsl_sf_result * result)
28112{
28113 if(a < 10.0) {
28114 double lnr;
28115 gsl_sf_result lg;
28116 gsl_sf_lngamma_e(a+1.0, &lg);
28117 lnr = a * log(x) - x - lg.val;
28118 result->val = exp(lnr);
28119 result->err = 2.0 * GSL_DBL_EPSILON * (fabs(lnr) + 1.0) * fabs(result->val);
28120 return GSL_SUCCESS;
28121 }
28122 else {
28123 gsl_sf_result gstar;
28124 gsl_sf_result ln_term;
28125 double term1;
28126 if (x < 0.5*a) {
28127 double u = x/a;
28128 double ln_u = log(u);
28129 ln_term.val = ln_u - u + 1.0;
28130 ln_term.err = (fabs(ln_u) + fabs(u) + 1.0) * GSL_DBL_EPSILON;
28131 } else {
28132 double mu = (x-a)/a;
28133 gsl_sf_log_1plusx_mx_e(mu, &ln_term); /* log(1+mu) - mu */
28134 /* Propagate cancellation error from x-a, since the absolute
28135 error of mu=x-a is DBL_EPSILON */
28136 ln_term.err += GSL_DBL_EPSILON * fabs(mu);
28137 };
28138 gsl_sf_gammastar_e(a, &gstar);
28139 term1 = exp(a*ln_term.val)/sqrt(2.0*M_PI*a);
28140 result->val = term1/gstar.val;
28141 result->err = 2.0 * GSL_DBL_EPSILON * (fabs(a*ln_term.val) + 1.0) * fabs(result->val);
28142 /* Include propagated error from log term */
28143 result->err += fabs(a) * ln_term.err * fabs(result->val);
28144 result->err += gstar.err/fabs(gstar.val) * fabs(result->val);
28145 return GSL_SUCCESS;
28146 }
28147
28148}
28149
28150
28151/* P series representation.
28152 */
28153static
28154int
28155gamma_inc_P_series(const double a, const double x, gsl_sf_result * result)
28156{
28157 const int nmax = 10000;
28158
28159 gsl_sf_result D;
28160 int stat_D = gamma_inc_D(a, x, &D);
28161
28162 /* Approximating the terms of the series using Stirling's
28163 approximation gives t_n = (x/a)^n * exp(-n(n+1)/(2a)), so the
28164 convergence condition is n^2 / (2a) + (1-(x/a) + (1/2a)) n >>
28165 -log(GSL_DBL_EPS) if we want t_n < O(1e-16) t_0. The condition
28166 below detects cases where the minimum value of n is > 5000 */
28167
28168 if (x > 0.995 * a && a > 1e5) { /* Difficult case: try continued fraction */
28169 gsl_sf_result cf_res;
28170 int status = gsl_sf_exprel_n_CF_e(a, x, &cf_res);
28171 result->val = D.val * cf_res.val;
28172 result->err = fabs(D.val * cf_res.err) + fabs(D.err * cf_res.val);
28173 return status;
28174 }
28175
28176 /* Series would require excessive number of terms */
28177
28178 if (x > (a + nmax)) {
28179 GSL_ERROR ("gamma_inc_P_series x>>a exceeds range", GSL_EMAXITER);
28180 }
28181
28182 /* Normal case: sum the series */
28183
28184 {
28185 double sum = 1.0;
28186 double term = 1.0;
28187 double remainder;
28188 int n;
28189
28190 /* Handle lower part of the series where t_n is increasing, |x| > a+n */
28191
28192 int nlow = (x > a) ? (x - a): 0;
28193
28194 for(n=1; n < nlow; n++) {
28195 term *= x/(a+n);
28196 sum += term;
28197 }
28198
28199 /* Handle upper part of the series where t_n is decreasing, |x| < a+n */
28200
28201 for (/* n = previous n */ ; n<nmax; n++) {
28202 term *= x/(a+n);
28203 sum += term;
28204 if(fabs(term/sum) < GSL_DBL_EPSILON) break;
28205 }
28206
28207 /* Estimate remainder of series ~ t_(n+1)/(1-x/(a+n+1)) */
28208 {
28209 double tnp1 = (x/(a+n)) * term;
28210 remainder = tnp1 / (1.0 - x/(a + n + 1.0));
28211 }
28212
28213 result->val = D.val * sum;
28214 result->err = D.err * fabs(sum) + fabs(D.val * remainder);
28215 result->err += (1.0 + n) * GSL_DBL_EPSILON * fabs(result->val);
28216
28217 if(n == nmax && fabs(remainder/sum) > GSL_SQRT_DBL_EPSILON)
28218 GSL_ERROR ("gamma_inc_P_series failed to converge", GSL_EMAXITER);
28219 else
28220 return stat_D;
28221 }
28222}
28223
28224
28225/* Q large x asymptotic
28226 */
28227static
28228int
28229gamma_inc_Q_large_x(const double a, const double x, gsl_sf_result * result)
28230{
28231 const int nmax = 5000;
28232
28233 gsl_sf_result D;
28234 const int stat_D = gamma_inc_D(a, x, &D);
28235
28236 double sum = 1.0;
28237 double term = 1.0;
28238 double last = 1.0;
28239 int n;
28240 for(n=1; n<nmax; n++) {
28241 term *= (a-n)/x;
28242 if(fabs(term/last) > 1.0) break;
28243 if(fabs(term/sum) < GSL_DBL_EPSILON) break;
28244 sum += term;
28245 last = term;
28246 }
28247
28248 result->val = D.val * (a/x) * sum;
28249 result->err = D.err * fabs((a/x) * sum);
28250 result->err += 2.0 * GSL_DBL_EPSILON * fabs(result->val);
28251
28252 if(n == nmax)
28253 GSL_ERROR ("error in large x asymptotic", GSL_EMAXITER);
28254 else
28255 return stat_D;
28256}
28257
28258
28259/* Uniform asymptotic for x near a, a and x large.
28260 * See [Temme, p. 285]
28261 */
28262static
28263int
28264gamma_inc_Q_asymp_unif(const double a, const double x, gsl_sf_result * result)
28265{
28266 const double rta = sqrt(a);
28267 const double eps = (x-a)/a;
28268
28269 gsl_sf_result ln_term;
28270 const int stat_ln = gsl_sf_log_1plusx_mx_e(eps, &ln_term); /* log(1+eps) - eps */
28271 const double eta = GSL_SIGN(eps) * sqrt(-2.0*ln_term.val);
28272
28273 gsl_sf_result erfc;
28274
28275 double R;
28276 double c0, c1;
28277
28278 /* This used to say erfc(eta*M_SQRT2*rta), which is wrong.
28279 * The sqrt(2) is in the denominator. Oops.
28280 * Fixed: [GJ] Mon Nov 15 13:25:32 MST 2004
28281 */
28282 gsl_sf_erfc_e(eta*rta/M_SQRT2, &erfc);
28283
28284 if(fabs(eps) < GSL_ROOT5_DBL_EPSILON) {
28285 c0 = -1.0/3.0 + eps*(1.0/12.0 - eps*(23.0/540.0 - eps*(353.0/12960.0 - eps*589.0/30240.0)));
28286 c1 = -1.0/540.0 - eps/288.0;
28287 }
28288 else {
28289 const double rt_term = sqrt(-2.0 * ln_term.val/(eps*eps));
28290 const double lam = x/a;
28291 c0 = (1.0 - 1.0/rt_term)/eps;
28292 c1 = -(eta*eta*eta * (lam*lam + 10.0*lam + 1.0) - 12.0 * eps*eps*eps) / (12.0 * eta*eta*eta*eps*eps*eps);
28293 }
28294
28295 R = exp(-0.5*a*eta*eta)/(M_SQRT2*M_SQRTPI*rta) * (c0 + c1/a);
28296
28297 result->val = 0.5 * erfc.val + R;
28298 result->err = GSL_DBL_EPSILON * fabs(R * 0.5 * a*eta*eta) + 0.5 * erfc.err;
28299 result->err += 2.0 * GSL_DBL_EPSILON * fabs(result->val);
28300
28301 return stat_ln;
28302}
28303
28304
28305/* Continued fraction which occurs in evaluation
28306 * of Q(a,x) or Gamma(a,x).
28307 *
28308 * 1 (1-a)/x 1/x (2-a)/x 2/x (3-a)/x
28309 * F(a,x) = ---- ------- ----- -------- ----- -------- ...
28310 * 1 + 1 + 1 + 1 + 1 + 1 +
28311 *
28312 * Hans E. Plesser, 2002-01-22 (hans dot plesser at itf dot nlh dot no).
28313 *
28314 * Split out from gamma_inc_Q_CF() by GJ [Tue Apr 1 13:16:41 MST 2003].
28315 * See gamma_inc_Q_CF() below.
28316 *
28317 */
28318static int
28319gamma_inc_F_CF(const double a, const double x, gsl_sf_result * result)
28320{
28321 const int nmax = 5000;
28322 const double small = gsl_pow_3 (GSL_DBL_EPSILON);
28323
28324 double hn = 1.0; /* convergent */
28325 double Cn = 1.0 / small;
28326 double Dn = 1.0;
28327 int n;
28328
28329 /* n == 1 has a_1, b_1, b_0 independent of a,x,
28330 so that has been done by hand */
28331 for ( n = 2 ; n < nmax ; n++ )
28332 {
28333 double an;
28334 double delta;
28335
28336 if(GSL_IS_ODD(n))
28337 an = 0.5*(n-1)/x;
28338 else
28339 an = (0.5*n-a)/x;
28340
28341 Dn = 1.0 + an * Dn;
28342 if ( fabs(Dn) < small )
28343 Dn = small;
28344 Cn = 1.0 + an/Cn;
28345 if ( fabs(Cn) < small )
28346 Cn = small;
28347 Dn = 1.0 / Dn;
28348 delta = Cn * Dn;
28349 hn *= delta;
28350 if(fabs(delta-1.0) < GSL_DBL_EPSILON) break;
28351 }
28352
28353 result->val = hn;
28354 result->err = 2.0*GSL_DBL_EPSILON * fabs(hn);
28355 result->err += GSL_DBL_EPSILON * (2.0 + 0.5*n) * fabs(result->val);
28356
28357 if(n == nmax)
28358 GSL_ERROR ("error in CF for F(a,x)", GSL_EMAXITER);
28359 else
28360 return GSL_SUCCESS;
28361}
28362
28363
28364/* Continued fraction for Q.
28365 *
28366 * Q(a,x) = D(a,x) a/x F(a,x)
28367 *
28368 * Hans E. Plesser, 2002-01-22 (hans dot plesser at itf dot nlh dot no):
28369 *
28370 * Since the Gautschi equivalent series method for CF evaluation may lead
28371 * to singularities, I have replaced it with the modified Lentz algorithm
28372 * given in
28373 *
28374 * I J Thompson and A R Barnett
28375 * Coulomb and Bessel Functions of Complex Arguments and Order
28376 * J Computational Physics 64:490-509 (1986)
28377 *
28378 * In consequence, gamma_inc_Q_CF_protected() is now obsolete and has been
28379 * removed.
28380 *
28381 * Identification of terms between the above equation for F(a, x) and
28382 * the first equation in the appendix of Thompson&Barnett is as follows:
28383 *
28384 * b_0 = 0, b_n = 1 for all n > 0
28385 *
28386 * a_1 = 1
28387 * a_n = (n/2-a)/x for n even
28388 * a_n = (n-1)/(2x) for n odd
28389 *
28390 */
28391static
28392int
28393gamma_inc_Q_CF(const double a, const double x, gsl_sf_result * result)
28394{
28395 gsl_sf_result D;
28396 gsl_sf_result F;
28397 const int stat_D = gamma_inc_D(a, x, &D);
28398 const int stat_F = gamma_inc_F_CF(a, x, &F);
28399
28400 result->val = D.val * (a/x) * F.val;
28401 result->err = D.err * fabs((a/x) * F.val) + fabs(D.val * a/x * F.err);
28402
28403 return GSL_ERROR_SELECT_2(stat_F, stat_D);
28404}
28405
28406
28407/* Useful for small a and x. Handles the subtraction analytically.
28408 */
28409static
28410int
28411gamma_inc_Q_series(const double a, const double x, gsl_sf_result * result)
28412{
28413 double term1; /* 1 - x^a/Gamma(a+1) */
28414 double sum; /* 1 + (a+1)/(a+2)(-x)/2! + (a+1)/(a+3)(-x)^2/3! + ... */
28415 int stat_sum;
28416 double term2; /* a temporary variable used at the end */
28417
28418 {
28419 /* Evaluate series for 1 - x^a/Gamma(a+1), small a
28420 */
28421 const double pg21 = -2.404113806319188570799476; /* PolyGamma[2,1] */
28422 const double lnx = log(x);
28423 const double el = M_EULER+lnx;
28424 const double c1 = -el;
28425 const double c2 = M_PI*M_PI/12.0 - 0.5*el*el;
28426 const double c3 = el*(M_PI*M_PI/12.0 - el*el/6.0) + pg21/6.0;
28427 const double c4 = -0.04166666666666666667
28428 * (-1.758243446661483480 + lnx)
28429 * (-0.764428657272716373 + lnx)
28430 * ( 0.723980571623507657 + lnx)
28431 * ( 4.107554191916823640 + lnx);
28432 const double c5 = -0.0083333333333333333
28433 * (-2.06563396085715900 + lnx)
28434 * (-1.28459889470864700 + lnx)
28435 * (-0.27583535756454143 + lnx)
28436 * ( 1.33677371336239618 + lnx)
28437 * ( 5.17537282427561550 + lnx);
28438 const double c6 = -0.0013888888888888889
28439 * (-2.30814336454783200 + lnx)
28440 * (-1.65846557706987300 + lnx)
28441 * (-0.88768082560020400 + lnx)
28442 * ( 0.17043847751371778 + lnx)
28443 * ( 1.92135970115863890 + lnx)
28444 * ( 6.22578557795474900 + lnx);
28445 const double c7 = -0.00019841269841269841
28446 * (-2.5078657901291800 + lnx)
28447 * (-1.9478900888958200 + lnx)
28448 * (-1.3194837322612730 + lnx)
28449 * (-0.5281322700249279 + lnx)
28450 * ( 0.5913834939078759 + lnx)
28451 * ( 2.4876819633378140 + lnx)
28452 * ( 7.2648160783762400 + lnx);
28453 const double c8 = -0.00002480158730158730
28454 * (-2.677341544966400 + lnx)
28455 * (-2.182810448271700 + lnx)
28456 * (-1.649350342277400 + lnx)
28457 * (-1.014099048290790 + lnx)
28458 * (-0.191366955370652 + lnx)
28459 * ( 0.995403817918724 + lnx)
28460 * ( 3.041323283529310 + lnx)
28461 * ( 8.295966556941250 + lnx);
28462 const double c9 = -2.75573192239859e-6
28463 * (-2.8243487670469080 + lnx)
28464 * (-2.3798494322701120 + lnx)
28465 * (-1.9143674728689960 + lnx)
28466 * (-1.3814529102920370 + lnx)
28467 * (-0.7294312810261694 + lnx)
28468 * ( 0.1299079285269565 + lnx)
28469 * ( 1.3873333251885240 + lnx)
28470 * ( 3.5857258865210760 + lnx)
28471 * ( 9.3214237073814600 + lnx);
28472 const double c10 = -2.75573192239859e-7
28473 * (-2.9540329644556910 + lnx)
28474 * (-2.5491366926991850 + lnx)
28475 * (-2.1348279229279880 + lnx)
28476 * (-1.6741881076349450 + lnx)
28477 * (-1.1325949616098420 + lnx)
28478 * (-0.4590034650618494 + lnx)
28479 * ( 0.4399352987435699 + lnx)
28480 * ( 1.7702236517651670 + lnx)
28481 * ( 4.1231539047474080 + lnx)
28482 * ( 10.342627908148680 + lnx);
28483
28484 term1 = a*(c1+a*(c2+a*(c3+a*(c4+a*(c5+a*(c6+a*(c7+a*(c8+a*(c9+a*c10)))))))));
28485 }
28486
28487 {
28488 /* Evaluate the sum.
28489 */
28490 const int nmax = 5000;
28491 double t = 1.0;
28492 int n;
28493 sum = 1.0;
28494
28495 for(n=1; n<nmax; n++) {
28496 t *= -x/(n+1.0);
28497 sum += (a+1.0)/(a+n+1.0)*t;
28498 if(fabs(t/sum) < GSL_DBL_EPSILON) break;
28499 }
28500
28501 if(n == nmax)
28502 stat_sum = GSL_EMAXITER;
28503 else
28504 stat_sum = GSL_SUCCESS;
28505 }
28506
28507 term2 = (1.0 - term1) * a/(a+1.0) * x * sum;
28508 result->val = term1 + term2;
28509 result->err = GSL_DBL_EPSILON * (fabs(term1) + 2.0*fabs(term2));
28510 result->err += 2.0 * GSL_DBL_EPSILON * fabs(result->val);
28511 return stat_sum;
28512}
28513
28514
28515/*-*-*-*-*-*-*-*-*-*-*-* Functions with Error Codes *-*-*-*-*-*-*-*-*-*-*-*/
28516
28517int
28518gsl_sf_gamma_inc_Q_e(const double a, const double x, gsl_sf_result * result)
28519{
28520 if(a < 0.0 || x < 0.0) {
28521 DOMAIN_ERROR(result);
28522 }
28523 else if(x == 0.0) {
28524 result->val = 1.0;
28525 result->err = 0.0;
28526 return GSL_SUCCESS;
28527 }
28528 else if(a == 0.0)
28529 {
28530 result->val = 0.0;
28531 result->err = 0.0;
28532 return GSL_SUCCESS;
28533 }
28534 else if(x <= 0.5*a) {
28535 /* If the series is quick, do that. It is
28536 * robust and simple.
28537 */
28538 gsl_sf_result P;
28539 int stat_P = gamma_inc_P_series(a, x, &P);
28540 result->val = 1.0 - P.val;
28541 result->err = P.err;
28542 result->err += 2.0 * GSL_DBL_EPSILON * fabs(result->val);
28543 return stat_P;
28544 }
28545 else if(a >= 1.0e+06 && (x-a)*(x-a) < a) {
28546 /* Then try the difficult asymptotic regime.
28547 * This is the only way to do this region.
28548 */
28549 return gamma_inc_Q_asymp_unif(a, x, result);
28550 }
28551 else if(a < 0.2 && x < 5.0) {
28552 /* Cancellations at small a must be handled
28553 * analytically; x should not be too big
28554 * either since the series terms grow
28555 * with x and log(x).
28556 */
28557 return gamma_inc_Q_series(a, x, result);
28558 }
28559 else if(a <= x) {
28560 if(x <= 1.0e+06) {
28561 /* Continued fraction is excellent for x >~ a.
28562 * We do not let x be too large when x > a since
28563 * it is somewhat pointless to try this there;
28564 * the function is rapidly decreasing for
28565 * x large and x > a, and it will just
28566 * underflow in that region anyway. We
28567 * catch that case in the standard
28568 * large-x method.
28569 */
28570 return gamma_inc_Q_CF(a, x, result);
28571 }
28572 else {
28573 return gamma_inc_Q_large_x(a, x, result);
28574 }
28575 }
28576 else {
28577 if(x > a - sqrt(a)) {
28578 /* Continued fraction again. The convergence
28579 * is a little slower here, but that is fine.
28580 * We have to trade that off against the slow
28581 * convergence of the series, which is the
28582 * only other option.
28583 */
28584 return gamma_inc_Q_CF(a, x, result);
28585 }
28586 else {
28587 gsl_sf_result P;
28588 int stat_P = gamma_inc_P_series(a, x, &P);
28589 result->val = 1.0 - P.val;
28590 result->err = P.err;
28591 result->err += 2.0 * GSL_DBL_EPSILON * fabs(result->val);
28592 return stat_P;
28593 }
28594 }
28595}
28596
28597
28598int
28599gsl_sf_gamma_inc_P_e(const double a, const double x, gsl_sf_result * result)
28600{
28601 if(a <= 0.0 || x < 0.0) {
28602 DOMAIN_ERROR(result);
28603 }
28604 else if(x == 0.0) {
28605 result->val = 0.0;
28606 result->err = 0.0;
28607 return GSL_SUCCESS;
28608 }
28609 else if(x < 20.0 || x < 0.5*a) {
28610 /* Do the easy series cases. Robust and quick.
28611 */
28612 return gamma_inc_P_series(a, x, result);
28613 }
28614 else if(a > 1.0e+06 && (x-a)*(x-a) < a) {
28615 /* Crossover region. Note that Q and P are
28616 * roughly the same order of magnitude here,
28617 * so the subtraction is stable.
28618 */
28619 gsl_sf_result Q;
28620 int stat_Q = gamma_inc_Q_asymp_unif(a, x, &Q);
28621 result->val = 1.0 - Q.val;
28622 result->err = Q.err;
28623 result->err += 2.0 * GSL_DBL_EPSILON * fabs(result->val);
28624 return stat_Q;
28625 }
28626 else if(a <= x) {
28627 /* Q <~ P in this area, so the
28628 * subtractions are stable.
28629 */
28630 gsl_sf_result Q;
28631 int stat_Q;
28632 if(a > 0.2*x) {
28633 stat_Q = gamma_inc_Q_CF(a, x, &Q);
28634 }
28635 else {
28636 stat_Q = gamma_inc_Q_large_x(a, x, &Q);
28637 }
28638 result->val = 1.0 - Q.val;
28639 result->err = Q.err;
28640 result->err += 2.0 * GSL_DBL_EPSILON * fabs(result->val);
28641 return stat_Q;
28642 }
28643 else {
28644 if((x-a)*(x-a) < a) {
28645 /* This condition is meant to insure
28646 * that Q is not very close to 1,
28647 * so the subtraction is stable.
28648 */
28649 gsl_sf_result Q;
28650 int stat_Q = gamma_inc_Q_CF(a, x, &Q);
28651 result->val = 1.0 - Q.val;
28652 result->err = Q.err;
28653 result->err += 2.0 * GSL_DBL_EPSILON * fabs(result->val);
28654 return stat_Q;
28655 }
28656 else {
28657 return gamma_inc_P_series(a, x, result);
28658 }
28659 }
28660}
28661
28662/*-*-*-*-*-*-*-*-*-* Functions w/ Natural Prototypes *-*-*-*-*-*-*-*-*-*-*/
28663
28664/* (eval.h macros already defined above) */
28665
28666double gsl_sf_gamma_inc_P(const double a, const double x)
28667{
28668 EVAL_RESULT(gsl_sf_gamma_inc_P_e(a, x, &result));
28669}
28670
28671double gsl_sf_gamma_inc_Q(const double a, const double x)
28672{
28673 EVAL_RESULT(gsl_sf_gamma_inc_Q_e(a, x, &result));
28674}
28675
28676/* end inlined source: specfunc/gamma_inc.c */
28677
28678/* begin inlined source: cdf/gamma.c (gsl_cdf_gamma_Q only) */
28679/* cdf/cdf_gamma.c
28680 *
28681 * Copyright (C) 2003 Jason Stover.
28682 *
28683 * This program is free software; you can redistribute it and/or modify
28684 * it under the terms of the GNU General Public License as published by
28685 * the Free Software Foundation; either version 3 of the License, or (at
28686 * your option) any later version.
28687 *
28688 * This program is distributed in the hope that it will be useful, but
28689 * WITHOUT ANY WARRANTY; without even the implied warranty of
28690 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28691 * General Public License for more details.
28692 *
28693 * You should have received a copy of the GNU General Public License
28694 * along with this program; if not, write to the Free Software Foundation,
28695 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28696 */
28697
28698/* Author: J. Stover */
28699
28700/* (stripped: #include directives — already handled above) */
28701/* (gsl_cdf_gamma_P omitted: not needed by MARLEY) */
28702
28703double
28704gsl_cdf_gamma_Q (const double x, const double a, const double b)
28705{
28706 double Q;
28707 double y;
28708
28709 /* Upstream GSL can return boundary values in some invalid-parameter and/or
28710 * x <= 0 cases. The reduced MARLEY fallback subset intentionally tightens
28711 * domain handling for unsupported, non-physical parameter domains so that
28712 * unsupported usage fails loudly via the GSL C error path.
28713 */
28714 if (a <= 0.0 || b <= 0.0)
28715 {
28716 GSL_ERROR_VAL ("unsupported parameter domain in built-in gsl_cdf_gamma_Q"
28717 " (require a > 0 and b > 0)", GSL_EDOM, GSL_NAN);
28718 }
28719
28720 y = x / b;
28721
28722 if (x <= 0.0)
28723 {
28724 return 1.0;
28725 }
28726
28727 if (y < a)
28728 {
28729 Q = 1 - gsl_sf_gamma_inc_P (a, y);
28730 }
28731 else
28732 {
28733 Q = gsl_sf_gamma_inc_Q (a, y);
28734 }
28735
28736 return Q;
28737}
28738/* end inlined source: cdf/gamma.c */
28739
28740/* Added to ensure extern "C" linking of gsl_cdf_gamma_Q below */
28741__BEGIN_DECLS
28742/* End addition */
28743
28744/* begin inlined source: cdf/chisq.c (gsl_cdf_chisq_Q only) */
28745/* cdf/cdf_chisq.c
28746 *
28747 * Copyright (C) 2003, 2007 Brian Gough
28748 *
28749 * This program is free software; you can redistribute it and/or modify
28750 * it under the terms of the GNU General Public License as published by
28751 * the Free Software Foundation; either version 3 of the License, or (at
28752 * your option) any later version.
28753 *
28754 * This program is distributed in the hope that it will be useful, but
28755 * WITHOUT ANY WARRANTY; without even the implied warranty of
28756 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28757 * General Public License for more details.
28758 *
28759 * You should have received a copy of the GNU General Public License
28760 * along with this program; if not, write to the Free Software Foundation,
28761 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28762 */
28763
28764/* (stripped: #include directives — already handled above) */
28765/* (gsl_cdf_chisq_P omitted: not needed by MARLEY) */
28766
28767double
28768gsl_cdf_chisq_Q (const double x, const double nu)
28769{
28770 /* Keep parameter-domain behavior aligned with the built-in gamma-Q guard:
28771 * reject unsupported/non-physical nu <= 0 through the GSL error path.
28772 */
28773 if (nu <= 0.0)
28774 {
28775 GSL_ERROR_VAL ("unsupported parameter domain in built-in gsl_cdf_chisq_Q"
28776 " (require nu > 0)", GSL_EDOM, GSL_NAN);
28777 }
28778
28779 return gsl_cdf_gamma_Q (x, nu / 2, 2.0);
28780}
28781/* end inlined source: cdf/chisq.c */
28782
28783/* Added to close the final __BEGIN_DECLS above (see comments up there) */
28784__END_DECLS
28785/* End addition */
28786
28787#endif // MARLEY_FOUND_GSL