| 1 |
/* integration/gsl_integration.h |
| 2 |
* |
| 3 |
* Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Brian Gough |
| 4 |
* |
| 5 |
* This program is free software; you can redistribute it and/or modify |
| 6 |
* it under the terms of the GNU General Public License as published by |
| 7 |
* the Free Software Foundation; either version 3 of the License, or (at |
| 8 |
* your option) any later version. |
| 9 |
* |
| 10 |
* This program is distributed in the hope that it will be useful, but |
| 11 |
* WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 |
* General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU General Public License |
| 16 |
* along with this program; if not, write to the Free Software |
| 17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 18 |
*/ |
| 19 |
|
| 20 |
#ifndef __GSL_INTEGRATION_H__ |
| 21 |
#define __GSL_INTEGRATION_H__ |
| 22 |
#include <stdlib.h> |
| 23 |
#include "gsl_math.h" |
| 24 |
|
| 25 |
#undef __BEGIN_DECLS |
| 26 |
#undef __END_DECLS |
| 27 |
#ifdef __cplusplus |
| 28 |
# define __BEGIN_DECLS extern "C" { |
| 29 |
# define __END_DECLS } |
| 30 |
#else |
| 31 |
# define __BEGIN_DECLS /* empty */ |
| 32 |
# define __END_DECLS /* empty */ |
| 33 |
#endif |
| 34 |
|
| 35 |
__BEGIN_DECLS |
| 36 |
|
| 37 |
/* Workspace for adaptive integrators */ |
| 38 |
|
| 39 |
typedef struct |
| 40 |
{ |
| 41 |
size_t limit; |
| 42 |
size_t size; |
| 43 |
size_t nrmax; |
| 44 |
size_t i; |
| 45 |
size_t maximum_level; |
| 46 |
double *alist; |
| 47 |
double *blist; |
| 48 |
double *rlist; |
| 49 |
double *elist; |
| 50 |
size_t *order; |
| 51 |
size_t *level; |
| 52 |
} |
| 53 |
gsl_integration_workspace; |
| 54 |
|
| 55 |
gsl_integration_workspace * |
| 56 |
gsl_integration_workspace_alloc (const size_t n); |
| 57 |
|
| 58 |
void |
| 59 |
gsl_integration_workspace_free (gsl_integration_workspace * w); |
| 60 |
|
| 61 |
|
| 62 |
/* Workspace for QAWS integrator */ |
| 63 |
|
| 64 |
typedef struct |
| 65 |
{ |
| 66 |
double alpha; |
| 67 |
double beta; |
| 68 |
int mu; |
| 69 |
int nu; |
| 70 |
double ri[25]; |
| 71 |
double rj[25]; |
| 72 |
double rg[25]; |
| 73 |
double rh[25]; |
| 74 |
} |
| 75 |
gsl_integration_qaws_table; |
| 76 |
|
| 77 |
gsl_integration_qaws_table * |
| 78 |
gsl_integration_qaws_table_alloc (double alpha, double beta, int mu, int nu); |
| 79 |
|
| 80 |
int |
| 81 |
gsl_integration_qaws_table_set (gsl_integration_qaws_table * t, |
| 82 |
double alpha, double beta, int mu, int nu); |
| 83 |
|
| 84 |
void |
| 85 |
gsl_integration_qaws_table_free (gsl_integration_qaws_table * t); |
| 86 |
|
| 87 |
/* Workspace for QAWO integrator */ |
| 88 |
|
| 89 |
enum gsl_integration_qawo_enum { GSL_INTEG_COSINE, GSL_INTEG_SINE }; |
| 90 |
|
| 91 |
typedef struct |
| 92 |
{ |
| 93 |
size_t n; |
| 94 |
double omega; |
| 95 |
double L; |
| 96 |
double par; |
| 97 |
enum gsl_integration_qawo_enum sine; |
| 98 |
double *chebmo; |
| 99 |
} |
| 100 |
gsl_integration_qawo_table; |
| 101 |
|
| 102 |
gsl_integration_qawo_table * |
| 103 |
gsl_integration_qawo_table_alloc (double omega, double L, |
| 104 |
enum gsl_integration_qawo_enum sine, |
| 105 |
size_t n); |
| 106 |
|
| 107 |
int |
| 108 |
gsl_integration_qawo_table_set (gsl_integration_qawo_table * t, |
| 109 |
double omega, double L, |
| 110 |
enum gsl_integration_qawo_enum sine); |
| 111 |
|
| 112 |
int |
| 113 |
gsl_integration_qawo_table_set_length (gsl_integration_qawo_table * t, |
| 114 |
double L); |
| 115 |
|
| 116 |
void |
| 117 |
gsl_integration_qawo_table_free (gsl_integration_qawo_table * t); |
| 118 |
|
| 119 |
|
| 120 |
/* Definition of an integration rule */ |
| 121 |
|
| 122 |
typedef void gsl_integration_rule (const gsl_function * f, |
| 123 |
double a, double b, |
| 124 |
double *result, double *abserr, |
| 125 |
double *defabs, double *resabs); |
| 126 |
|
| 127 |
void gsl_integration_qk15 (const gsl_function * f, double a, double b, |
| 128 |
double *result, double *abserr, |
| 129 |
double *resabs, double *resasc); |
| 130 |
|
| 131 |
void gsl_integration_qk21 (const gsl_function * f, double a, double b, |
| 132 |
double *result, double *abserr, |
| 133 |
double *resabs, double *resasc); |
| 134 |
|
| 135 |
void gsl_integration_qk31 (const gsl_function * f, double a, double b, |
| 136 |
double *result, double *abserr, |
| 137 |
double *resabs, double *resasc); |
| 138 |
|
| 139 |
void gsl_integration_qk41 (const gsl_function * f, double a, double b, |
| 140 |
double *result, double *abserr, |
| 141 |
double *resabs, double *resasc); |
| 142 |
|
| 143 |
void gsl_integration_qk51 (const gsl_function * f, double a, double b, |
| 144 |
double *result, double *abserr, |
| 145 |
double *resabs, double *resasc); |
| 146 |
|
| 147 |
void gsl_integration_qk61 (const gsl_function * f, double a, double b, |
| 148 |
double *result, double *abserr, |
| 149 |
double *resabs, double *resasc); |
| 150 |
|
| 151 |
void gsl_integration_qcheb (gsl_function * f, double a, double b, |
| 152 |
double *cheb12, double *cheb24); |
| 153 |
|
| 154 |
/* The low-level integration rules in QUADPACK are identified by small |
| 155 |
integers (1-6). We'll use symbolic constants to refer to them. */ |
| 156 |
|
| 157 |
enum |
| 158 |
{ |
| 159 |
GSL_INTEG_GAUSS15 = 1, /* 15 point Gauss-Kronrod rule */ |
| 160 |
GSL_INTEG_GAUSS21 = 2, /* 21 point Gauss-Kronrod rule */ |
| 161 |
GSL_INTEG_GAUSS31 = 3, /* 31 point Gauss-Kronrod rule */ |
| 162 |
GSL_INTEG_GAUSS41 = 4, /* 41 point Gauss-Kronrod rule */ |
| 163 |
GSL_INTEG_GAUSS51 = 5, /* 51 point Gauss-Kronrod rule */ |
| 164 |
GSL_INTEG_GAUSS61 = 6 /* 61 point Gauss-Kronrod rule */ |
| 165 |
}; |
| 166 |
|
| 167 |
void |
| 168 |
gsl_integration_qk (const int n, const double xgk[], |
| 169 |
const double wg[], const double wgk[], |
| 170 |
double fv1[], double fv2[], |
| 171 |
const gsl_function *f, double a, double b, |
| 172 |
double * result, double * abserr, |
| 173 |
double * resabs, double * resasc); |
| 174 |
|
| 175 |
|
| 176 |
int gsl_integration_qng (const gsl_function * f, |
| 177 |
double a, double b, |
| 178 |
double epsabs, double epsrel, |
| 179 |
double *result, double *abserr, |
| 180 |
size_t * neval); |
| 181 |
|
| 182 |
int gsl_integration_qag (const gsl_function * f, |
| 183 |
double a, double b, |
| 184 |
double epsabs, double epsrel, size_t limit, |
| 185 |
int key, |
| 186 |
gsl_integration_workspace * workspace, |
| 187 |
double *result, double *abserr); |
| 188 |
|
| 189 |
int gsl_integration_qagi (gsl_function * f, |
| 190 |
double epsabs, double epsrel, size_t limit, |
| 191 |
gsl_integration_workspace * workspace, |
| 192 |
double *result, double *abserr); |
| 193 |
|
| 194 |
int gsl_integration_qagiu (gsl_function * f, |
| 195 |
double a, |
| 196 |
double epsabs, double epsrel, size_t limit, |
| 197 |
gsl_integration_workspace * workspace, |
| 198 |
double *result, double *abserr); |
| 199 |
|
| 200 |
int gsl_integration_qagil (gsl_function * f, |
| 201 |
double b, |
| 202 |
double epsabs, double epsrel, size_t limit, |
| 203 |
gsl_integration_workspace * workspace, |
| 204 |
double *result, double *abserr); |
| 205 |
|
| 206 |
|
| 207 |
int gsl_integration_qags (const gsl_function * f, |
| 208 |
double a, double b, |
| 209 |
double epsabs, double epsrel, size_t limit, |
| 210 |
gsl_integration_workspace * workspace, |
| 211 |
double *result, double *abserr); |
| 212 |
|
| 213 |
int gsl_integration_qagp (const gsl_function * f, |
| 214 |
double *pts, size_t npts, |
| 215 |
double epsabs, double epsrel, size_t limit, |
| 216 |
gsl_integration_workspace * workspace, |
| 217 |
double *result, double *abserr); |
| 218 |
|
| 219 |
int gsl_integration_qawc (gsl_function *f, |
| 220 |
const double a, const double b, const double c, |
| 221 |
const double epsabs, const double epsrel, const size_t limit, |
| 222 |
gsl_integration_workspace * workspace, |
| 223 |
double * result, double * abserr); |
| 224 |
|
| 225 |
int gsl_integration_qaws (gsl_function * f, |
| 226 |
const double a, const double b, |
| 227 |
gsl_integration_qaws_table * t, |
| 228 |
const double epsabs, const double epsrel, |
| 229 |
const size_t limit, |
| 230 |
gsl_integration_workspace * workspace, |
| 231 |
double *result, double *abserr); |
| 232 |
|
| 233 |
int gsl_integration_qawo (gsl_function * f, |
| 234 |
const double a, |
| 235 |
const double epsabs, const double epsrel, |
| 236 |
const size_t limit, |
| 237 |
gsl_integration_workspace * workspace, |
| 238 |
gsl_integration_qawo_table * wf, |
| 239 |
double *result, double *abserr); |
| 240 |
|
| 241 |
int gsl_integration_qawf (gsl_function * f, |
| 242 |
const double a, |
| 243 |
const double epsabs, |
| 244 |
const size_t limit, |
| 245 |
gsl_integration_workspace * workspace, |
| 246 |
gsl_integration_workspace * cycle_workspace, |
| 247 |
gsl_integration_qawo_table * wf, |
| 248 |
double *result, double *abserr); |
| 249 |
|
| 250 |
__END_DECLS |
| 251 |
|
| 252 |
#endif /* __GSL_INTEGRATION_H__ */ |