forked from johannesgerer/jburkardt-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sparse_grid_hw.html
440 lines (406 loc) · 13.3 KB
/
sparse_grid_hw.html
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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
<html>
<head>
<title>
SPARSE_GRID_HW - Sparse Grids for Uniform and Normal Weights - Heiss and Winschel
</title>
</head>
<body bgcolor="#EEEEEE" link="#CC0000" alink="#FF3300" vlink="#000055">
<h1 align = "center">
SPARSE_GRID_HW <br> Sparse Grids for Uniform and Normal Weights <br> Heiss and Winschel
</h1>
<hr>
<p>
<b>SPARSE_GRID_HW</b>
is a C++ library which
can compute sparse grids for multidimensional integration,
based on 1D rules for the unit interval with unit weight function,
or for the real line with the Gauss-Hermite weight function.
The original MATLAB code is by Florian Heiss and Viktor Winschel.
</p>
<p>
The original version of this software, and other information,
is available at <a href = "http://sparse-grids.de/">
http://sparse-grids.de </a>.
<p>
Four built-in 1D families of quadrature rules are supplied, and the
user can extend the package by supplying any family of 1D quadrature
rules.
</p>
<p>
The built-in families are identified by a 3-letter key which is also
the name of the function that returns members of the family:
<ul>
<li>
<b>gqu</b>, standard Gauss-Legendre quadrature rules, for
the unit interval [0,1], with weight function w(x) = 1.
</li>
<li>
<b>gqn</b>, standard Gauss-Hermite quadrature rules, for
the infinite interval (-oo,+oo), with weight function
w(x) = exp(-x*x/2)/sqrt(2*pi).
</li>
<li>
<b>kpu</b>, Kronrod-Patterson quadrature rules, for
the unit interval [0,1], with weight function w(x) = 1.
These sacrifice some of the precision of <b>gqu</b> in
order to provide a family of nested rules.
</li>
<li>
<b>kpn</b>, Kronrod-Patterson quadrature rules, for
the infinite interval (-oo,+oo), with weight function
w(x) = exp(-x*x/2)/sqrt(2*pi).
These sacrifice some of the precision of <b>gqn</b> in
order to provide a family of nested rules.
</li>
</ul>
</p>
<p>
The user can build new sparse grids by supplying a 1D quadrature family.
Examples provided include:
<ul>
<li>
<b>cce_order</b>, Clenshaw-Curtis Exponential quadrature rules, for
the unit interval [0,1], with weight function w(x) = 1.
The K-th call returns the rule of order 1
if K is 1, and 2*(K-1)+1 otherwise.
</li>
<li>
<b>ccl_order</b>, Clenshaw-Curtis Linear quadrature rules, for
the unit interval [0,1], with weight function w(x) = 1.
The K-th call returns the rule of order 2*K-1.
</li>
<li>
<b>ccs_order</b>, slow Clenshaw-Curtis Slow quadrature rules, for
the unit interval [0,1], with weight function w(x) = 1.
The K-th call returns the rule of order 1
if K is 1, and otherwise a rule whose order N has the
form 2^E+1 and is the lowest such order with precision at least 2*K-1.
</li>
</ul>
</p>
<h3 align = "center">
Licensing:
</h3>
<p>
The computer code and data files described and made available on this web page
are distributed under
<a href = "../../txt/gnu_lgpl.txt">the GNU LGPL license.</a>
</p>
<h3 align = "center">
Languages:
</h3>
<p>
<b>SPARSE_GRID_HW</b> is available in
<a href = "../../c_src/sparse_grid_hw/sparse_grid_hw.html">a C version</a> and
<a href = "../../cpp_src/sparse_grid_hw/sparse_grid_hw.html">a C++ version</a> and
<a href = "../../f77_src/sparse_grid_hw/sparse_grid_hw.html">a FORTRAN77 version</a> and
<a href = "../../f_src/sparse_grid_hw/sparse_grid_hw.html">a FORTRAN90 version</a> and
<a href = "../../m_src/sparse_grid_hw/sparse_grid_hw.html">a MATLAB version</a>
</p>
<h3 align = "center">
Related Data and Programs:
</h3>
<p>
<a href = "../../cpp_src/quadrule/quadrule.html">
QUADRULE</a>,
a C++ library which
defines quadrature rules for various intervals and weight functions.
</p>
<p>
<a href = "../../cpp_src/sandia_rules/sandia_rules.html">
SANDIA_RULES</a>,
a C++ library which
generates Gauss quadrature rules of various orders and types.
</p>
<p>
<a href = "../../cpp_src/sgmga/sgmga.html">
SGMGA</a>,
a C++ library which
creates sparse grids based on a mixture of 1D quadrature rules,
allowing anisotropic weights for each dimension.
</p>
<p>
<a href = "../../c_src/smolpack/smolpack.html">
SMOLPACK</a>,
a C library which
implements Novak and Ritter's method for estimating the integral
of a function over a multidimensional hypercube using sparse grids,
by Knut Petras.
</p>
<h3 align = "center">
Author:
</h3>
<p>
Original MATLAB code by Florian Heiss and Viktor Winschel.
C++ version by John Burkardt.
</p>
<h3 align = "center">
Reference:
</h3>
<p>
<ul>
<li>
Alan Genz, Bradley Keister,<br>
Fully symmetric interpolatory rules for multiple integrals
over infinite regions with Gaussian weight,<br>
Journal of Computational and Applied Mathematics,<br>
Volume 71, 1996, pages 299-309.
</li>
<li>
Florian Heiss, Viktor Winschel,<br>
Likelihood approximation by numerical integration on sparse grids,<br>
Journal of Econometrics,<br>
Volume 144, Number 1, May 2008, pages 62-80.
</li>
<li>
Thomas Patterson,<br>
The optimal addition of points to quadrature formulae,<br>
Mathematics of Computation,<br>
Volume 22, Number 104, October 1968, pages 847-856.
</li>
<li>
Knut Petras,<br>
Smolyak Cubature of Given Polynomial Degree with Few Nodes
for Increasing Dimension,<br>
Numerische Mathematik,<br>
Volume 93, Number 4, February 2003, pages 729-753.
</li>
</ul>
</p>
<h3 align = "center">
Source Code:
</h3>
<p>
<ul>
<li>
<a href = "sparse_grid_hw.cpp">sparse_grid_hw.cpp</a>, the source code.
</li>
<li>
<a href = "sparse_grid_hw.hpp">sparse_grid_hw.hpp</a>, the include file.
</li>
<li>
<a href = "sparse_grid_hw.sh">sparse_grid_hw.sh</a>,
BASH commands to compile the source code.
</li>
</ul>
</p>
<h3 align = "center">
Examples and Tests:
</h3>
<p>
<ul>
<li>
<a href = "sparse_grid_hw_prb.cpp">sparse_grid_hw_prb.cpp</a>,
a sample calling program.
</li>
<li>
<a href = "sparse_grid_hw_prb.sh">sparse_grid_hw_prb.sh</a>,
BASH commands to compile and run the sample program.
</li>
<li>
<a href = "sparse_grid_hw_prb_output.txt">sparse_grid_hw_prb_output.txt</a>,
the output file.
</li>
</ul>
</p>
<h3 align = "center">
List of Routines:
</h3>
<p>
<ul>
<li>
<b>CCE_ORDER:</b> order of a Clenshaw-Curtis Exponential rule from the level.
</li>
<li>
<b>CCL_ORDER</b> computes the order of a CCL rule from the level.
</li>
<li>
<b>CCS_ORDER:</b> order of a "slow growth" Clenshaw Curtis quadrature rule.
</li>
<li>
<b>CC</b> computes a Clenshaw Curtis quadrature rule based on order.
</li>
<li>
<b>CPU_TIME</b> reports the elapsed CPU time.
</li>
<li>
<b>FN_INTEGRAL</b> is the integral of the Hermite test function.
</li>
<li>
<b>FN_VALUE</b> is a Hermite test function.
</li>
<li>
<b>FU_INTEGRAL</b> is the integral of the test function for the [0,1]^D interval.
</li>
<li>
<b>FU_VALUE</b> is a sample function for the [0,1]^D interval.
</li>
<li>
<b>GET_SEQ</b> generates all positive integer D-vectors that sum to NORM.
</li>
<li>
<b>GQN</b> provides data for Gauss quadrature with a normal weight.
</li>
<li>
<b>GQN_ORDER</b> computes the order of a GQN rule from the level.
</li>
<li>
<b>GQN2_ORDER</b> computes the order of a GQN rule from the level.
</li>
<li>
<b>GQU</b> provides data for Gauss quadrature with a uniform weight.
</li>
<li>
<b>GQU_ORDER</b> computes the order of a GQU rule from the level.
</li>
<li>
<b>I4_CHOOSE</b> computes the binomial coefficient C(N,K).
</li>
<li>
<b>I4_FACTORIAL2</b> computes the double factorial function.
</li>
<li>
<b>I4_MAX</b> returns the maximum of two I4's.
</li>
<li>
<b>I4_MIN</b> returns the minimum of two I4's.
</li>
<li>
<b>I4_MOP</b> returns the I-th power of -1 as an I4 value.
</li>
<li>
<b>I4_POWER</b> returns the value of I^J.
</li>
<li>
<b>I4MAT_PRINT</b> prints an I4MAT.
</li>
<li>
<b>I4MAT_PRINT_SOME</b> prints some of an I4MAT.
</li>
<li>
<b>I4VEC_CUM0_NEW</b> computes the cumulutive sum of the entries of an I4VEC.
</li>
<li>
<b>I4VEC_PRINT</b> prints an I4VEC.
</li>
<li>
<b>I4VEC_PRODUCT</b> multiplies the entries of an I4VEC.
</li>
<li>
<b>I4VEC_SUM</b> sums the entries of an I4VEC.
</li>
<li>
<b>I4VEC_TRANSPOSE_PRINT</b> prints an I4VEC "transposed".
</li>
<li>
<b>KPN</b> provides data for Kronrod-Patterson quadrature with a normal weight.
</li>
<li>
<b>KPN_ORDER</b> computes the order of a KPN rule from the level.
</li>
<li>
<b>KPU</b> provides data for Kronrod-Patterson quadrature with a uniform weight.
</li>
<li>
<b>KPU_ORDER</b> computes the order of a KPU rule from the level.
</li>
<li>
<b>NUM_SEQ</b> returns the number of compositions of the integer N into K parts.
</li>
<li>
<b>NWSPGR</b> generates nodes and weights for sparse grid integration.
</li>
<li>
<b>NWSPGR_SIZE</b> determines the size of a sparse grid rule.
</li>
<li>
<b>QUAD_RULE_PRINT</b> prints a multidimensional quadrature rule.
</li>
<li>
<b>R8_ABS</b> returns the absolute value of an R8.
</li>
<li>
<b>R8_UNIFORM_01</b> returns a unit pseudorandom R8.
</li>
<li>
<b>R8CVV_OFFSET</b> determines the row offsets of an R8CVV.
</li>
<li>
<b>R8CVV_PRINT</b> prints an R8CVV.
</li>
<li>
<b>R8CVV_RGET_NEW</b> gets row I from an R8CVV.
</li>
<li>
<b>R8CVV_RSET</b> sets row I from an R8CVV.
</li>
<li>
<b>R8MAT_NORMAL_01_NEW</b> returns a unit pseudonormal R8MAT.
</li>
<li>
<b>R8MAT_TRANSPOSE_PRINT</b> prints an R8MAT, transposed.
</li>
<li>
<b>R8MAT_TRANSPOSE_PRINT_SOME</b> prints some of an R8MAT, transposed.
</li>
<li>
<b>R8MAT_UNIFORM_01_NEW</b> returns a unit pseudorandom R8MAT.
</li>
<li>
<b>R8VEC_COPY</b> copies an R8VEC.
</li>
<li>
<b>R8VEC_DIRECT_PRODUCT</b> creates a direct product of R8VEC's.
</li>
<li>
<b>R8VEC_DIRECT_PRODUCT2</b> creates a direct product of R8VEC's.
</li>
<li>
<b>R8VEC_DOT_PRODUCT</b> computes the dot product of a pair of R8VEC's.
</li>
<li>
<b>R8VEC_NORMAL_01_NEW</b> returns a unit pseudonormal R8VEC.
</li>
<li>
<b>R8VEC_PRINT</b> prints an R8VEC.
</li>
<li>
<b>R8VEC_SUM</b> returns the sum of an R8VEC.
</li>
<li>
<b>R8VEC_TRANSPOSE_PRINT</b> prints an R8VEC "transposed".
</li>
<li>
<b>R8VEC_UNIFORM_01_NEW</b> returns a new unit pseudorandom R8VEC.
</li>
<li>
<b>RULE_SORT</b> sorts a multidimensional quadrature rule.
</li>
<li>
<b>SORT_HEAP_EXTERNAL</b> externally sorts a list of items into ascending order.
</li>
<li>
<b>SYMMETRIC_SPARSE_SIZE</b> sizes a symmetric sparse rule.
</li>
<li>
<b>TENSOR_PRODUCT</b> generates a tensor product quadrature rule.
</li>
<li>
<b>TENSOR_PRODUCT_CELL</b> generates a tensor product quadrature rule.
</li>
<li>
<b>TIMESTAMP</b> prints the current YMDHMS date as a time stamp.
</li>
</ul>
</p>
<p>
You can go up one level to <a href = "../cpp_src.html">
the C++ source codes</a>.
</p>
<hr>
<i>
Last revised on 26 February 2014.
</i>
<!-- John Burkardt -->
</body>
</html>