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
|
/*
decl.h
Type declarations
this file is part of Divonne
last modified 14 Nov 11 th
*/
#include "stddecl.h"
#define Tag(x) ((x) | INT_MIN)
#define Untag(x) ((x) & INT_MAX)
typedef struct {
real lower, upper;
} Bounds;
typedef const Bounds cBounds;
typedef struct {
real avg, err;
} PhaseResult;
typedef struct {
real avg, spreadsq;
real spread, secondspread;
real nneed, maxerrsq, mindevsq;
PhaseResult phase[2];
int iregion;
} Totals;
typedef struct {
void *first, *last;
real errcoeff[3];
count n;
} Rule;
typedef const Rule cRule;
typedef struct samples {
real *x, *f;
void (*sampler)(struct _this *t, ccount);
cRule *rule;
number n, neff;
count coeff;
} Samples;
typedef const Samples cSamples;
typedef struct {
real diff, err, spread;
} Errors;
typedef const Errors cErrors;
typedef int (*Integrand)(ccount *, creal *, ccount *, real *, void *, cint *);
typedef void (*PeakFinder)(ccount *, cBounds *, number *, real *);
typedef struct _this {
count ndim, ncomp;
#ifndef MLVERSION
Integrand integrand;
void *userdata;
PeakFinder peakfinder;
int ncores, *child;
int running, nchildren;
fd_set children;
#endif
real epsrel, epsabs;
int flags, seed;
number mineval, maxeval;
int key1, key2, key3;
count maxpass;
Bounds border;
real maxchisq, mindeviation;
number ngiven, nextra;
real *xgiven, *xextra, *fgiven, *fextra;
count ldxgiven;
count nregions;
number neval, neval_opt, neval_cut;
count phase;
count selectedcomp, size;
Samples samples[3];
Totals *totals;
Rule rule7, rule9, rule11, rule13;
RNGState rng;
void *voidregion;
jmp_buf abort;
} This;
typedef const This cThis;
#define TYPEDEFREGION \
typedef struct { \
real avg, err, spread, chisq; \
real fmin, fmax; \
real xmin[NDIM], xmax[NDIM]; \
} Result; \
typedef const Result cResult; \
typedef struct region { \
int depth, next; \
count isamples, cutcomp, xmajor; \
real fmajor, fminor, vol; \
Bounds bounds[NDIM]; \
Result result[NCOMP]; \
} Region
#define RegionPtr(n) (&((Region *)t->voidregion)[n])
#define CHUNKSIZE 4096
#define AllocRegions(t) \
MemAlloc((t)->voidregion, ((t)->size = CHUNKSIZE)*sizeof(Region))
#define EnlargeRegions(t, n) if( (t)->nregions + n > (t)->size ) \
ReAlloc((t)->voidregion, ((t)->size += CHUNKSIZE)*sizeof(Region))
#define SAMPLERDEFS \
TYPEDEFREGION; \
Region *region = RegionPtr(iregion); \
cBounds *b = region->bounds; \
Result *r = region->result; \
cSamples *samples = &t->samples[region->isamples]; \
real *x = samples->x, *f = samples->f; \
cnumber n = samples->n
|