-
Notifications
You must be signed in to change notification settings - Fork 1
/
sparse_grid_hw_jl.c
6492 lines (5134 loc) · 157 KB
/
sparse_grid_hw_jl.c
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
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# include <stdlib.h>
# include <stdio.h>
# include <math.h>
# include <time.h>
# include <string.h>
# include "sparse_grid_hw_jl.h"
/******************************************************************************/
int cce_order ( int l )
/******************************************************************************/
/*
Purpose:
CCE_ORDER: order of a Clenshaw-Curtis Exponential rule from the level.
Licensing:
This code is distributed under the GNU LGPL license.
Modified:
22 February 2014
Author:
John Burkardt.
Parameters:
Input, int L, the level of the rule.
1 <= L.
Output, int CCE_ORDER, the order of the rule.
*/
{
int n;
if ( l < 1 )
{
fprintf ( stderr, "\n" );
fprintf ( stderr, "CCE_ORDER - Fatal error!\n" );
fprintf ( stderr, " 1 <= L required.\n" );
fprintf ( stderr, " Input L = %d\n", l );
exit ( 1 );
}
else if ( l == 1 )
{
n = 1;
}
else
{
n = i4_power ( 2, l - 1 ) + 1;
}
return n;
}
/******************************************************************************/
int ccl_order ( int l )
/******************************************************************************/
/*
Purpose:
CCL_ORDER computes the order of a CCL rule from the level.
Licensing:
This code is distributed under the GNU LGPL license.
Modified:
19 February 2014
Author:
John Burkardt.
Parameters:
Input, int L, the level of the rule.
1 <= L.
Output, int CCL_ORDER, the order of the rule.
*/
{
int n;
if ( l < 1 )
{
fprintf ( stderr, "\n" );
fprintf ( stderr, "CCL_ORDER - Fatal error!\n" );
fprintf ( stderr, " 1 <= L required.\n" );
fprintf ( stderr, " Input L = %d\n", l );
exit ( 1 );
}
n = 2 * l - 1;
return n;
}
/******************************************************************************/
int ccs_order ( int l )
/******************************************************************************/
/*
Purpose:
CCS_ORDER: order of a "slow growth" Clenshaw Curtis quadrature rule.
Discussion:
Our convention is that the abscissas are numbered from left to right.
The rule is defined on [0,1].
The integral to approximate:
Integral ( 0 <= X <= 1 ) F(X) dX
The quadrature rule:
Sum ( 1 <= I <= N ) W(I) * F ( X(I) )
The input value L requests a rule of precision at least 2*L-1.
In order to preserve nestedness, this function returns the order
of a rule which is the smallest value of the form 1+2^E which
is greater than or equal to 2*L-1.
L 2*L-1 N
-- ----- --
1 1 1
2 3 3
3 5 5
4 7 9
5 9 9
6 11 17
7 13 17
8 15 17
9 17 17
10 19 33
Licensing:
This code is distributed under the GNU LGPL license.
Modified:
08 December 2012
Author:
John Burkardt
Parameters:
Input, int L, the level of the rule.
1 <= L.
Output, int CCS_ORDER, the appropriate order.
*/
{
int n;
if ( l < 1 )
{
fprintf ( stderr, "\n" );
fprintf ( stderr, "CCS_ORDER - Fatal error!\n" );
fprintf ( stderr, " Illegal value of L = %d\n", l );
exit ( 1 );
}
/*
Find the order N that satisfies the precision requirement.
*/
if ( l == 1 )
{
n = 1;
}
else
{
n = 3;
while ( n < 2 * l - 1 )
{
n = 2 * n - 1;
}
}
return n;
}
/******************************************************************************/
void cc ( int n, double x[], double w[] )
/******************************************************************************/
/*
Purpose:
CC computes a Clenshaw Curtis quadrature rule based on order.
Discussion:
Our convention is that the abscissas are numbered from left to right.
The rule is defined on [0,1].
The integral to approximate:
Integral ( 0 <= X <= 1 ) F(X) dX
The quadrature rule:
Sum ( 1 <= I <= N ) W(I) * F ( X(I) )
Licensing:
This code is distributed under the GNU LGPL license.
Modified:
08 December 2012
Author:
John Burkardt
Parameters:
Input, int N, the order of the rule.
1 <= N.
Output, double X[N], the abscissas.
Output, double W[N], the weights.
*/
{
double b;
int i;
int j;
double pi = 3.141592653589793;
double theta;
if ( n < 1 )
{
fprintf ( stderr, "\n" );
fprintf ( stderr, "CC - Fatal error!\n" );
fprintf ( stderr, " Illegal value of N = %d\n", n );
exit ( 1 );
}
if ( n == 1 )
{
x[0] = 0.0;
w[0] = 2.0;
}
else
{
for ( i = 0; i < n; i++ )
{
x[i] = cos ( ( double ) ( n - 1 - i ) * pi
/ ( double ) ( n - 1 ) );
}
x[0] = -1.0;
if ( ( n % 2 ) == 1 )
{
x[(n+1)/2-1] = 0.0;
}
x[n-1] = +1.0;
for ( i = 0; i < n; i++ )
{
theta = ( double ) ( i ) * pi
/ ( double ) ( n - 1 );
w[i] = 1.0;
for ( j = 1; j <= ( n - 1 ) / 2; j++ )
{
if ( 2 * j == ( n - 1 ) )
{
b = 1.0;
}
else
{
b = 2.0;
}
w[i] = w[i] - b * cos ( 2.0 * ( double ) ( j ) * theta )
/ ( double ) ( 4 * j * j - 1 );
}
}
w[0] = w[0] / ( double ) ( n - 1 );
for ( j = 1; j < n - 1; j++ )
{
w[j] = 2.0 * w[j] / ( double ) ( n - 1 );
}
w[n-1] = w[n-1] / ( double ) ( n - 1 );
}
/*
Transform from [-1,+1] to [0,1].
*/
rule_adjust ( -1.0, +1.0, 0.0, +1.0, n, x, w );
return;
}
/******************************************************************************/
double cpu_time ( )
/******************************************************************************/
/*
Purpose:
CPU_TIME returns the current reading on the CPU clock.
Discussion:
The CPU time measurements available through this routine are often
not very accurate. In some cases, the accuracy is no better than
a hundredth of a second.
Licensing:
This code is distributed under the GNU LGPL license.
Modified:
06 June 2005
Author:
John Burkardt
Parameters:
Output, double CPU_TIME, the current reading of the CPU clock, in seconds.
*/
{
double value;
value = ( double ) clock ( )
/ ( double ) CLOCKS_PER_SEC;
return value;
}
/******************************************************************************/
double fn_integral ( int d )
/******************************************************************************/
/*
Purpose:
FN_INTEGRAL is the integral of the Hermite test function.
Licensing:
This code is distributed under the GNU LGPL license.
Modified:
08 December 2012
Author:
John Burkardt.
Parameters:
Input, int D, the spatial dimension.
Output, double FN_INTEGRAL, the integral value.
*/
{
int exponent = 6;
double value;
value = ( double ) ( i4_factorial2 ( exponent - 1 ) );
return value;
}
/******************************************************************************/
double *fn_value ( int d, int n, double x[] )
/******************************************************************************/
/*
Purpose:
FN_VALUE is a Hermite test function.
Licensing:
This code is distributed under the GNU LGPL license.
Modified:
08 May 2012
Author:
John Burkardt.
Parameters:
Input, int D, the spatial dimension.
Input, int N, the number of points.
Input, double X[D*N], the points.
Output, double FN_VALUE[N], the function values.
*/
{
int exponent = 6;
double *fx;
int i;
fx = ( double * ) malloc ( n * sizeof ( double ) );
for ( i = 0; i < n; i++ )
{
fx[i] = pow ( x[0+i*d], exponent );
}
return fx;
}
/******************************************************************************/
double fu_integral ( int d )
/******************************************************************************/
/*
Purpose:
FU_INTEGRAL is the integral of the test function for the [0,1]^D interval.
Discussion:
The same function, integrated over [-1,+1]^D, has an integral
that is 2^D times larger.
Licensing:
This code is distributed under the GNU LGPL license.
Modified:
08 December 2012
Author:
John Burkardt.
Parameters:
Input, int D, the spatial dimension.
Output, double FU_INTEGRAL, the integral value.
*/
{
double value;
value = pow ( 0.5 * erf ( 0.5 / sqrt ( 2.0 ) ), d );
return value;
}
/******************************************************************************/
double *fu_value ( int d, int n, double x[] )
/******************************************************************************/
/*
Purpose:
FU_VALUE is a sample function for the [0,1]^D interval.
Licensing:
This code is distributed under the GNU LGPL license.
Modified:
08 December 2012
Author:
John Burkardt.
Parameters:
Input, int D, the spatial dimension.
Input, int N, the number of points.
Input, double X[D*N], the points.
Output, double FU_VALUE[N], the function values.
*/
{
double *fx;
int i;
int j;
double pi = 3.141592653589793;
fx = ( double * ) malloc ( n * sizeof ( double ) );
for ( j = 0; j < n; j++ )
{
fx[j] = 1.0;
for ( i = 0; i < d; i++ )
{
fx[j] = fx[j] * exp ( - pow ( x[i+j*d] / 2.0, 2 ) / 2.0 )
/ 2.0 / sqrt ( 2.0 * pi );
}
}
return fx;
}
/******************************************************************************/
int *get_seq ( int d, int norm, int seq_num )
/******************************************************************************/
/*
Purpose:
GET_SEQ generates all positive integer D-vectors that sum to NORM.
Discussion:
This function computes a list, in reverse dictionary order, of
all D-vectors of positive values that sum to NORM.
For example, call get_seq ( 3, 5, 6, fs ) returns
3 1 1
2 2 1
2 1 2
1 3 1
1 2 2
1 1 3
Licensing:
This code is distributed under the GNU LGPL license.
Modified:
08 December 2012
Author:
Original MATLAB version by Florian Heiss, Viktor Winschel.
C version by John Burkardt.
Reference:
Florian Heiss, Viktor Winschel,
Likelihood approximation by numerical integration on sparse grids,
Journal of Econometrics,
Volume 144, 2008, pages 62-80.
Parameters:
Input, int D, the dimension.
1 <= D.
Input, int NORM, the value that each row must sum to.
D <= NORM.
Input, int SEQ_NUM, the number of rows of FS.
Output, int GET_SEQ[SEQ_NUM*D]. Each row of FS represents
one vector with all elements positive and summing to NORM.
*/
{
int a;
int c;
int *fs;
int i;
int row;
int *seq;
seq = ( int * ) malloc ( d * sizeof ( int ) );
fs = ( int * ) malloc ( seq_num * d * sizeof ( int ) );
if ( norm < d )
{
fprintf ( stderr, "\n" );
fprintf ( stderr, "GET_SEQ - Fatal error!\n" );
fprintf ( stderr, " NORM = %d < D = %d\n", norm, d );
exit ( 1 ) ;
}
for ( i = 0; i < d; i++ )
{
seq[i] = 0;
}
/*
The algorithm is written to work with vectors whose minimum value is
allowed to be zero. So we subtract D from NORM at the beginning and
then increment the result vectors by 1 at the end!
*/
a = norm - d;
seq[0] = a;
row = 0;
for ( i = 0; i < d; i++ )
{
fs[row+i*seq_num] = seq[i] + 1;
}
c = 0;
while ( seq[d-1] < a )
{
if ( c == d - 1 )
{
for ( i = c - 1; 0 <= i; i-- )
{
c = i;
if ( seq[i] != 0 )
{
break;
}
}
}
seq[c] = seq[c] - 1;
c = c + 1;
seq[c] = a;
for ( i = 0; i < c; i++ )
{
seq[c] = seq[c] - seq[i];
}
if ( c < d - 1 )
{
for ( i = c + 1; i < d; i++ )
{
seq[i] = 0;
}
}
row = row + 1;
for ( i = 0; i < d; i++ )
{
fs[row+i*seq_num] = seq[i] + 1;
}
}
free ( seq );
return fs;
}
/******************************************************************************/
void gqn ( int n, double x[], double w[] )
/******************************************************************************/
/*
Purpose:
GQN provides data for Gauss quadrature with a normal weight.
Discussion:
This data assumes integration over the interval (-oo,+oo) with
weight function w(x) = exp(-x*x/2)/sqrt(2*pi).
Licensing:
This code is distributed under the GNU LGPL license.
Modified:
10 December 2012
Author:
Original MATLAB version by Florian Heiss, Viktor Winschel.
C version by John Burkardt.
Reference:
Florian Heiss, Viktor Winschel,
Likelihood approximation by numerical integration on sparse grids,
Journal of Econometrics,
Volume 144, 2008, pages 62-80.
Parameters:
Input, int N, the number of points and weights.
1 <= N <= 25.
Output, double X[N], the nodes.
Output, double W[N], the weights.
*/
{
double x01[1] = {
0.00000000000000000 };
double w01[1] = {
1.00000000000000000 };
double x02[2] = {
-1.00000000000000000, 1.00000000000000000 };
double w02[2] = {
0.50000000000000000, 0.50000000000000000 };
double x03[3] = {
-1.73205080756887719, 0.00000000000000000, 1.73205080756887719 };
double w03[3] = {
0.166666666666666741, 0.66666666666666663, 0.166666666666666741 };
double x04[4] = {
-2.33441421833897733, -0.741963784302725915, 0.741963784302725915,
2.33441421833897733 };
double w04[4] = {
0.0458758547680684983, 0.454124145231931453, 0.454124145231931453,
0.0458758547680684983 };
double x05[5] = {
-2.85697001387280558, -1.35562617997426593, 0.00000000000000000,
1.35562617997426593, 2.85697001387280558 };
double w05[5] = {
0.011257411327720691, 0.22207592200561263, 0.533333333333333437,
0.22207592200561263, 0.011257411327720691 };
double x06[6] = {
-3.32425743355211933, -1.88917587775371087, -0.616706590192594217,
0.616706590192594217, 1.88917587775371087, 3.32425743355211933 };
double w06[6] = {
0.00255578440205624308, 0.0886157460419145226, 0.408828469556029195,
0.408828469556029195, 0.0886157460419145226, 0.00255578440205624308 };
double x07[7] = {
-3.75043971772574247, -2.36675941073454155, -1.15440539473996817,
0.00000000000000000, 1.15440539473996817, 2.36675941073454155,
3.75043971772574247 };
double w07[7] = {
0.000548268855972218754, 0.0307571239675864909, 0.240123178605012505,
0.457142857142857573, 0.240123178605012505, 0.0307571239675864909,
0.000548268855972218754 };
double x08[8] = {
-4.14454718612589446, -2.80248586128754162, -1.63651904243510815,
-0.539079811351375171, 0.539079811351375171, 1.63651904243510815,
2.80248586128754162, 4.14454718612589446 };
double w08[8] = {
0.000112614538375367836, 0.00963522012078826297, 0.117239907661758971,
0.373012257679077364, 0.373012257679077364, 0.117239907661758971,
0.00963522012078826297, 0.000112614538375367836 };
double x09[9] = {
-4.51274586339978256, -3.20542900285647026, -2.07684797867783022,
-1.02325566378913257, 0.00000000000000000, 1.02325566378913257,
2.07684797867783022, 3.20542900285647026, 4.51274586339978256 };
double w09[9] = {
2.23458440077465626E-05, 0.0027891413212317675, 0.0499164067652179688,
0.244097502894939089, 0.406349206349206848, 0.244097502894939089,
0.0499164067652179688, 0.0027891413212317675, 2.23458440077465626E-05 };
double x10[10] = {
-4.85946282833231269, -3.58182348355192692, -2.48432584163895465,
-1.46598909439115821, -0.484935707515497638, 0.484935707515497638,
1.46598909439115821, 2.48432584163895465, 3.58182348355192692,
4.85946282833231269 };
double w10[10] = {
4.3106526307183106E-06, 0.000758070934312219725, 0.0191115805007703171,
0.135483702980267295, 0.344642334932019401, 0.344642334932019401,
0.135483702980267295, 0.0191115805007703171, 0.000758070934312219725,
4.3106526307183106E-06 };
double x11[11] = {
-5.18800122437487143, -3.93616660712997746, -2.8651231606436447,
-1.87603502015484591, -0.928868997381063877, 0.00000000000000000,
0.928868997381063877, 1.87603502015484591, 2.8651231606436447,
3.93616660712997746, 5.18800122437487143 };
double w11[11] = {
8.12184979021490357E-07, 0.000195671930271223244, 0.0067202852355372697,
0.0661387460710576441, 0.242240299873970027, 0.369408369408369575,
0.242240299873970027, 0.0661387460710576441, 0.0067202852355372697,
0.000195671930271223244, 8.12184979021490357E-07 };
double x12[12] = {
-5.50090170446774795, -4.27182584793228148, -3.22370982877009737,
-2.25946445100079929, -1.34037519715161668, -0.444403001944139009,
0.444403001944139009, 1.34037519715161668, 2.25946445100079929,
3.22370982877009737, 4.27182584793228148, 5.50090170446774795 };
double w12[12] = {
1.49992716763715968E-07, 4.83718492259060763E-05, 0.00220338068753318491,
0.0291166879123641378, 0.146967048045329951, 0.321664361512830066,
0.321664361512830066, 0.146967048045329951, 0.0291166879123641378,
0.00220338068753318491, 4.83718492259060763E-05, 1.49992716763715968E-07 };
double x13[13] = {
-5.8001672523865011, -4.59139844893652072, -3.56344438028163468,
-2.62068997343221488, -1.7254183795882394, -0.856679493519450053,
0.00000000000000000, 0.856679493519450053, 1.7254183795882394,
2.62068997343221488, 3.56344438028163468, 4.59139844893652072,
5.8001672523865011 };
double w13[13] = {
2.72262764280590389E-08, 1.15265965273338848E-05, 0.000681236350442926191,
0.0117705605059965426, 0.0791689558604501409, 0.237871522964135884,
0.340992340992341492, 0.237871522964135884, 0.0791689558604501409,
0.0117705605059965426, 0.000681236350442926191, 1.15265965273338848E-05,
2.72262764280590389E-08 };
double x14[14] = {
-6.08740954690129144, -4.89693639734556463, -3.88692457505976963,
-2.96303657983866753, -2.08834474570194439, -1.24268895548546432,
-0.412590457954601808, 0.412590457954601808, 1.24268895548546432,
2.08834474570194439, 2.96303657983866753, 3.88692457505976963,
4.89693639734556463, 6.08740954690129144 };
double w14[14] = {
4.86816125774838718E-09, 2.66099134406763342E-06, 0.00020033955376074381,
0.00442891910694740657, 0.0386501088242534319, 0.154083339842513656,
0.302634626813019447, 0.302634626813019447, 0.154083339842513656,
0.0386501088242534319, 0.00442891910694740657, 0.00020033955376074381,
2.66099134406763342E-06, 4.86816125774838718E-09 };
double x15[15] = {
-6.36394788882983775, -5.19009359130478209, -4.19620771126901548,
-3.28908242439876641, -2.43243682700975805, -1.60671006902873015,
-0.799129068324548109, 0.00000000000000000, 0.799129068324548109,
1.60671006902873015, 2.43243682700975805, 3.28908242439876641,
4.19620771126901548, 5.19009359130478209, 6.36394788882983775 };
double w15[15] = {
8.58964989963318053E-10, 5.97541959792059611E-07, 5.64214640518901565E-05,
0.00156735750354995707, 0.0173657744921376159, 0.0894177953998444436,
0.232462293609732223, 0.318259518259518204, 0.232462293609732223,
0.0894177953998444436, 0.0173657744921376159, 0.00156735750354995707,
5.64214640518901565E-05, 5.97541959792059611E-07, 8.58964989963318053E-10 };
double x16[16] = {
-6.63087819839312953, -5.47222570594934332, -4.49295530252001196,
-3.60087362417154866, -2.76024504763070189, -1.95198034571633361,
-1.1638291005549648, -0.386760604500557381, 0.386760604500557381,
1.1638291005549648, 1.95198034571633361, 2.76024504763070189,
3.60087362417154866, 4.49295530252001196, 5.47222570594934332,
6.63087819839312953 };
double w16[16] = {
1.49781472316183141E-10, 1.30947321628682029E-07, 1.53000321624872858E-05,
0.000525984926573909786, 0.0072669376011847411, 0.0472847523540140674,
0.158338372750949252, 0.286568521238012408, 0.286568521238012408,
0.158338372750949252, 0.0472847523540140674, 0.0072669376011847411,
0.000525984926573909786, 1.53000321624872858E-05, 1.30947321628682029E-07,
1.49781472316183141E-10 };
double x17[17] = {
-6.88912243989533302, -5.74446007865940711, -4.77853158962998403,
-3.90006571719801043, -3.07379717532819408, -2.28101944025298886,
-1.50988330779674085, -0.751842600703896302, 0.00000000000000000,
0.751842600703896302, 1.50988330779674085, 2.28101944025298886,
3.07379717532819408, 3.90006571719801043, 4.77853158962998403,
5.74446007865940711, 6.88912243989533302 };
double w17[17] = {
2.58431491937491514E-11, 2.80801611793057831E-08, 4.0126794479798725E-06,
0.000168491431551339447, 0.00285894606228464989, 0.023086657025711152,
0.0974063711627180806, 0.226706308468978768, 0.299538370126607556,
0.226706308468978768, 0.0974063711627180806, 0.023086657025711152,
0.00285894606228464989, 0.000168491431551339447, 4.0126794479798725E-06,
2.80801611793057831E-08, 2.58431491937491514E-11 };
double x18[18] = {
-7.13946484914647961, -6.00774591135959746, -5.05407268544274046,
-4.1880202316294044, -3.37473653577809074, -2.59583368891124033,
-1.83977992150864567, -1.09839551809150127, -0.365245755507697667,
0.365245755507697667, 1.09839551809150127, 1.83977992150864567,
2.59583368891124033, 3.37473653577809074, 4.1880202316294044,
5.05407268544274046, 6.00774591135959746, 7.13946484914647961 };
double w18[18] = {
4.41658876935870775E-12, 5.90548847883654844E-09, 1.02155239763698159E-06,
5.17989614411619621E-05, 0.00106548479629164959, 0.0105165177519413525,
0.0548966324802226541, 0.160685303893512627, 0.272783234654287887,
0.272783234654287887, 0.160685303893512627, 0.0548966324802226541,
0.0105165177519413525, 0.00106548479629164959, 5.17989614411619621E-05,
1.02155239763698159E-06, 5.90548847883654844E-09, 4.41658876935870775E-12 };
double x19[19] = {
-7.38257902403043165, -6.2628911565132519, -5.32053637733603857,
-4.46587262683103159, -3.66441654745063827, -2.89805127651575356,
-2.15550276131693508, -1.4288766760783731, -0.712085044042379933,
0.00000000000000000, 0.712085044042379933, 1.4288766760783731,
2.15550276131693508, 2.89805127651575356, 3.66441654745063827,
4.46587262683103159, 5.32053637733603857, 6.2628911565132519,
7.38257902403043165 };
double w19[19] = {
7.4828300540572308E-13, 1.22037084844747862E-09, 2.53222003209286807E-07,
1.53511459546667444E-05, 0.000378502109414267593, 0.00450723542034203555,
0.0286666910301184956, 0.103603657276143998, 0.220941712199143658,
0.283773192751521075, 0.220941712199143658, 0.103603657276143998,
0.0286666910301184956, 0.00450723542034203555, 0.000378502109414267593,
1.53511459546667444E-05, 2.53222003209286807E-07, 1.22037084844747862E-09,
7.4828300540572308E-13 };
double x20[20] = {
-7.61904854167975909, -6.51059015701365507, -5.57873880589320148,
-4.73458133404605519, -3.9439673506573163, -3.18901481655339003,
-2.45866361117236787, -1.74524732081412703, -1.04294534880275092,
-0.346964157081355917, 0.346964157081355917, 1.04294534880275092,
1.74524732081412703, 2.45866361117236787, 3.18901481655339003,
3.9439673506573163, 4.73458133404605519, 5.57873880589320148,
6.51059015701365507, 7.61904854167975909 };
double w20[20] = {
1.25780067243793047E-13, 2.4820623623151838E-10, 6.12749025998295973E-08,
4.40212109023086457E-06, 0.000128826279961928981, 0.00183010313108049175,
0.0139978374471010428, 0.0615063720639760295, 0.161739333984000255,
0.26079306344955544, 0.26079306344955544, 0.161739333984000255,
0.0615063720639760295, 0.0139978374471010428, 0.00183010313108049175,
0.000128826279961928981, 4.40212109023086457E-06, 6.12749025998295973E-08,
2.4820623623151838E-10, 1.25780067243793047E-13 };
double x21[21] = {
-7.84938289511382248, -6.75144471871746088, -5.82938200730447065,
-4.99496394478202532, -4.21434398168842161, -3.46984669047537642,
-2.75059298105237326, -2.0491024682571628, -1.35976582321123041,
-0.678045692440644054, 0.00000000000000000, 0.678045692440644054,
1.35976582321123041, 2.0491024682571628, 2.75059298105237326,
3.46984669047537642, 4.21434398168842161, 4.99496394478202532,
5.82938200730447065, 6.75144471871746088, 7.84938289511382248 };
double w21[21] = {
2.09899121956566525E-14, 4.97536860412174643E-11, 1.45066128449307397E-08,
1.22535483614825217E-06, 4.21923474255158655E-05, 0.000708047795481537364,
0.00643969705140877684, 0.0339527297865428387, 0.10839228562641938,
0.215333715695059824, 0.270260183572877066, 0.215333715695059824,
0.10839228562641938, 0.0339527297865428387, 0.00643969705140877684,
0.000708047795481537364, 4.21923474255158655E-05, 1.22535483614825217E-06,
1.45066128449307397E-08, 4.97536860412174643E-11, 2.09899121956566525E-14 };
double x22[22] = {
-8.07402998402171157, -6.98598042401881525, -6.07307495112289786,
-5.2477244337144251, -4.47636197731086849, -3.74149635026651772,
-3.03240422783167629, -2.34175999628770803, -1.6641248391179071,
-0.995162422271215541, -0.331179315715273814, 0.331179315715273814,
0.995162422271215541, 1.6641248391179071, 2.34175999628770803,
3.03240422783167629, 3.74149635026651772, 4.47636197731086849,
5.2477244337144251, 6.07307495112289786, 6.98598042401881525,
8.07402998402171157 };
double w22[22] = {
3.47946064787714279E-15, 9.84137898234601051E-12, 3.36651415945821088E-09,
3.31985374981400429E-07, 1.33459771268087124E-05, 0.000262283303255964159,
0.00280876104757721073, 0.0175690728808057736, 0.0671963114288898905,
0.161906293413675378, 0.250243596586935013, 0.250243596586935013,
0.161906293413675378, 0.0671963114288898905, 0.0175690728808057736,
0.00280876104757721073, 0.000262283303255964159, 1.33459771268087124E-05,
3.31985374981400429E-07, 3.36651415945821088E-09, 9.84137898234601051E-12,
3.47946064787714279E-15 };
double x23[23] = {
-8.29338602741735365, -7.21465943505186225, -6.31034985444839958,
-5.49347398647179475, -4.73072419745147332, -4.00477532173330442,
-3.30504002175296518, -2.62432363405918201, -1.9573275529334242,
-1.29987646830397896, -0.648471153534495803, 0.00000000000000000,
0.648471153534495803, 1.29987646830397896, 1.9573275529334242,
2.62432363405918201, 3.30504002175296518, 4.00477532173330442,
4.73072419745147332, 5.49347398647179475, 6.31034985444839958,
7.21465943505186225, 8.29338602741735365 };
double w23[23] = {
5.73238316780208728E-16, 1.92293531156779128E-12, 7.67088886239990765E-10,
8.77506248386171607E-08, 4.08997724499215494E-06, 9.34081860903129835E-05,
0.00116762863749786134, 0.00857967839146566401, 0.0388671837034809467,
0.112073382602620911, 0.209959669577542613, 0.258509740808839039,
0.209959669577542613, 0.112073382602620911, 0.0388671837034809467,
0.00857967839146566401, 0.00116762863749786134, 9.34081860903129835E-05,
4.08997724499215494E-06, 8.77506248386171607E-08, 7.67088886239990765E-10,
1.92293531156779128E-12, 5.73238316780208728E-16 };
double x24[24] = {
-8.50780351919525835, -7.43789066602166304, -6.54167500509863409,
-5.73274717525120092, -4.97804137463912078, -4.26038360501990532,
-3.56930676407356096, -2.89772864322331403, -2.24046785169175244,
-1.59348042981642024, -0.953421922932109256, -0.317370096629452314,
0.317370096629452314, 0.953421922932109256, 1.59348042981642024,
2.24046785169175244, 2.89772864322331403, 3.56930676407356096,
4.26038360501990532, 4.97804137463912078, 5.73274717525120092,
6.54167500509863409, 7.43789066602166304, 8.50780351919525835 };
double w24[24] = {
9.39019368904192022E-17, 3.71497415276241595E-13, 1.71866492796486901E-10,
2.26746167348046514E-08, 1.21765974544258296E-06, 3.20950056527459886E-05,
0.000464718718779397633, 0.00397660892918131129, 0.0211263444089670287,
0.0720693640171784361, 0.161459512867000249, 0.240870115546640562,
0.240870115546640562, 0.161459512867000249, 0.0720693640171784361,
0.0211263444089670287, 0.00397660892918131129, 0.000464718718779397633,
3.20950056527459886E-05, 1.21765974544258296E-06, 2.26746167348046514E-08,
1.71866492796486901E-10, 3.71497415276241595E-13, 9.39019368904192022E-17 };
double x25[25] = {
-8.71759767839958855, -7.65603795539307619, -6.76746496380971685,
-5.96601469060670198, -5.21884809364427937, -4.50892992296728501,
-3.82590056997249173, -3.16277567938819271, -2.51447330395220581,
-1.8770583699478387, -1.24731197561678919, -0.622462279186076106,
0.00000000000000000, 0.622462279186076106, 1.24731197561678919,
1.8770583699478387, 2.51447330395220581, 3.16277567938819271,
3.82590056997249173, 4.50892992296728501, 5.21884809364427937,
5.96601469060670198, 6.76746496380971685, 7.65603795539307619,
8.71759767839958855 };
double w25[25] = {
1.53003899799868247E-17, 7.10210303700392527E-14, 3.79115000047718706E-11,
5.7380238688993763E-09, 3.53015256024549785E-07, 1.06721949052025363E-05,
0.0001777669069265266, 0.00175785040526379608, 0.0108567559914623159,
0.0433799701676449712, 0.114880924303951637, 0.204851025650340413,
0.248169351176485475, 0.204851025650340413, 0.114880924303951637,
0.0433799701676449712, 0.0108567559914623159, 0.00175785040526379608,
0.0001777669069265266, 1.06721949052025363E-05, 3.53015256024549785E-07,
5.7380238688993763E-09, 3.79115000047718706E-11, 7.10210303700392527E-14,
1.53003899799868247E-17 };
if ( n == 1 )
{
r8vec_copy ( n, x01, x );
r8vec_copy ( n, w01, w );
}
else if ( n == 2 )
{
r8vec_copy ( n, x02, x );
r8vec_copy ( n, w02, w );
}
else if ( n == 3 )