/usr/include/autogk.h is in libalglib-dev 2.6.0-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 | /*************************************************************************
Copyright (c) 2005-2009, Sergey Bochkanov (ALGLIB project).
>>> SOURCE LICENSE >>>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation (www.fsf.org); either version 2 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
A copy of the GNU General Public License is available at
http://www.fsf.org/licensing/licenses
>>> END OF LICENSE >>>
*************************************************************************/
#ifndef _autogk_h
#define _autogk_h
#include "ap.h"
#include "ialglib.h"
#include "tsort.h"
#include "hblas.h"
#include "reflections.h"
#include "creflections.h"
#include "sblas.h"
#include "ablasf.h"
#include "ablas.h"
#include "ortfac.h"
#include "blas.h"
#include "rotations.h"
#include "hsschur.h"
#include "evd.h"
#include "gammafunc.h"
#include "gq.h"
#include "gkq.h"
/*************************************************************************
Integration report:
* TerminationType = completetion code:
* -5 non-convergence of Gauss-Kronrod nodes
calculation subroutine.
* -1 incorrect parameters were specified
* 1 OK
* Rep.NFEV countains number of function calculations
* Rep.NIntervals contains number of intervals [a,b]
was partitioned into.
*************************************************************************/
struct autogkreport
{
int terminationtype;
int nfev;
int nintervals;
};
struct autogkinternalstate
{
double a;
double b;
double eps;
double xwidth;
double x;
double f;
int info;
double r;
ap::real_2d_array heap;
int heapsize;
int heapwidth;
int heapused;
double sumerr;
double sumabs;
ap::real_1d_array qn;
ap::real_1d_array wg;
ap::real_1d_array wk;
ap::real_1d_array wr;
int n;
ap::rcommstate rstate;
};
/*************************************************************************
This structure stores internal state of the integration algorithm between
subsequent calls of the AutoGKIteration() subroutine.
*************************************************************************/
struct autogkstate
{
double a;
double b;
double alpha;
double beta;
double xwidth;
double x;
double xminusa;
double bminusx;
double f;
int wrappermode;
autogkinternalstate internalstate;
ap::rcommstate rstate;
double v;
int terminationtype;
int nfev;
int nintervals;
};
/*************************************************************************
Integration of a smooth function F(x) on a finite interval [a,b].
Fast-convergent algorithm based on a Gauss-Kronrod formula is used. Result
is calculated with accuracy close to the machine precision.
Algorithm works well only with smooth integrands. It may be used with
continuous non-smooth integrands, but with less performance.
It should never be used with integrands which have integrable singularities
at lower or upper limits - algorithm may crash. Use AutoGKSingular in such
cases.
INPUT PARAMETERS:
A, B - interval boundaries (A<B, A=B or A>B)
OUTPUT PARAMETERS
State - structure which stores algorithm state between subsequent
calls of AutoGKIteration. Used for reverse communication.
This structure should be passed to the AutoGKIteration
subroutine.
SEE ALSO
AutoGKSmoothW, AutoGKSingular, AutoGKIteration, AutoGKResults.
-- ALGLIB --
Copyright 06.05.2009 by Bochkanov Sergey
*************************************************************************/
void autogksmooth(double a, double b, autogkstate& state);
/*************************************************************************
Integration of a smooth function F(x) on a finite interval [a,b].
This subroutine is same as AutoGKSmooth(), but it guarantees that interval
[a,b] is partitioned into subintervals which have width at most XWidth.
Subroutine can be used when integrating nearly-constant function with
narrow "bumps" (about XWidth wide). If "bumps" are too narrow, AutoGKSmooth
subroutine can overlook them.
INPUT PARAMETERS:
A, B - interval boundaries (A<B, A=B or A>B)
OUTPUT PARAMETERS
State - structure which stores algorithm state between subsequent
calls of AutoGKIteration. Used for reverse communication.
This structure should be passed to the AutoGKIteration
subroutine.
SEE ALSO
AutoGKSmooth, AutoGKSingular, AutoGKIteration, AutoGKResults.
-- ALGLIB --
Copyright 06.05.2009 by Bochkanov Sergey
*************************************************************************/
void autogksmoothw(double a, double b, double xwidth, autogkstate& state);
/*************************************************************************
Integration on a finite interval [A,B].
Integrand have integrable singularities at A/B.
F(X) must diverge as "(x-A)^alpha" at A, as "(B-x)^beta" at B, with known
alpha/beta (alpha>-1, beta>-1). If alpha/beta are not known, estimates
from below can be used (but these estimates should be greater than -1 too).
One of alpha/beta variables (or even both alpha/beta) may be equal to 0,
which means than function F(x) is non-singular at A/B. Anyway (singular at
bounds or not), function F(x) is supposed to be continuous on (A,B).
Fast-convergent algorithm based on a Gauss-Kronrod formula is used. Result
is calculated with accuracy close to the machine precision.
INPUT PARAMETERS:
A, B - interval boundaries (A<B, A=B or A>B)
Alpha - power-law coefficient of the F(x) at A,
Alpha>-1
Beta - power-law coefficient of the F(x) at B,
Beta>-1
OUTPUT PARAMETERS
State - structure which stores algorithm state between subsequent
calls of AutoGKIteration. Used for reverse communication.
This structure should be passed to the AutoGKIteration
subroutine.
SEE ALSO
AutoGKSmooth, AutoGKSmoothW, AutoGKIteration, AutoGKResults.
-- ALGLIB --
Copyright 06.05.2009 by Bochkanov Sergey
*************************************************************************/
void autogksingular(double a,
double b,
double alpha,
double beta,
autogkstate& state);
/*************************************************************************
One step of adaptive integration process.
Called after initialization with one of AutoGKXXX subroutines.
See HTML documentation for examples.
Input parameters:
State - structure which stores algorithm state between calls and
which is used for reverse communication. Must be
initialized with one of AutoGKXXX subroutines.
If suborutine returned False, iterative proces has converged. If subroutine
returned True, caller should calculate function value State.F at State.X
and call AutoGKIteration again.
NOTE:
When integrating "difficult" functions with integrable singularities like
F(x) = (x-A)^alpha * (B-x)^beta
subroutine may require the value of F at points which are too close to A/B.
Sometimes to calculate integral with high enough precision we may need to
calculate F(A+delta) when delta is less than machine epsilon. In finite
precision arithmetics A+delta will be effectively equal to A, so we may
find us in situation when we are trying to calculate something like
1/sqrt(1-1).
To avoid such situations, AutoGKIteration subroutine fills not only
State.X field, but also State.XMinusA (which equals to X-A) and
State.BMinusX (which equals to B-X) fields. If X is too close to A or B
(X-A<0.001*A, or B-X<0.001*B, for example) use these fields instead of
State.X
-- ALGLIB --
Copyright 07.05.2009 by Bochkanov Sergey
*************************************************************************/
bool autogkiteration(autogkstate& state);
/*************************************************************************
Adaptive integration results
Called after AutoGKIteration returned False.
Input parameters:
State - algorithm state (used by AutoGKIteration).
Output parameters:
V - integral(f(x)dx,a,b)
Rep - optimization report (see AutoGKReport description)
-- ALGLIB --
Copyright 14.11.2007 by Bochkanov Sergey
*************************************************************************/
void autogkresults(const autogkstate& state, double& v, autogkreport& rep);
#endif
|