15 double a0,
double b0,
double a1,
double b1,
16 double x00,
double x0c,
double x0n,
17 double xc0,
double xcc,
double xcn,
18 double xn0,
double xnc,
double xnn)
19 : value(value), error(error),
20 a0(a0), b0(b0), a1(a1), b1(b1),
21 x00(x00), x0c(x0c), x0n(x0n),
22 xc0(xc0), xcc(xcc), xcn(xcn),
23 xn0(xn0), xnc(xnc), xnn(xnn)
29 return std::abs(error) < std::abs(other.error);
53 static const int n = 2*N-1;
54 static const double p[n];
55 static const double w[n];
56 static const double e[n];
63 static const int n = 2*N-1;
64 static const double p[n];
65 static const double w[n];
66 static const double e[n];
77 template<
typename Rule,
typename Function>
78 inline quadrature_result quadrature(Function f,
double a0,
double b0,
double a1,
double b1,
double pg,
double ag)
83 typedef std::vector<quadrature_task> queue_container;
86 typedef queue_container::const_iterator queue_iterator;
89 double values[Rule::n][Rule::n];
92 const int n = Rule::n-1;
93 const int c = (Rule::n-1)/2;
96 for(
int i = 0; i < Rule::n; ++i)
97 for(
int j = 0; j < Rule::n; ++j)
98 values[i][j] = f(0.5*((b0-a0)*Rule::p[i]+a0+b0), 0.5*((b1-a1)*Rule::p[j]+a1+b1));
102 for(
int i = 0; i < Rule::n; ++i)
104 for(
int j = 0; j < Rule::n; ++j)
106 result.value += Rule::w[i]*Rule::w[j]*values[i][j];
107 result.error += Rule::e[i]*Rule::e[j]*values[i][j];
110 result.value = 0.25*(b0-a0)*(b1-a1)*result.value;
111 result.error = 0.25*(b0-a0)*(b1-a1)*std::abs(result.error);
114 queue_container queue;
115 std::make_heap(queue.begin(), queue.end());
118 queue.push_back(quadrature_task(
119 result.value, result.error,
121 values[0][0], values[0][c], values[0][n],
122 values[c][0], values[c][c], values[c][n],
123 values[n][0], values[n][c], values[n][n]
125 std::push_heap(queue.begin(), queue.end());
128 while(result.error > std::abs(result.value)*pg && result.error > ag)
131 quadrature_task task = queue.front();
134 std::pop_heap(queue.begin(), queue.end());
138 for(
int k = 0; k < 4; ++k)
145 b0 = 0.5*(task.a0+task.b0);
147 b1 = 0.5*(task.a1+task.b1);
148 values[0][0] = task.x00;
149 values[0][n] = task.x0c;
150 values[n][0] = task.xc0;
151 values[n][n] = task.xcc;
155 a0 = 0.5*(task.a0+task.b0);
158 b1 = 0.5*(task.a1+task.b1);
159 values[0][0] = task.xc0;
160 values[0][n] = task.xcc;
161 values[n][0] = task.xn0;
162 values[n][n] = task.xnc;
167 b0 = 0.5*(task.a0+task.b0);
168 a1 = 0.5*(task.a1+task.b1);
170 values[0][0] = task.x0c;
171 values[0][n] = task.x0n;
172 values[n][0] = task.xcc;
173 values[n][n] = task.xcn;
177 a0 = 0.5*(task.a0+task.b0);
179 a1 = 0.5*(task.a1+task.b1);
181 values[0][0] = task.xcc;
182 values[0][n] = task.xcn;
183 values[n][0] = task.xnc;
184 values[n][n] = task.xnn;
189 for(
int j = 1; j < n; ++j)
190 values[0][j] = f(0.5*((b0-a0)*Rule::p[0]+a0+b0), 0.5*((b1-a1)*Rule::p[j]+a1+b1));
191 for(
int i = 1; i < n; ++i)
192 for(
int j = 0; j < Rule::n; ++j)
193 values[i][j] = f(0.5*((b0-a0)*Rule::p[i]+a0+b0), 0.5*((b1-a1)*Rule::p[j]+a1+b1));
194 for(
int j = 1; j < n; ++j)
195 values[n][j] = f(0.5*((b0-a0)*Rule::p[n]+a0+b0), 0.5*((b1-a1)*Rule::p[j]+a1+b1));
198 quadrature_result sub = {0, 0};
199 for(
int i = 0; i < Rule::n; ++i)
201 for(
int j = 0; j < Rule::n; ++j)
203 sub.value += Rule::w[i]*Rule::w[j]*values[i][j];
204 sub.error += Rule::e[i]*Rule::e[j]*values[i][j];
207 sub.value = 0.25*(b0-a0)*(b1-a1)*sub.value;
208 sub.error = 0.25*(b0-a0)*(b1-a1)*sub.error;
211 queue.push_back(quadrature_task(
212 sub.value, sub.error,
214 values[0][0], values[0][c], values[0][n],
215 values[c][0], values[c][c], values[c][n],
216 values[n][0], values[n][c], values[n][n]
218 std::push_heap(queue.begin(), queue.end());
224 for(queue_iterator it = queue.begin(); it != queue.end(); ++it)
226 result.value += it->value;
227 result.error += it->error;
229 result.error = std::abs(result.error);
ISOP namespace is for functions related to isoparametric interpolation.
Definition isop.h:7
Clenshaw-Curtis quadrature data.
Definition quadrature.h:52
Lobatto-Kronrod quadrature data.
Definition quadrature.h:62
Subdivided area in quadrature with value and error estimate.
Definition quadrature.h:13
Result of numerical integration.
Definition quadrature.h:72