ROL
ROL_SandiaRulesDef.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ************************************************************************
3 //
4 // Rapid Optimization Library (ROL) Package
5 // Copyright (2014) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact lead developers:
38 // Drew Kouri (dpkouri@sandia.gov) and
39 // Denis Ridzal (dridzal@sandia.gov)
40 //
41 // ************************************************************************
42 // @HEADER
43 
44 
45 namespace ROL {
46 
47 //**************************************************************************80
48 void SandiaRules::binary_vector_next ( int n, int bvec[] )
49 //**************************************************************************80
50 //
51 // Purpose:
52 //
53 // BINARY_VECTOR_NEXT generates the next binary vector.
54 //
55 // Discussion:
56 //
57 // A binary vector is a vector whose entries are 0 or 1.
58 //
59 // The user inputs an initial zero vector to start. The program returns
60 // the "next" vector.
61 //
62 // The vectors are produced in the order:
63 //
64 // ( 0, 0, 0, ..., 0 )
65 // ( 1, 0, 0, ..., 0 )
66 // ( 0, 1, 0, ..., 0 )
67 // ( 1, 1, 0, ..., 0 )
68 // ( 0, 0, 1, ..., 0 )
69 // ( 1, 0, 1, ..., 0 )
70 // ...
71 // ( 1, 1, 1, ..., 1)
72 //
73 // and the "next" vector after (1,1,...,1) is (0,0,...,0). That is,
74 // we allow wrap around.
75 //
76 // Example:
77 //
78 // N = 3
79 //
80 // Input Output
81 // ----- ------
82 // 0 0 0 => 1 0 0
83 // 1 0 0 => 0 1 0
84 // 0 1 0 => 1 1 0
85 // 1 1 0 => 0 0 1
86 // 0 0 1 => 1 0 1
87 // 1 0 1 => 0 1 1
88 // 0 1 1 => 1 1 1
89 // 1 1 1 => 0 0 0
90 //
91 // Licensing:
92 //
93 // This code is distributed under the GNU LGPL license.
94 //
95 // Modified:
96 //
97 // 04 September 2009
98 //
99 // Author:
100 //
101 // John Burkardt
102 //
103 // Parameters:
104 //
105 // Input, int N, the dimension of the vectors.
106 //
107 // Input/output, int BVEC[N], on output, the successor
108 // to the input vector.
109 //
110 {
111  int i;
112 
113  for ( i = 0; i < n; i++ )
114  {
115  if ( bvec[i] == 1 )
116  {
117  bvec[i] = 0;
118  }
119  else
120  {
121  bvec[i] = 1;
122  break;
123  }
124  }
125  return;
126 }
127 
128 
129 //**************************************************************************80
130 void SandiaRules::ccn_compute ( int n, double x[], double w[] )
131 //**************************************************************************80
132 //
133 // Purpose:
134 //
135 // CCN_COMPUTE computes a nested Clenshaw Curtis quadrature rule.
136 //
137 // Licensing:
138 //
139 // This code is distributed under the GNU LGPL license.
140 //
141 // Modified:
142 //
143 // 07 March 2011
144 //
145 // Author:
146 //
147 // John Burkardt
148 //
149 // Parameters:
150 //
151 // Input, int N, the order.
152 // 1 <= N.
153 //
154 // Output, double X[N], the abscissas.
155 //
156 // Output, double W[N], the weights.
157 //
158 {
159  ccn_compute_points ( n, x );
160  ccn_compute_weights ( n, w );
161 
162  return;
163 }
164 
165 
166 //**************************************************************************80
167 void SandiaRules::ccn_compute_np ( int n, int np, double p[], double x[], double w[] )
168 //**************************************************************************80
169 //
170 // Purpose:
171 //
172 // CCN_COMPUTE_NP computes a nested Clenshaw Curtis quadrature rule.
173 //
174 // Licensing:
175 //
176 // This code is distributed under the GNU LGPL license.
177 //
178 // Modified:
179 //
180 // 07 March 2011
181 //
182 // Author:
183 //
184 // John Burkardt
185 //
186 // Parameters:
187 //
188 // Input, int N, the order.
189 // 1 <= N.
190 //
191 // Input, int NP, the number of parameters.
192 //
193 // Input, double P[NP], parameters which are not needed by this function.
194 //
195 // Output, double X[N], the abscissas.
196 //
197 // Output, double W[N], the weights.
198 //
199 {
200  ccn_compute_points ( n, x );
201  ccn_compute_weights ( n, w );
202 
203  return;
204 }
205 //**************************************************************************80
206 
207 void SandiaRules::ccn_compute_points ( int n, double x[] )
208 
209 //**************************************************************************80
210 //
211 // Purpose:
212 //
213 // CCN_COMPUTE_POINTS: compute nested Clenshaw Curtis points.
214 //
215 // Discussion:
216 //
217 // We want to compute the following sequence:
218 //
219 // 1/2,
220 // 0, 1
221 // 1/4, 3/4
222 // 1/8, 3/8, 5/8, 7/8,
223 // 1/16, 3/16, 5/16, 7/16, 9/16, 11/16, 13/16, 15/16, and so on.
224 //
225 // But we would prefer that the numbers in each row be regrouped in pairs
226 // that are symmetric about 1/2, with the number above 1/2 coming first.
227 // Thus, the last row might become:
228 // (9/16, 7/16), (11/16, 5/16), ..., (15/16, 1/16).
229 //
230 // Once we have our sequence, we apply the Chebyshev transformation
231 // which maps [0,1] to [-1,+1].
232 //
233 // Licensing:
234 //
235 // This code is distributed under the GNU LGPL license.
236 //
237 // Modified:
238 //
239 // 06 March 2011
240 //
241 // Author:
242 //
243 // John Burkardt
244 //
245 // Parameters:
246 //
247 // Input, int N, the number of elements to compute.
248 //
249 // Output, double X[N], the elements of the sequence.
250 //
251 {
252  int d;
253  int i;
254  int k;
255  int m;
256  double pi = 3.141592653589793;
257  int td;
258  int tu;
259 //
260 // Handle first three entries specially.
261 //
262  if ( 1 <= n )
263  {
264  x[0] = 0.5;
265  }
266 
267  if ( 2 <= n )
268  {
269  x[1] = 1.0;
270  }
271 
272  if ( 3 <= n )
273  {
274  x[2] = 0.0;
275  }
276 
277  m = 3;
278  d = 2;
279 
280  while ( m < n )
281  {
282  tu = d + 1;
283  td = d - 1;
284 
285  k = i4_min ( d, n - m );
286 
287  for ( i = 1; i <= k; i++ )
288  {
289  if ( ( i % 2 ) == 1 )
290  {
291  x[m+i-1] = tu / 2.0 / ( double ) ( k );
292  tu = tu + 2;
293  }
294  else
295  {
296  x[m+i-1] = td / 2.0 / ( double ) ( k );
297  td = td - 2;
298  }
299  }
300  m = m + k;
301  d = d * 2;
302  }
303 //
304 // Apply the Chebyshev transformation.
305 //
306  for ( i = 0; i < n; i++ )
307  {
308  x[i] = std::cos ( x[i] * pi );
309  }
310  x[0] = 0.0;
311 
312  if ( 2 <= n )
313  {
314  x[1] = -1.0;
315  }
316 
317  if ( 3 <= n )
318  {
319  x[2] = +1.0;
320  }
321 
322  return;
323 }
324 //**************************************************************************80
325 
326 void SandiaRules::ccn_compute_points_np ( int n, int np, double p[], double x[] )
327 
328 //**************************************************************************80
329 //
330 // Purpose:
331 //
332 // CCN_COMPUTE_POINTS_NP: nested Clenshaw Curtis quadrature points.
333 //
334 // Licensing:
335 //
336 // This code is distributed under the GNU LGPL license.
337 //
338 // Modified:
339 //
340 // 07 March 2011
341 //
342 // Author:
343 //
344 // John Burkardt
345 //
346 // Parameters:
347 //
348 // Input, int N, the order.
349 //
350 // Input, int NP, the number of parameters.
351 //
352 // Input, double P[NP], parameters which are not needed by this function.
353 //
354 // Output, double X[N], the abscissas.
355 //
356 {
357  ccn_compute_points ( n, x );
358 
359  return;
360 }
361 //**************************************************************************80
362 
363 void SandiaRules::ccn_compute_weights ( int n, double w[] )
364 
365 //**************************************************************************80
366 //
367 // Purpose:
368 //
369 // CCN_COMPUTE_WEIGHTS: weights for nested Clenshaw Curtis rule.
370 //
371 // Licensing:
372 //
373 // This code is distributed under the GNU LGPL license.
374 //
375 // Modified:
376 //
377 // 07 March 2011
378 //
379 // Author:
380 //
381 // John Burkardt
382 //
383 // Parameters:
384 //
385 // Input, int N, the order of the rule.
386 //
387 // Output, double W[N], the weights.
388 //
389 {
390  double *x;
391  double x_max;
392  double x_min;
393 
394  x = new double[n];
395 
396  ccn_compute_points ( n, x );
397 //
398 // Get the weights.
399 //
400  x_min = -1.0;
401  x_max = +1.0;
402 
403  nc_compute ( n, x_min, x_max, x, w );
404 
405  delete [] x;
406 
407  return;
408 }
409 //**************************************************************************80
410 
411 void SandiaRules::ccn_compute_weights_np ( int n, int np, double p[], double w[] )
412 
413 //**************************************************************************80
414 //
415 // Purpose:
416 //
417 // CCN_COMPUTE_WEIGHTS_NP: nested Clenshaw Curtis quadrature weights.
418 //
419 // Licensing:
420 //
421 // This code is distributed under the GNU LGPL license.
422 //
423 // Modified:
424 //
425 // 07 March 2011
426 //
427 // Author:
428 //
429 // John Burkardt
430 //
431 // Parameters:
432 //
433 // Input, int N, the order.
434 //
435 // Input, int NP, the number of parameters.
436 //
437 // Input, double P[NP], parameters which are not needed by this function.
438 //
439 // Output, double W[N], the weights.
440 //
441 {
442  ccn_compute_weights ( n, w );
443 
444  return;
445 }
446 //**************************************************************************80
447 
448 void SandiaRules::chebyshev1_compute ( int n, double x[], double w[] )
449 
450 //**************************************************************************80
451 //
452 // Purpose:
453 //
454 // CHEBYSHEV1_COMPUTE computes a Chebyshev type 1 quadrature rule.
455 //
456 // Discussion:
457 //
458 // The integral:
459 //
460 // Integral ( -1 <= X <= 1 ) F(X) / sqrt ( 1 - x^2 ) dX
461 //
462 // The quadrature rule:
463 //
464 // Sum ( 1 <= I <= N ) W(I) * F ( X(I) )
465 //
466 // Licensing:
467 //
468 // This code is distributed under the GNU LGPL license.
469 //
470 // Modified:
471 //
472 // 13 June 2009
473 //
474 // Author:
475 //
476 // John Burkardt
477 //
478 // Reference:
479 //
480 // Philip Davis, Philip Rabinowitz,
481 // Methods of Numerical Integration,
482 // Second Edition,
483 // Dover, 2007,
484 // ISBN: 0486453391,
485 // LC: QA299.3.D28.
486 //
487 // Parameters:
488 //
489 // Input, int N, the order.
490 // 1 <= N.
491 //
492 // Output, double X[N], the abscissas.
493 //
494 // Output, double W[N], the weights.
495 //
496 {
497  int i;
498  double pi = 3.141592653589793;
499 
500  if ( n < 1 )
501  {
502  std::cerr << "\n";
503  std::cerr << "CHEBYSHEV1_COMPUTE - Fatal error!\n";
504  std::cerr << " Illegal value of N = " << n << "\n";
505  std::exit ( 1 );
506  }
507 
508  for ( i = 0; i < n; i++ )
509  {
510  w[i] = pi / ( double ) ( n );
511  }
512  for ( i = 0; i < n; i++ )
513  {
514  x[i] = std::cos ( pi * ( double ) ( 2 * n - 1 - 2 * i )
515  / ( double ) ( 2 * n ) );
516  }
517  if ( ( n % 2 ) == 1 )
518  {
519  x[(n-1)/2] = 0.0;
520  }
521 
522  return;
523 }
524 //**************************************************************************80
525 
526 void SandiaRules::chebyshev1_compute_np ( int n, int np, double p[], double x[],
527  double w[] )
528 
529 //**************************************************************************80
530 //
531 // Purpose:
532 //
533 // CHEBYSHEV1_COMPUTE_NP computes a Chebyshev type 1 quadrature rule.
534 //
535 // Discussion:
536 //
537 // The integral:
538 //
539 // Integral ( -1 <= X <= 1 ) F(X) / sqrt ( 1 - x^2 ) dX
540 //
541 // The quadrature rule:
542 //
543 // Sum ( 1 <= I <= N ) W(I) * F ( X(I) )
544 //
545 // Licensing:
546 //
547 // This code is distributed under the GNU LGPL license.
548 //
549 // Modified:
550 //
551 // 22 June 2009
552 //
553 // Author:
554 //
555 // John Burkardt
556 //
557 // Reference:
558 //
559 // Philip Davis, Philip Rabinowitz,
560 // Methods of Numerical Integration,
561 // Second Edition,
562 // Dover, 2007,
563 // ISBN: 0486453391,
564 // LC: QA299.3.D28.
565 //
566 // Parameters:
567 //
568 // Input, int N, the order.
569 // 1 <= N.
570 //
571 // Input, int NP, the number of parameters.
572 //
573 // Input, double P[NP], parameters which are not needed by this function.
574 //
575 // Output, double X[N], the abscissas.
576 //
577 // Output, double W[N], the weights.
578 //
579 {
580  chebyshev1_compute ( n, x, w );
581 
582  return;
583 }
584 //**************************************************************************80
585 
586 void SandiaRules::chebyshev1_compute_points ( int n, double x[] )
587 
588 //**************************************************************************80
589 //
590 // Purpose:
591 //
592 // CHEBYSHEV1_COMPUTE_POINTS computes Chebyshev type 1 quadrature points.
593 //
594 // Licensing:
595 //
596 // This code is distributed under the GNU LGPL license.
597 //
598 // Modified:
599 //
600 // 13 June 2009
601 //
602 // Author:
603 //
604 // John Burkardt
605 //
606 // Reference:
607 //
608 // Philip Davis, Philip Rabinowitz,
609 // Methods of Numerical Integration,
610 // Second Edition,
611 // Dover, 2007,
612 // ISBN: 0486453391,
613 // LC: QA299.3.D28.
614 //
615 // Parameters:
616 //
617 // Input, int N, the order.
618 // 1 <= N.
619 //
620 // Output, double X[N], the abscissas.
621 //
622 {
623  int i;
624  double pi = 3.141592653589793;
625 
626  if ( n < 1 )
627  {
628  std::cerr << "\n";
629  std::cerr << "CHEBYSHEV1_COMPUTE_POINTS - Fatal error!\n";
630  std::cerr << " Illegal value of N = " << n << "\n";
631  std::exit ( 1 );
632  }
633 
634  for ( i = 0; i < n; i++ )
635  {
636  x[i] = std::cos ( pi * ( double ) ( 2 * n - 1 - 2 * i )
637  / ( double ) ( 2 * n ) );
638  }
639  if ( ( n % 2 ) == 1 )
640  {
641  x[(n-1)/2] = 0.0;
642  }
643 
644  return;
645 }
646 //**************************************************************************80
647 
648 void SandiaRules::chebyshev1_compute_points_np ( int n, int np, double p[], double x[] )
649 
650 //**************************************************************************80
651 //
652 // Purpose:
653 //
654 // CHEBYSHEV1_COMPUTE_POINTS_NP computes Chebyshev type 1 quadrature points.
655 //
656 // Licensing:
657 //
658 // This code is distributed under the GNU LGPL license.
659 //
660 // Modified:
661 //
662 // 22 June 2009
663 //
664 // Author:
665 //
666 // John Burkardt
667 //
668 // Reference:
669 //
670 // Philip Davis, Philip Rabinowitz,
671 // Methods of Numerical Integration,
672 // Second Edition,
673 // Dover, 2007,
674 // ISBN: 0486453391,
675 // LC: QA299.3.D28.
676 //
677 // Parameters:
678 //
679 // Input, int N, the order.
680 // 1 <= N.
681 //
682 // Input, int NP, the number of parameters.
683 //
684 // Input, double P[NP], parameters which are not needed by this function.
685 //
686 // Output, double X[N], the abscissas.
687 //
688 {
689  chebyshev1_compute_points ( n, x );
690 
691  return;
692 }
693 //**************************************************************************80
694 
695 void SandiaRules::chebyshev1_compute_weights ( int n, double w[] )
696 
697 //**************************************************************************80
698 //
699 // Purpose:
700 //
701 // CHEBYSHEV1_COMPUTE_WEIGHTS computes Chebyshev type 1 quadrature weights.
702 //
703 // Licensing:
704 //
705 // This code is distributed under the GNU LGPL license.
706 //
707 // Modified:
708 //
709 // 13 June 2009
710 //
711 // Author:
712 //
713 // John Burkardt
714 //
715 // Reference:
716 //
717 // Philip Davis, Philip Rabinowitz,
718 // Methods of Numerical Integration,
719 // Second Edition,
720 // Dover, 2007,
721 // ISBN: 0486453391,
722 // LC: QA299.3.D28.
723 //
724 // Parameters:
725 //
726 // Input, int N, the order.
727 // 1 <= N.
728 //
729 // Output, double W[N], the weights.
730 //
731 {
732  int i;
733  double pi = 3.141592653589793;
734 
735  if ( n < 1 )
736  {
737  std::cerr << "\n";
738  std::cerr << "CHEBYSHEV1_COMPUTE_WEIGHTS - Fatal error!\n";
739  std::cerr << " Illegal value of N = " << n << "\n";
740  std::exit ( 1 );
741  }
742 
743  for ( i = 0; i < n; i++ )
744  {
745  w[i] = pi / ( double ) ( n );
746  }
747 
748  return;
749 }
750 //**************************************************************************80
751 
752 void SandiaRules::chebyshev1_compute_weights_np ( int n, int np, double p[], double w[] )
753 
754 //**************************************************************************80
755 //
756 // Purpose:
757 //
758 // CHEBYSHEV1_COMPUTE_WEIGHTS_NP: Chebyshev type 1 quadrature weights.
759 //
760 // Licensing:
761 //
762 // This code is distributed under the GNU LGPL license.
763 //
764 // Modified:
765 //
766 // 22 June 2009
767 //
768 // Author:
769 //
770 // John Burkardt
771 //
772 // Reference:
773 //
774 // Philip Davis, Philip Rabinowitz,
775 // Methods of Numerical Integration,
776 // Second Edition,
777 // Dover, 2007,
778 // ISBN: 0486453391,
779 // LC: QA299.3.D28.
780 //
781 // Parameters:
782 //
783 // Input, int N, the order.
784 // 1 <= N.
785 //
786 // Input, int NP, the number of parameters.
787 //
788 // Input, double P[NP], parameters which are not needed by this function.
789 //
790 // Output, double W[N], the weights.
791 //
792 {
794 
795  return;
796 }
797 //**************************************************************************80
798 
800 
801 //**************************************************************************80
802 //
803 // Purpose:
804 //
805 // CHEBYSHEV1_INTEGRAL evaluates a monomial Chebyshev type 1 integral.
806 //
807 // Discussion:
808 //
809 // The integral:
810 //
811 // integral ( -1 <= x <= +1 ) x^n / sqrt ( 1 - x^2 ) dx
812 //
813 // Licensing:
814 //
815 // This code is distributed under the GNU LGPL license.
816 //
817 // Modified:
818 //
819 // 26 February 2008
820 //
821 // Author:
822 //
823 // John Burkardt
824 //
825 // Parameters:
826 //
827 // Input, int EXPON, the exponent.
828 //
829 // Output, double CHEBYSHEV1_INTEGRAL, the value of the exact integral.
830 //
831 {
832  double bot;
833  double exact;
834  int i;
835  double pi = 3.141592653589793;
836  double top;
837 //
838 // Get the exact value of the integral.
839 //
840  if ( ( expon % 2 ) == 0 )
841  {
842  top = 1;
843  bot = 1;
844  for ( i = 2; i <= expon; i = i + 2 )
845  {
846  top = top * ( i - 1 );
847  bot = bot * i;
848  }
849 
850  exact = pi * ( double ) ( top ) / ( double ) ( bot );
851  }
852  else
853  {
854  exact = 0.0;
855  }
856 
857  return exact;
858 }
859 //**************************************************************************80
860 
861 void SandiaRules::chebyshev2_compute ( int n, double x[], double w[] )
862 
863 //**************************************************************************80
864 //
865 // Purpose:
866 //
867 // CHEBYSHEV2_COMPUTE computes a Chebyshev type 2 quadrature rule.
868 //
869 // Discussion:
870 //
871 // The integral:
872 //
873 // integral ( -1 <= x <= 1 ) f(x) sqrt ( 1 - x^2 ) dx
874 //
875 // The quadrature rule:
876 //
877 // sum ( 1 <= i <= n ) w(i) * f ( x(i) )
878 //
879 // Licensing:
880 //
881 // This code is distributed under the GNU LGPL license.
882 //
883 // Modified:
884 //
885 // 13 June 2009
886 //
887 // Author:
888 //
889 // John Burkardt
890 //
891 // Reference:
892 //
893 // Philip Davis, Philip Rabinowitz,
894 // Methods of Numerical Integration,
895 // Second Edition,
896 // Dover, 2007,
897 // ISBN: 0486453391,
898 // LC: QA299.3.D28.
899 //
900 // Parameters:
901 //
902 // Input, int N, the order.
903 // 1 <= N.
904 //
905 // Output, double X[N], the abscissas.
906 //
907 // Output, double W[N], the weights.
908 //
909 {
910  double angle;
911  int i;
912  double pi = 3.141592653589793;
913 
914  if ( n < 1 )
915  {
916  std::cerr << "\n";
917  std::cerr << "CHEBYSHEV2_COMPUTE - Fatal error!\n";
918  std::cerr << " Illegal value of N = " << n << "\n";
919  std::exit ( 1 );
920  }
921 
922  for ( i = 0; i < n; i++ )
923  {
924  angle = pi * ( double ) ( n - i ) / ( double ) ( n + 1 );
925  w[i] = pi / ( double ) ( n + 1 ) * std::pow ( std::sin ( angle ), 2 );
926  x[i] = std::cos ( angle );
927  }
928 
929  if ( ( n % 2 ) == 1 )
930  {
931  x[(n-1)/2] = 0.0;
932  }
933 
934  return;
935 }
936 //**************************************************************************80
937 
938 void SandiaRules::chebyshev2_compute_np ( int n, int np, double p[], double x[],
939  double w[] )
940 
941 //**************************************************************************80
942 //
943 // Purpose:
944 //
945 // CHEBYSHEV2_COMPUTE_NP computes a Chebyshev type 2 quadrature rule.
946 //
947 // Discussion:
948 //
949 // The integral:
950 //
951 // Integral ( -1 <= X <= 1 ) F(X) sqrt ( 1 - x^2 ) dX
952 //
953 // The quadrature rule:
954 //
955 // Sum ( 1 <= I <= N ) W(I) * F ( X(I) )
956 //
957 // Licensing:
958 //
959 // This code is distributed under the GNU LGPL license.
960 //
961 // Modified:
962 //
963 // 22 June 2009
964 //
965 // Author:
966 //
967 // John Burkardt
968 //
969 // Reference:
970 //
971 // Philip Davis, Philip Rabinowitz,
972 // Methods of Numerical Integration,
973 // Second Edition,
974 // Dover, 2007,
975 // ISBN: 0486453391,
976 // LC: QA299.3.D28.
977 //
978 // Parameters:
979 //
980 // Input, int N, the order.
981 // 1 <= N.
982 //
983 // Input, int NP, the number of parameters.
984 //
985 // Input, double P[NP], parameters which are not needed by this function.
986 //
987 // Output, double X[N], the abscissas.
988 //
989 // Output, double W[N], the weights.
990 //
991 {
992  chebyshev2_compute ( n, x, w );
993 
994  return;
995 }
996 //**************************************************************************80
997 
998 void SandiaRules::chebyshev2_compute_points ( int n, double x[] )
999 
1000 //**************************************************************************80
1001 //
1002 // Purpose:
1003 //
1004 // CHEBYSHEV2_COMPUTE_POINTS computes Chebyshev type 2 quadrature points.
1005 //
1006 // Licensing:
1007 //
1008 // This code is distributed under the GNU LGPL license.
1009 //
1010 // Modified:
1011 //
1012 // 13 June 2009
1013 //
1014 // Author:
1015 //
1016 // John Burkardt
1017 //
1018 // Reference:
1019 //
1020 // Philip Davis, Philip Rabinowitz,
1021 // Methods of Numerical Integration,
1022 // Second Edition,
1023 // Dover, 2007,
1024 // ISBN: 0486453391,
1025 // LC: QA299.3.D28.
1026 //
1027 // Parameters:
1028 //
1029 // Input, int N, the order.
1030 // 1 <= N.
1031 //
1032 // Output, double X[N], the abscissas.
1033 //
1034 {
1035  double angle;
1036  int i;
1037  double pi = 3.141592653589793;
1038 
1039  if ( n < 1 )
1040  {
1041  std::cerr << "\n";
1042  std::cerr << "CHEBYSHEV2_COMPUTE_POINTS - Fatal error!\n";
1043  std::cerr << " Illegal value of N = " << n << "\n";
1044  std::exit ( 1 );
1045  }
1046 
1047  for ( i = 0; i < n; i++ )
1048  {
1049  angle = pi * ( double ) ( n - i ) / ( double ) ( n + 1 );
1050  x[i] = std::cos ( angle );
1051  }
1052 
1053  if ( ( n % 2 ) == 1 )
1054  {
1055  x[(n-1)/2] = 0.0;
1056  }
1057 
1058  return;
1059 }
1060 //**************************************************************************80
1061 
1062 void SandiaRules::chebyshev2_compute_points_np ( int n, int np, double p[], double x[] )
1063 
1064 //**************************************************************************80
1065 //
1066 // Purpose:
1067 //
1068 // CHEBYSHEV2_COMPUTE_POINTS_NP computes Chebyshev type 2 quadrature points.
1069 //
1070 // Licensing:
1071 //
1072 // This code is distributed under the GNU LGPL license.
1073 //
1074 // Modified:
1075 //
1076 // 03 June 2009
1077 //
1078 // Author:
1079 //
1080 // John Burkardt
1081 //
1082 // Reference:
1083 //
1084 // Philip Davis, Philip Rabinowitz,
1085 // Methods of Numerical Integration,
1086 // Second Edition,
1087 // Dover, 2007,
1088 // ISBN: 0486453391,
1089 // LC: QA299.3.D28.
1090 //
1091 // Parameters:
1092 //
1093 // Input, int N, the order.
1094 // 1 <= N.
1095 //
1096 // Input, int NP, the number of parameters.
1097 //
1098 // Input, double P[NP], parameters which are not needed by this function.
1099 //
1100 // Output, double X[N], the abscissas.
1101 //
1102 {
1103  chebyshev2_compute_points ( n, x );
1104 
1105  return;
1106 }
1107 //**************************************************************************80
1108 
1110 
1111 //**************************************************************************80
1112 //
1113 // Purpose:
1114 //
1115 // CHEBYSHEV2_COMPUTE_WEIGHTS computes Chebyshev type 2 quadrature weights.
1116 //
1117 // Licensing:
1118 //
1119 // This code is distributed under the GNU LGPL license.
1120 //
1121 // Modified:
1122 //
1123 // 13 June 2009
1124 //
1125 // Author:
1126 //
1127 // John Burkardt
1128 //
1129 // Reference:
1130 //
1131 // Philip Davis, Philip Rabinowitz,
1132 // Methods of Numerical Integration,
1133 // Second Edition,
1134 // Dover, 2007,
1135 // ISBN: 0486453391,
1136 // LC: QA299.3.D28.
1137 //
1138 // Parameters:
1139 //
1140 // Input, int N, the order.
1141 // 1 <= N.
1142 //
1143 // Output, double W[N], the weights.
1144 //
1145 {
1146  double angle;
1147  int i;
1148  double pi = 3.141592653589793;
1149 
1150  if ( n < 1 )
1151  {
1152  std::cerr << "\n";
1153  std::cerr << "CHEBYSHEV2_COMPUTE_WEIGHTS - Fatal error!\n";
1154  std::cerr << " Illegal value of N = " << n << "\n";
1155  std::exit ( 1 );
1156  }
1157 
1158  for ( i = 0; i < n; i++ )
1159  {
1160  angle = pi * ( double ) ( n - i ) / ( double ) ( n + 1 );
1161  w[i] = pi / ( double ) ( n + 1 ) * std::pow ( std::sin ( angle ), 2 );
1162  }
1163 
1164  return;
1165 }
1166 //**************************************************************************80
1167 
1168 void SandiaRules::chebyshev2_compute_weights_np ( int n, int np, double p[], double w[] )
1169 
1170 //**************************************************************************80
1171 //
1172 // Purpose:
1173 //
1174 // CHEBYSHEV2_COMPUTE_WEIGHTS_NP: Chebyshev type 2 quadrature weights.
1175 //
1176 // Licensing:
1177 //
1178 // This code is distributed under the GNU LGPL license.
1179 //
1180 // Modified:
1181 //
1182 // 22 June 2009
1183 //
1184 // Author:
1185 //
1186 // John Burkardt
1187 //
1188 // Reference:
1189 //
1190 // Philip Davis, Philip Rabinowitz,
1191 // Methods of Numerical Integration,
1192 // Second Edition,
1193 // Dover, 2007,
1194 // ISBN: 0486453391,
1195 // LC: QA299.3.D28.
1196 //
1197 // Parameters:
1198 //
1199 // Input, int N, the order.
1200 // 1 <= N.
1201 //
1202 // Input, int NP, the number of parameters.
1203 //
1204 // Input, double P[NP], parameters which are not needed by this function.
1205 //
1206 // Output, double W[N], the weights.
1207 //
1208 {
1209  chebyshev2_compute_weights ( n, w );
1210 
1211  return;
1212 }
1213 //**************************************************************************80
1214 
1216 
1217 //**************************************************************************80
1218 //
1219 // Purpose:
1220 //
1221 // CHEBYSHEV2_INTEGRAL evaluates a monomial Chebyshev type 2 integral.
1222 //
1223 // Discussion:
1224 //
1225 // The integral:
1226 //
1227 // integral ( -1 <= x <= +1 ) x^n * sqrt ( 1 - x^2 ) dx
1228 //
1229 // Licensing:
1230 //
1231 // This code is distributed under the GNU LGPL license.
1232 //
1233 // Modified:
1234 //
1235 // 26 February 2008
1236 //
1237 // Author:
1238 //
1239 // John Burkardt
1240 //
1241 // Parameters:
1242 //
1243 // Input, int EXPON, the exponent.
1244 //
1245 // Output, double CHEBYSHEV2_INTEGRAL, the value of the exact integral.
1246 //
1247 {
1248  double bot;
1249  double exact;
1250  int i;
1251  double pi = 3.141592653589793;
1252  double top;
1253 //
1254 // Get the exact value of the integral.
1255 //
1256  if ( ( expon % 2 ) == 0 )
1257  {
1258  top = 1;
1259  bot = 1;
1260  for ( i = 2; i <= expon; i = i + 2 )
1261  {
1262  top = top * ( i - 1 );
1263  bot = bot * i;
1264  }
1265 
1266  bot = bot * ( double ) ( expon + 2 );
1267 
1268  exact = pi * ( double ) ( top ) / ( double ) ( bot );
1269  }
1270  else
1271  {
1272  exact = 0.0;
1273  }
1274  return exact;
1275 }
1276 //**************************************************************************80
1277 
1278 void SandiaRules::clenshaw_curtis_compute ( int n, double x[], double w[] )
1279 
1280 //**************************************************************************80
1281 //
1282 // Purpose:
1283 //
1284 // CLENSHAW_CURTIS_COMPUTE computes a Clenshaw Curtis quadrature rule.
1285 //
1286 // Discussion:
1287 //
1288 // The integral:
1289 //
1290 // Integral ( -1 <= X <= 1 ) F(X) dX
1291 //
1292 // The quadrature rule:
1293 //
1294 // Sum ( 1 <= I <= N ) W(I) * F ( X(I) )
1295 //
1296 // Licensing:
1297 //
1298 // This code is distributed under the GNU LGPL license.
1299 //
1300 // Modified:
1301 //
1302 // 19 March 2009
1303 //
1304 // Author:
1305 //
1306 // John Burkardt
1307 //
1308 // Parameters:
1309 //
1310 // Input, int N, the order.
1311 // 1 <= N.
1312 //
1313 // Output, double X[N], the abscissas.
1314 //
1315 // Output, double W[N], the weights.
1316 //
1317 {
1318  double b;
1319  int i;
1320  int j;
1321  double pi = 3.141592653589793;
1322  double theta;
1323 
1324  if ( n < 1 )
1325  {
1326  std::cerr << "\n";
1327  std::cerr << "CLENSHAW_CURTIS_COMPUTE - Fatal error!\n";
1328  std::cerr << " Illegal value of N = " << n << "\n";
1329  std::exit ( 1 );
1330  }
1331  else if ( n == 1 )
1332  {
1333  x[0] = 0.0;
1334  w[0] = 2.0;
1335  }
1336  else
1337  {
1338  for ( i = 0; i < n; i++ )
1339  {
1340  x[i] = std::cos ( ( double ) ( n - 1 - i ) * pi
1341  / ( double ) ( n - 1 ) );
1342  }
1343  x[0] = -1.0;
1344  if ( ( n % 2 ) == 1 )
1345  {
1346  x[(n-1)/2] = 0.0;
1347  }
1348  x[n-1] = +1.0;
1349 
1350  for ( i = 0; i < n; i++ )
1351  {
1352  theta = ( double ) ( i ) * pi / ( double ) ( n - 1 );
1353 
1354  w[i] = 1.0;
1355 
1356  for ( j = 1; j <= ( n - 1 ) / 2; j++ )
1357  {
1358  if ( 2 * j == ( n - 1 ) )
1359  {
1360  b = 1.0;
1361  }
1362  else
1363  {
1364  b = 2.0;
1365  }
1366 
1367  w[i] = w[i] - b * std::cos ( 2.0 * ( double ) ( j ) * theta )
1368  / ( double ) ( 4 * j * j - 1 );
1369  }
1370  }
1371 
1372  w[0] = w[0] / ( double ) ( n - 1 );
1373  for ( i = 1; i < n - 1; i++ )
1374  {
1375  w[i] = 2.0 * w[i] / ( double ) ( n - 1 );
1376  }
1377  w[n-1] = w[n-1] / ( double ) ( n - 1 );
1378  }
1379 
1380  return;
1381 }
1382 //**************************************************************************80
1383 
1384 void SandiaRules::clenshaw_curtis_compute_np ( int n, int np, double p[], double x[],
1385  double w[] )
1386 
1387 //**************************************************************************80
1388 //
1389 // Purpose:
1390 //
1391 // CLENSHAW_CURTIS_COMPUTE_NP computes a Clenshaw Curtis quadrature rule.
1392 //
1393 // Discussion:
1394 //
1395 // The integral:
1396 //
1397 // Integral ( -1 <= X <= 1 ) F(X) dX
1398 //
1399 // The quadrature rule:
1400 //
1401 // Sum ( 1 <= I <= N ) W(I) * F ( X(I) )
1402 //
1403 // Licensing:
1404 //
1405 // This code is distributed under the GNU LGPL license.
1406 //
1407 // Modified:
1408 //
1409 // 22 June 2009
1410 //
1411 // Author:
1412 //
1413 // John Burkardt
1414 //
1415 // Parameters:
1416 //
1417 // Input, int N, the order.
1418 // 1 <= N.
1419 //
1420 // Input, int NP, the number of parameters.
1421 //
1422 // Input, double P[NP], parameters which are not needed by this function.
1423 //
1424 // Output, double X[N], the abscissas.
1425 //
1426 // Output, double W[N], the weights.
1427 //
1428 {
1429  clenshaw_curtis_compute ( n, x, w );
1430 
1431  return;
1432 }
1433 //**************************************************************************80
1434 
1436 
1437 //**************************************************************************80
1438 //
1439 // Purpose:
1440 //
1441 // CLENSHAW_CURTIS_COMPUTE_POINTS computes Clenshaw Curtis quadrature points.
1442 //
1443 // Discussion:
1444 //
1445 // Our convention is that the abscissas are numbered from left to right.
1446 //
1447 // This rule is defined on [-1,1].
1448 //
1449 // Licensing:
1450 //
1451 // This code is distributed under the GNU LGPL license.
1452 //
1453 // Modified:
1454 //
1455 // 13 June 2009
1456 //
1457 // Author:
1458 //
1459 // John Burkardt
1460 //
1461 // Parameters:
1462 //
1463 // Input, int N, the order.
1464 //
1465 // Output, double X[N], the abscissas.
1466 //
1467 {
1468  int index;
1469  double pi = 3.141592653589793;
1470 
1471  if ( n < 1 )
1472  {
1473  std::cerr << "\n";
1474  std::cerr << "CLENSHAW_CURTIS_COMPUTE_POINTS - Fatal error!\n";
1475  std::cerr << " N < 1.\n";
1476  std::exit ( 1 );
1477  }
1478  else if ( n == 1 )
1479  {
1480  x[0] = 0.0;
1481  }
1482  else
1483  {
1484  for ( index = 1; index <= n; index++ )
1485  {
1486  x[index-1] = std::cos ( ( double ) ( n - index ) * pi
1487  / ( double ) ( n - 1 ) );
1488  }
1489  x[0] = -1.0;
1490  if ( ( n % 2 ) == 1 )
1491  {
1492  x[(n-1)/2] = 0.0;
1493  }
1494  x[n-1] = +1.0;
1495  }
1496  return;
1497 }
1498 //**************************************************************************80
1499 
1500 void SandiaRules::clenshaw_curtis_compute_points_np ( int n, int np, double p[], double x[] )
1501 
1502 //**************************************************************************80
1503 //
1504 // Purpose:
1505 //
1506 // CLENSHAW_CURTIS_COMPUTE_POINTS_NP: Clenshaw Curtis quadrature points.
1507 //
1508 // Discussion:
1509 //
1510 // Our convention is that the abscissas are numbered from left to right.
1511 //
1512 // This rule is defined on [-1,1].
1513 //
1514 // Licensing:
1515 //
1516 // This code is distributed under the GNU LGPL license.
1517 //
1518 // Modified:
1519 //
1520 // 22 June 2009
1521 //
1522 // Author:
1523 //
1524 // John Burkardt
1525 //
1526 // Parameters:
1527 //
1528 // Input, int N, the order.
1529 //
1530 // Input, int NP, the number of parameters.
1531 //
1532 // Input, double P[NP], parameters which are not needed by this function.
1533 //
1534 // Output, double X[N], the abscissas.
1535 //
1536 {
1538 
1539  return;
1540 }
1541 //**************************************************************************80
1542 
1544 
1545 //**************************************************************************80
1546 //
1547 // Purpose:
1548 //
1549 // CLENSHAW_CURTIS_COMPUTE_WEIGHTS computes Clenshaw Curtis quadrature weights.
1550 //
1551 // Discussion:
1552 //
1553 // The user must preallocate space for the output array W.
1554 //
1555 // Licensing:
1556 //
1557 // This code is distributed under the GNU LGPL license.
1558 //
1559 // Modified:
1560 //
1561 // 13 June 2009
1562 //
1563 // Author:
1564 //
1565 // John Burkardt
1566 //
1567 // Reference:
1568 //
1569 // Charles Clenshaw, Alan Curtis,
1570 // A Method for Numerical Integration on an Automatic Computer,
1571 // Numerische Mathematik,
1572 // Volume 2, Number 1, December 1960, pages 197-205.
1573 //
1574 // Parameters:
1575 //
1576 // Input, int N, the order.
1577 //
1578 // Output, double W[N], the weights.
1579 //
1580 {
1581  double b;
1582  int i;
1583  int j;
1584  double pi = 3.141592653589793;
1585  double theta;
1586 
1587  if ( n < 1 )
1588  {
1589  std::cerr << "\n";
1590  std::cerr << "CLENSHAW_CURTIS_COMPUTE_WEIGHTS - Fatal error!\n";
1591  std::cerr << " N < 1.\n";
1592  std::exit ( 1 );
1593  }
1594  else if ( n == 1 )
1595  {
1596  w[0] = 2.0;
1597  return;
1598  }
1599 
1600  for ( i = 1; i <= n; i++ )
1601  {
1602  theta = ( double ) ( i - 1 ) * pi / ( double ) ( n - 1 );
1603 
1604  w[i-1] = 1.0;
1605 
1606  for ( j = 1; j <= ( n - 1 ) / 2; j++ )
1607  {
1608  if ( 2 * j == ( n - 1 ) )
1609  {
1610  b = 1.0;
1611  }
1612  else
1613  {
1614  b = 2.0;
1615  }
1616 
1617  w[i-1] = w[i-1] - b * std::cos ( 2.0 * ( double ) ( j ) * theta )
1618  / ( double ) ( 4 * j * j - 1 );
1619  }
1620  }
1621 
1622  w[0] = w[0] / ( double ) ( n - 1 );
1623  for ( i = 1; i < n - 1; i++ )
1624  {
1625  w[i] = 2.0 * w[i] / ( double ) ( n - 1 );
1626  }
1627  w[n-1] = w[n-1] / ( double ) ( n - 1 );
1628 
1629  return;
1630 }
1631 //**************************************************************************80
1632 
1633 void SandiaRules::clenshaw_curtis_compute_weights_np ( int n, int np, double p[],
1634  double w[] )
1635 
1636 //**************************************************************************80
1637 //
1638 // Purpose:
1639 //
1640 // CLENSHAW_CURTIS_COMPUTE_WEIGHTS_NP: Clenshaw Curtis quadrature weights.
1641 //
1642 // Discussion:
1643 //
1644 // The user must preallocate space for the output array W.
1645 //
1646 // Licensing:
1647 //
1648 // This code is distributed under the GNU LGPL license.
1649 //
1650 // Modified:
1651 //
1652 // 22 June 2009
1653 //
1654 // Author:
1655 //
1656 // John Burkardt
1657 //
1658 // Reference:
1659 //
1660 // Charles Clenshaw, Alan Curtis,
1661 // A Method for Numerical Integration on an Automatic Computer,
1662 // Numerische Mathematik,
1663 // Volume 2, Number 1, December 1960, pages 197-205.
1664 //
1665 // Parameters:
1666 //
1667 // Input, int N, the order.
1668 //
1669 // Input, int NP, the number of parameters.
1670 //
1671 // Input, double P[NP], parameters which are not needed by this function.
1672 //
1673 // Output, double W[N], the weights.
1674 //
1675 {
1677 
1678  return;
1679 }
1680 //**************************************************************************80
1681 
1682 void SandiaRules::comp_next ( int n, int k, int a[], bool *more, int *h, int *t )
1683 
1684 //**************************************************************************80
1685 //
1686 // Purpose:
1687 //
1688 // COMP_NEXT computes the compositions of the integer N into K parts.
1689 //
1690 // Discussion:
1691 //
1692 // A composition of the integer N into K parts is an ordered sequence
1693 // of K nonnegative integers which sum to N. The compositions (1,2,1)
1694 // and (1,1,2) are considered to be distinct.
1695 //
1696 // The routine computes one composition on each call until there are no more.
1697 // For instance, one composition of 6 into 3 parts is
1698 // 3+2+1, another would be 6+0+0.
1699 //
1700 // On the first call to this routine, set MORE = FALSE. The routine
1701 // will compute the first element in the sequence of compositions, and
1702 // return it, as well as setting MORE = TRUE. If more compositions
1703 // are desired, call again, and again. Each time, the routine will
1704 // return with a new composition.
1705 //
1706 // However, when the LAST composition in the sequence is computed
1707 // and returned, the routine will reset MORE to FALSE, signaling that
1708 // the end of the sequence has been reached.
1709 //
1710 // This routine originally used a SAVE statement to maintain the
1711 // variables H and T. I have decided that it is safer
1712 // to pass these variables as arguments, even though the user should
1713 // never alter them. This allows this routine to safely shuffle
1714 // between several ongoing calculations.
1715 //
1716 //
1717 // There are 28 compositions of 6 into three parts. This routine will
1718 // produce those compositions in the following order:
1719 //
1720 // I A
1721 // - ---------
1722 // 1 6 0 0
1723 // 2 5 1 0
1724 // 3 4 2 0
1725 // 4 3 3 0
1726 // 5 2 4 0
1727 // 6 1 5 0
1728 // 7 0 6 0
1729 // 8 5 0 1
1730 // 9 4 1 1
1731 // 10 3 2 1
1732 // 11 2 3 1
1733 // 12 1 4 1
1734 // 13 0 5 1
1735 // 14 4 0 2
1736 // 15 3 1 2
1737 // 16 2 2 2
1738 // 17 1 3 2
1739 // 18 0 4 2
1740 // 19 3 0 3
1741 // 20 2 1 3
1742 // 21 1 2 3
1743 // 22 0 3 3
1744 // 23 2 0 4
1745 // 24 1 1 4
1746 // 25 0 2 4
1747 // 26 1 0 5
1748 // 27 0 1 5
1749 // 28 0 0 6
1750 //
1751 // Licensing:
1752 //
1753 // This code is distributed under the GNU LGPL license.
1754 //
1755 // Modified:
1756 //
1757 // 02 July 2008
1758 //
1759 // Author:
1760 //
1761 // Original FORTRAN77 version by Albert Nijenhuis, Herbert Wilf.
1762 // C++ version by John Burkardt.
1763 //
1764 // Reference:
1765 //
1766 // Albert Nijenhuis, Herbert Wilf,
1767 // Combinatorial Algorithms for Computers and Calculators,
1768 // Second Edition,
1769 // Academic Press, 1978,
1770 // ISBN: 0-12-519260-6,
1771 // LC: QA164.N54.
1772 //
1773 // Parameters:
1774 //
1775 // Input, int N, the integer whose compositions are desired.
1776 //
1777 // Input, int K, the number of parts in the composition.
1778 //
1779 // Input/output, int A[K], the parts of the composition.
1780 //
1781 // Input/output, bool *MORE.
1782 // Set MORE = FALSE on first call. It will be reset to TRUE on return
1783 // with a new composition. Each new call returns another composition until
1784 // MORE is set to FALSE when the last composition has been computed
1785 // and returned.
1786 //
1787 // Input/output, int *H, *T, two internal parameters needed for the
1788 // computation. The user should allocate space for these in the calling
1789 // program, include them in the calling sequence, but never alter them!
1790 //
1791 {
1792  int i;
1793 
1794  if ( !( *more ) )
1795  {
1796  *t = n;
1797  *h = 0;
1798  a[0] = n;
1799  for ( i = 1; i < k; i++ )
1800  {
1801  a[i] = 0;
1802  }
1803  }
1804  else
1805  {
1806  if ( 1 < *t )
1807  {
1808  *h = 0;
1809  }
1810  *h = *h + 1;
1811  *t = a[*h-1];
1812  a[*h-1] = 0;
1813  a[0] = *t - 1;
1814  a[*h] = a[*h] + 1;
1815  }
1816 
1817  *more = ( a[k-1] != n );
1818 
1819  return;
1820 }
1821 //**************************************************************************80
1822 
1824 
1825 //**************************************************************************80
1826 //
1827 // Purpose:
1828 //
1829 // CPU_TIME reports the elapsed CPU time.
1830 //
1831 // Licensing:
1832 //
1833 // This code is distributed under the GNU LGPL license.
1834 //
1835 // Modified:
1836 //
1837 // 26 July 2010
1838 //
1839 // Author:
1840 //
1841 // John Burkardt
1842 //
1843 // Parameters:
1844 //
1845 // Output, double CPU_TIME, the current total elapsed CPU time in second.
1846 //
1847 {
1848  double value;
1849 
1850  value = ( double ) std::clock ( ) / ( double ) CLOCKS_PER_SEC;
1851 
1852  return value;
1853 }
1854 //**************************************************************************80
1855 
1856 void SandiaRules::dif_deriv ( int nd, double xd[], double yd[], int *ndp, double xdp[],
1857  double ydp[] )
1858 
1859 //**************************************************************************80
1860 //
1861 // Purpose:
1862 //
1863 // DIF_DERIV computes the derivative of a polynomial in divided difference form.
1864 //
1865 // Licensing:
1866 //
1867 // This code is distributed under the GNU LGPL license.
1868 //
1869 // Modified:
1870 //
1871 // 23 June 2011
1872 //
1873 // Author:
1874 //
1875 // John Burkardt
1876 //
1877 // Reference:
1878 //
1879 // Carl deBoor,
1880 // A Practical Guide to Splines,
1881 // Springer, 2001,
1882 // ISBN: 0387953663,
1883 // LC: QA1.A647.v27.
1884 //
1885 // Parameters:
1886 //
1887 // Input, int ND, the size of the input table.
1888 //
1889 // Input, double XD[ND], the abscissas for the divided
1890 // difference table.
1891 //
1892 // Input, double YD[ND], the divided difference table.
1893 //
1894 // Output, int *NDP, the size of the output table, which is ND-1.
1895 //
1896 // Input, double XDP[NP], the abscissas for the divided
1897 // difference table for the derivative.
1898 //
1899 // Output, double YDP[NDP], the divided difference
1900 // table for the derivative.
1901 //
1902 {
1903  int i;
1904  double *xd_temp;
1905  double *yd_temp;
1906 //
1907 // Using a temporary copy of the difference table, shift the
1908 // abscissas to zero.
1909 //
1910  xd_temp = new double[nd];
1911  yd_temp = new double[nd];
1912 
1913  for ( i = 0; i < nd; i++ )
1914  {
1915  xd_temp[i] = xd[i];
1916  }
1917  for ( i = 0; i < nd; i++ )
1918  {
1919  yd_temp[i] = yd[i];
1920  }
1921 
1922  dif_shift_zero ( nd, xd_temp, yd_temp );
1923 //
1924 // Construct the derivative.
1925 //
1926  *ndp = nd - 1;
1927 
1928  for ( i = 0; i < *ndp; i++ )
1929  {
1930  xdp[i] = 0.0;
1931  }
1932 
1933  for ( i = 0; i < *ndp; i++ )
1934  {
1935  ydp[i] = ( double ) ( i + 1 ) * yd_temp[i+1];
1936  }
1937 
1938  delete [] xd_temp;
1939  delete [] yd_temp;
1940 
1941  return;
1942 }
1943 //**************************************************************************80
1944 
1945 void SandiaRules::dif_shift_x ( int nd, double xd[], double yd[], double xv )
1946 
1947 //**************************************************************************80
1948 //
1949 // Purpose:
1950 //
1951 // DIF_SHIFT_X replaces one abscissa of a divided difference table with a new one.
1952 //
1953 // Discussion:
1954 //
1955 // This routine shifts the representation of a divided difference polynomial by
1956 // dropping the last X value in XD, and adding a new X value to the
1957 // beginning of the Xd array, suitably modifying the coefficients stored
1958 // in YD.
1959 //
1960 // The representation of the polynomial is changed, but the polynomial itself
1961 // should be identical.
1962 //
1963 // Licensing:
1964 //
1965 // This code is distributed under the GNU LGPL license.
1966 //
1967 // Modified:
1968 //
1969 // 23 June 2011
1970 //
1971 // Author:
1972 //
1973 // John Burkardt
1974 //
1975 // Reference:
1976 //
1977 // Carl deBoor,
1978 // A Practical Guide to Splines,
1979 // Springer, 2001,
1980 // ISBN: 0387953663,
1981 // LC: QA1.A647.v27.
1982 //
1983 // Parameters:
1984 //
1985 // Input, int ND, the number of divided difference coefficients, and
1986 // the number of entries in XD.
1987 //
1988 // Input/output, double XD[ND], the X values used in the representation of
1989 // the divided difference polynomial. After a call to this routine, the
1990 // last entry of XD has been dropped, the other
1991 // entries have shifted up one index, and XV has been inserted at the
1992 // beginning of the array.
1993 //
1994 // Input/output, double YD[ND], the divided difference coefficients
1995 // corresponding to the XD array. On output, this array has been
1996 // adjusted.
1997 //
1998 // Input, double XV, a new X value which is to be used in the representation
1999 // of the polynomial. On output, XD[0] equals XV and the representation
2000 // of the polynomial has been suitably changed.
2001 // Note that XV does not have to be distinct from any of the original XD
2002 // values.
2003 //
2004 {
2005  int i;
2006 //
2007 // Recompute the divided difference coefficients.
2008 //
2009  for ( i = nd - 2; 0 <= i; i-- )
2010  {
2011  yd[i] = yd[i] + ( xv - xd[i] ) * yd[i+1];
2012  }
2013 //
2014 // Shift the X values up one position and insert XV.
2015 //
2016  for ( i = nd - 1; 0 < i; i-- )
2017  {
2018  xd[i] = xd[i-1];
2019  }
2020 
2021  xd[0] = xv;
2022 
2023  return;
2024 }
2025 //**************************************************************************80
2026 
2027 void SandiaRules::dif_shift_zero ( int nd, double xd[], double yd[] )
2028 
2029 //**************************************************************************80
2030 //
2031 // Purpose:
2032 //
2033 // DIF_SHIFT_ZERO shifts a divided difference table so that all abscissas are zero.
2034 //
2035 // Discussion:
2036 //
2037 // When the abscissas are changed, the coefficients naturally
2038 // must also be changed.
2039 //
2040 // The resulting pair (XD, YD) still represents the
2041 // same polynomial, but the entries in YD are now the
2042 // standard polynomial coefficients.
2043 //
2044 // Licensing:
2045 //
2046 // This code is distributed under the GNU LGPL license.
2047 //
2048 // Modified:
2049 //
2050 // 23 June 2011
2051 //
2052 // Author:
2053 //
2054 // John Burkardt
2055 //
2056 // Reference:
2057 //
2058 // Carl deBoor,
2059 // A Practical Guide to Splines,
2060 // Springer, 2001,
2061 // ISBN: 0387953663,
2062 // LC: QA1.A647.v27.
2063 //
2064 // Parameters:
2065 //
2066 // Input, int ND, the length of the XD and YD arrays.
2067 //
2068 // Input/output, double XD[ND], the X values that correspond to the
2069 // divided difference table. On output, XD contains only zeroes.
2070 //
2071 // Input/output, double YD[ND], the divided difference table
2072 // for the polynomial. On output, YD is also
2073 // the coefficient array for the standard representation
2074 // of the polynomial.
2075 //
2076 {
2077  int i;
2078  double xv;
2079 
2080  xv = 0.0;
2081 
2082  for ( i = 1; i <= nd; i++ )
2083  {
2084  dif_shift_x ( nd, xd, yd, xv );
2085  }
2086 
2087  return;
2088 }
2089 //**************************************************************************80
2090 
2091 void SandiaRules::dif_to_r8poly ( int nd, double xd[], double yd[], double c[] )
2092 
2093 //**************************************************************************80
2094 //
2095 // Purpose:
2096 //
2097 // DIF_TO_R8POLY converts a divided difference table to a standard polynomial.
2098 //
2099 // Licensing:
2100 //
2101 // This code is distributed under the GNU LGPL license.
2102 //
2103 // Modified:
2104 //
2105 // 21 February 2011
2106 //
2107 // Author:
2108 //
2109 // John Burkardt
2110 //
2111 // Reference:
2112 //
2113 // Carl deBoor,
2114 // A Practical Guide to Splines,
2115 // Springer, 2001,
2116 // ISBN: 0387953663,
2117 // LC: QA1.A647.v27.
2118 //
2119 // Parameters:
2120 //
2121 // Input, int ND, the number of coefficients, and abscissas.
2122 //
2123 // Input, double XD[ND], the X values used in the divided difference
2124 // representation of the polynomial.
2125 //
2126 // Input, double YD[ND], the divided difference table.
2127 //
2128 // Output, double C[ND], the standard form polyomial coefficients.
2129 // C[0] is the constant term, and C[ND-1] is the coefficient
2130 // of X^(ND-1).
2131 //
2132 {
2133  int i;
2134  int j;
2135 
2136  for ( i = 0; i < nd; i++ )
2137  {
2138  c[i] = yd[i];
2139  }
2140 //
2141 // Recompute the divided difference coefficients.
2142 //
2143  for ( j = 1; j <= nd - 1; j++ )
2144  {
2145  for ( i = 1; i <= nd - j; i++ )
2146  {
2147  c[nd-i-1] = c[nd-i-1] - xd[nd-i-j] * c[nd-i];
2148  }
2149  }
2150 
2151  return;
2152 }
2153 //**************************************************************************80
2154 
2155 void SandiaRules::fejer2_compute ( int n, double x[], double w[] )
2156 
2157 //**************************************************************************80
2158 //
2159 // Purpose:
2160 //
2161 // FEJER2_COMPUTE computes a Fejer type 2 rule.
2162 //
2163 // Discussion:
2164 //
2165 // Our convention is that the abscissas are numbered from left to right.
2166 //
2167 // The rule is defined on [-1,1].
2168 //
2169 // Licensing:
2170 //
2171 // This code is distributed under the GNU LGPL license.
2172 //
2173 // Modified:
2174 //
2175 // 13 June 2009
2176 //
2177 // Author:
2178 //
2179 // John Burkardt
2180 //
2181 // Parameters:
2182 //
2183 // Input, int N, the order.
2184 // 1 <= N.
2185 //
2186 // Output, double X[N], the abscissas.
2187 //
2188 // Output, double W[N], the weights.
2189 //
2190 {
2191  int i;
2192  int j;
2193  double p;
2194  double pi = 3.141592653589793;
2195  double theta;
2196 
2197  if ( n < 1 )
2198  {
2199  std::cerr << "\n";
2200  std::cerr << "FEJER2_COMPUTE - Fatal error!\n";
2201  std::cerr << " Illegal value of N = " << n << "\n";
2202  std::exit ( 1 );
2203  }
2204  else if ( n == 1 )
2205  {
2206  x[0] = 0.0;
2207  w[0] = 2.0;
2208  return;
2209  }
2210 
2211  for ( i = 0; i < n; i++ )
2212  {
2213  x[i] = std::cos ( ( double ) ( n - i ) * pi
2214  / ( double ) ( n + 1 ) );
2215  }
2216  if ( ( n % 2 ) == 1 )
2217  {
2218  x[(n-1)/2] = 0.0;
2219  }
2220 
2221  if ( n == 2 )
2222  {
2223  w[0] = 1.0;
2224  w[1] = 1.0;
2225  }
2226  else
2227  {
2228  for ( i = 0; i < n; i++ )
2229  {
2230  theta = ( double ) ( n - i ) * pi
2231  / ( double ) ( n + 1 );
2232 
2233  w[i] = 1.0;
2234 
2235  for ( j = 1; j <= ( ( n - 1 ) / 2 ); j++ )
2236  {
2237  w[i] = w[i] - 2.0 * std::cos ( 2.0 * ( double ) ( j ) * theta )
2238  / ( double ) ( 4 * j * j - 1 );
2239  }
2240  p = 2.0 * ( double ) ( ( ( n + 1 ) / 2 ) ) - 1.0;
2241  w[i] = w[i] - std::cos ( ( p + 1.0 ) * theta ) / p;
2242  }
2243  for ( i = 0; i < n; i++ )
2244  {
2245  w[i] = 2.0 * w[i] / ( double ) ( n + 1 );
2246  }
2247  }
2248  return;
2249 }
2250 //**************************************************************************80
2251 
2252 void SandiaRules::fejer2_compute_np ( int n, int np, double p[], double x[], double w[] )
2253 
2254 //**************************************************************************80
2255 //
2256 // Purpose:
2257 //
2258 // FEJER2_COMPUTE_NP computes a Fejer type 2 rule.
2259 //
2260 // Discussion:
2261 //
2262 // Our convention is that the abscissas are numbered from left to right.
2263 //
2264 // The rule is defined on [-1,1].
2265 //
2266 // Licensing:
2267 //
2268 // This code is distributed under the GNU LGPL license.
2269 //
2270 // Modified:
2271 //
2272 // 22 June 2009
2273 //
2274 // Author:
2275 //
2276 // John Burkardt
2277 //
2278 // Parameters:
2279 //
2280 // Input, int N, the order.
2281 // 1 <= N.
2282 //
2283 // Input, int NP, the number of parameters.
2284 //
2285 // Input, double P[NP], parameters which are not needed by this function.
2286 //
2287 // Output, double X[N], the abscissas.
2288 //
2289 // Output, double W[N], the weights.
2290 //
2291 {
2292  fejer2_compute ( n, x, w );
2293 
2294  return;
2295 }
2296 //**************************************************************************80
2297 
2298 void SandiaRules::fejer2_compute_points ( int n, double x[] )
2299 
2300 //**************************************************************************80
2301 //
2302 // Purpose:
2303 //
2304 // FEJER2_COMPUTE_POINTS computes Fejer type 2 quadrature points.
2305 //
2306 // Discussion:
2307 //
2308 // Our convention is that the abscissas are numbered from left to right.
2309 //
2310 // The rule is defined on [-1,1].
2311 //
2312 // Licensing:
2313 //
2314 // This code is distributed under the GNU LGPL license.
2315 //
2316 // Modified:
2317 //
2318 // 13 June 2009
2319 //
2320 // Author:
2321 //
2322 // John Burkardt
2323 //
2324 // Parameters:
2325 //
2326 // Input, int N, the order.
2327 // 1 <= N.
2328 //
2329 // Output, double X[N], the abscissas.
2330 //
2331 {
2332  int i;
2333  double pi = 3.141592653589793;
2334 
2335  if ( n < 1 )
2336  {
2337  std::cerr << "\n";
2338  std::cerr << "FEJER2_COMPUTE_POINTS - Fatal error!\n";
2339  std::cerr << " N < 1.\n";
2340  std::exit ( 1 );
2341  }
2342  else if ( n == 1 )
2343  {
2344  x[0] = 0.0;
2345  }
2346  else
2347  {
2348  for ( i = 1; i <= n; i++ )
2349  {
2350  x[i-1] = std::cos ( ( double ) ( n + 1 - i ) * pi
2351  / ( double ) ( n + 1 ) );
2352  }
2353  if ( ( n % 2 ) == 1 )
2354  {
2355  x[(n-1)/2] = 0.0;
2356  }
2357  }
2358  return;
2359 }
2360 //**************************************************************************80
2361 
2362 void SandiaRules::fejer2_compute_points_np ( int n, int np, double p[], double x[] )
2363 
2364 //**************************************************************************80
2365 //
2366 // Purpose:
2367 //
2368 // FEJER2_COMPUTE_POINTS_NP computes Fejer type 2 quadrature points.
2369 //
2370 // Discussion:
2371 //
2372 // Our convention is that the abscissas are numbered from left to right.
2373 //
2374 // The rule is defined on [-1,1].
2375 //
2376 // Licensing:
2377 //
2378 // This code is distributed under the GNU LGPL license.
2379 //
2380 // Modified:
2381 //
2382 // 22 June 2009
2383 //
2384 // Author:
2385 //
2386 // John Burkardt
2387 //
2388 // Parameters:
2389 //
2390 // Input, int N, the order.
2391 // 1 <= N.
2392 //
2393 // Input, int NP, the number of parameters.
2394 //
2395 // Input, double P[NP], parameters which are not needed by this function.
2396 //
2397 // Output, double X[N], the abscissas.
2398 //
2399 {
2400  fejer2_compute_points ( n, x );
2401 
2402  return;
2403 }
2404 //**************************************************************************80
2405 
2406 void SandiaRules::fejer2_compute_weights ( int n, double w[] )
2407 
2408 //**************************************************************************80
2409 //
2410 // Purpose:
2411 //
2412 // FEJER2_COMPUTE_WEIGHTS computes Fejer type 2 quadrature weights.
2413 //
2414 // Discussion:
2415 //
2416 // The user must preallocate space for the output array W.
2417 //
2418 // Licensing:
2419 //
2420 // This code is distributed under the GNU LGPL license.
2421 //
2422 // Modified:
2423 //
2424 // 13 June 2009
2425 //
2426 // Author:
2427 //
2428 // John Burkardt
2429 //
2430 // Reference:
2431 //
2432 // Philip Davis, Philip Rabinowitz,
2433 // Methods of Numerical Integration,
2434 // Second Edition,
2435 // Dover, 2007,
2436 // ISBN: 0486453391,
2437 // LC: QA299.3.D28.
2438 //
2439 // Walter Gautschi,
2440 // Numerical Quadrature in the Presence of a Singularity,
2441 // SIAM Journal on Numerical Analysis,
2442 // Volume 4, Number 3, 1967, pages 357-362.
2443 //
2444 // Joerg Waldvogel,
2445 // Fast Construction of the Fejer and Clenshaw-Curtis Quadrature Rules,
2446 // BIT Numerical Mathematics,
2447 // Volume 43, Number 1, 2003, pages 1-18.
2448 //
2449 // Parameters:
2450 //
2451 // Input, int N, the order.
2452 //
2453 // Output, double W[N], the weights.
2454 //
2455 {
2456  int i;
2457  int j;
2458  double p;
2459  double pi = 3.141592653589793;
2460  double theta;
2461 
2462  if ( n < 1 )
2463  {
2464  std::cerr << "\n";
2465  std::cerr << "FEJER2_COMPUTE_WEIGHTS - Fatal error!\n";
2466  std::cerr << " N < 1.\n";
2467  std::exit ( 1 );
2468  }
2469  else if ( n == 1 )
2470  {
2471  w[0] = 2.0;
2472  }
2473  else if ( n == 2 )
2474  {
2475  w[0] = 1.0;
2476  w[1] = 1.0;
2477  }
2478  else
2479  {
2480  for ( i = 1; i <= n; i++ )
2481  {
2482  theta = ( double ) ( n + 1 - i ) * pi
2483  / ( double ) ( n + 1 );
2484 
2485  w[i-1] = 1.0;
2486 
2487  for ( j = 1; j <= ( ( n - 1 ) / 2 ); j++ )
2488  {
2489  w[i-1] = w[i-1] - 2.0 * std::cos ( 2.0 * ( double ) ( j ) * theta )
2490  / ( double ) ( 4 * j * j - 1 );
2491  }
2492  p = 2.0 * ( double ) ( ( ( n + 1 ) / 2 ) ) - 1.0;
2493  w[i-1] = w[i-1] - std::cos ( ( p + 1.0 ) * theta ) / p;
2494  }
2495  for ( i = 0; i < n; i++ )
2496  {
2497  w[i] = 2.0 * w[i] / ( double ) ( n + 1 );
2498  }
2499  }
2500  return;
2501 }
2502 //**************************************************************************80
2503 
2504 void SandiaRules::fejer2_compute_weights_np ( int n, int np, double p[], double w[] )
2505 
2506 //**************************************************************************80
2507 //
2508 // Purpose:
2509 //
2510 // FEJER2_COMPUTE_WEIGHTS_NP computes Fejer type 2 quadrature weights.
2511 //
2512 // Discussion:
2513 //
2514 // The user must preallocate space for the output array W.
2515 //
2516 // Licensing:
2517 //
2518 // This code is distributed under the GNU LGPL license.
2519 //
2520 // Modified:
2521 //
2522 // 22 June 2009
2523 //
2524 // Author:
2525 //
2526 // John Burkardt
2527 //
2528 // Reference:
2529 //
2530 // Philip Davis, Philip Rabinowitz,
2531 // Methods of Numerical Integration,
2532 // Second Edition,
2533 // Dover, 2007,
2534 // ISBN: 0486453391,
2535 // LC: QA299.3.D28.
2536 //
2537 // Walter Gautschi,
2538 // Numerical Quadrature in the Presence of a Singularity,
2539 // SIAM Journal on Numerical Analysis,
2540 // Volume 4, Number 3, 1967, pages 357-362.
2541 //
2542 // Joerg Waldvogel,
2543 // Fast Construction of the Fejer and Clenshaw-Curtis Quadrature Rules,
2544 // BIT Numerical Mathematics,
2545 // Volume 43, Number 1, 2003, pages 1-18.
2546 //
2547 // Parameters:
2548 //
2549 // Input, int N, the order.
2550 //
2551 // Input, int NP, the number of parameters.
2552 //
2553 // Input, double P[NP], parameters which are not needed by this function.
2554 //
2555 // Output, double W[N], the weights.
2556 //
2557 {
2558  fejer2_compute_weights ( n, w );
2559 
2560  return;
2561 }
2562 //**************************************************************************80
2563 
2564 void SandiaRules::gegenbauer_compute ( int order, double alpha, double x[], double w[] )
2565 
2566 //**************************************************************************80
2567 //
2568 // Purpose:
2569 //
2570 // GEGENBAUER_COMPUTE computes a Gegenbauer quadrature rule.
2571 //
2572 // Discussion:
2573 //
2574 // The integral:
2575 //
2576 // Integral ( -1 <= X <= 1 ) (1-X^2)^ALPHA * F(X) dX
2577 //
2578 // The quadrature rule:
2579 //
2580 // Sum ( 1 <= I <= ORDER ) W(I) * F ( X(I) )
2581 //
2582 // Thanks to Janiki Raman for pointing out a problem in an earlier
2583 // version of the code that occurred when ALPHA was -0.5.
2584 //
2585 // Licensing:
2586 //
2587 // This code is distributed under the GNU LGPL license.
2588 //
2589 // Modified:
2590 //
2591 // 13 June 2009
2592 //
2593 // Author:
2594 //
2595 // John Burkardt
2596 //
2597 // Reference:
2598 //
2599 // Arthur Stroud, Don Secrest,
2600 // Gaussian Quadrature Formulas,
2601 // Prentice Hall, 1966,
2602 // LC: QA299.4G3S7.
2603 //
2604 // Parameters:
2605 //
2606 // Input, int ORDER, the order.
2607 // 1 <= ORDER.
2608 //
2609 // Input, double ALPHA, the exponent of (1-X^2). -1.0 < ALPHA is required.
2610 //
2611 // Output, double X[ORDER], the abscissas.
2612 //
2613 // Output, double W[ORDER], the weights.
2614 //
2615 {
2616  double an;
2617  double *c;
2618  double cc;
2619  double delta;
2620  double dp2;
2621  int i;
2622  double p1;
2623  double prod;
2624  double r1;
2625  double r2;
2626  double r3;
2627  double temp;
2628  double x0;
2629 //
2630 // Check ORDER.
2631 //
2632  if ( order < 1 )
2633  {
2634  std::cerr << "\n";
2635  std::cerr << "GEGENBAUER_COMPUTE - Fatal error!\n";
2636  std::cerr << " 1 <= ORDER is required.\n";
2637  std::exit ( 1 );
2638  }
2639  c = new double[order];
2640 //
2641 // Check ALPHA.
2642 //
2643  if ( alpha <= -1.0 )
2644  {
2645  std::cerr << "\n";
2646  std::cerr << "GEGENBAUER_COMPUTE - Fatal error!\n";
2647  std::cerr << " -1.0 < ALPHA is required.\n";
2648  std::exit ( 1 );
2649  }
2650 //
2651 // Set the recursion coefficients.
2652 //
2653  c[0] = 0.0;
2654  if ( 2 <= order )
2655  {
2656  c[1] = 1.0 / ( 2.0 * alpha + 3.0 );
2657  }
2658 
2659  for ( i = 3; i <= order; i++ )
2660  {
2661  c[i-1] = ( double ) ( i - 1 )
2662  * ( alpha + alpha + ( double ) ( i - 1 ) ) /
2663  ( ( alpha + alpha + ( double ) ( 2 * i - 1 ) )
2664  * ( alpha + alpha + ( double ) ( 2 * i - 3 ) ) );
2665  }
2666 
2667  delta = r8_gamma ( alpha + 1.0 )
2668  * r8_gamma ( alpha + 1.0 )
2669  / r8_gamma ( alpha + alpha + 2.0 );
2670 
2671  prod = 1.0;
2672  for ( i = 2; i <= order; i++ )
2673  {
2674  prod = prod * c[i-1];
2675  }
2676  cc = delta * std::pow ( 2.0, alpha + alpha + 1.0 ) * prod;
2677 
2678  for ( i = 1; i <= order; i++ )
2679  {
2680  if ( i == 1 )
2681  {
2682  an = alpha / ( double ) ( order );
2683 
2684  r1 = ( 1.0 + alpha )
2685  * ( 2.78 / ( 4.0 + ( double ) ( order * order ) )
2686  + 0.768 * an / ( double ) ( order ) );
2687 
2688  r2 = 1.0 + 2.44 * an + 1.282 * an * an;
2689 
2690  x0 = ( r2 - r1 ) / r2;
2691  }
2692  else if ( i == 2 )
2693  {
2694  r1 = ( 4.1 + alpha ) /
2695  ( ( 1.0 + alpha ) * ( 1.0 + 0.156 * alpha ) );
2696 
2697  r2 = 1.0 + 0.06 * ( ( double ) ( order ) - 8.0 ) *
2698  ( 1.0 + 0.12 * alpha ) / ( double ) ( order );
2699 
2700  r3 = 1.0 + 0.012 * alpha *
2701  ( 1.0 + 0.25 * r8_abs ( alpha ) ) / ( double ) ( order );
2702 
2703  x0 = x0 - r1 * r2 * r3 * ( 1.0 - x0 );
2704  }
2705  else if ( i == 3 )
2706  {
2707  r1 = ( 1.67 + 0.28 * alpha ) / ( 1.0 + 0.37 * alpha );
2708 
2709  r2 = 1.0 + 0.22 * ( ( double ) ( order ) - 8.0 )
2710  / ( double ) ( order );
2711 
2712  r3 = 1.0 + 8.0 * alpha /
2713  ( ( 6.28 + alpha ) * ( double ) ( order * order ) );
2714 
2715  x0 = x0 - r1 * r2 * r3 * ( x[0] - x0 );
2716  }
2717  else if ( i < order - 1 )
2718  {
2719  x0 = 3.0 * x[i-2] - 3.0 * x[i-3] + x[i-4];
2720  }
2721  else if ( i == order - 1 )
2722  {
2723  r1 = ( 1.0 + 0.235 * alpha ) / ( 0.766 + 0.119 * alpha );
2724 
2725  r2 = 1.0 / ( 1.0 + 0.639
2726  * ( ( double ) ( order ) - 4.0 )
2727  / ( 1.0 + 0.71 * ( ( double ) ( order ) - 4.0 ) ) );
2728 
2729  r3 = 1.0 / ( 1.0 + 20.0 * alpha / ( ( 7.5 + alpha ) *
2730  ( double ) ( order * order ) ) );
2731 
2732  x0 = x0 + r1 * r2 * r3 * ( x0 - x[i-3] );
2733  }
2734  else if ( i == order )
2735  {
2736  r1 = ( 1.0 + 0.37 * alpha ) / ( 1.67 + 0.28 * alpha );
2737 
2738  r2 = 1.0 /
2739  ( 1.0 + 0.22 * ( ( double ) ( order ) - 8.0 )
2740  / ( double ) ( order ) );
2741 
2742  r3 = 1.0 / ( 1.0 + 8.0 * alpha /
2743  ( ( 6.28 + alpha ) * ( double ) ( order * order ) ) );
2744 
2745  x0 = x0 + r1 * r2 * r3 * ( x0 - x[i-3] );
2746  }
2747 
2748  gegenbauer_root ( &x0, order, alpha, &dp2, &p1, c );
2749 
2750  x[i-1] = x0;
2751  w[i-1] = cc / ( dp2 * p1 );
2752  }
2753 //
2754 // Reverse the order of the values.
2755 //
2756  for ( i = 1; i <= order/2; i++ )
2757  {
2758  temp = x[i-1];
2759  x[i-1] = x[order-i];
2760  x[order-i] = temp;
2761  }
2762 
2763  for ( i = 1; i <=order/2; i++ )
2764  {
2765  temp = w[i-1];
2766  w[i-1] = w[order-i];
2767  w[order-i] = temp;
2768  }
2769 
2770  delete [] c;
2771 
2772  return;
2773 }
2774 //**************************************************************************80
2775 
2776 void SandiaRules::gegenbauer_compute_np ( int order, int np, double p[], double x[],
2777  double w[] )
2778 
2779 //**************************************************************************80
2780 //
2781 // Purpose:
2782 //
2783 // GEGENBAUER_COMPUTE_NP computes a Gegenbauer quadrature rule.
2784 //
2785 // Discussion:
2786 //
2787 // The integral:
2788 //
2789 // Integral ( -1 <= X <= 1 ) (1-X^2)^ALPHA * F(X) dX
2790 //
2791 // The quadrature rule:
2792 //
2793 // Sum ( 1 <= I <= ORDER ) W(I) * F ( X(I) )
2794 //
2795 // Thanks to Janiki Raman for pointing out a problem in an earlier
2796 // version of the code that occurred when ALPHA was -0.5.
2797 //
2798 // Licensing:
2799 //
2800 // This code is distributed under the GNU LGPL license.
2801 //
2802 // Modified:
2803 //
2804 // 22 June 2009
2805 //
2806 // Author:
2807 //
2808 // John Burkardt
2809 //
2810 // Reference:
2811 //
2812 // Arthur Stroud, Don Secrest,
2813 // Gaussian Quadrature Formulas,
2814 // Prentice Hall, 1966,
2815 // LC: QA299.4G3S7.
2816 //
2817 // Parameters:
2818 //
2819 // Input, int ORDER, the order.
2820 // 1 <= ORDER.
2821 //
2822 // Input, int NP, the number of parameters.
2823 //
2824 // Input, double P[NP], contains parameters.
2825 // P[0] = ALPHA = the exponent of (1-X^2). -1.0 < ALPHA is required.
2826 //
2827 // Output, double X[ORDER], the abscissas.
2828 //
2829 // Output, double W[ORDER], the weights.
2830 //
2831 {
2832  double alpha;
2833 
2834  alpha = p[0];
2835 
2836  gegenbauer_compute ( order, alpha, x, w );
2837 
2838  return;
2839 }
2840 //**************************************************************************80
2841 
2842 void SandiaRules::gegenbauer_compute_points ( int order, double alpha, double x[] )
2843 
2844 //**************************************************************************80
2845 //
2846 // Purpose:
2847 //
2848 // GEGENBAUER_COMPUTE_POINTS computes Gegenbauer quadrature points.
2849 //
2850 // Licensing:
2851 //
2852 // This code is distributed under the GNU LGPL license.
2853 //
2854 // Modified:
2855 //
2856 // 13 June 2009
2857 //
2858 // Author:
2859 //
2860 // John Burkardt
2861 //
2862 // Reference:
2863 //
2864 // Arthur Stroud, Don Secrest,
2865 // Gaussian Quadrature Formulas,
2866 // Prentice Hall, 1966,
2867 // LC: QA299.4G3S7.
2868 //
2869 // Parameters:
2870 //
2871 // Input, int ORDER, the order.
2872 // 1 <= ORDER.
2873 //
2874 // Input, double ALPHA, the exponent of (1-X^2). -1.0 < ALPHA is required.
2875 //
2876 // Output, double X[ORDER], the abscissas.
2877 //
2878 {
2879  double *w;
2880 
2881  w = new double[order];
2882 
2883  gegenbauer_compute ( order, alpha, x, w );
2884 
2885  delete [] w;
2886 
2887  return;
2888 }
2889 //**************************************************************************80
2890 
2891 void SandiaRules::gegenbauer_compute_points_np ( int order, int np, double p[], double x[] )
2892 
2893 //**************************************************************************80
2894 //
2895 // Purpose:
2896 //
2897 // GEGENBAUER_COMPUTE_POINTS_NP computes Gegenbauer quadrature points.
2898 //
2899 // Licensing:
2900 //
2901 // This code is distributed under the GNU LGPL license.
2902 //
2903 // Modified:
2904 //
2905 // 22 June 2009
2906 //
2907 // Author:
2908 //
2909 // John Burkardt
2910 //
2911 // Reference:
2912 //
2913 // Arthur Stroud, Don Secrest,
2914 // Gaussian Quadrature Formulas,
2915 // Prentice Hall, 1966,
2916 // LC: QA299.4G3S7.
2917 //
2918 // Parameters:
2919 //
2920 // Input, int ORDER, the order.
2921 // 1 <= ORDER.
2922 //
2923 // Input, int NP, the number of parameters.
2924 //
2925 // Input, double P[NP], contains parameters.
2926 // P[0] = ALPHA = the exponent of (1-X^2). -1.0 < ALPHA is required.
2927 //
2928 // Output, double X[ORDER], the abscissas.
2929 //
2930 {
2931  double alpha;
2932 
2933  alpha = p[0];
2934 
2935  gegenbauer_compute_points ( order, alpha, x );
2936 
2937  return;
2938 }
2939 //**************************************************************************80
2940 
2941 void SandiaRules::gegenbauer_compute_weights ( int order, double alpha, double w[] )
2942 
2943 //**************************************************************************80
2944 //
2945 // Purpose:
2946 //
2947 // GEGENBAUER_COMPUTE_WEIGHTS computes Gegenbauer quadrature weights.
2948 //
2949 // Licensing:
2950 //
2951 // This code is distributed under the GNU LGPL license.
2952 //
2953 // Modified:
2954 //
2955 // 13 June 2009
2956 //
2957 // Author:
2958 //
2959 // John Burkardt
2960 //
2961 // Reference:
2962 //
2963 // Arthur Stroud, Don Secrest,
2964 // Gaussian Quadrature Formulas,
2965 // Prentice Hall, 1966,
2966 // LC: QA299.4G3S7.
2967 //
2968 // Parameters:
2969 //
2970 // Input, int ORDER, the order.
2971 // 1 <= ORDER.
2972 //
2973 // Input, double ALPHA, the exponent of (1-X^2). -1.0 < ALPHA is required.
2974 //
2975 // Output, double W[ORDER], the weights.
2976 //
2977 {
2978  double *x;
2979 
2980  x = new double[order];
2981 
2982  gegenbauer_compute ( order, alpha, x, w );
2983 
2984  delete [] x;
2985 
2986  return;
2987 }
2988 //**************************************************************************80
2989 
2990 void SandiaRules::gegenbauer_compute_weights_np ( int order, int np, double p[], double w[] )
2991 
2992 //**************************************************************************80
2993 //
2994 // Purpose:
2995 //
2996 // GEGENBAUER_COMPUTE_WEIGHTS_NP computes Gegenbauer quadrature weights.
2997 //
2998 // Licensing:
2999 //
3000 // This code is distributed under the GNU LGPL license.
3001 //
3002 // Modified:
3003 //
3004 // 22 June 2009
3005 //
3006 // Author:
3007 //
3008 // John Burkardt
3009 //
3010 // Reference:
3011 //
3012 // Arthur Stroud, Don Secrest,
3013 // Gaussian Quadrature Formulas,
3014 // Prentice Hall, 1966,
3015 // LC: QA299.4G3S7.
3016 //
3017 // Parameters:
3018 //
3019 // Input, int ORDER, the order.
3020 // 1 <= ORDER.
3021 //
3022 // Input, double P[1], contains parameters.
3023 // P[0] = ALPHA = the exponent of (1-X^2). -1.0 < ALPHA is required.
3024 //
3025 // Output, double W[ORDER], the weights.
3026 //
3027 {
3028  double alpha;
3029 
3030  alpha = p[0];
3031 
3032  gegenbauer_compute_weights ( order, alpha, w );
3033 
3034  return;
3035 }
3036 //**************************************************************************80
3037 
3038 double SandiaRules::gegenbauer_integral ( int expon, double alpha )
3039 
3040 //**************************************************************************80
3041 //
3042 // Purpose:
3043 //
3044 // GEGENBAUER_INTEGRAL integrates a monomial with Gegenbauer weight.
3045 //
3046 // Discussion:
3047 //
3048 // VALUE = Integral ( -1 <= X <= +1 ) x^EXPON (1-x^2)^ALPHA dx
3049 //
3050 // Licensing:
3051 //
3052 // This code is distributed under the GNU LGPL license.
3053 //
3054 // Modified:
3055 //
3056 // 26 February 2008
3057 //
3058 // Author:
3059 //
3060 // John Burkardt
3061 //
3062 // Parameters:
3063 //
3064 // Input, int EXPON, the exponent.
3065 //
3066 // Input, double ALPHA, the exponent of (1-X^2) in the weight factor.
3067 //
3068 // Output, double GEGENBAUER_INTEGRAL, the value of the integral.
3069 //
3070 {
3071  double arg1;
3072  double arg2;
3073  double arg3;
3074  double arg4;
3075  double c;
3076  double value;
3077  double value1;
3078 
3079  if ( ( expon % 2 ) == 1 )
3080  {
3081  value = 0.0;
3082  return value;
3083  }
3084 
3085  c = ( double ) ( expon );
3086 
3087  arg1 = - alpha;
3088  arg2 = 1.0 + c;
3089  arg3 = 2.0 + alpha + c;
3090  arg4 = - 1.0;
3091 
3092  value1 = r8_hyper_2f1 ( arg1, arg2, arg3, arg4 );
3093 
3094  value = r8_gamma ( 1.0 + c ) * 2.0
3095  * r8_gamma ( 1.0 + alpha ) * value1
3096  / r8_gamma ( 2.0 + alpha + c );
3097 
3098  return value;
3099 }
3100 //**************************************************************************80
3101 
3102 void SandiaRules::gegenbauer_recur ( double *p2, double *dp2, double *p1, double x,
3103  int order, double alpha, double c[] )
3104 
3105 //**************************************************************************80
3106 //
3107 // Purpose:
3108 //
3109 // GEGENBAUER_RECUR evaluates a Gegenbauer polynomial.
3110 //
3111 // Licensing:
3112 //
3113 // This code is distributed under the GNU LGPL license.
3114 //
3115 // Modified:
3116 //
3117 // 26 February 2008
3118 //
3119 // Author:
3120 //
3121 // John Burkardt
3122 //
3123 // Reference:
3124 //
3125 // Arthur Stroud, Don Secrest,
3126 // Gaussian Quadrature Formulas,
3127 // Prentice Hall, 1966,
3128 // LC: QA299.4G3S7.
3129 //
3130 // Parameters:
3131 //
3132 // Output, double *P2, the value of J(ORDER)(X).
3133 //
3134 // Output, double *DP2, the value of J'(ORDER)(X).
3135 //
3136 // Output, double *P1, the value of J(ORDER-1)(X).
3137 //
3138 // Input, double X, the point at which polynomials are evaluated.
3139 //
3140 // Input, int ORDER, the order of the polynomial.
3141 //
3142 // Input, double ALPHA, the exponents of (1-X^2).
3143 //
3144 // Input, double C[ORDER], the recursion coefficients.
3145 //
3146 {
3147  double dp0;
3148  double dp1;
3149  int i;
3150  double p0;
3151 
3152  *p1 = 1.0;
3153  dp1 = 0.0;
3154 
3155  *p2 = x;
3156  *dp2 = 1.0;
3157 
3158  for ( i = 2; i <= order; i++ )
3159  {
3160  p0 = *p1;
3161  dp0 = dp1;
3162 
3163  *p1 = *p2;
3164  dp1 = *dp2;
3165 
3166  *p2 = x * ( *p1 ) - c[i-1] * p0;
3167  *dp2 = x * dp1 + ( *p1 ) - c[i-1] * dp0;
3168  }
3169  return;
3170 }
3171 //**************************************************************************80
3172 
3173 void SandiaRules::gegenbauer_root ( double *x, int order, double alpha, double *dp2,
3174  double *p1, double c[] )
3175 
3176 //**************************************************************************80
3177 //
3178 // Purpose:
3179 //
3180 // GEGENBAUER_ROOT improves an approximate root of a Gegenbauer polynomial.
3181 //
3182 // Licensing:
3183 //
3184 // This code is distributed under the GNU LGPL license.
3185 //
3186 // Modified:
3187 //
3188 // 26 February 2008
3189 //
3190 // Author:
3191 //
3192 // John Burkardt
3193 //
3194 // Reference:
3195 //
3196 // Arthur Stroud, Don Secrest,
3197 // Gaussian Quadrature Formulas,
3198 // Prentice Hall, 1966,
3199 // LC: QA299.4G3S7.
3200 //
3201 // Parameters:
3202 //
3203 // Input/output, double *X, the approximate root, which
3204 // should be improved on output.
3205 //
3206 // Input, int ORDER, the order of the polynomial.
3207 //
3208 // Input, double ALPHA, the exponents of (1-X^2).
3209 //
3210 // Output, double *DP2, the value of J'(ORDER)(X).
3211 //
3212 // Output, double *P1, the value of J(ORDER-1)(X).
3213 //
3214 // Input, double C[ORDER], the recursion coefficients.
3215 //
3216 {
3217  double d;
3218  double eps;
3219  double p2;
3220  int step;
3221  int step_max = 10;
3222 
3223  eps = r8_epsilon ( );
3224 
3225  for ( step = 1; step <= step_max; step++ )
3226  {
3227  gegenbauer_recur ( &p2, dp2, p1, *x, order, alpha, c );
3228 
3229  d = p2 / ( *dp2 );
3230  *x = *x - d;
3231 
3232  if ( r8_abs ( d ) <= eps * ( r8_abs ( *x ) + 1.0 ) )
3233  {
3234  return;
3235  }
3236  }
3237  return;
3238 }
3239 //**************************************************************************80
3240 
3241 void SandiaRules::gen_hermite_compute ( int n, double alpha, double x[], double w[] )
3242 
3243 //**************************************************************************80
3244 //
3245 // Purpose:
3246 //
3247 // GEN_HERMITE_COMPUTE computes a generalized Gauss-Hermite quadrature rule.
3248 //
3249 // Discussion:
3250 //
3251 // The code uses an algorithm by Elhay and Kautsky.
3252 //
3253 // The integral:
3254 //
3255 // integral ( -oo < x < +oo ) |x|^alpha exp(-x^2) f(x) dx
3256 //
3257 // The quadrature rule:
3258 //
3259 // sum ( 1 <= i <= n ) w(i) * f ( x(i) )
3260 //
3261 // Licensing:
3262 //
3263 // This code is distributed under the GNU LGPL license.
3264 //
3265 // Modified:
3266 //
3267 // 30 April 2011
3268 //
3269 // Author:
3270 //
3271 // Original FORTRAN77 version by Sylvan Elhay, Jaroslav Kautsky.
3272 // C++ version by John Burkardt.
3273 //
3274 // Reference:
3275 //
3276 // Sylvan Elhay, Jaroslav Kautsky,
3277 // Algorithm 655: IQPACK, FORTRAN Subroutines for the Weights of
3278 // Interpolatory Quadrature,
3279 // ACM Transactions on Mathematical Software,
3280 // Volume 13, Number 4, December 1987, pages 399-415.
3281 //
3282 // Parameters:
3283 //
3284 // Input, int N, the number of abscissas.
3285 //
3286 // Input, double ALPHA, the parameter.
3287 // -1.0 < ALPHA.
3288 //
3289 // Output, double X[N], the abscissas.
3290 //
3291 // Output, double W[N], the weights.
3292 //
3293 {
3294  double *bj;
3295  int i;
3296  double i_r8;
3297  double zemu;
3298 //
3299 // Define the zero-th moment.
3300 //
3301  zemu = r8_gamma ( ( alpha + 1.0 ) / 2.0 );
3302 //
3303 // Define the Jacobi matrix.
3304 //
3305  bj = new double[n];
3306 
3307  for ( i = 0; i < n; i++ )
3308  {
3309  i_r8 = ( double ) ( i + 1 );
3310  if ( ( i % 2 ) == 0 )
3311  {
3312  bj[i] = ( i_r8 + alpha ) / 2.0;
3313  }
3314  else
3315  {
3316  bj[i] = i_r8 / 2.0;
3317  }
3318  }
3319 
3320  for ( i = 0; i < n; i++ )
3321  {
3322  bj[i] = std::sqrt ( bj[i] );
3323  }
3324 
3325  for ( i = 0; i < n; i++ )
3326  {
3327  x[i] = 0.0;
3328  }
3329 
3330  w[0] = std::sqrt ( zemu );
3331  for ( i = 1; i < n; i++ )
3332  {
3333  w[i] = 0.0;
3334  }
3335 //
3336 // Diagonalize the Jacobi matrix.
3337 //
3338  imtqlx ( n, x, bj, w );
3339 
3340  for ( i = 0; i < n; i++ )
3341  {
3342  w[i] = w[i] * w[i];
3343  }
3344 
3345  delete [] bj;
3346 
3347  return;
3348 }
3349 //**************************************************************************80
3350 
3351 void SandiaRules::gen_hermite_compute_np ( int order, int np, double p[], double x[],
3352  double w[] )
3353 
3354 //**************************************************************************80
3355 //
3356 // Purpose:
3357 //
3358 // GEN_HERMITE_COMPUTE_NP computes a Generalized Hermite quadrature rule.
3359 //
3360 // Discussion:
3361 //
3362 // The integral:
3363 //
3364 // Integral ( -oo < x < +oo ) |x|^ALPHA exp(-x^2) f(x) dx
3365 //
3366 // Licensing:
3367 //
3368 // This code is distributed under the GNU LGPL license.
3369 //
3370 // Modified:
3371 //
3372 // 22 June 2009
3373 //
3374 // Author:
3375 //
3376 // John Burkardt
3377 //
3378 // Reference:
3379 //
3380 // Philip Davis, Philip Rabinowitz,
3381 // Methods of Numerical Integration,
3382 // Second Edition,
3383 // Dover, 2007,
3384 // ISBN: 0486453391,
3385 // LC: QA299.3.D28.
3386 //
3387 // Parameters:
3388 //
3389 // Input, int ORDER, the order.
3390 // 1 <= ORDER.
3391 //
3392 // Input, int NP, the number of parameters.
3393 //
3394 // Input, double P[NP], contains parameters.
3395 // P[0] = ALPHA, the exponent of the X factor. -1.0 < ALPHA.
3396 //
3397 // Output, double X[ORDER], the abscissas.
3398 //
3399 // Output, double W[ORDER], the weights.
3400 //
3401 {
3402  double alpha;
3403 
3404  alpha = p[0];
3405 
3406  gen_hermite_compute ( order, alpha, x, w );
3407 
3408  return;
3409 }
3410 //**************************************************************************80
3411 
3412 void SandiaRules::gen_hermite_compute_points ( int order, double alpha, double x[] )
3413 
3414 //**************************************************************************80
3415 //
3416 // Purpose:
3417 //
3418 // GEN_HERMITE_COMPUTE_POINTS computes Generalized Hermite quadrature points.
3419 //
3420 // Licensing:
3421 //
3422 // This code is distributed under the GNU LGPL license.
3423 //
3424 // Modified:
3425 //
3426 // 13 June 2009
3427 //
3428 // Author:
3429 //
3430 // John Burkardt
3431 //
3432 // Parameters:
3433 //
3434 // Input, int ORDER, the order.
3435 //
3436 // Input, double ALPHA, the exponent of the X factor.
3437 // -1.0 < ALPHA.
3438 //
3439 // Output, double X[ORDER], the abscissas.
3440 //
3441 {
3442  double *w;
3443 
3444  w = new double[order];
3445 
3446  gen_hermite_compute ( order, alpha, x, w );
3447 
3448  delete [] w;
3449 
3450  return;
3451 }
3452 //**************************************************************************80
3453 
3454 void SandiaRules::gen_hermite_compute_points_np ( int order, int np, double p[], double x[] )
3455 
3456 //**************************************************************************80
3457 //
3458 // Purpose:
3459 //
3460 // GEN_HERMITE_COMPUTE_POINTS_NP: Generalized Hermite quadrature points.
3461 //
3462 // Licensing:
3463 //
3464 // This code is distributed under the GNU LGPL license.
3465 //
3466 // Modified:
3467 //
3468 // 22 June 2009
3469 //
3470 // Author:
3471 //
3472 // John Burkardt
3473 //
3474 // Parameters:
3475 //
3476 // Input, int ORDER, the order.
3477 //
3478 // Input, int NP, the number of parameters.
3479 //
3480 // Input, double P[NP], contains parameters.
3481 // P[0] = ALPHA, the exponent of the X factor. -1.0 < ALPHA.
3482 //
3483 // Output, double X[ORDER], the abscissas.
3484 //
3485 {
3486  double alpha;
3487 
3488  alpha = p[0];
3489 
3490  gen_hermite_compute_points ( order, alpha, x );
3491 
3492  return;
3493 }
3494 //**************************************************************************80
3495 
3496 void SandiaRules::gen_hermite_compute_weights ( int order, double alpha, double w[] )
3497 
3498 //**************************************************************************80
3499 //
3500 // Purpose:
3501 //
3502 // GEN_HERMITE_COMPUTE_WEIGHTS computes Generalized Hermite quadrature weights.
3503 //
3504 // Licensing:
3505 //
3506 // This code is distributed under the GNU LGPL license.
3507 //
3508 // Modified:
3509 //
3510 // 13 June 2009
3511 //
3512 // Author:
3513 //
3514 // John Burkardt
3515 //
3516 // Parameters:
3517 //
3518 // Input, int ORDER, the order.
3519 //
3520 // Input, double ALPHA, the exponent of the X factor.
3521 // -1.0 < ALPHA.
3522 //
3523 // Output, double W[ORDER], the weights.
3524 //
3525 {
3526  double *x;
3527 
3528  x = new double[order];
3529 
3530  gen_hermite_compute ( order, alpha, x, w );
3531 
3532  delete [] x;
3533 
3534  return;
3535 }
3536 //**************************************************************************80
3537 
3538 void SandiaRules::gen_hermite_compute_weights_np ( int order, int np, double p[],
3539  double w[] )
3540 
3541 //**************************************************************************80
3542 //
3543 // Purpose:
3544 //
3545 // GEN_HERMITE_COMPUTE_WEIGHTS_NP: Generalized Hermite quadrature weights.
3546 //
3547 // Licensing:
3548 //
3549 // This code is distributed under the GNU LGPL license.
3550 //
3551 // Modified:
3552 //
3553 // 22 June 2009
3554 //
3555 // Author:
3556 //
3557 // John Burkardt
3558 //
3559 // Parameters:
3560 //
3561 // Input, int ORDER, the order.
3562 //
3563 // Input, int NP, the number of parameters.
3564 //
3565 // Input, double P[NP], contains parameters.
3566 // P[0] = ALPHA, the exponent of the X factor. -1.0 < ALPHA.
3567 //
3568 // Output, double W[ORDER], the weights.
3569 //
3570 {
3571  double alpha;
3572 
3573  alpha = p[0];
3574 
3575  gen_hermite_compute_weights ( order, alpha, w );
3576 
3577  return;
3578 }
3579 //**************************************************************************80
3580 
3581 void SandiaRules::gen_hermite_dr_compute ( int order, double alpha, double x[], double w[] )
3582 
3583 //**************************************************************************80
3584 //
3585 // Purpose:
3586 //
3587 // GEN_HERMITE_DR_COMPUTE computes a Generalized Hermite quadrature rule.
3588 //
3589 // Discussion:
3590 //
3591 // The integral:
3592 //
3593 // Integral ( -oo < x < +oo ) |x|^ALPHA exp(-x^2) f(x) dx
3594 //
3595 // Licensing:
3596 //
3597 // This code is distributed under the GNU LGPL license.
3598 //
3599 // Modified:
3600 //
3601 // 13 June 2009
3602 //
3603 // Author:
3604 //
3605 // John Burkardt
3606 //
3607 // Reference:
3608 //
3609 // Philip Davis, Philip Rabinowitz,
3610 // Methods of Numerical Integration,
3611 // Second Edition,
3612 // Dover, 2007,
3613 // ISBN: 0486453391,
3614 // LC: QA299.3.D28.
3615 //
3616 // Parameters:
3617 //
3618 // Input, int ORDER, the order.
3619 // 1 <= ORDER.
3620 //
3621 // Input, double ALPHA, the exponent of the X factor.
3622 // -1.0 < ALPHA.
3623 //
3624 // Output, double X[ORDER], the abscissas.
3625 //
3626 // Output, double W[ORDER], the weights.
3627 //
3628 {
3629  double alpha_laguerre;
3630  double arg;
3631  int i;
3632  int order_laguerre;
3633  double *w_laguerre;
3634  double *x_laguerre;
3635 
3636  if ( order < 1 )
3637  {
3638  std::cerr << "\n";
3639  std::cerr << "GEN_HERMITE_DR_COMPUTE - Fatal error!\n";
3640  std::cerr << " Illegal value of ORDER = " << order << "\n";
3641  std::exit ( 1 );
3642  }
3643 
3644  if ( order == 1 )
3645  {
3646  arg = ( alpha + 1.0 ) / 2.0;
3647  x[0] = 0.0;
3648  w[0] = r8_gamma ( arg );
3649  return;
3650  }
3651 
3652  if ( ( order % 2 ) == 0 )
3653  {
3654  order_laguerre = order / 2;
3655  alpha_laguerre = ( alpha - 1.0 ) / 2.0;
3656  }
3657  else
3658  {
3659  order_laguerre = ( order - 1 ) / 2;
3660  alpha_laguerre = ( alpha + 1.0 ) / 2.0;
3661  }
3662 
3663  w_laguerre = new double[order_laguerre];
3664  x_laguerre = new double[order_laguerre];
3665 
3666  gen_laguerre_ss_compute ( order_laguerre, alpha_laguerre, x_laguerre,
3667  w_laguerre );
3668 
3669  if ( ( order % 2 ) == 0 )
3670  {
3671  for ( i = 0; i < order_laguerre; i++ )
3672  {
3673  x[i] = - std::sqrt ( x_laguerre[order_laguerre-1-i] );
3674  }
3675  for ( i = 0; i < order_laguerre; i++ )
3676  {
3677  x[order_laguerre+i] = std::sqrt ( x_laguerre[i] );
3678  }
3679  for ( i = 0; i < order_laguerre; i++ )
3680  {
3681  w[i] = 0.5 * w_laguerre[order_laguerre-1-i];
3682  }
3683  for ( i = 0; i < order_laguerre; i++ )
3684  {
3685  w[order_laguerre+i] = 0.5 * w_laguerre[i];
3686  }
3687  }
3688  else if ( ( order % 2 ) == 1 )
3689  {
3690  for ( i = 0; i < order_laguerre; i++ )
3691  {
3692  x[i] = - std::sqrt ( x_laguerre[order_laguerre-1-i] );
3693  }
3694  x[order_laguerre] = 0.0;
3695  for ( i = 0; i < order_laguerre; i++ )
3696  {
3697  x[order_laguerre+1+i] = std::sqrt ( x_laguerre[i] );
3698  }
3699  for ( i = 0; i < order_laguerre; i++ )
3700  {
3701  w[i] = 0.5 * w_laguerre[order_laguerre-1-i] / x_laguerre[order_laguerre-1-i];
3702  }
3703 
3704  arg = ( alpha + 1.0 ) / 2.0;
3705  w[order_laguerre] = r8_gamma ( arg );
3706  for ( i = 0; i < order_laguerre; i++ )
3707  {
3708  w[order_laguerre] = w[order_laguerre] - w_laguerre[i] / x_laguerre[i];
3709  }
3710 
3711  for ( i = 0; i < order_laguerre; i++ )
3712  {
3713  w[order_laguerre+1+i] = 0.5 * w_laguerre[i] / x_laguerre[i];
3714  }
3715  }
3716  delete [] w_laguerre;
3717  delete [] x_laguerre;
3718 
3719  return;
3720 }
3721 //**************************************************************************80
3722 
3723 double SandiaRules::gen_hermite_integral ( int expon, double alpha )
3724 
3725 //**************************************************************************80
3726 //
3727 // Purpose:
3728 //
3729 // GEN_HERMITE_INTEGRAL evaluates a monomial Generalized Hermite integral.
3730 //
3731 // Discussion:
3732 //
3733 // H(n,alpha) = Integral ( -oo < x < +oo ) x^n |x|^alpha exp(-x^2) dx
3734 //
3735 // Licensing:
3736 //
3737 // This code is distributed under the GNU LGPL license.
3738 //
3739 // Modified:
3740 //
3741 // 19 February 2008
3742 //
3743 // Author:
3744 //
3745 // John Burkardt
3746 //
3747 // Parameters:
3748 //
3749 // Input, int EXPON, the exponent of the monomial.
3750 // 0 <= EXPON.
3751 //
3752 // Input, double ALPHA, the exponent of |X| in the weight function.
3753 // -1.0 < ALPHA.
3754 //
3755 // Output, double GEN_HERMITE_INTEGRAL, the value of the integral.
3756 //
3757 {
3758  double a;
3759  double arg;
3760  double value;
3761 
3762  if ( ( expon % 2 ) == 1 )
3763  {
3764  value = 0.0;
3765  }
3766  else
3767  {
3768  a = alpha + ( double ) ( expon );
3769  if ( a <= - 1.0 )
3770  {
3771  value = - r8_huge ( );
3772  }
3773  else
3774  {
3775  arg = ( a + 1.0 ) / 2.0;
3776  value = r8_gamma ( arg );
3777  }
3778  }
3779  return value;
3780 }
3781 //**************************************************************************80
3782 
3783 void SandiaRules::gen_laguerre_compute ( int n, double alpha, double x[], double w[] )
3784 
3785 //**************************************************************************80
3786 //
3787 // Purpose:
3788 //
3789 // GEN_LAGUERRE_COMPUTE: generalized Gauss-Laguerre quadrature rule.
3790 //
3791 // Discussion:
3792 //
3793 // The integral:
3794 //
3795 // integral ( 0 <= x < +oo ) exp ( - x ) * x^alpha * f(x) dx
3796 //
3797 // The quadrature rule:
3798 //
3799 // sum ( 1 <= i <= n ) w(i) * f ( x(i) )
3800 //
3801 // The integral:
3802 //
3803 // integral ( 0 <= x < +oo ) x^alpha * f(x) dx
3804 //
3805 // The quadrature rule:
3806 //
3807 // sum ( 1 <= i <= n ) w(i) * exp ( x(i) ) * f ( x(i) )
3808 //
3809 // Licensing:
3810 //
3811 // This code is distributed under the GNU LGPL license.
3812 //
3813 // Modified:
3814 //
3815 // 23 April 2011
3816 //
3817 // Author:
3818 //
3819 // Original FORTRAN77 version by Sylvan Elhay, Jaroslav Kautsky.
3820 // C++ version by John Burkardt.
3821 //
3822 // Reference:
3823 //
3824 // Sylvan Elhay, Jaroslav Kautsky,
3825 // Algorithm 655: IQPACK, FORTRAN Subroutines for the Weights of
3826 // Interpolatory Quadrature,
3827 // ACM Transactions on Mathematical Software,
3828 // Volume 13, Number 4, December 1987, pages 399-415.
3829 //
3830 // Parameters:
3831 //
3832 // Input, int N, the order.
3833 //
3834 // Input, double ALPHA, the exponent of the X factor.
3835 // ALPHA must be nonnegative.
3836 //
3837 // Output, double X[N], the abscissas.
3838 //
3839 // Output, double W[N], the weights.
3840 //
3841 {
3842  double *bj;
3843  int i;
3844  double i_r8;
3845  double zemu;
3846 //
3847 // Define the zero-th moment.
3848 //
3849  zemu = r8_gamma ( alpha + 1.0 );
3850 //
3851 // Define the Jacobi matrix.
3852 //
3853  bj = new double[n];
3854 
3855  for ( i = 0; i < n; i++ )
3856  {
3857  i_r8 = ( double ) ( i + 1 );
3858  bj[i] = std::sqrt ( i_r8 * ( i_r8 + alpha ) );
3859  }
3860 
3861  for ( i = 0; i < n; i++ )
3862  {
3863  i_r8 = ( double ) ( i + 1 );
3864  x[i] = 2.0 * i_r8 - 1.0 + alpha;
3865  }
3866 
3867  w[0] = std::sqrt ( zemu );
3868 
3869  for ( i = 1; i < n; i++ )
3870  {
3871  w[i] = 0.0;
3872  }
3873 //
3874 // Diagonalize the Jacobi matrix.
3875 //
3876  imtqlx ( n, x, bj, w );
3877 
3878  for ( i = 0; i < n; i++ )
3879  {
3880  w[i] = w[i] * w[i];
3881  }
3882 
3883  delete [] bj;
3884 
3885  return;
3886 }
3887 //**************************************************************************80
3888 
3889 void SandiaRules::gen_laguerre_compute_np ( int order, int np, double p[], double x[],
3890  double w[] )
3891 
3892 //**************************************************************************80
3893 //
3894 // Purpose:
3895 //
3896 // GEN_LAGUERRE_COMPUTE_NP computes a Generalized Laguerre quadrature rule.
3897 //
3898 // Discussion:
3899 //
3900 // In the simplest case, ALPHA is 0, and we are approximating the
3901 // integral from 0 to +oo of exp(-X) * F(X). When this is so,
3902 // it is easy to modify the rule to approximate the integral from
3903 // A to +oo as well.
3904 //
3905 // If ALPHA is nonzero, then there is no simple way to extend the
3906 // rule to approximate the integral from A to +oo. The simplest
3907 // procedures would be to approximate the integral from 0 to A.
3908 //
3909 // If the integral to approximate is:
3910 //
3911 // Integral ( A <= X < +oo ) exp ( - X ) * F(X) dX
3912 // or
3913 // Integral ( 0 <= X < +oo ) exp ( - X ) * X^ALPHA * F(X) dX
3914 //
3915 // then the quadrature rule is:
3916 //
3917 // exp ( - A ) * Sum ( 1 <= I <= ORDER ) W(I) * F ( A+X(I) )
3918 // or
3919 // Sum ( 1 <= I <= ORDER ) W(I) * F ( X(I) )
3920 //
3921 //
3922 // If the integral to approximate is:
3923 //
3924 // Integral ( A <= X < +oo ) F(X) dX
3925 // or
3926 // Integral ( 0 <= X < +oo ) X^ALPHA * F(X) dX
3927 //
3928 // then the quadrature rule is:
3929 //
3930 // exp ( - A ) * Sum ( 1 <= I <= ORDER )
3931 // W(I) * exp(A+X(I)) * F ( A+X(I) )
3932 // or
3933 // Sum ( 1 <= I <= ORDER ) W(I) * exp(X(I)) * F ( X(I) )
3934 //
3935 // Licensing:
3936 //
3937 // This code is distributed under the GNU LGPL license.
3938 //
3939 // Modified:
3940 //
3941 // 22 June 2009
3942 //
3943 // Author:
3944 //
3945 // Original FORTRAN77 version by Arthur Stroud, Don Secrest.
3946 // C++ version by John Burkardt.
3947 //
3948 // Reference:
3949 //
3950 // Arthur Stroud, Don Secrest,
3951 // Gaussian Quadrature Formulas,
3952 // Prentice Hall, 1966,
3953 // LC: QA299.4G3S7.
3954 //
3955 // Parameters:
3956 //
3957 // Input, int ORDER, the order.
3958 // 1 <= ORDER.
3959 //
3960 // Input, double P[1], contains parameters.
3961 // P[0] = ALPHA, the exponent of the X factor.
3962 // Set ALPHA = 0.0 for the simplest rule.
3963 // ALPHA must be nonnegative.
3964 //
3965 // Output, double X[ORDER], the abscissas.
3966 //
3967 // Output, double W[ORDER], the weights.
3968 //
3969 {
3970  double alpha;
3971 
3972  alpha = p[0];
3973 
3974  gen_laguerre_compute ( order, alpha, x, w );
3975 
3976  return;
3977 }
3978 //**************************************************************************80
3979 
3980 void SandiaRules::gen_laguerre_compute_points ( int order, double alpha, double x[] )
3981 
3982 //**************************************************************************80
3983 //
3984 // Purpose:
3985 //
3986 // GEN_LAGUERRE_COMPUTE_POINTS: Generalized Laguerre quadrature points.
3987 //
3988 // Licensing:
3989 //
3990 // This code is distributed under the GNU LGPL license.
3991 //
3992 // Modified:
3993 //
3994 // 19 March 2009
3995 //
3996 // Author:
3997 //
3998 // John Burkardt
3999 //
4000 // Parameters:
4001 //
4002 // Input, int ORDER, the order.
4003 //
4004 // Input, double ALPHA, the exponent of the X factor.
4005 // Set ALPHA = 0.0 for the simplest rule.
4006 // ALPHA must be nonnegative.
4007 //
4008 // Output, double X[ORDER], the abscissas.
4009 //
4010 {
4011  double *w;
4012 
4013  w = new double[order];
4014 
4015  gen_laguerre_compute ( order, alpha, x, w );
4016 
4017  delete [] w;
4018 
4019  return;
4020 }
4021 //**************************************************************************80
4022 
4023 void SandiaRules::gen_laguerre_compute_points_np ( int order, int np, double p[],
4024  double x[] )
4025 
4026 //**************************************************************************80
4027 //
4028 // Purpose:
4029 //
4030 // GEN_LAGUERRE_COMPUTE_POINTS_NP: Generalized Laguerre quadrature points.
4031 //
4032 // Licensing:
4033 //
4034 // This code is distributed under the GNU LGPL license.
4035 //
4036 // Modified:
4037 //
4038 // 22 June 2009
4039 //
4040 // Author:
4041 //
4042 // John Burkardt
4043 //
4044 // Parameters:
4045 //
4046 // Input, int ORDER, the order.
4047 //
4048 // Input, int NP, the number of parameters.
4049 //
4050 // Input, double P[NP], contains parameters.
4051 // P[0] = ALPHA, the exponent of the X factor.
4052 // Set ALPHA = 0.0 for the simplest rule.
4053 // ALPHA must be nonnegative.
4054 //
4055 // Output, double X[ORDER], the abscissas.
4056 //
4057 {
4058  double alpha;
4059 
4060  alpha = p[0];
4061 
4062  gen_laguerre_compute_points ( order, alpha, x );
4063 
4064  return;
4065 }
4066 //**************************************************************************80
4067 
4068 void SandiaRules::gen_laguerre_compute_weights ( int order, double alpha, double w[] )
4069 
4070 //**************************************************************************80
4071 //
4072 // Purpose:
4073 //
4074 // GEN_LAGUERRE_COMPUTE_WEIGHTS: Generalized Laguerre quadrature weights.
4075 //
4076 // Licensing:
4077 //
4078 // This code is distributed under the GNU LGPL license.
4079 //
4080 // Modified:
4081 //
4082 // 13 June 2009
4083 //
4084 // Author:
4085 //
4086 // John Burkardt
4087 //
4088 // Parameters:
4089 //
4090 // Input, int ORDER, the order.
4091 //
4092 // Input, double ALPHA, the exponent of the X factor.
4093 // Set ALPHA = 0.0 for the simplest rule.
4094 // ALPHA must be nonnegative.
4095 //
4096 // Output, double W[ORDER], the weights.
4097 //
4098 {
4099  double *x;
4100 
4101  x = new double[order];
4102 
4103  gen_laguerre_compute ( order, alpha, x, w );
4104 
4105  delete [] x;
4106 
4107  return;
4108 }
4109 //**************************************************************************80
4110 
4111 void SandiaRules::gen_laguerre_compute_weights_np ( int order, int np, double p[],
4112  double w[] )
4113 
4114 //**************************************************************************80
4115 //
4116 // Purpose:
4117 //
4118 // GEN_LAGUERRE_COMPUTE_WEIGHTS_NP: Generalized Laguerre quadrature weights.
4119 //
4120 // Licensing:
4121 //
4122 // This code is distributed under the GNU LGPL license.
4123 //
4124 // Modified:
4125 //
4126 // 22 June 2009
4127 //
4128 // Author:
4129 //
4130 // John Burkardt
4131 //
4132 // Parameters:
4133 //
4134 // Input, int ORDER, the order.
4135 //
4136 // Input, int NP, the number of parameters.
4137 //
4138 // Input, double P[NP], contains parameters.
4139 // P[0] = ALPHA, the exponent of the X factor.
4140 // Set ALPHA = 0.0 for the simplest rule.
4141 // ALPHA must be nonnegative.
4142 //
4143 // Output, double W[ORDER], the weights.
4144 //
4145 {
4146  double alpha;
4147 
4148  alpha = p[0];
4149 
4150  gen_laguerre_compute_weights ( order, alpha, w );
4151 
4152  return;
4153 }
4154 //**************************************************************************80
4155 
4156 double SandiaRules::gen_laguerre_integral ( int expon, double alpha )
4157 
4158 //**************************************************************************80
4159 //
4160 // Purpose:
4161 //
4162 // GEN_LAGUERRE_INTEGRAL evaluates a monomial Generalized Laguerre integral.
4163 //
4164 // Discussion:
4165 //
4166 // L(n,alpha) = Integral ( 0 <= x < +oo ) x^n * x^alpha exp(-x) dx
4167 //
4168 // Licensing:
4169 //
4170 // This code is distributed under the GNU LGPL license.
4171 //
4172 // Modified:
4173 //
4174 // 20 February 2008
4175 //
4176 // Author:
4177 //
4178 // John Burkardt
4179 //
4180 // Parameters:
4181 //
4182 // Input, int EXPON, the exponent of the monomial.
4183 // 0 <= EXPON.
4184 //
4185 // Input, double ALPHA, the exponent of X in the weight function.
4186 // -1.0 < ALPHA.
4187 //
4188 // Output, double GEN_LAGUERRE_INTEGRAL, the value of the integral.
4189 //
4190 {
4191  double arg;
4192  double value;
4193 
4194  arg = alpha + ( double ) ( expon + 1.0 );
4195  value = r8_gamma ( arg );
4196 
4197  return value;
4198 }
4199 //**************************************************************************80
4200 
4201 void SandiaRules::gen_laguerre_ss_compute ( int order, double alpha, double x[], double w[] )
4202 
4203 //**************************************************************************80
4204 //
4205 // Purpose:
4206 //
4207 // GEN_LAGUERRE_SS_COMPUTE computes a Generalized Laguerre quadrature rule.
4208 //
4209 // Discussion:
4210 //
4211 // In the simplest case, ALPHA is 0, and we are approximating the
4212 // integral from 0 to +oo of exp(-X) * F(X). When this is so,
4213 // it is easy to modify the rule to approximate the integral from
4214 // A to +oo as well.
4215 //
4216 // If ALPHA is nonzero, then there is no simple way to extend the
4217 // rule to approximate the integral from A to +oo. The simplest
4218 // procedures would be to approximate the integral from 0 to A.
4219 //
4220 // If the integral to approximate is:
4221 //
4222 // Integral ( A <= X < +oo ) exp ( - X ) * F(X) dX
4223 // or
4224 // Integral ( 0 <= X < +oo ) exp ( - X ) * X^ALPHA * F(X) dX
4225 //
4226 // then the quadrature rule is:
4227 //
4228 // exp ( - A ) * Sum ( 1 <= I <= ORDER ) W(I) * F ( A+X(I) )
4229 // or
4230 // Sum ( 1 <= I <= ORDER ) W(I) * F ( X(I) )
4231 //
4232 //
4233 // If the integral to approximate is:
4234 //
4235 // Integral ( A <= X < +oo ) F(X) dX
4236 // or
4237 // Integral ( 0 <= X < +oo ) X^ALPHA * F(X) dX
4238 //
4239 // then the quadrature rule is:
4240 //
4241 // exp ( - A ) * Sum ( 1 <= I <= ORDER )
4242 // W(I) * exp(A+X(I)) * F ( A+X(I) )
4243 // or
4244 // Sum ( 1 <= I <= ORDER ) W(I) * exp(X(I)) * F ( X(I) )
4245 //
4246 // Licensing:
4247 //
4248 // This code is distributed under the GNU LGPL license.
4249 //
4250 // Modified:
4251 //
4252 // 13 June 2009
4253 //
4254 // Author:
4255 //
4256 // Original FORTRAN77 version by Arthur Stroud, Don Secrest.
4257 // C++ version by John Burkardt.
4258 //
4259 // Reference:
4260 //
4261 // Arthur Stroud, Don Secrest,
4262 // Gaussian Quadrature Formulas,
4263 // Prentice Hall, 1966,
4264 // LC: QA299.4G3S7.
4265 //
4266 // Parameters:
4267 //
4268 // Input, int ORDER, the order.
4269 // 1 <= ORDER.
4270 //
4271 // Input, double ALPHA, the exponent of the X factor.
4272 // Set ALPHA = 0.0 for the simplest rule.
4273 // ALPHA must be nonnegative.
4274 //
4275 // Output, double X[ORDER], the abscissas.
4276 //
4277 // Output, double W[ORDER], the weights.
4278 //
4279 {
4280  double *b;
4281  double *c;
4282  double cc;
4283  double dp2;
4284  int i;
4285  double p1;
4286  double prod;
4287  double r1;
4288  double r2;
4289  double ratio;
4290  double x0;
4291 
4292  if ( order < 1 )
4293  {
4294  std::cerr << "\n";
4295  std::cerr << "GEN_LAGUERRE_SS_COMPUTE - Fatal error!\n";
4296  std::cerr << " Illegal value of ORDER = " << order << "\n";
4297  std::exit ( 1 );
4298  }
4299 
4300  b = new double[order];
4301  c = new double[order];
4302 //
4303 // Set the recursion coefficients.
4304 //
4305  for ( i = 0; i < order; i++ )
4306  {
4307  b[i] = ( alpha + ( double ) ( 2 * i + 1 ) );
4308  }
4309 
4310  for ( i = 0; i < order; i++ )
4311  {
4312  c[i] = ( double ) ( i ) * ( alpha + ( double ) ( i ) );
4313  }
4314  prod = 1.0;
4315  for ( i = 1; i < order; i++ )
4316  {
4317  prod = prod * c[i];
4318  }
4319  cc = r8_gamma ( alpha + 1.0 ) * prod;
4320 
4321  for ( i = 0; i < order; i++ )
4322  {
4323 //
4324 // Compute an estimate for the root.
4325 //
4326  if ( i == 0 )
4327  {
4328  x0 = ( 1.0 + alpha ) * ( 3.0+ 0.92 * alpha ) /
4329  ( 1.0 + 2.4 * ( double ) ( order ) + 1.8 * alpha );
4330  }
4331  else if ( i == 1 )
4332  {
4333  x0 = x0 + ( 15.0 + 6.25 * alpha ) /
4334  ( 1.0 + 0.9 * alpha + 2.5 * ( double ) ( order ) );
4335  }
4336  else
4337  {
4338  r1 = ( 1.0 + 2.55 * ( double ) ( i - 1 ) )
4339  / ( 1.9 * ( double ) ( i - 1 ) );
4340 
4341  r2 = 1.26 * ( double ) ( i - 1 ) * alpha /
4342  ( 1.0 + 3.5 * ( double ) ( i - 1 ) );
4343 
4344  ratio = ( r1 + r2 ) / ( 1.0 + 0.3 * alpha );
4345 
4346  x0 = x0 + ratio * ( x0 - x[i-2] );
4347  }
4348 //
4349 // Use iteration to find the root.
4350 //
4351  gen_laguerre_ss_root ( &x0, order, alpha, &dp2, &p1, b, c );
4352 //
4353 // Set the abscissa and weight.
4354 //
4355  x[i] = x0;
4356  w[i] = ( cc / dp2 ) / p1;
4357  }
4358 
4359  delete [] b;
4360  delete [] c;
4361 
4362  return;
4363 }
4364 //**************************************************************************80
4365 
4366 void SandiaRules::gen_laguerre_ss_recur ( double *p2, double *dp2, double *p1, double x,
4367  int order, double alpha, double b[], double c[] )
4368 
4369 //**************************************************************************80
4370 //
4371 // Purpose:
4372 //
4373 // GEN_LAGUERRE_SS_RECUR evaluates a Generalized Laguerre polynomial.
4374 //
4375 // Licensing:
4376 //
4377 // This code is distributed under the GNU LGPL license.
4378 //
4379 // Modified:
4380 //
4381 // 18 February 2008
4382 //
4383 // Author:
4384 //
4385 // Original FORTRAN77 version by Arthur Stroud, Don Secrest.
4386 // C++ version by John Burkardt.
4387 //
4388 // Reference:
4389 //
4390 // Arthur Stroud, Don Secrest,
4391 // Gaussian Quadrature Formulas,
4392 // Prentice Hall, 1966,
4393 // LC: QA299.4G3S7.
4394 //
4395 // Parameters:
4396 //
4397 // Output, double *P2, the value of L(ORDER)(X).
4398 //
4399 // Output, double *DP2, the value of L'(ORDER)(X).
4400 //
4401 // Output, double *P1, the value of L(ORDER-1)(X).
4402 //
4403 // Input, double X, the point at which polynomials are evaluated.
4404 //
4405 // Input, int ORDER, the order of the polynomial.
4406 //
4407 // Input, double ALPHA, the exponent of the X factor in the
4408 // integrand.
4409 //
4410 // Input, double B[ORDER], C[ORDER], the recursion coefficients.
4411 //
4412 {
4413  double dp0;
4414  double dp1;
4415  int i;
4416  double p0;
4417 
4418  *p1 = 1.0;
4419  dp1 = 0.0;
4420 
4421  *p2 = x - alpha - 1.0;
4422  *dp2 = 1.0;
4423 
4424  for ( i = 1; i < order; i++ )
4425  {
4426  p0 = *p1;
4427  dp0 = dp1;
4428 
4429  *p1 = *p2;
4430  dp1 = *dp2;
4431 
4432  *p2 = ( x - b[i] ) * ( *p1 ) - c[i] * p0;
4433  *dp2 = ( x - b[i] ) * dp1 + ( *p1 ) - c[i] * dp0;
4434  }
4435 
4436  return;
4437 }
4438 //**************************************************************************80
4439 
4440 void SandiaRules::gen_laguerre_ss_root ( double *x, int order, double alpha, double *dp2,
4441  double *p1, double b[], double c[] )
4442 
4443 //**************************************************************************80
4444 //
4445 // Purpose:
4446 //
4447 // GEN_LAGUERRE_SS_ROOT improves a root of a Generalized Laguerre polynomial.
4448 //
4449 // Licensing:
4450 //
4451 // This code is distributed under the GNU LGPL license.
4452 //
4453 // Modified:
4454 //
4455 // 18 February 2008
4456 //
4457 // Author:
4458 //
4459 // Original FORTRAN77 version by Arthur Stroud, Don Secrest.
4460 // C++ version by John Burkardt.
4461 //
4462 // Reference:
4463 //
4464 // Arthur Stroud, Don Secrest,
4465 // Gaussian Quadrature Formulas,
4466 // Prentice Hall, 1966,
4467 // LC: QA299.4G3S7.
4468 //
4469 // Parameters:
4470 //
4471 // Input/output, double *X, the approximate root, which
4472 // should be improved on output.
4473 //
4474 // Input, int ORDER, the order of the polynomial.
4475 //
4476 // Input, double ALPHA, the exponent of the X factor.
4477 //
4478 // Output, double *DP2, the value of L'(ORDER)(X).
4479 //
4480 // Output, double *P1, the value of L(ORDER-1)(X).
4481 //
4482 // Input, double B[ORDER], C[ORDER], the recursion coefficients.
4483 //
4484 {
4485  double d;
4486  double eps;
4487  double p2;
4488  int step;
4489  int step_max = 10;
4490 
4491  eps = r8_epsilon ( );
4492 
4493  for ( step = 1; step <= step_max; step++ )
4494  {
4495  gen_laguerre_ss_recur ( &p2, dp2, p1, *x, order, alpha, b, c );
4496 
4497  d = p2 / ( *dp2 );
4498  *x = *x - d;
4499 
4500  if ( r8_abs ( d ) <= eps * ( r8_abs ( *x ) + 1.0 ) )
4501  {
4502  break;
4503  }
4504  }
4505  return;
4506 }
4507 //**************************************************************************80
4508 
4509 void SandiaRules::hc_compute_weights_from_points ( int nhalf, double xhalf[], double w[] )
4510 
4511 //**************************************************************************80
4512 //
4513 // Purpose:
4514 //
4515 // HC_COMPUTE_WEIGHTS_FROM_POINTS: Hermite-Cubic weights, user-supplied points.
4516 //
4517 // Discussion:
4518 //
4519 // An interval [A,B] has been divided by NHALF points X; at each
4520 // point both function and derivative information is available.
4521 //
4522 // The piecewise cubic Hermite interpolant is constructed for this data.
4523 //
4524 // A quadrature rule is determined for the interpolant.
4525 //
4526 // There will be N=2*NHALF weights. If the quadrature rule is to be written
4527 // out, one would normally list each point twice, so that the number of points
4528 // and weights are equal. The listing of the same point value twice is an
4529 // implicit indication that both function and derivative values should be
4530 // used.
4531 //
4532 // Licensing:
4533 //
4534 // This code is distributed under the GNU LGPL license.
4535 //
4536 // Modified:
4537 //
4538 // 28 March 2011
4539 //
4540 // Author:
4541 //
4542 // John Burkardt
4543 //
4544 // Parameters:
4545 //
4546 // Input, int NHALF, the number of points, not counting repetitions.
4547 //
4548 // Input, double XHALF[NHALF], the points, without repetition.
4549 //
4550 // Output, double W[2*NHALF], the weights. The first two weights are
4551 // associated with the first point, and so on.
4552 //
4553 {
4554  int j;
4555 
4556  w[0+0*2] = 0.5 * ( xhalf[1] - xhalf[0] );
4557  w[1+0*2] = std::pow ( xhalf[1] - xhalf[0], 2 ) / 12.0;
4558 
4559  for ( j = 1; j < nhalf - 1; j++ )
4560  {
4561  w[0+j*2] = 0.5 * ( xhalf[j+1] - xhalf[j-1] );
4562  w[1+j*2] = ( xhalf[j+1] - xhalf[j-1] )
4563  * ( xhalf[j+1] - 2.0 * xhalf[j] + xhalf[j-1] ) / 12.0;
4564  }
4565 
4566  w[0+(nhalf-1)*2] = 0.5 * ( xhalf[nhalf-1] - xhalf[nhalf-2] );
4567  w[1+(nhalf-1)*2] = - std::pow ( xhalf[nhalf-2] - xhalf[nhalf-1], 2 ) / 12.0;
4568 
4569  return;
4570 }
4571 //**************************************************************************80
4572 
4573 void SandiaRules::hcc_compute ( int n, double x[], double w[] )
4574 
4575 //**************************************************************************80
4576 //
4577 // Purpose:
4578 //
4579 // HCC_COMPUTE computes a Hermite-Cubic-Chebyshev-Spacing quadrature rule.
4580 //
4581 // Discussion:
4582 //
4583 // For the HCE rule, we assume that an interval has been divided by
4584 // M nodes X into Chebyshev-spaced subintervals, and that at each
4585 // abscissa both function and derivative information is available.
4586 // The piecewise cubic Hermite interpolant is constructed for this data.
4587 // The quadrature rule uses N = 2 * M abscissas, where each node is
4588 // listed twice, and the weights occur in pairs, with the first multiplying
4589 // the function value and the second the derivative.
4590 //
4591 // Licensing:
4592 //
4593 // This code is distributed under the GNU LGPL license.
4594 //
4595 // Modified:
4596 //
4597 // 24 March 2011
4598 //
4599 // Author:
4600 //
4601 // John Burkardt
4602 //
4603 // Parameters:
4604 //
4605 // Input, int N, the order.
4606 // 1 <= N.
4607 //
4608 // Output, double X[N], the abscissas.
4609 //
4610 // Output, double W[N], the weights.
4611 //
4612 {
4613  int nhalf;
4614  double *xhalf;
4615 
4616  nhalf = n / 2;
4617  xhalf = new double[nhalf];
4618 
4619  clenshaw_curtis_compute_points ( nhalf, xhalf );
4620  r8vec_stutter ( nhalf, xhalf, 2, x );
4621  hc_compute_weights_from_points ( nhalf, xhalf, w );
4622 
4623  delete [] xhalf;
4624 
4625  return;
4626 }
4627 //**************************************************************************80
4628 
4629 void SandiaRules::hcc_compute_np ( int n, int np, double p[], double x[], double w[] )
4630 
4631 //**************************************************************************80
4632 //
4633 // Purpose:
4634 //
4635 // HCC_COMPUTE_NP computes a Hermite-Cubic-Chebyshev-Spacing quadrature rule.
4636 //
4637 // Discussion:
4638 //
4639 // For the HCE rule, we assume that an interval has been divided by
4640 // M nodes X into Chebyshev-spaced subintervals, and that at each
4641 // abscissa both function and derivative information is available.
4642 // The piecewise cubic Hermite interpolant is constructed for this data.
4643 // The quadrature rule uses N = 2 * M abscissas, where each node is
4644 // listed twice, and the weights occur in pairs, with the first multiplying
4645 // the function value and the second the derivative.
4646 //
4647 // Licensing:
4648 //
4649 // This code is distributed under the GNU LGPL license.
4650 //
4651 // Modified:
4652 //
4653 // 17 March 2011
4654 //
4655 // Author:
4656 //
4657 // John Burkardt
4658 //
4659 // Parameters:
4660 //
4661 // Input, int N, the order.
4662 // 1 <= N.
4663 //
4664 // Input, int NP, the number of parameters.
4665 //
4666 // Input, double P[NP], parameters which are not needed by this function.
4667 //
4668 // Output, double X[N], the abscissas.
4669 //
4670 // Output, double W[N], the weights.
4671 //
4672 {
4673  hcc_compute ( n, x, w );
4674 
4675  return;
4676 }
4677 //**************************************************************************80
4678 
4679 void SandiaRules::hcc_compute_points ( int n, double x[] )
4680 
4681 //**************************************************************************80
4682 //
4683 // Purpose:
4684 //
4685 // HCC_COMPUTE_POINTS computes Hermite-Cubic-Chebyshev-Spacing quadrature points.
4686 //
4687 // Discussion:
4688 //
4689 // For the HCE rule, we assume that an interval has been divided by
4690 // M nodes X into Chebyshev-spaced subintervals, and that at each
4691 // abscissa both function and derivative information is available.
4692 // The piecewise cubic Hermite interpolant is constructed for this data.
4693 // The quadrature rule uses N = 2 * M abscissas, where each node is
4694 // listed twice, and the weights occur in pairs, with the first multiplying
4695 // the function value and the second the derivative.
4696 //
4697 // Licensing:
4698 //
4699 // This code is distributed under the GNU LGPL license.
4700 //
4701 // Modified:
4702 //
4703 // 24 March 2011
4704 //
4705 // Author:
4706 //
4707 // John Burkardt
4708 //
4709 // Parameters:
4710 //
4711 // Input, int N, the order.
4712 //
4713 // Output, double X[N], the abscissas.
4714 //
4715 {
4716  int nhalf;
4717  double *xhalf;
4718 
4719  if ( ( n % 2 ) != 0 )
4720  {
4721  std::cerr << "\n";
4722  std::cerr << "HCC_COMPUTE_POINTS - Fatal error!\n";
4723  std::cerr << " Order of rule N is not even.\n";
4724  std::exit ( 1 );
4725  }
4726 
4727  nhalf = n / 2;
4728  xhalf = new double[nhalf];
4729 
4730  clenshaw_curtis_compute_points ( nhalf, xhalf );
4731  r8vec_stutter ( nhalf, xhalf, 2, x );
4732 
4733  delete [] xhalf;
4734 
4735  return;
4736 }
4737 //**************************************************************************80
4738 
4739 void SandiaRules::hcc_compute_points_np ( int n, int np, double p[], double x[] )
4740 
4741 //**************************************************************************80
4742 //
4743 // Purpose:
4744 //
4745 // HCC_COMPUTE_POINTS_NP: Hermite-Cubic-Chebyshev-Spacing quadrature points.
4746 //
4747 // Discussion:
4748 //
4749 // For the HCE rule, we assume that an interval has been divided by
4750 // M nodes X into Chebyshev-spaced subintervals, and that at each
4751 // abscissa both function and derivative information is available.
4752 // The piecewise cubic Hermite interpolant is constructed for this data.
4753 // The quadrature rule uses N = 2 * M abscissas, where each node is
4754 // listed twice, and the weights occur in pairs, with the first multiplying
4755 // the function value and the second the derivative.
4756 //
4757 // Licensing:
4758 //
4759 // This code is distributed under the GNU LGPL license.
4760 //
4761 // Modified:
4762 //
4763 // 17 March 2011
4764 //
4765 // Author:
4766 //
4767 // John Burkardt
4768 //
4769 // Parameters:
4770 //
4771 // Input, int N, the order.
4772 //
4773 // Input, int NP, the number of parameters.
4774 //
4775 // Input, double P[NP], parameters which are not needed by this function.
4776 //
4777 // Output, double X[N], the abscissas.
4778 //
4779 {
4780  hcc_compute_points ( n, x );
4781 
4782  return;
4783 }
4784 //**************************************************************************80
4785 
4786 void SandiaRules::hcc_compute_weights ( int n, double w[] )
4787 
4788 //**************************************************************************80
4789 //
4790 // Purpose:
4791 //
4792 // HCC_COMPUTE_WEIGHTS: Hermite-Cubic-Chebyshev-Spacing quadrature weights.
4793 //
4794 // Discussion:
4795 //
4796 // For the HCE rule, we assume that an interval has been divided by
4797 // M nodes X into Chebyshev-spaced subintervals, and that at each
4798 // abscissa both function and derivative information is available.
4799 // The piecewise cubic Hermite interpolant is constructed for this data.
4800 // The quadrature rule uses N = 2 * M abscissas, where each node is
4801 // listed twice, and the weights occur in pairs, with the first multiplying
4802 // the function value and the second the derivative.
4803 //
4804 // Licensing:
4805 //
4806 // This code is distributed under the GNU LGPL license.
4807 //
4808 // Modified:
4809 //
4810 // 24 March 2011
4811 //
4812 // Author:
4813 //
4814 // John Burkardt
4815 //
4816 // Parameters:
4817 //
4818 // Input, int N, the order.
4819 //
4820 // Output, double W[N], the weights.
4821 //
4822 {
4823  int nhalf;
4824  double *xhalf;
4825 
4826  if ( ( n % 2 ) != 0 )
4827  {
4828  std::cerr << "\n";
4829  std::cerr << "HCC_COMPUTE_WEIGHTS - Fatal error!\n";
4830  std::cerr << " Order of rule N is not even.\n";
4831  std::exit ( 1 );
4832  }
4833 
4834  nhalf = n / 2;
4835  xhalf = new double[nhalf];
4836 
4837  hc_compute_weights_from_points ( nhalf, xhalf, w );
4838 
4839  delete [] xhalf;
4840 
4841  return;
4842 }
4843 //**************************************************************************80
4844 
4845 void SandiaRules::hcc_compute_weights_np ( int n, int np, double p[], double w[] )
4846 
4847 //**************************************************************************80
4848 //
4849 // Purpose:
4850 //
4851 // HCC_COMPUTE_WEIGHTS_NP: Hermite-Cubic-Chebyshev-Spacing quadrature weights.
4852 //
4853 // Discussion:
4854 //
4855 // For the HCE rule, we assume that an interval has been divided by
4856 // M nodes X into Chebyshev-spaced subintervals, and that at each
4857 // abscissa both function and derivative information is available.
4858 // The piecewise cubic Hermite interpolant is constructed for this data.
4859 // The quadrature rule uses N = 2 * M abscissas, where each node is
4860 // listed twice, and the weights occur in pairs, with the first multiplying
4861 // the function value and the second the derivative.
4862 //
4863 // Licensing:
4864 //
4865 // This code is distributed under the GNU LGPL license.
4866 //
4867 // Modified:
4868 //
4869 // 17 March 2011
4870 //
4871 // Author:
4872 //
4873 // John Burkardt
4874 //
4875 // Parameters:
4876 //
4877 // Input, int N, the order.
4878 //
4879 // Input, int NP, the number of parameters.
4880 //
4881 // Input, double P[NP], parameters which are not needed by this function.
4882 //
4883 // Output, double W[N], the weights.
4884 //
4885 {
4886  hcc_compute_weights ( n, w );
4887 
4888  return;
4889 }
4890 //**************************************************************************80
4891 
4892 void SandiaRules::hce_compute ( int n, double x[], double w[] )
4893 
4894 //**************************************************************************80
4895 //
4896 // Purpose:
4897 //
4898 // HCE_COMPUTE computes a Hermite-Cubic-Equal-Spacing quadrature rule.
4899 //
4900 // Discussion:
4901 //
4902 // For the HCE rule, we assume that an interval has been divided by
4903 // M nodes X into equally spaced subintervals, and that at each
4904 // abscissa both function and derivative information is available.
4905 // The piecewise cubic Hermite interpolant is constructed for this data.
4906 // The quadrature rule uses N = 2 * M abscissas, where each node is
4907 // listed twice, and the weights occur in pairs, with the first multiplying
4908 // the function value and the second the derivative.
4909 //
4910 // Licensing:
4911 //
4912 // This code is distributed under the GNU LGPL license.
4913 //
4914 // Modified:
4915 //
4916 // 28 March 2011
4917 //
4918 // Author:
4919 //
4920 // John Burkardt
4921 //
4922 // Parameters:
4923 //
4924 // Input, int N, the order.
4925 // 1 <= N.
4926 //
4927 // Output, double X[N], the abscissas.
4928 //
4929 // Output, double W[N], the weights.
4930 //
4931 {
4932  double a_high = 1.0;
4933  double a_low = 0.0;
4934  int nhalf;
4935  double *xhalf;
4936 
4937  a_low = 0.0;
4938  a_high = 1.0;
4939 
4940  nhalf = n / 2;
4941 
4942  xhalf = r8vec_linspace_new ( nhalf, a_low, a_high );
4943  r8vec_stutter ( nhalf, xhalf, 2, x );
4944  hc_compute_weights_from_points ( nhalf, xhalf, w );
4945 
4946  delete [] xhalf;
4947 
4948  return;
4949 }
4950 //**************************************************************************80
4951 
4952 void SandiaRules::hce_compute_np ( int n, int np, double p[], double x[], double w[] )
4953 
4954 //**************************************************************************80
4955 //
4956 // Purpose:
4957 //
4958 // HCE_COMPUTE_NP computes a Hermite-Cubic-Equal-Spacing quadrature rule.
4959 //
4960 // Discussion:
4961 //
4962 // For the HCE rule, we assume that an interval has been divided by
4963 // M nodes X into equally spaced subintervals, and that at each
4964 // abscissa both function and derivative information is available.
4965 // The piecewise cubic Hermite interpolant is constructed for this data.
4966 // The quadrature rule uses N = 2 * M abscissas, where each node is
4967 // listed twice, and the weights occur in pairs, with the first multiplying
4968 // the function value and the second the derivative.
4969 //
4970 // Licensing:
4971 //
4972 // This code is distributed under the GNU LGPL license.
4973 //
4974 // Modified:
4975 //
4976 // 07 March 2011
4977 //
4978 // Author:
4979 //
4980 // John Burkardt
4981 //
4982 // Parameters:
4983 //
4984 // Input, int N, the order.
4985 // 1 <= N.
4986 //
4987 // Input, int NP, the number of parameters.
4988 //
4989 // Input, double P[NP], parameters which are not needed by this function.
4990 //
4991 // Output, double X[N], the abscissas.
4992 //
4993 // Output, double W[N], the weights.
4994 //
4995 {
4996  hce_compute ( n, x, w );
4997 
4998  return;
4999 }
5000 //**************************************************************************80
5001 
5002 void SandiaRules::hce_compute_points ( int n, double x[] )
5003 
5004 //**************************************************************************80
5005 //
5006 // Purpose:
5007 //
5008 // HCE_COMPUTE_POINTS computes Hermite-Cubic-Equal-Spacing quadrature points.
5009 //
5010 // Discussion:
5011 //
5012 // For the HCE rule, we assume that an interval has been divided by
5013 // M nodes X into equally spaced subintervals, and that at each
5014 // abscissa both function and derivative information is available.
5015 // The piecewise cubic Hermite interpolant is constructed for this data.
5016 // The quadrature rule uses N = 2 * M abscissas, where each node is
5017 // listed twice, and the weights occur in pairs, with the first multiplying
5018 // the function value and the second the derivative.
5019 //
5020 // Licensing:
5021 //
5022 // This code is distributed under the GNU LGPL license.
5023 //
5024 // Modified:
5025 //
5026 // 07 March 2011
5027 //
5028 // Author:
5029 //
5030 // John Burkardt
5031 //
5032 // Parameters:
5033 //
5034 // Input, int N, the order.
5035 //
5036 // Output, double X[N], the abscissas.
5037 //
5038 {
5039  int i;
5040  int j;
5041  int m;
5042  double x_value;
5043 
5044  if ( ( n % 2 ) != 0 )
5045  {
5046  std::cerr << "\n";
5047  std::cerr << "HCE_COMPUTE_POINTS - Fatal error!\n";
5048  std::cerr << " Order of rule N is not even.\n";
5049  std::exit ( 1 );
5050  }
5051  m = n / 2;
5052 
5053  for ( j = 0; j < m; j++ )
5054  {
5055  x_value = ( double ) ( 2 * j + 1 - m ) / ( double ) ( m - 1 );
5056  for ( i = 0; i < 2; i++ )
5057  {
5058  x[i+j*2] = x_value;
5059  }
5060  }
5061  return;
5062 }
5063 //**************************************************************************80
5064 
5065 void SandiaRules::hce_compute_points_np ( int n, int np, double p[], double x[] )
5066 
5067 //**************************************************************************80
5068 //
5069 // Purpose:
5070 //
5071 // HCE_COMPUTE_POINTS_NP: Hermite-Cubic-Equal-Spacing quadrature points.
5072 //
5073 // Discussion:
5074 //
5075 // For the HCE rule, we assume that an interval has been divided by
5076 // M nodes X into equally spaced subintervals, and that at each
5077 // abscissa both function and derivative information is available.
5078 // The piecewise cubic Hermite interpolant is constructed for this data.
5079 // The quadrature rule uses N = 2 * M abscissas, where each node is
5080 // listed twice, and the weights occur in pairs, with the first multiplying
5081 // the function value and the second the derivative.
5082 //
5083 // Licensing:
5084 //
5085 // This code is distributed under the GNU LGPL license.
5086 //
5087 // Modified:
5088 //
5089 // 07 March 2011
5090 //
5091 // Author:
5092 //
5093 // John Burkardt
5094 //
5095 // Parameters:
5096 //
5097 // Input, int N, the order.
5098 //
5099 // Input, int NP, the number of parameters.
5100 //
5101 // Input, double P[NP], parameters which are not needed by this function.
5102 //
5103 // Output, double X[N], the abscissas.
5104 //
5105 {
5106  hce_compute_points ( n, x );
5107 
5108  return;
5109 }
5110 //**************************************************************************80
5111 
5112 void SandiaRules::hce_compute_weights ( int n, double w[] )
5113 
5114 //**************************************************************************80
5115 //
5116 // Purpose:
5117 //
5118 // HCE_COMPUTE_WEIGHTS: Hermite-Cubic-Equal-Spacing quadrature weights.
5119 //
5120 // Discussion:
5121 //
5122 // For the HCE rule, we assume that an interval has been divided by
5123 // M nodes X into equally spaced subintervals, and that at each
5124 // abscissa both function and derivative information is available.
5125 // The piecewise cubic Hermite interpolant is constructed for this data.
5126 // The quadrature rule uses N = 2 * M abscissas, where each node is
5127 // listed twice, and the weights occur in pairs, with the first multiplying
5128 // the function value and the second the derivative.
5129 //
5130 // Licensing:
5131 //
5132 // This code is distributed under the GNU LGPL license.
5133 //
5134 // Modified:
5135 //
5136 // 24 March 2011
5137 //
5138 // Author:
5139 //
5140 // John Burkardt
5141 //
5142 // Parameters:
5143 //
5144 // Input, int N, the order.
5145 //
5146 // Output, double W[N], the weights.
5147 //
5148 {
5149  int nhalf;
5150  double *xhalf;
5151 
5152  if ( ( n % 2 ) != 0 )
5153  {
5154  std::cerr << "\n";
5155  std::cerr << "HCE_COMPUTE_WEIGHTS - Fatal error!\n";
5156  std::cerr << " Order of rule N is not even.\n";
5157  std::exit ( 1 );
5158  }
5159 
5160  nhalf = n / 2;
5161  xhalf = new double[nhalf];
5162 
5163  hc_compute_weights_from_points ( nhalf, xhalf, w );
5164 
5165  delete [] xhalf;
5166 
5167  return;
5168 }
5169 //**************************************************************************80
5170 
5171 void SandiaRules::hce_compute_weights_np ( int n, int np, double p[], double w[] )
5172 
5173 //**************************************************************************80
5174 //
5175 // Purpose:
5176 //
5177 // HCE_COMPUTE_WEIGHTS_NP: Hermite-Cubic-Equal-Spacing quadrature weights.
5178 //
5179 // Discussion:
5180 //
5181 // For the HCE rule, we assume that an interval has been divided by
5182 // M nodes X into equally spaced subintervals, and that at each
5183 // abscissa both function and derivative information is available.
5184 // The piecewise cubic Hermite interpolant is constructed for this data.
5185 // The quadrature rule uses N = 2 * M abscissas, where each node is
5186 // listed twice, and the weights occur in pairs, with the first multiplying
5187 // the function value and the second the derivative.
5188 //
5189 // Licensing:
5190 //
5191 // This code is distributed under the GNU LGPL license.
5192 //
5193 // Modified:
5194 //
5195 // 07 March 2011
5196 //
5197 // Author:
5198 //
5199 // John Burkardt
5200 //
5201 // Parameters:
5202 //
5203 // Input, int N, the order.
5204 //
5205 // Input, int NP, the number of parameters.
5206 //
5207 // Input, double P[NP], parameters which are not needed by this function.
5208 //
5209 // Output, double W[N], the weights.
5210 //
5211 {
5212  hce_compute_weights ( n, w );
5213 
5214  return;
5215 }
5216 //**************************************************************************80
5217 
5218 void SandiaRules::hermite_compute ( int n, double x[], double w[] )
5219 
5220 //**************************************************************************80
5221 //
5222 // Purpose:
5223 //
5224 // HERMITE_COMPUTE computes a Gauss-Hermite quadrature rule.
5225 //
5226 // Discussion:
5227 //
5228 // The code uses an algorithm by Elhay and Kautsky.
5229 //
5230 // The abscissas are the zeros of the N-th order Hermite polynomial.
5231 //
5232 // The integral:
5233 //
5234 // integral ( -oo < x < +oo ) exp ( - x * x ) * f(x) dx
5235 //
5236 // The quadrature rule:
5237 //
5238 // sum ( 1 <= i <= n ) w(i) * f ( x(i) )
5239 //
5240 // Licensing:
5241 //
5242 // This code is distributed under the GNU LGPL license.
5243 //
5244 // Modified:
5245 //
5246 // 19 April 2011
5247 //
5248 // Author:
5249 //
5250 // Original FORTRAN77 version by Sylvan Elhay, Jaroslav Kautsky.
5251 // C++ version by John Burkardt.
5252 //
5253 // Reference:
5254 //
5255 // Sylvan Elhay, Jaroslav Kautsky,
5256 // Algorithm 655: IQPACK, FORTRAN Subroutines for the Weights of
5257 // Interpolatory Quadrature,
5258 // ACM Transactions on Mathematical Software,
5259 // Volume 13, Number 4, December 1987, pages 399-415.
5260 //
5261 // Parameters:
5262 //
5263 // Input, int N, the number of abscissas.
5264 //
5265 // Output, double X[N], the abscissas.
5266 //
5267 // Output, double W[N], the weights.
5268 //
5269 {
5270  double arg;
5271  double *bj;
5272  int i;
5273  double zemu;
5274 //
5275 // Define the zero-th moment.
5276 //
5277  arg = 0.5;
5278  zemu = r8_gamma ( arg );
5279 //
5280 // Define the Jacobi matrix.
5281 //
5282  bj = new double[n];
5283 
5284  for ( i = 0; i < n; i++ )
5285  {
5286  bj[i] = std::sqrt ( ( double ) ( i + 1 ) / 2.0 );
5287  }
5288 
5289  for ( i = 0; i < n; i++ )
5290  {
5291  x[i] = 0.0;
5292  }
5293 
5294  w[0] = std::sqrt ( zemu );
5295  for ( i = 1; i < n; i++ )
5296  {
5297  w[i] = 0.0;
5298  }
5299 //
5300 // Diagonalize the Jacobi matrix.
5301 //
5302  imtqlx ( n, x, bj, w );
5303 
5304  for ( i = 0; i < n; i++ )
5305  {
5306  w[i] = w[i] * w[i];
5307  }
5308 
5309  delete [] bj;
5310 
5311  return;
5312 }
5313 //**************************************************************************80
5314 
5315 void SandiaRules::hermite_compute_np ( int order, int np, double p[], double x[],
5316  double w[] )
5317 
5318 //**************************************************************************80
5319 //
5320 // Purpose:
5321 //
5322 // HERMITE_COMPUTE_NP computes a Hermite quadrature rule.
5323 //
5324 // Discussion:
5325 //
5326 // The abscissas are the zeros of the N-th order Hermite polynomial.
5327 //
5328 // The integral:
5329 //
5330 // Integral ( -oo < X < +oo ) exp ( - X * X ) * F(X) dX
5331 //
5332 // The quadrature rule:
5333 //
5334 // Sum ( 1 <= I <= ORDER ) W(I) * F ( X(I) )
5335 //
5336 // Licensing:
5337 //
5338 // This code is distributed under the GNU LGPL license.
5339 //
5340 // Modified:
5341 //
5342 // 22 June 2009
5343 //
5344 // Author:
5345 //
5346 // Original FORTRAN77 version by Arthur Stroud, Don Secrest.
5347 // C++ version by John Burkardt.
5348 //
5349 // Reference:
5350 //
5351 // Arthur Stroud, Don Secrest,
5352 // Gaussian Quadrature Formulas,
5353 // Prentice Hall, 1966,
5354 // LC: QA299.4G3S7.
5355 //
5356 // Parameters:
5357 //
5358 // Input, int ORDER, the order.
5359 // 1 <= ORDER.
5360 //
5361 // Input, int NP, the number of parameters.
5362 //
5363 // Input, double P[NP], parameters which are not needed by this function.
5364 //
5365 // Output, double X[ORDER], the abscissas.
5366 //
5367 // Output, double W[ORDER], the weights.
5368 //
5369 {
5370  hermite_compute ( order, x, w );
5371 
5372  return;
5373 }
5374 //**************************************************************************80
5375 
5376 void SandiaRules::hermite_compute_points ( int order, double x[] )
5377 
5378 //**************************************************************************80
5379 //
5380 // Purpose:
5381 //
5382 // HERMITE_COMPUTE_POINTS computes Hermite quadrature points.
5383 //
5384 // Licensing:
5385 //
5386 // This code is distributed under the GNU LGPL license.
5387 //
5388 // Modified:
5389 //
5390 // 13 June 2009
5391 //
5392 // Author:
5393 //
5394 // John Burkardt
5395 //
5396 // Parameters:
5397 //
5398 // Input, int ORDER, the order.
5399 //
5400 // Output, double X[ORDER], the abscissas.
5401 //
5402 {
5403  double *w;
5404 
5405  w = new double[order];
5406 
5407  hermite_compute ( order, x, w );
5408 
5409  delete [] w;
5410 
5411  return;
5412 }
5413 //**************************************************************************80
5414 
5415 void SandiaRules::hermite_compute_points_np ( int order, int np, double p[], double x[] )
5416 
5417 //**************************************************************************80
5418 //
5419 // Purpose:
5420 //
5421 // HERMITE_COMPUTE_POINTS_NP computes Hermite quadrature points.
5422 //
5423 // Licensing:
5424 //
5425 // This code is distributed under the GNU LGPL license.
5426 //
5427 // Modified:
5428 //
5429 // 22 June 2009
5430 //
5431 // Author:
5432 //
5433 // John Burkardt
5434 //
5435 // Parameters:
5436 //
5437 // Input, int ORDER, the order.
5438 //
5439 // Input, int NP, the number of parameters.
5440 //
5441 // Input, double P[NP], parameters which are not needed by this function.
5442 //
5443 // Output, double X[ORDER], the abscissas.
5444 //
5445 {
5446  hermite_compute_points ( order, x );
5447 
5448  return;
5449 }
5450 //**************************************************************************80
5451 
5452 void SandiaRules::hermite_compute_weights ( int order, double w[] )
5453 
5454 //**************************************************************************80
5455 //
5456 // Purpose:
5457 //
5458 // HERMITE_COMPUTE_WEIGHTS computes Hermite quadrature weights.
5459 //
5460 // Licensing:
5461 //
5462 // This code is distributed under the GNU LGPL license.
5463 //
5464 // Modified:
5465 //
5466 // 13 June 2009
5467 //
5468 // Author:
5469 //
5470 // John Burkardt
5471 //
5472 // Parameters:
5473 //
5474 // Input, int ORDER, the order.
5475 //
5476 // Output, double W[ORDER], the weights.
5477 //
5478 {
5479  double *x;
5480 
5481  x = new double[order];
5482 
5483  hermite_compute ( order, x, w );
5484 
5485  delete [] x;
5486 
5487  return;
5488 }
5489 //**************************************************************************80
5490 
5491 void SandiaRules::hermite_compute_weights_np ( int order, int np, double p[], double w[] )
5492 
5493 //**************************************************************************80
5494 //
5495 // Purpose:
5496 //
5497 // HERMITE_COMPUTE_WEIGHTS_NP computes Hermite quadrature weights.
5498 //
5499 // Licensing:
5500 //
5501 // This code is distributed under the GNU LGPL license.
5502 //
5503 // Modified:
5504 //
5505 // 22 June 2009
5506 //
5507 // Author:
5508 //
5509 // John Burkardt
5510 //
5511 // Parameters:
5512 //
5513 // Input, int ORDER, the order.
5514 //
5515 // Input, int NP, the number of parameters.
5516 //
5517 // Input, double P[NP], parameters which are not needed by this function.
5518 //
5519 // Output, double W[ORDER], the weights.
5520 //
5521 {
5522  hermite_compute_weights ( order, w );
5523 
5524  return;
5525 }
5526 //**************************************************************************80
5527 
5528 void SandiaRules::hermite_genz_keister_lookup ( int n, double x[], double w[] )
5529 
5530 //**************************************************************************80
5531 //
5532 // Purpose:
5533 //
5534 // HERMITE_GENZ_KEISTER_LOOKUP looks up a Genz-Keister Hermite rule.
5535 //
5536 // Discussion:
5537 //
5538 // The integral:
5539 //
5540 // integral ( -oo <= x <= +oo ) f(x) exp ( - x * x ) dx
5541 //
5542 // The quadrature rule:
5543 //
5544 // sum ( 1 <= i <= n ) w(i) * f ( x(i) )
5545 //
5546 // A nested family of rules for the Hermite integration problem
5547 // was produced by Genz and Keister. The structure of the nested
5548 // family was denoted by 1+2+6+10+16, that is, it comprised rules
5549 // of successive orders O = 1, 3, 9, 19, and 35.
5550 //
5551 // The precisions of these rules are P = 1, 5, 15, 29, and 51.
5552 //
5553 // Licensing:
5554 //
5555 // This code is distributed under the GNU LGPL license.
5556 //
5557 // Modified:
5558 //
5559 // 07 June 2010
5560 //
5561 // Author:
5562 //
5563 // John Burkardt
5564 //
5565 // Reference:
5566 //
5567 // Alan Genz, Bradley Keister,
5568 // Fully symmetric interpolatory rules for multiple integrals
5569 // over infinite regions with Gaussian weight,
5570 // Journal of Computational and Applied Mathematics,
5571 // Volume 71, 1996, pages 299-309
5572 //
5573 // Florian Heiss, Viktor Winschel,
5574 // Likelihood approximation by numerical integration on sparse grids,
5575 // Journal of Econometrics,
5576 // Volume 144, 2008, pages 62-80.
5577 //
5578 // Thomas Patterson,
5579 // The Optimal Addition of Points to Quadrature Formulae,
5580 // Mathematics of Computation,
5581 // Volume 22, Number 104, October 1968, pages 847-856.
5582 //
5583 // Parameters:
5584 //
5585 // Input, int N, the order.
5586 // N must be 1, 3, 9, 19, 35, 37, 41 or 43.
5587 //
5588 // Output, double X[N], the abscissas.
5589 //
5590 // Output, double W[N], the weights.
5591 //
5592 {
5595 
5596  return;
5597 }
5598 //**************************************************************************80
5599 
5601 
5602 //**************************************************************************80
5603 //
5604 // Purpose:
5605 //
5606 // HERMITE_GENZ_KEISTER_LOOKUP_POINTS looks up Genz-Keister Hermite abscissas.
5607 //
5608 // Discussion:
5609 //
5610 // The integral:
5611 //
5612 // integral ( -oo <= x <= +oo ) f(x) exp ( - x * x ) dx
5613 //
5614 // The quadrature rule:
5615 //
5616 // sum ( 1 <= i <= n ) w(i) * f ( x(i) )
5617 //
5618 // A nested family of rules for the Hermite integration problem
5619 // was produced by Genz and Keister. The structure of the nested
5620 // family was denoted by 1+2+6+10+?, that is, it comprised rules
5621 // of successive orders O = 1, 3, 9, 19, and a final rule of order
5622 // 35, 37, 41 or 43.
5623 //
5624 // The precisions of these rules are P = 1, 5, 15, 29,
5625 // with the final rule of precision 51, 55, 63 or 67.
5626 //
5627 // Three related families begin the same way, but end with a different final
5628 // rule. As a convenience, this function includes these final rules as well:
5629 //
5630 // Designation Orders Precisions
5631 //
5632 // 1+2+6+10+16, 1,3,9,19,35 1,5,15,29,51
5633 // 1+2+6+10+18 1,3,9,19,37 1,5,15,29,55
5634 // 1+2+6+10+22 1,3,9,19,41 1,5,15,29,63
5635 // 1+2+6+10+24 1,3,9,19,43 1,5,15,29,67
5636 //
5637 // Some of the data in this function was kindly supplied directly by
5638 // Alan Genz on 24 April 2011.
5639 //
5640 // Licensing:
5641 //
5642 // This code is distributed under the GNU LGPL license.
5643 //
5644 // Modified:
5645 //
5646 // 04 October 2011
5647 //
5648 // Author:
5649 //
5650 // John Burkardt
5651 //
5652 // Reference:
5653 //
5654 // Alan Genz, Bradley Keister,
5655 // Fully symmetric interpolatory rules for multiple integrals
5656 // over infinite regions with Gaussian weight,
5657 // Journal of Computational and Applied Mathematics,
5658 // Volume 71, 1996, pages 299-309
5659 //
5660 // Florian Heiss, Viktor Winschel,
5661 // Likelihood approximation by numerical integration on sparse grids,
5662 // Journal of Econometrics,
5663 // Volume 144, 2008, pages 62-80.
5664 //
5665 // Thomas Patterson,
5666 // The Optimal Addition of Points to Quadrature Formulae,
5667 // Mathematics of Computation,
5668 // Volume 22, Number 104, October 1968, pages 847-856.
5669 //
5670 // Parameters:
5671 //
5672 // Input, int N, the order.
5673 // N must be 1, 3, 9, 19, 35, 37, 41, or 43.
5674 //
5675 // Output, double X[N], the abscissas.
5676 //
5677 {
5678  if ( n == 1 )
5679  {
5680  x[ 0] = 0.0000000000000000E+00;
5681  }
5682  else if ( n == 3 )
5683  {
5684  x[ 0] = -1.2247448713915889E+00;
5685  x[ 1] = 0.0000000000000000E+00;
5686  x[ 2] = 1.2247448713915889E+00;
5687  }
5688  else if ( n == 9 )
5689  {
5690  x[ 0] = -2.9592107790638380E+00;
5691  x[ 1] = -2.0232301911005157E+00;
5692  x[ 2] = -1.2247448713915889E+00;
5693  x[ 3] = -5.2403354748695763E-01;
5694  x[ 4] = 0.0000000000000000E+00;
5695  x[ 5] = 5.2403354748695763E-01;
5696  x[ 6] = 1.2247448713915889E+00;
5697  x[ 7] = 2.0232301911005157E+00;
5698  x[ 8] = 2.9592107790638380E+00;
5699  }
5700  else if ( n == 19 )
5701  {
5702  x[ 0] = -4.4995993983103881E+00;
5703  x[ 1] = -3.6677742159463378E+00;
5704  x[ 2] = -2.9592107790638380E+00;
5705  x[ 3] = -2.2665132620567876E+00;
5706  x[ 4] = -2.0232301911005157E+00;
5707  x[ 5] = -1.8357079751751868E+00;
5708  x[ 6] = -1.2247448713915889E+00;
5709  x[ 7] = -8.7004089535290285E-01;
5710  x[ 8] = -5.2403354748695763E-01;
5711  x[ 9] = 0.0000000000000000E+00;
5712  x[10] = 5.2403354748695763E-01;
5713  x[11] = 8.7004089535290285E-01;
5714  x[12] = 1.2247448713915889E+00;
5715  x[13] = 1.8357079751751868E+00;
5716  x[14] = 2.0232301911005157E+00;
5717  x[15] = 2.2665132620567876E+00;
5718  x[16] = 2.9592107790638380E+00;
5719  x[17] = 3.6677742159463378E+00;
5720  x[18] = 4.4995993983103881E+00;
5721  }
5722  else if ( n == 35 )
5723  {
5724  x[ 0] = -6.3759392709822356E+00;
5725  x[ 1] = -5.6432578578857449E+00;
5726  x[ 2] = -5.0360899444730940E+00;
5727  x[ 3] = -4.4995993983103881E+00;
5728  x[ 4] = -4.0292201405043713E+00;
5729  x[ 5] = -3.6677742159463378E+00;
5730  x[ 6] = -3.3491639537131945E+00;
5731  x[ 7] = -2.9592107790638380E+00;
5732  x[ 8] = -2.5705583765842968E+00;
5733  x[ 9] = -2.2665132620567876E+00;
5734  x[10] = -2.0232301911005157E+00;
5735  x[11] = -1.8357079751751868E+00;
5736  x[12] = -1.5794121348467671E+00;
5737  x[13] = -1.2247448713915889E+00;
5738  x[14] = -8.7004089535290285E-01;
5739  x[15] = -5.2403354748695763E-01;
5740  x[16] = -1.7606414208200893E-01;
5741  x[17] = 0.0000000000000000E+00;
5742  x[18] = 1.7606414208200893E-01;
5743  x[19] = 5.2403354748695763E-01;
5744  x[20] = 8.7004089535290285E-01;
5745  x[21] = 1.2247448713915889E+00;
5746  x[22] = 1.5794121348467671E+00;
5747  x[23] = 1.8357079751751868E+00;
5748  x[24] = 2.0232301911005157E+00;
5749  x[25] = 2.2665132620567876E+00;
5750  x[26] = 2.5705583765842968E+00;
5751  x[27] = 2.9592107790638380E+00;
5752  x[28] = 3.3491639537131945E+00;
5753  x[29] = 3.6677742159463378E+00;
5754  x[30] = 4.0292201405043713E+00;
5755  x[31] = 4.4995993983103881E+00;
5756  x[32] = 5.0360899444730940E+00;
5757  x[33] = 5.6432578578857449E+00;
5758  x[34] = 6.3759392709822356E+00;
5759  }
5760  else if ( n == 37 )
5761  {
5762  x[ 0] = -6.853200069757519;
5763  x[ 1] = -6.124527854622158;
5764  x[ 2] = -5.521865209868350;
5765  x[ 3] = -4.986551454150765;
5766  x[ 4] = -4.499599398310388;
5767  x[ 5] = -4.057956316089741;
5768  x[ 6] = -3.667774215946338;
5769  x[ 7] = -3.315584617593290;
5770  x[ 8] = -2.959210779063838;
5771  x[ 9] = -2.597288631188366;
5772  x[10] = -2.266513262056788;
5773  x[11] = -2.023230191100516;
5774  x[12] = -1.835707975175187;
5775  x[13] = -1.561553427651873;
5776  x[14] = -1.224744871391589;
5777  x[15] = -0.870040895352903;
5778  x[16] = -0.524033547486958;
5779  x[17] = -0.214618180588171;
5780  x[18] = 0.000000000000000;
5781  x[19] = 0.214618180588171;
5782  x[20] = 0.524033547486958;
5783  x[21] = 0.870040895352903;
5784  x[22] = 1.224744871391589;
5785  x[23] = 1.561553427651873;
5786  x[24] = 1.835707975175187;
5787  x[25] = 2.023230191100516;
5788  x[26] = 2.266513262056788;
5789  x[27] = 2.597288631188366;
5790  x[28] = 2.959210779063838;
5791  x[29] = 3.315584617593290;
5792  x[30] = 3.667774215946338;
5793  x[31] = 4.057956316089741;
5794  x[32] = 4.499599398310388;
5795  x[33] = 4.986551454150765;
5796  x[34] = 5.521865209868350;
5797  x[35] = 6.124527854622158;
5798  x[36] = 6.853200069757519;
5799  }
5800  else if ( n == 41 )
5801  {
5802  x[ 0] = -7.251792998192644;
5803  x[ 1] = -6.547083258397540;
5804  x[ 2] = -5.961461043404500;
5805  x[ 3] = -5.437443360177798;
5806  x[ 4] = -4.953574342912980;
5807  x[ 5] = -4.4995993983103881;
5808  x[ 6] = -4.070919267883068;
5809  x[ 7] = -3.6677742159463378;
5810  x[ 8] = -3.296114596212218;
5811  x[ 9] = -2.9592107790638380;
5812  x[10] = -2.630415236459871;
5813  x[11] = -2.2665132620567876;
5814  x[12] = -2.043834754429505;
5815  x[13] = -2.0232301911005157;
5816  x[14] = -1.8357079751751868;
5817  x[15] = -1.585873011819188;
5818  x[16] = -1.2247448713915889;
5819  x[17] = -0.87004089535290285;
5820  x[18] = -0.52403354748695763;
5821  x[19] = -0.195324784415805;
5822  x[20] = 0.0000000000000000;
5823  x[21] = 0.195324784415805;
5824  x[22] = 0.52403354748695763;
5825  x[23] = 0.87004089535290285;
5826  x[24] = 1.2247448713915889;
5827  x[25] = 1.585873011819188;
5828  x[26] = 1.8357079751751868;
5829  x[27] = 2.0232301911005157;
5830  x[28] = 2.043834754429505;
5831  x[29] = 2.2665132620567876;
5832  x[30] = 2.630415236459871;
5833  x[31] = 2.9592107790638380;
5834  x[32] = 3.296114596212218;
5835  x[33] = 3.6677742159463378;
5836  x[34] = 4.070919267883068;
5837  x[35] = 4.4995993983103881;
5838  x[36] = 4.953574342912980;
5839  x[37] = 5.437443360177798;
5840  x[38] = 5.961461043404500;
5841  x[39] = 6.547083258397540;
5842  x[40] = 7.251792998192644;
5843  }
5844  else if ( n == 43 )
5845  {
5846  x[ 0] = -10.167574994881873;
5847  x[ 1] = -7.231746029072501;
5848  x[ 2] = -6.535398426382995;
5849  x[ 3] = -5.954781975039809;
5850  x[ 4] = -5.434053000365068;
5851  x[ 5] = -4.952329763008589;
5852  x[ 6] = -4.4995993983103881;
5853  x[ 7] = -4.071335874253583;
5854  x[ 8] = -3.6677742159463378;
5855  x[ 9] = -3.295265921534226;
5856  x[10] = -2.9592107790638380;
5857  x[11] = -2.633356763661946;
5858  x[12] = -2.2665132620567876;
5859  x[13] = -2.089340389294661;
5860  x[14] = -2.0232301911005157;
5861  x[15] = -1.8357079751751868;
5862  x[16] = -1.583643465293944;
5863  x[17] = -1.2247448713915889;
5864  x[18] = -0.87004089535290285;
5865  x[19] = -0.52403354748695763;
5866  x[20] = -0.196029453662011;
5867  x[21] = 0.0000000000000000;
5868  x[22] = 0.196029453662011;
5869  x[23] = 0.52403354748695763;
5870  x[24] = 0.87004089535290285;
5871  x[25] = 1.2247448713915889;
5872  x[26] = 1.583643465293944;
5873  x[27] = 1.8357079751751868;
5874  x[28] = 2.0232301911005157;
5875  x[29] = 2.089340389294661;
5876  x[30] = 2.2665132620567876;
5877  x[31] = 2.633356763661946;
5878  x[32] = 2.9592107790638380;
5879  x[33] = 3.295265921534226;
5880  x[34] = 3.6677742159463378;
5881  x[35] = 4.071335874253583;
5882  x[36] = 4.4995993983103881;
5883  x[37] = 4.952329763008589;
5884  x[38] = 5.434053000365068;
5885  x[39] = 5.954781975039809;
5886  x[40] = 6.535398426382995;
5887  x[41] = 7.231746029072501;
5888  x[42] = 10.167574994881873;
5889  }
5890  else
5891  {
5892  std::cerr << "\n";
5893  std::cerr << "HERMITE_GENZ_KEISTER_LOOKUP_POINTS - Fatal error!\n";
5894  std::cerr << " Illegal input value of N.\n";
5895  std::cerr << " N must be 1, 3, 9, 19, 35, 37, 41 or 43.\n";
5896  std::exit ( 1 );
5897  }
5898  return;
5899 }
5900 //**************************************************************************80
5901 
5903  double x[] )
5904 
5905 //**************************************************************************80
5906 //
5907 // Purpose:
5908 //
5909 // HERMITE_GENZ_KEISTER_LOOKUP_POINTS_NP looks up Genz-Keister Hermite abscissas.
5910 //
5911 // Discussion:
5912 //
5913 // The integral:
5914 //
5915 // integral ( -oo <= x <= +oo ) f(x) exp ( - x * x ) dx
5916 //
5917 // The quadrature rule:
5918 //
5919 // sum ( 1 <= i <= n ) w(i) * f ( x(i) )
5920 //
5921 // A nested family of rules for the Hermite integration problem
5922 // was produced by Genz and Keister. The structure of the nested
5923 // family was denoted by 1+2+6+10+?, that is, it comprised rules
5924 // of successive orders O = 1, 3, 9, 19, and a final rule of order
5925 // 35, 37, 41 or 43.
5926 //
5927 // The precisions of these rules are P = 1, 5, 15, 29,
5928 // with the final rule of precision 51, 55, 63 or 67.
5929 //
5930 // Licensing:
5931 //
5932 // This code is distributed under the GNU LGPL license.
5933 //
5934 // Modified:
5935 //
5936 // 04 October 2011
5937 //
5938 // Author:
5939 //
5940 // John Burkardt
5941 //
5942 // Reference:
5943 //
5944 // Alan Genz, Bradley Keister,
5945 // Fully symmetric interpolatory rules for multiple integrals
5946 // over infinite regions with Gaussian weight,
5947 // Journal of Computational and Applied Mathematics,
5948 // Volume 71, 1996, pages 299-309
5949 //
5950 // Florian Heiss, Viktor Winschel,
5951 // Likelihood approximation by numerical integration on sparse grids,
5952 // Journal of Econometrics,
5953 // Volume 144, 2008, pages 62-80.
5954 //
5955 // Thomas Patterson,
5956 // The Optimal Addition of Points to Quadrature Formulae,
5957 // Mathematics of Computation,
5958 // Volume 22, Number 104, October 1968, pages 847-856.
5959 //
5960 // Parameters:
5961 //
5962 // Input, int N, the order.
5963 // N must be 1, 3, 9, 19, 35, 37, 41 or 43.
5964 //
5965 // Input, int NP, the number of parameters.
5966 //
5967 // Input, double P[NP], parameters which are not needed by this function.
5968 //
5969 // Output, double X[N], the abscissas.
5970 //
5971 {
5973 
5974  return;
5975 }
5976 //**************************************************************************80
5977 
5979 
5980 //**************************************************************************80
5981 //
5982 // Purpose:
5983 //
5984 // HERMITE_GENZ_KEISTER_LOOKUP_WEIGHTS looks up Genz-Keister Hermite weights.
5985 //
5986 // Discussion:
5987 //
5988 // The integral:
5989 //
5990 // integral ( -oo <= x <= +oo ) f(x) exp ( - x * x ) dx
5991 //
5992 // The quadrature rule:
5993 //
5994 // sum ( 1 <= i <= n ) w(i) * f ( x(i) )
5995 //
5996 // A nested family of rules for the Hermite integration problem
5997 // was produced by Genz and Keister. The structure of the nested
5998 // family was denoted by 1+2+6+10+?, that is, it comprised rules
5999 // of successive orders O = 1, 3, 9, 19, and a final rule of order
6000 // 35, 37, 41 or 43.
6001 //
6002 // The precisions of these rules are P = 1, 5, 15, 29,
6003 // with the final rule of precision 51, 55, 63 or 67.
6004 //
6005 // Three related families begin the same way, but end with a different final
6006 // rule. As a convenience, this function includes these final rules as well:
6007 //
6008 // Designation Orders Precisions
6009 //
6010 // 1+2+6+10+16, 1,3,9,19,35 1,5,15,29,51
6011 // 1+2+6+10+18 1,3,9,19,37 1,5,15,29,55
6012 // 1+2+6+10+22 1,3,9,19,41 1,5,15,29,63
6013 // 1+2+6+10+24 1,3,9,19,43 1,5,15,29,67
6014 //
6015 // Some of the data in this function was kindly supplied directly by
6016 // Alan Genz on 24 April 2011.
6017 //
6018 // Licensing:
6019 //
6020 // This code is distributed under the GNU LGPL license.
6021 //
6022 // Modified:
6023 //
6024 // 04 October 2011
6025 //
6026 // Author:
6027 //
6028 // John Burkardt
6029 //
6030 // Reference:
6031 //
6032 // Alan Genz, Bradley Keister,
6033 // Fully symmetric interpolatory rules for multiple integrals
6034 // over infinite regions with Gaussian weight,
6035 // Journal of Computational and Applied Mathematics,
6036 // Volume 71, 1996, pages 299-309
6037 //
6038 // Florian Heiss, Viktor Winschel,
6039 // Likelihood approximation by numerical integration on sparse grids,
6040 // Journal of Econometrics,
6041 // Volume 144, 2008, pages 62-80.
6042 //
6043 // Thomas Patterson,
6044 // The Optimal Addition of Points to Quadrature Formulae,
6045 // Mathematics of Computation,
6046 // Volume 22, Number 104, October 1968, pages 847-856.
6047 //
6048 // Parameters:
6049 //
6050 // Input, int N, the order.
6051 // N must be 1, 3, 9, 19, 35, 37, 41, or 43.
6052 //
6053 // Output, double W[N], the weights.
6054 //
6055 {
6056  //static double sqrtpi = 1.7724538509055159;
6057 
6058  if ( n == 1 )
6059  {
6060  w[ 0] = 1.7724538509055159E+00;
6061  }
6062  else if ( n == 3 )
6063  {
6064  w[ 0] = 2.9540897515091930E-01;
6065  w[ 1] = 1.1816359006036772E+00;
6066  w[ 2] = 2.9540897515091930E-01;
6067  }
6068  else if ( n == 9 )
6069  {
6070  w[ 0] = 1.6708826306882348E-04;
6071  w[ 1] = 1.4173117873979098E-02;
6072  w[ 2] = 1.6811892894767771E-01;
6073  w[ 3] = 4.7869428549114124E-01;
6074  w[ 4] = 4.5014700975378197E-01;
6075  w[ 5] = 4.7869428549114124E-01;
6076  w[ 6] = 1.6811892894767771E-01;
6077  w[ 7] = 1.4173117873979098E-02;
6078  w[ 8] = 1.6708826306882348E-04;
6079  }
6080  else if ( n == 19 )
6081  {
6082  w[ 0] = 1.5295717705322357E-09;
6083  w[ 1] = 1.0802767206624762E-06;
6084  w[ 2] = 1.0656589772852267E-04;
6085  w[ 3] = 5.1133174390883855E-03;
6086  w[ 4] = -1.1232438489069229E-02;
6087  w[ 5] = 3.2055243099445879E-02;
6088  w[ 6] = 1.1360729895748269E-01;
6089  w[ 7] = 1.0838861955003017E-01;
6090  w[ 8] = 3.6924643368920851E-01;
6091  w[ 9] = 5.3788160700510168E-01;
6092  w[10] = 3.6924643368920851E-01;
6093  w[11] = 1.0838861955003017E-01;
6094  w[12] = 1.1360729895748269E-01;
6095  w[13] = 3.2055243099445879E-02;
6096  w[14] = -1.1232438489069229E-02;
6097  w[15] = 5.1133174390883855E-03;
6098  w[16] = 1.0656589772852267E-04;
6099  w[17] = 1.0802767206624762E-06;
6100  w[18] = 1.5295717705322357E-09;
6101  }
6102  else if ( n == 35 )
6103  {
6104  w[ 0] = 1.8684014894510604E-18;
6105  w[ 1] = 9.6599466278563243E-15;
6106  w[ 2] = 5.4896836948499462E-12;
6107  w[ 3] = 8.1553721816916897E-10;
6108  w[ 4] = 3.7920222392319532E-08;
6109  w[ 5] = 4.3737818040926989E-07;
6110  w[ 6] = 4.8462799737020461E-06;
6111  w[ 7] = 6.3328620805617891E-05;
6112  w[ 8] = 4.8785399304443770E-04;
6113  w[ 9] = 1.4515580425155904E-03;
6114  w[10] = 4.0967527720344047E-03;
6115  w[11] = 5.5928828911469180E-03;
6116  w[12] = 2.7780508908535097E-02;
6117  w[13] = 8.0245518147390893E-02;
6118  w[14] = 1.6371221555735804E-01;
6119  w[15] = 2.6244871488784277E-01;
6120  w[16] = 3.3988595585585218E-01;
6121  w[17] = 9.1262675363737921E-04;
6122  w[18] = 3.3988595585585218E-01;
6123  w[19] = 2.6244871488784277E-01;
6124  w[20] = 1.6371221555735804E-01;
6125  w[21] = 8.0245518147390893E-02;
6126  w[22] = 2.7780508908535097E-02;
6127  w[23] = 5.5928828911469180E-03;
6128  w[24] = 4.0967527720344047E-03;
6129  w[25] = 1.4515580425155904E-03;
6130  w[26] = 4.8785399304443770E-04;
6131  w[27] = 6.3328620805617891E-05;
6132  w[28] = 4.8462799737020461E-06;
6133  w[29] = 4.3737818040926989E-07;
6134  w[30] = 3.7920222392319532E-08;
6135  w[31] = 8.1553721816916897E-10;
6136  w[32] = 5.4896836948499462E-12;
6137  w[33] = 9.6599466278563243E-15;
6138  w[34] = 1.8684014894510604E-18;
6139  }
6140  else if ( n == 37 )
6141  {
6142  w[ 0] = 0.337304188079177058E-20;
6143  w[ 1] = 0.332834739632930463E-16;
6144  w[ 2] = 0.323016866782871498E-13;
6145  w[ 3] = 0.809333688669950037E-11;
6146  w[ 4] = 0.748907559239519284E-09;
6147  w[ 5] = 0.294146671497083432E-07;
6148  w[ 6] = 0.524482423744884136E-06;
6149  w[ 7] = 0.586639457073896277E-05;
6150  w[ 8] = 0.571885531470621903E-04;
6151  w[ 9] = 0.41642095727577091E-03;
6152  w[10] = 0.174733389581099482E-02;
6153  w[11] = 0.313373786000304381E-02;
6154  w[12] = 0.768092665770660459E-02;
6155  w[13] = 0.274962713372148476E-01;
6156  w[14] = 0.783630990508037449E-01;
6157  w[15] = 0.16611584261479281E+00;
6158  w[16] = 0.253636910481387185E+00;
6159  w[17] = 0.261712932511430884E+00;
6160  w[18] = 0.171719680968980257E+00;
6161  w[19] = 0.261712932511430884E+00;
6162  w[20] = 0.253636910481387185E+00;
6163  w[21] = 0.16611584261479281E+00;
6164  w[22] = 0.783630990508037449E-01;
6165  w[23] = 0.274962713372148476E-01;
6166  w[24] = 0.768092665770660459E-02;
6167  w[25] = 0.313373786000304381E-02;
6168  w[26] = 0.174733389581099482E-02;
6169  w[27] = 0.41642095727577091E-03;
6170  w[28] = 0.571885531470621903E-04;
6171  w[29] = 0.586639457073896277E-05;
6172  w[30] = 0.524482423744884136E-06;
6173  w[31] = 0.294146671497083432E-07;
6174  w[32] = 0.748907559239519284E-09;
6175  w[33] = 0.809333688669950037E-11;
6176  w[34] = 0.323016866782871498E-13;
6177  w[35] = 0.332834739632930463E-16;
6178  w[36] = 0.337304188079177058E-20;
6179  }
6180  else if ( n == 41 )
6181  {
6182  w[ 0] = 0.117725656974405367E-22;
6183  w[ 1] = 0.152506745534300636E-18;
6184  w[ 2] = 0.202183949965101288E-15;
6185  w[ 3] = 0.724614869051195508E-13;
6186  w[ 4] = 0.103121966469463034E-10;
6187  w[ 5] = 0.710371395169350952E-09;
6188  w[ 6] = 0.264376044449260516E-07;
6189  w[ 7] = 0.558982787078644997E-06;
6190  w[ 8] = 0.675628907134744976E-05;
6191  w[ 9] = 0.512198007019776873E-04;
6192  w[10] = 0.335013114947200879E-03;
6193  w[11] = 0.249379691096933139E-02;
6194  w[12] = - 0.25616995850607458E-01;
6195  w[13] = 0.317007878644325588E-01;
6196  w[14] = 0.125041498584003435E-02;
6197  w[15] = 0.293244560924894295E-01;
6198  w[16] = 0.799536390803302298E-01;
6199  w[17] = 0.164543666806555251E+00;
6200  w[18] = 0.258718519718241095E+00;
6201  w[19] = 0.293588795735908566E+00;
6202  w[20] = 0.997525375254611951E-01;
6203  w[21] = 0.293588795735908566E+00;
6204  w[22] = 0.258718519718241095E+00;
6205  w[23] = 0.164543666806555251E+00;
6206  w[24] = 0.799536390803302298E-01;
6207  w[25] = 0.293244560924894295E-01;
6208  w[26] = 0.125041498584003435E-02;
6209  w[27] = 0.317007878644325588E-01;
6210  w[28] = - 0.25616995850607458E-01;
6211  w[29] = 0.249379691096933139E-02;
6212  w[30] = 0.335013114947200879E-03;
6213  w[31] = 0.512198007019776873E-04;
6214  w[32] = 0.675628907134744976E-05;
6215  w[33] = 0.558982787078644997E-06;
6216  w[34] = 0.264376044449260516E-07;
6217  w[35] = 0.710371395169350952E-09;
6218  w[36] = 0.103121966469463034E-10;
6219  w[37] = 0.724614869051195508E-13;
6220  w[38] = 0.202183949965101288E-15;
6221  w[39] = 0.152506745534300636E-18;
6222  w[40] = 0.117725656974405367E-22;
6223  }
6224  else if ( n == 43 )
6225  {
6226  w[ 0] = 0.968100020641528185E-37;
6227  w[ 1] = 0.15516931262860431E-22;
6228  w[ 2] = 0.175937309107750992E-18;
6229  w[ 3] = 0.217337608710893738E-15;
6230  w[ 4] = 0.747837010380540069E-13;
6231  w[ 5] = 0.104028132097205732E-10;
6232  w[ 6] = 0.70903573389336778E-09;
6233  w[ 7] = 0.263481722999966618E-07;
6234  w[ 8] = 0.560127964848432175E-06;
6235  w[ 9] = 0.680410934802210232E-05;
6236  w[10] = 0.508343873102544037E-04;
6237  w[11] = 0.32753080006610181E-03;
6238  w[12] = 0.267479828788552937E-02;
6239  w[13] = - 0.687704270963253854E-02;
6240  w[14] = 0.119383201790913588E-01;
6241  w[15] = 0.248083722871002796E-02;
6242  w[16] = 0.29000335749726387E-01;
6243  w[17] = 0.798689557875757008E-01;
6244  w[18] = 0.164609842422580606E+00;
6245  w[19] = 0.258535954731607738E+00;
6246  w[20] = 0.292243810406117141E+00;
6247  w[21] = 0.102730713753441829E+00;
6248  w[22] = 0.292243810406117141E+00;
6249  w[23] = 0.258535954731607738E+00;
6250  w[24] = 0.164609842422580606E+00;
6251  w[25] = 0.798689557875757008E-01;
6252  w[26] = 0.29000335749726387E-01;
6253  w[27] = 0.248083722871002796E-02;
6254  w[28] = 0.119383201790913588E-01;
6255  w[29] = - 0.687704270963253854E-02;
6256  w[30] = 0.267479828788552937E-02;
6257  w[31] = 0.32753080006610181E-03;
6258  w[32] = 0.508343873102544037E-04;
6259  w[33] = 0.680410934802210232E-05;
6260  w[34] = 0.560127964848432175E-06;
6261  w[35] = 0.263481722999966618E-07;
6262  w[36] = 0.70903573389336778E-09;
6263  w[37] = 0.104028132097205732E-10;
6264  w[38] = 0.747837010380540069E-13;
6265  w[39] = 0.217337608710893738E-15;
6266  w[40] = 0.175937309107750992E-18;
6267  w[41] = 0.15516931262860431E-22;
6268  w[42] = 0.968100020641528185E-37;
6269  }
6270  else
6271  {
6272  std::cerr << "\n";
6273  std::cerr << "HERMITE_GENZ_KEISTER_LOOKUP_WEIGHTS - Fatal error!\n";
6274  std::cerr << " Illegal input value of N.\n";
6275  std::cerr << " N must be 1, 3, 9, 19, 35, 37, 41 or 43.\n";
6276  std::exit ( 1 );
6277  }
6278  return;
6279 }
6280 //**************************************************************************80
6281 
6283  double w[] )
6284 
6285 //**************************************************************************80
6286 //
6287 // Purpose:
6288 //
6289 // HERMITE_GENZ_KEISTER_LOOKUP_WEIGHTS_NP looks up Genz-Keister Hermite weights.
6290 //
6291 // Discussion:
6292 //
6293 // The integral:
6294 //
6295 // integral ( -oo <= x <= +oo ) f(x) exp ( - x * x ) dx
6296 //
6297 // The quadrature rule:
6298 //
6299 // sum ( 1 <= i <= n ) w(i) * f ( x(i) )
6300 //
6301 // A nested family of rules for the Hermite integration problem
6302 // was produced by Genz and Keister. The structure of the nested
6303 // family was denoted by 1+2+6+10+?, that is, it comprised rules
6304 // of successive orders O = 1, 3, 9, 19, and a final rule of order
6305 // 35, 37, 41 or 43.
6306 //
6307 // The precisions of these rules are P = 1, 5, 15, 29,
6308 // with the final rule of precision 51, 55, 63 or 67.
6309 //
6310 // Licensing:
6311 //
6312 // This code is distributed under the GNU LGPL license.
6313 //
6314 // Modified:
6315 //
6316 // 04 October 2011
6317 //
6318 // Author:
6319 //
6320 // John Burkardt
6321 //
6322 // Reference:
6323 //
6324 // Alan Genz, Bradley Keister,
6325 // Fully symmetric interpolatory rules for multiple integrals
6326 // over infinite regions with Gaussian weight,
6327 // Journal of Computational and Applied Mathematics,
6328 // Volume 71, 1996, pages 299-309
6329 //
6330 // Florian Heiss, Viktor Winschel,
6331 // Likelihood approximation by numerical integration on sparse grids,
6332 // Journal of Econometrics,
6333 // Volume 144, 2008, pages 62-80.
6334 //
6335 // Thomas Patterson,
6336 // The Optimal Addition of Points to Quadrature Formulae,
6337 // Mathematics of Computation,
6338 // Volume 22, Number 104, October 1968, pages 847-856.
6339 //
6340 // Parameters:
6341 //
6342 // Input, int N, the order.
6343 // N must be 1, 3, 9, 19, 35, 37, 41 or 43.
6344 //
6345 // Input, int NP, the number of parameters.
6346 //
6347 // Input, double P[NP], parameters which are not needed by this function.
6348 //
6349 // Output, double W[N], the weights.
6350 //
6351 {
6353 
6354  return;
6355 }
6356 //**************************************************************************80
6357 
6359 
6360 //**************************************************************************80
6361 //
6362 // Purpose:
6363 //
6364 // HERMITE_GK18_LOOKUP_POINTS: abscissas of a Hermite Genz-Keister 18 rule.
6365 //
6366 // Discussion:
6367 //
6368 // The integral:
6369 //
6370 // integral ( -oo <= x <= +oo ) f(x) exp ( - x * x ) dx
6371 //
6372 // The quadrature rule:
6373 //
6374 // sum ( 1 <= i <= n ) w(i) * f ( x(i) )
6375 //
6376 // A nested family of rules for the Hermite integration problem
6377 // was produced by Genz and Keister. The structure of the nested
6378 // family was denoted by 1+2+6+10+18, that is, it comprised rules
6379 // of successive orders O = 1, 3, 9, 19, and 37.
6380 //
6381 // The precisions of these rules are P = 1, 5, 15, 29, and 55.
6382 //
6383 // Some of the data in this function was kindly supplied directly by
6384 // Alan Genz on 24 April 2011.
6385 //
6386 // Licensing:
6387 //
6388 // This code is distributed under the GNU LGPL license.
6389 //
6390 // Modified:
6391 //
6392 // 30 April 2011
6393 //
6394 // Author:
6395 //
6396 // John Burkardt
6397 //
6398 // Reference:
6399 //
6400 // Alan Genz, Bradley Keister,
6401 // Fully symmetric interpolatory rules for multiple integrals
6402 // over infinite regions with Gaussian weight,
6403 // Journal of Computational and Applied Mathematics,
6404 // Volume 71, 1996, pages 299-309
6405 //
6406 // Florian Heiss, Viktor Winschel,
6407 // Likelihood approximation by numerical integration on sparse grids,
6408 // Journal of Econometrics,
6409 // Volume 144, 2008, pages 62-80.
6410 //
6411 // Thomas Patterson,
6412 // The Optimal Addition of Points to Quadrature Formulae,
6413 // Mathematics of Computation,
6414 // Volume 22, Number 104, October 1968, pages 847-856.
6415 //
6416 // Parameters:
6417 //
6418 // Input, int N, the order.
6419 // N must be 1, 3, 9, 19, or 37.
6420 //
6421 // Output, double X[N], the abscissas.
6422 //
6423 {
6424  if ( n == 1 )
6425  {
6426  x[ 0] = 0.0000000000000000E+00;
6427  }
6428  else if ( n == 3 )
6429  {
6430  x[ 0] = -1.2247448713915889E+00;
6431  x[ 1] = 0.0000000000000000E+00;
6432  x[ 2] = 1.2247448713915889E+00;
6433  }
6434  else if ( n == 9 )
6435  {
6436  x[ 0] = -2.9592107790638380E+00;
6437  x[ 1] = -2.0232301911005157E+00;
6438  x[ 2] = -1.2247448713915889E+00;
6439  x[ 3] = -5.2403354748695763E-01;
6440  x[ 4] = 0.0000000000000000E+00;
6441  x[ 5] = 5.2403354748695763E-01;
6442  x[ 6] = 1.2247448713915889E+00;
6443  x[ 7] = 2.0232301911005157E+00;
6444  x[ 8] = 2.9592107790638380E+00;
6445  }
6446  else if ( n == 19 )
6447  {
6448  x[ 0] = -4.4995993983103881E+00;
6449  x[ 1] = -3.6677742159463378E+00;
6450  x[ 2] = -2.9592107790638380E+00;
6451  x[ 3] = -2.2665132620567876E+00;
6452  x[ 4] = -2.0232301911005157E+00;
6453  x[ 5] = -1.8357079751751868E+00;
6454  x[ 6] = -1.2247448713915889E+00;
6455  x[ 7] = -8.7004089535290285E-01;
6456  x[ 8] = -5.2403354748695763E-01;
6457  x[ 9] = 0.0000000000000000E+00;
6458  x[10] = 5.2403354748695763E-01;
6459  x[11] = 8.7004089535290285E-01;
6460  x[12] = 1.2247448713915889E+00;
6461  x[13] = 1.8357079751751868E+00;
6462  x[14] = 2.0232301911005157E+00;
6463  x[15] = 2.2665132620567876E+00;
6464  x[16] = 2.9592107790638380E+00;
6465  x[17] = 3.6677742159463378E+00;
6466  x[18] = 4.4995993983103881E+00;
6467  }
6468  else if ( n == 35 )
6469  {
6470  x[ 0] = -6.853200069757519;
6471  x[ 1] = -6.124527854622158;
6472  x[ 2] = -5.521865209868350;
6473  x[ 3] = -4.986551454150765;
6474  x[ 4] = -4.499599398310388;
6475  x[ 5] = -4.057956316089741;
6476  x[ 6] = -3.667774215946338;
6477  x[ 7] = -3.315584617593290;
6478  x[ 8] = -2.959210779063838;
6479  x[ 9] = -2.597288631188366;
6480  x[10] = -2.266513262056788;
6481  x[11] = -2.023230191100516;
6482  x[12] = -1.835707975175187;
6483  x[13] = -1.561553427651873;
6484  x[14] = -1.224744871391589;
6485  x[15] = -0.870040895352903;
6486  x[16] = -0.524033547486958;
6487  x[17] = -0.214618180588171;
6488  x[18] = 0.000000000000000;
6489  x[19] = 0.214618180588171;
6490  x[20] = 0.524033547486958;
6491  x[21] = 0.870040895352903;
6492  x[22] = 1.224744871391589;
6493  x[23] = 1.561553427651873;
6494  x[24] = 1.835707975175187;
6495  x[25] = 2.023230191100516;
6496  x[26] = 2.266513262056788;
6497  x[27] = 2.597288631188366;
6498  x[28] = 2.959210779063838;
6499  x[29] = 3.315584617593290;
6500  x[30] = 3.667774215946338;
6501  x[31] = 4.057956316089741;
6502  x[32] = 4.499599398310388;
6503  x[33] = 4.986551454150765;
6504  x[34] = 5.521865209868350;
6505  x[35] = 6.124527854622158;
6506  x[36] = 6.853200069757519;
6507  }
6508  else
6509  {
6510  std::cerr << "\n";
6511  std::cerr << "HERMITE_GK18_LOOKUP_POINTS - Fatal error!\n";
6512  std::cerr << " Illegal input value of N.\n";
6513  std::cerr << " N must be 1, 3, 9, 19, or 37.\n";
6514  std::exit ( 1 );
6515  }
6516  return;
6517 }
6518 //**************************************************************************80
6519 
6521 
6522 //**************************************************************************80
6523 //
6524 // Purpose:
6525 //
6526 // HERMITE_GK22_LOOKUP_POINTS looks up Hermite Genz-Keister 22 points.
6527 //
6528 // Discussion:
6529 //
6530 // The integral:
6531 //
6532 // integral ( -oo <= x <= +oo ) f(x) exp ( - x * x ) dx
6533 //
6534 // The quadrature rule:
6535 //
6536 // sum ( 1 <= i <= n ) w(i) * f ( x(i) )
6537 //
6538 // A nested family of rules for the Hermite integration problem
6539 // was produced by Genz and Keister. The structure of the nested
6540 // family was denoted by 1+2+6+10+16, that is, it comprised rules
6541 // of successive orders O = 1, 3, 9, 19, and 41.
6542 //
6543 // The precisions of these rules are P = 1, 5, 15, 29, and 63.
6544 //
6545 // Some of the data in this function was kindly supplied directly by
6546 // Alan Genz on 24 April 2011.
6547 //
6548 // Licensing:
6549 //
6550 // This code is distributed under the GNU LGPL license.
6551 //
6552 // Modified:
6553 //
6554 // 26 April 2011
6555 //
6556 // Author:
6557 //
6558 // John Burkardt
6559 //
6560 // Reference:
6561 //
6562 // Alan Genz, Bradley Keister,
6563 // Fully symmetric interpolatory rules for multiple integrals
6564 // over infinite regions with Gaussian weight,
6565 // Journal of Computational and Applied Mathematics,
6566 // Volume 71, 1996, pages 299-309
6567 //
6568 // Thomas Patterson,
6569 // The Optimal Addition of Points to Quadrature Formulae,
6570 // Mathematics of Computation,
6571 // Volume 22, Number 104, October 1968, pages 847-856.
6572 //
6573 // Parameters:
6574 //
6575 // Input, int N, the order.
6576 // N must be 1, 3, 9, 19, or 41.
6577 //
6578 // Output, double X[N], the abscissas.
6579 //
6580 {
6581  if ( n == 1 )
6582  {
6583  x[ 0] = 0.0000000000000000E+00;
6584  }
6585  else if ( n == 3 )
6586  {
6587  x[ 0] = -1.2247448713915889E+00;
6588  x[ 1] = 0.0000000000000000E+00;
6589  x[ 2] = 1.2247448713915889E+00;
6590  }
6591  else if ( n == 9 )
6592  {
6593  x[ 0] = -2.9592107790638380E+00;
6594  x[ 1] = -2.0232301911005157E+00;
6595  x[ 2] = -1.2247448713915889E+00;
6596  x[ 3] = -5.2403354748695763E-01;
6597  x[ 4] = 0.0000000000000000E+00;
6598  x[ 5] = 5.2403354748695763E-01;
6599  x[ 6] = 1.2247448713915889E+00;
6600  x[ 7] = 2.0232301911005157E+00;
6601  x[ 8] = 2.9592107790638380E+00;
6602  }
6603  else if ( n == 19 )
6604  {
6605  x[ 0] = -4.4995993983103881E+00;
6606  x[ 1] = -3.6677742159463378E+00;
6607  x[ 2] = -2.9592107790638380E+00;
6608  x[ 3] = -2.2665132620567876E+00;
6609  x[ 4] = -2.0232301911005157E+00;
6610  x[ 5] = -1.8357079751751868E+00;
6611  x[ 6] = -1.2247448713915889E+00;
6612  x[ 7] = -8.7004089535290285E-01;
6613  x[ 8] = -5.2403354748695763E-01;
6614  x[ 9] = 0.0000000000000000E+00;
6615  x[10] = 5.2403354748695763E-01;
6616  x[11] = 8.7004089535290285E-01;
6617  x[12] = 1.2247448713915889E+00;
6618  x[13] = 1.8357079751751868E+00;
6619  x[14] = 2.0232301911005157E+00;
6620  x[15] = 2.2665132620567876E+00;
6621  x[16] = 2.9592107790638380E+00;
6622  x[17] = 3.6677742159463378E+00;
6623  x[18] = 4.4995993983103881E+00;
6624  }
6625  else if ( n == 41 )
6626  {
6627  x[ 0] = -7.251792998192644;
6628  x[ 1] = -6.547083258397540;
6629  x[ 2] = -5.961461043404500;
6630  x[ 3] = -5.437443360177798;
6631  x[ 4] = -4.953574342912980;
6632  x[ 5] = -4.4995993983103881;
6633  x[ 6] = -4.070919267883068;
6634  x[ 7] = -3.6677742159463378;
6635  x[ 8] = -3.296114596212218;
6636  x[ 9] = -2.9592107790638380;
6637  x[10] = -2.630415236459871;
6638  x[11] = -2.2665132620567876;
6639  x[12] = -2.043834754429505;
6640  x[13] = -2.0232301911005157;
6641  x[14] = -1.8357079751751868;
6642  x[15] = -1.585873011819188;
6643  x[16] = -1.2247448713915889;
6644  x[17] = -0.87004089535290285;
6645  x[18] = -0.52403354748695763;
6646  x[19] = -0.195324784415805;
6647  x[20] = 0.0000000000000000;
6648  x[21] = 0.195324784415805;
6649  x[22] = 0.52403354748695763;
6650  x[23] = 0.87004089535290285;
6651  x[24] = 1.2247448713915889;
6652  x[25] = 1.585873011819188;
6653  x[26] = 1.8357079751751868;
6654  x[27] = 2.0232301911005157;
6655  x[28] = 2.043834754429505;
6656  x[29] = 2.2665132620567876;
6657  x[30] = 2.630415236459871;
6658  x[31] = 2.9592107790638380;
6659  x[32] = 3.296114596212218;
6660  x[33] = 3.6677742159463378;
6661  x[34] = 4.070919267883068;
6662  x[35] = 4.4995993983103881;
6663  x[36] = 4.953574342912980;
6664  x[37] = 5.437443360177798;
6665  x[38] = 5.961461043404500;
6666  x[39] = 6.547083258397540;
6667  x[40] = 7.251792998192644;
6668  }
6669  else
6670  {
6671  std::cerr << "\n";
6672  std::cerr << "HERMITE_GK22_LOOKUP_POINTS - Fatal error!\n";
6673  std::cerr << " Illegal input value of N.\n";
6674  std::cerr << " N must be 1, 3, 9, 19, or 41.\n";
6675  std::exit ( 1 );
6676  }
6677  return;
6678 }
6679 //**************************************************************************80
6680 
6682 
6683 //**************************************************************************80
6684 //
6685 // Purpose:
6686 //
6687 // HERMITE_GK24_LOOKUP_POINTS looks up Hermite Genz-Keister 24 points.
6688 //
6689 // Discussion:
6690 //
6691 // The integral:
6692 //
6693 // integral ( -oo <= x <= +oo ) f(x) exp ( - x * x ) dx
6694 //
6695 // The quadrature rule:
6696 //
6697 // sum ( 1 <= i <= n ) w(i) * f ( x(i) )
6698 //
6699 // A nested family of rules for the Hermite integration problem
6700 // was produced by Genz and Keister. The structure of the nested
6701 // family was denoted by 1+2+6+10+16, that is, it comprised rules
6702 // of successive orders O = 1, 3, 9, 19, and 43.
6703 //
6704 // The precisions of these rules are P = 1, 5, 15, 29, and 67.
6705 //
6706 // Some of the data in this function was kindly supplied directly by
6707 // Alan Genz on 24 April 2011.
6708 //
6709 // Licensing:
6710 //
6711 // This code is distributed under the GNU LGPL license.
6712 //
6713 // Modified:
6714 //
6715 // 26 April 2011
6716 //
6717 // Author:
6718 //
6719 // John Burkardt
6720 //
6721 // Reference:
6722 //
6723 // Alan Genz, Bradley Keister,
6724 // Fully symmetric interpolatory rules for multiple integrals
6725 // over infinite regions with Gaussian weight,
6726 // Journal of Computational and Applied Mathematics,
6727 // Volume 71, 1996, pages 299-309
6728 //
6729 // Thomas Patterson,
6730 // The Optimal Addition of Points to Quadrature Formulae,
6731 // Mathematics of Computation,
6732 // Volume 22, Number 104, October 1968, pages 847-856.
6733 //
6734 // Parameters:
6735 //
6736 // Input, int N, the order.
6737 // N must be 1, 3, 9 19, or 43.
6738 //
6739 // Output, double X[N], the abscissas.
6740 //
6741 {
6742  if ( n == 1 )
6743  {
6744  x[ 0] = 0.0000000000000000E+00;
6745  }
6746  else if ( n == 3 )
6747  {
6748  x[ 0] = -1.2247448713915889E+00;
6749  x[ 1] = 0.0000000000000000E+00;
6750  x[ 2] = 1.2247448713915889E+00;
6751  }
6752  else if ( n == 9 )
6753  {
6754  x[ 0] = -2.9592107790638380E+00;
6755  x[ 1] = -2.0232301911005157E+00;
6756  x[ 2] = -1.2247448713915889E+00;
6757  x[ 3] = -5.2403354748695763E-01;
6758  x[ 4] = 0.0000000000000000E+00;
6759  x[ 5] = 5.2403354748695763E-01;
6760  x[ 6] = 1.2247448713915889E+00;
6761  x[ 7] = 2.0232301911005157E+00;
6762  x[ 8] = 2.9592107790638380E+00;
6763  }
6764  else if ( n == 19 )
6765  {
6766  x[ 0] = -4.4995993983103881E+00;
6767  x[ 1] = -3.6677742159463378E+00;
6768  x[ 2] = -2.9592107790638380E+00;
6769  x[ 3] = -2.2665132620567876E+00;
6770  x[ 4] = -2.0232301911005157E+00;
6771  x[ 5] = -1.8357079751751868E+00;
6772  x[ 6] = -1.2247448713915889E+00;
6773  x[ 7] = -8.7004089535290285E-01;
6774  x[ 8] = -5.2403354748695763E-01;
6775  x[ 9] = 0.0000000000000000E+00;
6776  x[10] = 5.2403354748695763E-01;
6777  x[11] = 8.7004089535290285E-01;
6778  x[12] = 1.2247448713915889E+00;
6779  x[13] = 1.8357079751751868E+00;
6780  x[14] = 2.0232301911005157E+00;
6781  x[15] = 2.2665132620567876E+00;
6782  x[16] = 2.9592107790638380E+00;
6783  x[17] = 3.6677742159463378E+00;
6784  x[18] = 4.4995993983103881E+00;
6785  }
6786  else if ( n == 43 )
6787  {
6788  x[ 0] = -10.167574994881873;
6789  x[ 1] = -7.231746029072501;
6790  x[ 2] = -6.535398426382995;
6791  x[ 3] = -5.954781975039809;
6792  x[ 4] = -5.434053000365068;
6793  x[ 5] = -4.952329763008589;
6794  x[ 6] = -4.4995993983103881;
6795  x[ 7] = -4.071335874253583;
6796  x[ 8] = -3.6677742159463378;
6797  x[ 9] = -3.295265921534226;
6798  x[10] = -2.9592107790638380;
6799  x[11] = -2.633356763661946;
6800  x[12] = -2.2665132620567876;
6801  x[13] = -2.089340389294661;
6802  x[14] = -2.0232301911005157;
6803  x[15] = -1.8357079751751868;
6804  x[16] = -1.583643465293944;
6805  x[17] = -1.2247448713915889;
6806  x[18] = -0.87004089535290285;
6807  x[19] = -0.52403354748695763;
6808  x[20] = -0.196029453662011;
6809  x[21] = 0.0000000000000000;
6810  x[22] = 0.196029453662011;
6811  x[23] = 0.52403354748695763;
6812  x[24] = 0.87004089535290285;
6813  x[25] = 1.2247448713915889;
6814  x[26] = 1.583643465293944;
6815  x[27] = 1.8357079751751868;
6816  x[28] = 2.0232301911005157;
6817  x[29] = 2.089340389294661;
6818  x[30] = 2.2665132620567876;
6819  x[31] = 2.633356763661946;
6820  x[32] = 2.9592107790638380;
6821  x[33] = 3.295265921534226;
6822  x[34] = 3.6677742159463378;
6823  x[35] = 4.071335874253583;
6824  x[36] = 4.4995993983103881;
6825  x[37] = 4.952329763008589;
6826  x[38] = 5.434053000365068;
6827  x[39] = 5.954781975039809;
6828  x[40] = 6.535398426382995;
6829  x[41] = 7.231746029072501;
6830  x[42] = 10.167574994881873;
6831  }
6832  else
6833  {
6834  std::cerr << "\n";
6835  std::cerr << "HERMITE_GK24_LOOKUP_POINTS - Fatal error!\n";
6836  std::cerr << " Illegal input value of N.\n";
6837  std::cerr << " N must be 1, 3, 9, 19, or 43.\n";
6838  std::exit ( 1 );
6839  }
6840  return;
6841 }
6842 //**************************************************************************80
6843 
6845 
6846 //**************************************************************************80
6847 //
6848 // Purpose:
6849 //
6850 // HERMITE_INTEGRAL evaluates a monomial Hermite integral.
6851 //
6852 // Discussion:
6853 //
6854 // H(n) = Integral ( -oo < x < +oo ) x^n exp(-x^2) dx
6855 //
6856 // H(n) is 0 for n odd.
6857 //
6858 // H(n) = (n-1)!! * sqrt(pi) / 2^(n/2) for n even.
6859 //
6860 // Licensing:
6861 //
6862 // This code is distributed under the GNU LGPL license.
6863 //
6864 // Modified:
6865 //
6866 // 19 February 2008
6867 //
6868 // Author:
6869 //
6870 // John Burkardt
6871 //
6872 // Parameters:
6873 //
6874 // Input, int N, the order of the integral.
6875 // 0 <= N.
6876 //
6877 // Output, double VALUE, the value of the integral.
6878 //
6879 {
6880  double pi = 3.141592653589793;
6881  double value;
6882 
6883  if ( n < 0 )
6884  {
6885  value = - r8_huge ( );
6886  }
6887  else if ( ( n % 2 ) == 1 )
6888  {
6889  value = 0.0;
6890  }
6891  else
6892  {
6893  value = r8_factorial2 ( n - 1 ) * std::sqrt ( pi )
6894  / std::pow ( 2.0, n / 2 );
6895  }
6896 
6897  return value;
6898 }
6899 //**************************************************************************80
6900 
6901 void SandiaRules::hermite_interpolant ( int n, double x[], double y[], double yp[],
6902  double xd[], double yd[], double xdp[], double ydp[] )
6903 
6904 //**************************************************************************80
6905 //
6906 // Purpose:
6907 //
6908 // HERMITE_INTERPOLANT sets up a divided difference table from Hermite data.
6909 //
6910 // Discussion:
6911 //
6912 // The polynomial represented by the divided difference table can be
6913 // evaluated by calling DIF_VALS.
6914 //
6915 // Licensing:
6916 //
6917 // This code is distributed under the GNU LGPL license.
6918 //
6919 // Modified:
6920 //
6921 // 31 October 2011
6922 //
6923 // Author:
6924 //
6925 // John Burkardt
6926 //
6927 // Reference:
6928 //
6929 // Carl deBoor,
6930 // A Practical Guide to Splines,
6931 // Springer, 2001,
6932 // ISBN: 0387953663,
6933 // LC: QA1.A647.v27.
6934 //
6935 // Parameters:
6936 //
6937 // Input, int N, of items of data
6938 // ( X(I), Y(I), YP(I) ).
6939 //
6940 // Input, double X[N], the abscissas.
6941 // These values must be distinct.
6942 //
6943 // Input, double Y[N], YP[N], the function and derivative values.
6944 //
6945 // Output, double XD[2*N], YD[2*N], the divided difference table
6946 // for the interpolant value.
6947 //
6948 // Output, double XDP[2*N-1], YDP[2*N-1], the divided difference
6949 // table for the interpolant derivative.
6950 //
6951 {
6952  int i;
6953  int j;
6954  int nd;
6955  int ndp;
6956 //
6957 // Copy the data.
6958 //
6959  nd = 2 * n;
6960 
6961  for ( i = 0; i < n; i++ )
6962  {
6963  xd[0+i*2] = x[i];
6964  xd[1+i*2] = x[i];
6965  }
6966 //
6967 // Carry out the first step of differencing.
6968 //
6969  yd[0] = y[0];
6970  for ( i = 1; i < n; i++ )
6971  {
6972  yd[0+2*i] = ( y[i] - y[i-1] ) / ( x[i] - x[i-1] );
6973  }
6974  for ( i = 0; i < n; i++ )
6975  {
6976  yd[1+2*i] = yp[i];
6977  }
6978 //
6979 // Carry out the remaining steps in the usual way.
6980 //
6981  for ( i = 2; i < nd; i++ )
6982  {
6983  for ( j = nd - 1; i <= j; j-- )
6984  {
6985  yd[j] = ( yd[j] - yd[j-1] ) / ( xd[j] - xd[j-i] );
6986  }
6987  }
6988 //
6989 // Compute the difference table for the derivative.
6990 //
6991  dif_deriv ( nd, xd, yd, &ndp, xdp, ydp );
6992 
6993  return;
6994 }
6995 //**************************************************************************80
6996 
6997 void SandiaRules::hermite_interpolant_rule ( int n, double a, double b, double x[],
6998  double w[] )
6999 
7000 //**************************************************************************80
7001 //
7002 // Purpose:
7003 //
7004 // HERMITE_INTERPOLANT_RULE: quadrature rule for a Hermite interpolant.
7005 //
7006 // Licensing:
7007 //
7008 // This code is distributed under the GNU LGPL license.
7009 //
7010 // Modified:
7011 //
7012 // 23 October 2011
7013 //
7014 // Author:
7015 //
7016 // John Burkardt
7017 //
7018 // Parameters:
7019 //
7020 // Input, int N, the number of abscissas.
7021 //
7022 // Input, double A, B, the integration limits.
7023 //
7024 // Input, double X[N], the abscissas.
7025 //
7026 // Output, double W[2*N], the quadrature
7027 // coefficients, given as pairs for function and derivative values
7028 // at each abscissa.
7029 //
7030 {
7031  double a_value;
7032  double b_value;
7033  double *c;
7034  int i;
7035  //int j;
7036  int k;
7037  int nd;
7038  int ndp;
7039  double *xd;
7040  double *xdp;
7041  double *y;
7042  double *yd;
7043  double *ydp;
7044  double *yp;
7045 
7046  y = new double[n];
7047  yp = new double[n];
7048 
7049  nd = 2 * n;
7050  c = new double[nd];
7051  xd = new double[nd];
7052  yd = new double[nd];
7053 
7054  ndp = 2 * n - 1;
7055  xdp = new double[ndp];
7056  ydp = new double[ndp];
7057 
7058  for ( i = 0; i < n; i++ )
7059  {
7060  y[i] = 0.0;
7061  yp[i] = 0.0;
7062  }
7063 
7064  k = 0;
7065 
7066  for ( i = 0; i < n; i++ )
7067  {
7068  y[i] = 1.0;
7069  hermite_interpolant ( n, x, y, yp, xd, yd, xdp, ydp );
7070  dif_to_r8poly ( nd, xd, yd, c );
7071  a_value = r8poly_ant_val ( n, c, a );
7072  b_value = r8poly_ant_val ( n, c, b );
7073  w[k] = b_value - a_value;
7074  y[i] = 0.0;
7075  k = k + 1;
7076 
7077  yp[i] = 1.0;
7078  hermite_interpolant ( n, x, y, yp, xd, yd, xdp, ydp );
7079  dif_to_r8poly ( nd, xd, yd, c );
7080  a_value = r8poly_ant_val ( n, c, a );
7081  b_value = r8poly_ant_val ( n, c, b );
7082  w[k] = b_value - a_value;
7083  yp[i] = 0.0;
7084  k = k + 1;
7085  }
7086 
7087  delete [] c;
7088  delete [] xd;
7089  delete [] xdp;
7090  delete [] y;
7091  delete [] yd;
7092  delete [] ydp;
7093  delete [] yp;
7094 
7095  return;
7096 }
7097 //**************************************************************************80
7098 
7099 void SandiaRules::hermite_interpolant_value ( int nd, double xd[], double yd[], double xdp[],
7100  double ydp[], int nv, double xv[], double yv[], double yvp[] )
7101 
7102 //**************************************************************************80
7103 //
7104 // Purpose:
7105 //
7106 // HERMITE_INTERPOLANT_VALUE evaluates the Hermite interpolant polynomial.
7107 //
7108 // Discussion:
7109 //
7110 // In fact, this function will evaluate an arbitrary polynomial that is
7111 // represented by a difference table.
7112 //
7113 // Licensing:
7114 //
7115 // This code is distributed under the GNU LGPL license.
7116 //
7117 // Modified:
7118 //
7119 // 31 October 2011
7120 //
7121 // Author:
7122 //
7123 // John Burkardt
7124 //
7125 // Reference:
7126 //
7127 // Carl deBoor,
7128 // A Practical Guide to Splines,
7129 // Springer, 2001,
7130 // ISBN: 0387953663,
7131 // LC: QA1.A647.v27.
7132 //
7133 // Parameters:
7134 //
7135 // Input, int ND, the order of the difference table.
7136 //
7137 // Input, double XD[ND], YD[ND], the difference table for the
7138 // interpolant value.
7139 //
7140 // Input, double XDP[ND-1], YDP[ND-1], the difference table for
7141 // the interpolant derivative.
7142 //
7143 // Input, int NV, the number of evaluation points.
7144 //
7145 // Input, double XV[NV], the evaluation points.
7146 //
7147 // Output, double YV[NV], YVP[NV], the value of the interpolant and
7148 // its derivative at the evaluation points.
7149 //
7150 {
7151  int i;
7152  int j;
7153  int ndp;
7154 
7155  ndp = nd - 1;
7156 
7157  for ( j = 0; j < nv; j++ )
7158  {
7159  yv[j] = yd[nd-1];
7160  for ( i = nd - 2; 0 <= i; i-- )
7161  {
7162  yv[j] = yd[i] + ( xv[j] - xd[i] ) * yv[j];
7163  }
7164 
7165  yvp[j] = ydp[ndp-1];
7166  for ( i = ndp - 2; 0 <= i; i-- )
7167  {
7168  yvp[j] = ydp[i] + ( xv[j] - xdp[i] ) * yvp[j];
7169  }
7170  }
7171  return;
7172 }
7173 //**************************************************************************80
7174 
7175 void SandiaRules::hermite_lookup ( int n, double x[], double w[] )
7176 
7177 //**************************************************************************80
7178 //
7179 // Purpose:
7180 //
7181 // HERMITE_LOOKUP looks up abscissas and weights for Gauss-Hermite quadrature.
7182 //
7183 // Licensing:
7184 //
7185 // This code is distributed under the GNU LGPL license.
7186 //
7187 // Modified:
7188 //
7189 // 27 April 2010
7190 //
7191 // Author:
7192 //
7193 // John Burkardt
7194 //
7195 // Reference:
7196 //
7197 // Milton Abramowitz, Irene Stegun,
7198 // Handbook of Mathematical Functions,
7199 // National Bureau of Standards, 1964,
7200 // ISBN: 0-486-61272-4,
7201 // LC: QA47.A34.
7202 //
7203 // Vladimir Krylov,
7204 // Approximate Calculation of Integrals,
7205 // Dover, 2006,
7206 // ISBN: 0486445798.
7207 // LC: QA311.K713.
7208 //
7209 // Arthur Stroud, Don Secrest,
7210 // Gaussian Quadrature Formulas,
7211 // Prentice Hall, 1966,
7212 // LC: QA299.4G3S7.
7213 //
7214 // Stephen Wolfram,
7215 // The Mathematica Book,
7216 // Fourth Edition,
7217 // Cambridge University Press, 1999,
7218 // ISBN: 0-521-64314-7,
7219 // LC: QA76.95.W65.
7220 //
7221 // Daniel Zwillinger, editor,
7222 // CRC Standard Mathematical Tables and Formulae,
7223 // 30th Edition,
7224 // CRC Press, 1996,
7225 // ISBN: 0-8493-2479-3,
7226 // LC: QA47.M315.
7227 //
7228 // Parameters:
7229 //
7230 // Input, int N, the order.
7231 // N must be between 1 and 20.
7232 //
7233 // Output, double X[N], the abscissas.
7234 //
7235 // Output, double W[N], the weights.
7236 //
7237 {
7238  hermite_lookup_points ( n, x );
7239 
7240  hermite_lookup_weights ( n, w );
7241 
7242  return;
7243 }
7244 //**************************************************************************80
7245 
7246 void SandiaRules::hermite_lookup_points ( int n, double x[] )
7247 
7248 //**************************************************************************80
7249 //
7250 // Purpose:
7251 //
7252 // HERMITE_LOOKUP_POINTS looks up abscissas for Hermite quadrature.
7253 //
7254 // Discussion:
7255 //
7256 // The integral:
7257 //
7258 // integral ( -oo < x < +oo ) exp ( - x * x ) * f(x) dx
7259 //
7260 // The quadrature rule:
7261 //
7262 // sum ( 1 <= i <= n ) w(i) * f ( x(i) ).
7263 //
7264 // Mathematica can numerically estimate the abscissas
7265 // of order N to P digits by the command:
7266 //
7267 // NSolve [ HermiteH [ n, x ] == 0, x, p ]
7268 //
7269 // Licensing:
7270 //
7271 // This code is distributed under the GNU LGPL license.
7272 //
7273 // Modified:
7274 //
7275 // 27 April 2010
7276 //
7277 // Author:
7278 //
7279 // John Burkardt
7280 //
7281 // Reference:
7282 //
7283 // Milton Abramowitz, Irene Stegun,
7284 // Handbook of Mathematical Functions,
7285 // National Bureau of Standards, 1964,
7286 // ISBN: 0-486-61272-4,
7287 // LC: QA47.A34.
7288 //
7289 // Vladimir Krylov,
7290 // Approximate Calculation of Integrals,
7291 // Dover, 2006,
7292 // ISBN: 0486445798,
7293 // LC: QA311.K713.
7294 //
7295 // Arthur Stroud, Don Secrest,
7296 // Gaussian Quadrature Formulas,
7297 // Prentice Hall, 1966,
7298 // LC: QA299.4G3S7.
7299 //
7300 // Stephen Wolfram,
7301 // The Mathematica Book,
7302 // Fourth Edition,
7303 // Cambridge University Press, 1999,
7304 // ISBN: 0-521-64314-7,
7305 // LC: QA76.95.W65.
7306 //
7307 // Daniel Zwillinger, editor,
7308 // CRC Standard Mathematical Tables and Formulae,
7309 // 30th Edition,
7310 // CRC Press, 1996,
7311 // ISBN: 0-8493-2479-3,
7312 // LC: QA47.M315.
7313 //
7314 // Parameters:
7315 //
7316 // Input, int N, the order.
7317 // N must be between 1 and 20.
7318 //
7319 // Output, double X[N], the abscissas.
7320 //
7321 {
7322  if ( n == 1 )
7323  {
7324  x[0] = 0.0;
7325  }
7326  else if ( n == 2 )
7327  {
7328  x[0] = - 0.707106781186547524400844362105E+00;
7329  x[1] = 0.707106781186547524400844362105E+00;
7330  }
7331  else if ( n == 3 )
7332  {
7333  x[0] = - 0.122474487139158904909864203735E+01;
7334  x[1] = 0.0E+00;
7335  x[2] = 0.122474487139158904909864203735E+01;
7336  }
7337  else if ( n == 4 )
7338  {
7339  x[0] = - 0.165068012388578455588334111112E+01;
7340  x[1] = - 0.524647623275290317884060253835E+00;
7341  x[2] = 0.524647623275290317884060253835E+00;
7342  x[3] = 0.165068012388578455588334111112E+01;
7343  }
7344  else if ( n == 5 )
7345  {
7346  x[0] = - 0.202018287045608563292872408814E+01;
7347  x[1] = - 0.958572464613818507112770593893E+00;
7348  x[2] = 0.0E+00;
7349  x[3] = 0.958572464613818507112770593893E+00;
7350  x[4] = 0.202018287045608563292872408814E+01;
7351  }
7352  else if ( n == 6 )
7353  {
7354  x[0] = - 0.235060497367449222283392198706E+01;
7355  x[1] = - 0.133584907401369694971489528297E+01;
7356  x[2] = - 0.436077411927616508679215948251E+00;
7357  x[3] = 0.436077411927616508679215948251E+00;
7358  x[4] = 0.133584907401369694971489528297E+01;
7359  x[5] = 0.235060497367449222283392198706E+01;
7360  }
7361  else if ( n == 7 )
7362  {
7363  x[0] = - 0.265196135683523349244708200652E+01;
7364  x[1] = - 0.167355162876747144503180139830E+01;
7365  x[2] = - 0.816287882858964663038710959027E+00;
7366  x[3] = 0.0E+00;
7367  x[4] = 0.816287882858964663038710959027E+00;
7368  x[5] = 0.167355162876747144503180139830E+01;
7369  x[6] = 0.265196135683523349244708200652E+01;
7370  }
7371  else if ( n == 8 )
7372  {
7373  x[0] = - 0.293063742025724401922350270524E+01;
7374  x[1] = - 0.198165675669584292585463063977E+01;
7375  x[2] = - 0.115719371244678019472076577906E+01;
7376  x[3] = - 0.381186990207322116854718885584E+00;
7377  x[4] = 0.381186990207322116854718885584E+00;
7378  x[5] = 0.115719371244678019472076577906E+01;
7379  x[6] = 0.198165675669584292585463063977E+01;
7380  x[7] = 0.293063742025724401922350270524E+01;
7381  }
7382  else if ( n == 9 )
7383  {
7384  x[0] = - 0.319099320178152760723004779538E+01;
7385  x[1] = - 0.226658058453184311180209693284E+01;
7386  x[2] = - 0.146855328921666793166701573925E+01;
7387  x[3] = - 0.723551018752837573322639864579E+00;
7388  x[4] = 0.0E+00;
7389  x[5] = 0.723551018752837573322639864579E+00;
7390  x[6] = 0.146855328921666793166701573925E+01;
7391  x[7] = 0.226658058453184311180209693284E+01;
7392  x[8] = 0.319099320178152760723004779538E+01;
7393  }
7394  else if ( n == 10 )
7395  {
7396  x[0] = - 0.343615911883773760332672549432E+01;
7397  x[1] = - 0.253273167423278979640896079775E+01;
7398  x[2] = - 0.175668364929988177345140122011E+01;
7399  x[3] = - 0.103661082978951365417749191676E+01;
7400  x[4] = - 0.342901327223704608789165025557E+00;
7401  x[5] = 0.342901327223704608789165025557E+00;
7402  x[6] = 0.103661082978951365417749191676E+01;
7403  x[7] = 0.175668364929988177345140122011E+01;
7404  x[8] = 0.253273167423278979640896079775E+01;
7405  x[9] = 0.343615911883773760332672549432E+01;
7406  }
7407  else if ( n == 11 )
7408  {
7409  x[0] = - 0.366847084655958251845837146485E+01;
7410  x[1] = - 0.278329009978165177083671870152E+01;
7411  x[2] = - 0.202594801582575533516591283121E+01;
7412  x[3] = - 0.132655708449493285594973473558E+01;
7413  x[4] = - 0.656809566882099765024611575383E+00;
7414  x[5] = 0.0E+00;
7415  x[6] = 0.656809566882099765024611575383E+00;
7416  x[7] = 0.132655708449493285594973473558E+01;
7417  x[8] = 0.202594801582575533516591283121E+01;
7418  x[9] = 0.278329009978165177083671870152E+01;
7419  x[10] = 0.366847084655958251845837146485E+01;
7420  }
7421  else if ( n == 12 )
7422  {
7423  x[0] = - 0.388972489786978191927164274724E+01;
7424  x[1] = - 0.302063702512088977171067937518E+01;
7425  x[2] = - 0.227950708050105990018772856942E+01;
7426  x[3] = - 0.159768263515260479670966277090E+01;
7427  x[4] = - 0.947788391240163743704578131060E+00;
7428  x[5] = - 0.314240376254359111276611634095E+00;
7429  x[6] = 0.314240376254359111276611634095E+00;
7430  x[7] = 0.947788391240163743704578131060E+00;
7431  x[8] = 0.159768263515260479670966277090E+01;
7432  x[9] = 0.227950708050105990018772856942E+01;
7433  x[10] = 0.302063702512088977171067937518E+01;
7434  x[11] = 0.388972489786978191927164274724E+01;
7435  }
7436  else if ( n == 13 )
7437  {
7438  x[0] = - 0.410133759617863964117891508007E+01;
7439  x[1] = - 0.324660897837240998812205115236E+01;
7440  x[2] = - 0.251973568567823788343040913628E+01;
7441  x[3] = - 0.185310765160151214200350644316E+01;
7442  x[4] = - 0.122005503659074842622205526637E+01;
7443  x[5] = - 0.605763879171060113080537108602E+00;
7444  x[6] = 0.0E+00;
7445  x[7] = 0.605763879171060113080537108602E+00;
7446  x[8] = 0.122005503659074842622205526637E+01;
7447  x[9] = 0.185310765160151214200350644316E+01;
7448  x[10] = 0.251973568567823788343040913628E+01;
7449  x[11] = 0.324660897837240998812205115236E+01;
7450  x[12] = 0.410133759617863964117891508007E+01;
7451  }
7452  else if ( n == 14 )
7453  {
7454  x[0] = - 0.430444857047363181262129810037E+01;
7455  x[1] = - 0.346265693360227055020891736115E+01;
7456  x[2] = - 0.274847072498540256862499852415E+01;
7457  x[3] = - 0.209518325850771681573497272630E+01;
7458  x[4] = - 0.147668273114114087058350654421E+01;
7459  x[5] = - 0.878713787329399416114679311861E+00;
7460  x[6] = - 0.291745510672562078446113075799E+00;
7461  x[7] = 0.291745510672562078446113075799E+00;
7462  x[8] = 0.878713787329399416114679311861E+00;
7463  x[9] = 0.147668273114114087058350654421E+01;
7464  x[10] = 0.209518325850771681573497272630E+01;
7465  x[11] = 0.274847072498540256862499852415E+01;
7466  x[12] = 0.346265693360227055020891736115E+01;
7467  x[13] = 0.430444857047363181262129810037E+01;
7468  }
7469  else if ( n == 15 )
7470  {
7471  x[0] = - 0.449999070730939155366438053053E+01;
7472  x[1] = - 0.366995037340445253472922383312E+01;
7473  x[2] = - 0.296716692790560324848896036355E+01;
7474  x[3] = - 0.232573248617385774545404479449E+01;
7475  x[4] = - 0.171999257518648893241583152515E+01;
7476  x[5] = - 0.113611558521092066631913490556E+01;
7477  x[6] = - 0.565069583255575748526020337198E+00;
7478  x[7] = 0.0E+00;
7479  x[8] = 0.565069583255575748526020337198E+00;
7480  x[9] = 0.113611558521092066631913490556E+01;
7481  x[10] = 0.171999257518648893241583152515E+01;
7482  x[11] = 0.232573248617385774545404479449E+01;
7483  x[12] = 0.296716692790560324848896036355E+01;
7484  x[13] = 0.366995037340445253472922383312E+01;
7485  x[14] = 0.449999070730939155366438053053E+01;
7486  }
7487  else if ( n == 16 )
7488  {
7489  x[0] = - 0.468873893930581836468849864875E+01;
7490  x[1] = - 0.386944790486012269871942409801E+01;
7491  x[2] = - 0.317699916197995602681399455926E+01;
7492  x[3] = - 0.254620215784748136215932870545E+01;
7493  x[4] = - 0.195178799091625397743465541496E+01;
7494  x[5] = - 0.138025853919888079637208966969E+01;
7495  x[6] = - 0.822951449144655892582454496734E+00;
7496  x[7] = - 0.273481046138152452158280401965E+00;
7497  x[8] = 0.273481046138152452158280401965E+00;
7498  x[9] = 0.822951449144655892582454496734E+00;
7499  x[10] = 0.138025853919888079637208966969E+01;
7500  x[11] = 0.195178799091625397743465541496E+01;
7501  x[12] = 0.254620215784748136215932870545E+01;
7502  x[13] = 0.317699916197995602681399455926E+01;
7503  x[14] = 0.386944790486012269871942409801E+01;
7504  x[15] = 0.468873893930581836468849864875E+01;
7505  }
7506  else if ( n == 17 )
7507  {
7508  x[0] = - 0.487134519367440308834927655662E+01;
7509  x[1] = - 0.406194667587547430689245559698E+01;
7510  x[2] = - 0.337893209114149408338327069289E+01;
7511  x[3] = - 0.275776291570388873092640349574E+01;
7512  x[4] = - 0.217350282666662081927537907149E+01;
7513  x[5] = - 0.161292431422123133311288254454E+01;
7514  x[6] = - 0.106764872574345055363045773799E+01;
7515  x[7] = - 0.531633001342654731349086553718E+00;
7516  x[8] = 0.0E+00;
7517  x[9] = 0.531633001342654731349086553718E+00;
7518  x[10] = 0.106764872574345055363045773799E+01;
7519  x[11] = 0.161292431422123133311288254454E+01;
7520  x[12] = 0.217350282666662081927537907149E+01;
7521  x[13] = 0.275776291570388873092640349574E+01;
7522  x[14] = 0.337893209114149408338327069289E+01;
7523  x[15] = 0.406194667587547430689245559698E+01;
7524  x[16] = 0.487134519367440308834927655662E+01;
7525  }
7526  else if ( n == 18 )
7527  {
7528  x[0] = - 0.504836400887446676837203757885E+01;
7529  x[1] = - 0.424811787356812646302342016090E+01;
7530  x[2] = - 0.357376906848626607950067599377E+01;
7531  x[3] = - 0.296137750553160684477863254906E+01;
7532  x[4] = - 0.238629908916668600026459301424E+01;
7533  x[5] = - 0.183553160426162889225383944409E+01;
7534  x[6] = - 0.130092085838961736566626555439E+01;
7535  x[7] = - 0.776682919267411661316659462284E+00;
7536  x[8] = - 0.258267750519096759258116098711E+00;
7537  x[9] = 0.258267750519096759258116098711E+00;
7538  x[10] = 0.776682919267411661316659462284E+00;
7539  x[11] = 0.130092085838961736566626555439E+01;
7540  x[12] = 0.183553160426162889225383944409E+01;
7541  x[13] = 0.238629908916668600026459301424E+01;
7542  x[14] = 0.296137750553160684477863254906E+01;
7543  x[15] = 0.357376906848626607950067599377E+01;
7544  x[16] = 0.424811787356812646302342016090E+01;
7545  x[17] = 0.504836400887446676837203757885E+01;
7546  }
7547  else if ( n == 19 )
7548  {
7549  x[0] = - 0.522027169053748216460967142500E+01;
7550  x[1] = - 0.442853280660377943723498532226E+01;
7551  x[2] = - 0.376218735196402009751489394104E+01;
7552  x[3] = - 0.315784881834760228184318034120E+01;
7553  x[4] = - 0.259113378979454256492128084112E+01;
7554  x[5] = - 0.204923170985061937575050838669E+01;
7555  x[6] = - 0.152417061939353303183354859367E+01;
7556  x[7] = - 0.101036838713431135136859873726E+01;
7557  x[8] = - 0.503520163423888209373811765050E+00;
7558  x[9] = 0.0E+00;
7559  x[10] = 0.503520163423888209373811765050E+00;
7560  x[11] = 0.101036838713431135136859873726E+01;
7561  x[12] = 0.152417061939353303183354859367E+01;
7562  x[13] = 0.204923170985061937575050838669E+01;
7563  x[14] = 0.259113378979454256492128084112E+01;
7564  x[15] = 0.315784881834760228184318034120E+01;
7565  x[16] = 0.376218735196402009751489394104E+01;
7566  x[17] = 0.442853280660377943723498532226E+01;
7567  x[18] = 0.522027169053748216460967142500E+01;
7568  }
7569  else if ( n == 20 )
7570  {
7571  x[0] = - 0.538748089001123286201690041068E+01;
7572  x[1] = - 0.460368244955074427307767524898E+01;
7573  x[2] = - 0.394476404011562521037562880052E+01;
7574  x[3] = - 0.334785456738321632691492452300E+01;
7575  x[4] = - 0.278880605842813048052503375640E+01;
7576  x[5] = - 0.225497400208927552308233334473E+01;
7577  x[6] = - 0.173853771211658620678086566214E+01;
7578  x[7] = - 0.123407621539532300788581834696E+01;
7579  x[8] = - 0.737473728545394358705605144252E+00;
7580  x[9] = - 0.245340708300901249903836530634E+00;
7581  x[10] = 0.245340708300901249903836530634E+00;
7582  x[11] = 0.737473728545394358705605144252E+00;
7583  x[12] = 0.123407621539532300788581834696E+01;
7584  x[13] = 0.173853771211658620678086566214E+01;
7585  x[14] = 0.225497400208927552308233334473E+01;
7586  x[15] = 0.278880605842813048052503375640E+01;
7587  x[16] = 0.334785456738321632691492452300E+01;
7588  x[17] = 0.394476404011562521037562880052E+01;
7589  x[18] = 0.460368244955074427307767524898E+01;
7590  x[19] = 0.538748089001123286201690041068E+01;
7591  }
7592  else
7593  {
7594  std::cerr << "\n";
7595  std::cerr << "HERMITE_LOOKUP_POINTS - Fatal error!\n";
7596  std::cerr << " Illegal value of N = " << n << "\n";
7597  std::cerr << " Legal values are 1 through 20.\n";
7598  std::exit ( 1 );
7599  }
7600 
7601  return;
7602 }
7603 //**************************************************************************80
7604 
7605 void SandiaRules::hermite_lookup_weights ( int n, double w[] )
7606 
7607 //**************************************************************************80
7608 //
7609 // Purpose:
7610 //
7611 // HERMITE_LOOKUP_WEIGHTS looks up weights for Hermite quadrature.
7612 //
7613 // Discussion:
7614 //
7615 // The integral:
7616 //
7617 // integral ( -oo < x < +oo ) exp ( - x * x ) * f(x) dx
7618 //
7619 // The quadrature rule:
7620 //
7621 // sum ( 1 <= i <= n ) w(i) * f ( x(i) ).
7622 //
7623 // Mathematica can numerically estimate the abscissas
7624 // of order N to P digits by the command:
7625 //
7626 // NSolve [ HermiteH [ n, x ] == 0, x, p ]
7627 //
7628 // Licensing:
7629 //
7630 // This code is distributed under the GNU LGPL license.
7631 //
7632 // Modified:
7633 //
7634 // 27 April 2010
7635 //
7636 // Author:
7637 //
7638 // John Burkardt
7639 //
7640 // Reference:
7641 //
7642 // Milton Abramowitz, Irene Stegun,
7643 // Handbook of Mathematical Functions,
7644 // National Bureau of Standards, 1964,
7645 // ISBN: 0-486-61272-4,
7646 // LC: QA47.A34.
7647 //
7648 // Vladimir Krylov,
7649 // Approximate Calculation of Integrals,
7650 // Dover, 2006,
7651 // ISBN: 0486445798,
7652 // LC: QA311.K713.
7653 //
7654 // Arthur Stroud, Don Secrest,
7655 // Gaussian Quadrature Formulas,
7656 // Prentice Hall, 1966,
7657 // LC: QA299.4G3S7.
7658 //
7659 // Stephen Wolfram,
7660 // The Mathematica Book,
7661 // Fourth Edition,
7662 // Cambridge University Press, 1999,
7663 // ISBN: 0-521-64314-7,
7664 // LC: QA76.95.W65.
7665 //
7666 // Daniel Zwillinger, editor,
7667 // CRC Standard Mathematical Tables and Formulae,
7668 // 30th Edition,
7669 // CRC Press, 1996,
7670 // ISBN: 0-8493-2479-3,
7671 // LC: QA47.M315.
7672 //
7673 // Parameters:
7674 //
7675 // Input, int N, the order.
7676 // N must be between 1 and 20.
7677 //
7678 // Output, double W[N], the weights.
7679 //
7680 {
7681  if ( n == 1 )
7682  {
7683  w[0] = 1.77245385090551602729816748334;
7684  }
7685  else if ( n == 2 )
7686  {
7687  w[0] = 0.886226925452758013649083741671E+00;
7688  w[1] = 0.886226925452758013649083741671E+00;
7689  }
7690  else if ( n == 3 )
7691  {
7692  w[0] = 0.295408975150919337883027913890E+00;
7693  w[1] = 0.118163590060367735153211165556E+01;
7694  w[2] = 0.295408975150919337883027913890E+00;
7695  }
7696  else if ( n == 4 )
7697  {
7698  w[0] = 0.813128354472451771430345571899E-01;
7699  w[1] = 0.804914090005512836506049184481E+00;
7700  w[2] = 0.804914090005512836506049184481E+00;
7701  w[3] = 0.813128354472451771430345571899E-01;
7702  }
7703  else if ( n == 5 )
7704  {
7705  w[0] = 0.199532420590459132077434585942E-01;
7706  w[1] = 0.393619323152241159828495620852E+00;
7707  w[2] = 0.945308720482941881225689324449E+00;
7708  w[3] = 0.393619323152241159828495620852E+00;
7709  w[4] = 0.199532420590459132077434585942E-01;
7710  }
7711  else if ( n == 6 )
7712  {
7713  w[0] = 0.453000990550884564085747256463E-02;
7714  w[1] = 0.157067320322856643916311563508E+00;
7715  w[2] = 0.724629595224392524091914705598E+00;
7716  w[3] = 0.724629595224392524091914705598E+00;
7717  w[4] = 0.157067320322856643916311563508E+00;
7718  w[5] = 0.453000990550884564085747256463E-02;
7719  }
7720  else if ( n == 7 )
7721  {
7722  w[0] = 0.971781245099519154149424255939E-03;
7723  w[1] = 0.545155828191270305921785688417E-01;
7724  w[2] = 0.425607252610127800520317466666E+00;
7725  w[3] = 0.810264617556807326764876563813E+00;
7726  w[4] = 0.425607252610127800520317466666E+00;
7727  w[5] = 0.545155828191270305921785688417E-01;
7728  w[6] = 0.971781245099519154149424255939E-03;
7729  }
7730  else if ( n == 8 )
7731  {
7732  w[0] = 0.199604072211367619206090452544E-03;
7733  w[1] = 0.170779830074134754562030564364E-01;
7734  w[2] = 0.207802325814891879543258620286E+00;
7735  w[3] = 0.661147012558241291030415974496E+00;
7736  w[4] = 0.661147012558241291030415974496E+00;
7737  w[5] = 0.207802325814891879543258620286E+00;
7738  w[6] = 0.170779830074134754562030564364E-01;
7739  w[7] = 0.199604072211367619206090452544E-03;
7740  }
7741  else if ( n == 9 )
7742  {
7743  w[0] = 0.396069772632643819045862946425E-04;
7744  w[1] = 0.494362427553694721722456597763E-02;
7745  w[2] = 0.884745273943765732879751147476E-01;
7746  w[3] = 0.432651559002555750199812112956E+00;
7747  w[4] = 0.720235215606050957124334723389E+00;
7748  w[5] = 0.432651559002555750199812112956E+00;
7749  w[6] = 0.884745273943765732879751147476E-01;
7750  w[7] = 0.494362427553694721722456597763E-02;
7751  w[8] = 0.396069772632643819045862946425E-04;
7752  }
7753  else if ( n == 10 )
7754  {
7755  w[0] = 0.764043285523262062915936785960E-05;
7756  w[1] = 0.134364574678123269220156558585E-02;
7757  w[2] = 0.338743944554810631361647312776E-01;
7758  w[3] = 0.240138611082314686416523295006E+00;
7759  w[4] = 0.610862633735325798783564990433E+00;
7760  w[5] = 0.610862633735325798783564990433E+00;
7761  w[6] = 0.240138611082314686416523295006E+00;
7762  w[7] = 0.338743944554810631361647312776E-01;
7763  w[8] = 0.134364574678123269220156558585E-02;
7764  w[9] = 0.764043285523262062915936785960E-05;
7765  }
7766  else if ( n == 11 )
7767  {
7768  w[0] = 0.143956039371425822033088366032E-05;
7769  w[1] = 0.346819466323345510643413772940E-03;
7770  w[2] = 0.119113954449115324503874202916E-01;
7771  w[3] = 0.117227875167708503381788649308E+00;
7772  w[4] = 0.429359752356125028446073598601E+00;
7773  w[5] = 0.654759286914591779203940657627E+00;
7774  w[6] = 0.429359752356125028446073598601E+00;
7775  w[7] = 0.117227875167708503381788649308E+00;
7776  w[8] = 0.119113954449115324503874202916E-01;
7777  w[9] = 0.346819466323345510643413772940E-03;
7778  w[10] = 0.143956039371425822033088366032E-05;
7779  }
7780  else if ( n == 12 )
7781  {
7782  w[0] = 0.265855168435630160602311400877E-06;
7783  w[1] = 0.857368704358785865456906323153E-04;
7784  w[2] = 0.390539058462906185999438432620E-02;
7785  w[3] = 0.516079856158839299918734423606E-01;
7786  w[4] = 0.260492310264161129233396139765E+00;
7787  w[5] = 0.570135236262479578347113482275E+00;
7788  w[6] = 0.570135236262479578347113482275E+00;
7789  w[7] = 0.260492310264161129233396139765E+00;
7790  w[8] = 0.516079856158839299918734423606E-01;
7791  w[9] = 0.390539058462906185999438432620E-02;
7792  w[10] = 0.857368704358785865456906323153E-04;
7793  w[11] = 0.265855168435630160602311400877E-06;
7794  }
7795  else if ( n == 13 )
7796  {
7797  w[0] = 0.482573185007313108834997332342E-07;
7798  w[1] = 0.204303604027070731248669432937E-04;
7799  w[2] = 0.120745999271938594730924899224E-02;
7800  w[3] = 0.208627752961699392166033805050E-01;
7801  w[4] = 0.140323320687023437762792268873E+00;
7802  w[5] = 0.421616296898543221746893558568E+00;
7803  w[6] = 0.604393187921161642342099068579E+00;
7804  w[7] = 0.421616296898543221746893558568E+00;
7805  w[8] = 0.140323320687023437762792268873E+00;
7806  w[9] = 0.208627752961699392166033805050E-01;
7807  w[10] = 0.120745999271938594730924899224E-02;
7808  w[11] = 0.204303604027070731248669432937E-04;
7809  w[12] = 0.482573185007313108834997332342E-07;
7810  }
7811  else if ( n == 14 )
7812  {
7813  w[0] = 0.862859116812515794532041783429E-08;
7814  w[1] = 0.471648435501891674887688950105E-05;
7815  w[2] = 0.355092613551923610483661076691E-03;
7816  w[3] = 0.785005472645794431048644334608E-02;
7817  w[4] = 0.685055342234652055387163312367E-01;
7818  w[5] = 0.273105609064246603352569187026E+00;
7819  w[6] = 0.536405909712090149794921296776E+00;
7820  w[7] = 0.536405909712090149794921296776E+00;
7821  w[8] = 0.273105609064246603352569187026E+00;
7822  w[9] = 0.685055342234652055387163312367E-01;
7823  w[10] = 0.785005472645794431048644334608E-02;
7824  w[11] = 0.355092613551923610483661076691E-03;
7825  w[12] = 0.471648435501891674887688950105E-05;
7826  w[13] = 0.862859116812515794532041783429E-08;
7827  }
7828  else if ( n == 15 )
7829  {
7830  w[0] = 0.152247580425351702016062666965E-08;
7831  w[1] = 0.105911554771106663577520791055E-05;
7832  w[2] = 0.100004441232499868127296736177E-03;
7833  w[3] = 0.277806884291277589607887049229E-02;
7834  w[4] = 0.307800338725460822286814158758E-01;
7835  w[5] = 0.158488915795935746883839384960E+00;
7836  w[6] = 0.412028687498898627025891079568E+00;
7837  w[7] = 0.564100308726417532852625797340E+00;
7838  w[8] = 0.412028687498898627025891079568E+00;
7839  w[9] = 0.158488915795935746883839384960E+00;
7840  w[10] = 0.307800338725460822286814158758E-01;
7841  w[11] = 0.277806884291277589607887049229E-02;
7842  w[12] = 0.100004441232499868127296736177E-03;
7843  w[13] = 0.105911554771106663577520791055E-05;
7844  w[14] = 0.152247580425351702016062666965E-08;
7845  }
7846  else if ( n == 16 )
7847  {
7848  w[0] = 0.265480747401118224470926366050E-09;
7849  w[1] = 0.232098084486521065338749423185E-06;
7850  w[2] = 0.271186009253788151201891432244E-04;
7851  w[3] = 0.932284008624180529914277305537E-03;
7852  w[4] = 0.128803115355099736834642999312E-01;
7853  w[5] = 0.838100413989858294154207349001E-01;
7854  w[6] = 0.280647458528533675369463335380E+00;
7855  w[7] = 0.507929479016613741913517341791E+00;
7856  w[8] = 0.507929479016613741913517341791E+00;
7857  w[9] = 0.280647458528533675369463335380E+00;
7858  w[10] = 0.838100413989858294154207349001E-01;
7859  w[11] = 0.128803115355099736834642999312E-01;
7860  w[12] = 0.932284008624180529914277305537E-03;
7861  w[13] = 0.271186009253788151201891432244E-04;
7862  w[14] = 0.232098084486521065338749423185E-06;
7863  w[15] = 0.265480747401118224470926366050E-09;
7864  }
7865  else if ( n == 17 )
7866  {
7867  w[0] = 0.458057893079863330580889281222E-10;
7868  w[1] = 0.497707898163079405227863353715E-07;
7869  w[2] = 0.711228914002130958353327376218E-05;
7870  w[3] = 0.298643286697753041151336643059E-03;
7871  w[4] = 0.506734995762753791170069495879E-02;
7872  w[5] = 0.409200341495762798094994877854E-01;
7873  w[6] = 0.172648297670097079217645196219E+00;
7874  w[7] = 0.401826469470411956577635085257E+00;
7875  w[8] = 0.530917937624863560331883103379E+00;
7876  w[9] = 0.401826469470411956577635085257E+00;
7877  w[10] = 0.172648297670097079217645196219E+00;
7878  w[11] = 0.409200341495762798094994877854E-01;
7879  w[12] = 0.506734995762753791170069495879E-02;
7880  w[13] = 0.298643286697753041151336643059E-03;
7881  w[14] = 0.711228914002130958353327376218E-05;
7882  w[15] = 0.497707898163079405227863353715E-07;
7883  w[16] = 0.458057893079863330580889281222E-10;
7884  }
7885  else if ( n == 18 )
7886  {
7887  w[0] = 0.782819977211589102925147471012E-11;
7888  w[1] = 0.104672057957920824443559608435E-07;
7889  w[2] = 0.181065448109343040959702385911E-05;
7890  w[3] = 0.918112686792940352914675407371E-04;
7891  w[4] = 0.188852263026841789438175325426E-02;
7892  w[5] = 0.186400423875446519219315221973E-01;
7893  w[6] = 0.973017476413154293308537234155E-01;
7894  w[7] = 0.284807285669979578595606820713E+00;
7895  w[8] = 0.483495694725455552876410522141E+00;
7896  w[9] = 0.483495694725455552876410522141E+00;
7897  w[10] = 0.284807285669979578595606820713E+00;
7898  w[11] = 0.973017476413154293308537234155E-01;
7899  w[12] = 0.186400423875446519219315221973E-01;
7900  w[13] = 0.188852263026841789438175325426E-02;
7901  w[14] = 0.918112686792940352914675407371E-04;
7902  w[15] = 0.181065448109343040959702385911E-05;
7903  w[16] = 0.104672057957920824443559608435E-07;
7904  w[17] = 0.782819977211589102925147471012E-11;
7905  }
7906  else if ( n == 19 )
7907  {
7908  w[0] = 0.132629709449851575185289154385E-11;
7909  w[1] = 0.216305100986355475019693077221E-08;
7910  w[2] = 0.448824314722312295179447915594E-06;
7911  w[3] = 0.272091977631616257711941025214E-04;
7912  w[4] = 0.670877521407181106194696282100E-03;
7913  w[5] = 0.798886677772299020922211491861E-02;
7914  w[6] = 0.508103869090520673569908110358E-01;
7915  w[7] = 0.183632701306997074156148485766E+00;
7916  w[8] = 0.391608988613030244504042313621E+00;
7917  w[9] = 0.502974888276186530840731361096E+00;
7918  w[10] = 0.391608988613030244504042313621E+00;
7919  w[11] = 0.183632701306997074156148485766E+00;
7920  w[12] = 0.508103869090520673569908110358E-01;
7921  w[13] = 0.798886677772299020922211491861E-02;
7922  w[14] = 0.670877521407181106194696282100E-03;
7923  w[15] = 0.272091977631616257711941025214E-04;
7924  w[16] = 0.448824314722312295179447915594E-06;
7925  w[17] = 0.216305100986355475019693077221E-08;
7926  w[18] = 0.132629709449851575185289154385E-11;
7927  }
7928  else if ( n == 20 )
7929  {
7930  w[0] = 0.222939364553415129252250061603E-12;
7931  w[1] = 0.439934099227318055362885145547E-09;
7932  w[2] = 0.108606937076928169399952456345E-06;
7933  w[3] = 0.780255647853206369414599199965E-05;
7934  w[4] = 0.228338636016353967257145917963E-03;
7935  w[5] = 0.324377334223786183218324713235E-02;
7936  w[6] = 0.248105208874636108821649525589E-01;
7937  w[7] = 0.109017206020023320013755033535E+00;
7938  w[8] = 0.286675505362834129719659706228E+00;
7939  w[9] = 0.462243669600610089650328639861E+00;
7940  w[10] = 0.462243669600610089650328639861E+00;
7941  w[11] = 0.286675505362834129719659706228E+00;
7942  w[12] = 0.109017206020023320013755033535E+00;
7943  w[13] = 0.248105208874636108821649525589E-01;
7944  w[14] = 0.324377334223786183218324713235E-02;
7945  w[15] = 0.228338636016353967257145917963E-03;
7946  w[16] = 0.780255647853206369414599199965E-05;
7947  w[17] = 0.108606937076928169399952456345E-06;
7948  w[18] = 0.439934099227318055362885145547E-09;
7949  w[19] = 0.222939364553415129252250061603E-12;
7950  }
7951  else
7952  {
7953  std::cerr << "\n";
7954  std::cerr << "HERMITE_LOOKUP_WEIGHTS - Fatal error!\n";
7955  std::cerr << " Illegal value of N = " << n << "\n";
7956  std::cerr << " Legal values are 1 through 20.\n";
7957  std::exit ( 1 );
7958  }
7959 
7960  return;
7961 }
7962 //**************************************************************************80
7963 
7964 void SandiaRules::hermite_ss_compute ( int order, double x[], double w[] )
7965 
7966 //**************************************************************************80
7967 //
7968 // Purpose:
7969 //
7970 // HERMITE_SS_COMPUTE computes a Hermite quadrature rule.
7971 //
7972 // Discussion:
7973 //
7974 // The abscissas are the zeros of the N-th order Hermite polynomial.
7975 //
7976 // The integral:
7977 //
7978 // Integral ( -oo < X < +oo ) exp ( - X * X ) * F(X) dX
7979 //
7980 // The quadrature rule:
7981 //
7982 // Sum ( 1 <= I <= ORDER ) W(I) * F ( X(I) )
7983 //
7984 // Licensing:
7985 //
7986 // This code is distributed under the GNU LGPL license.
7987 //
7988 // Modified:
7989 //
7990 // 19 April 2011
7991 //
7992 // Author:
7993 //
7994 // Original FORTRAN77 version by Arthur Stroud, Don Secrest.
7995 // C++ version by John Burkardt.
7996 //
7997 // Reference:
7998 //
7999 // Arthur Stroud, Don Secrest,
8000 // Gaussian Quadrature Formulas,
8001 // Prentice Hall, 1966,
8002 // LC: QA299.4G3S7.
8003 //
8004 // Parameters:
8005 //
8006 // Input, int ORDER, the order.
8007 // 1 <= ORDER.
8008 //
8009 // Output, double X[ORDER], the abscissas.
8010 //
8011 // Output, double W[ORDER], the weights.
8012 //
8013 {
8014  double cc;
8015  double dp2;
8016  int i;
8017  double p1;
8018  double s;
8019  double temp;
8020  double x0;
8021 
8022  if ( order < 1 )
8023  {
8024  std::cerr << "\n";
8025  std::cerr << "HERMITE_SS_COMPUTE - Fatal error!\n";
8026  std::cerr << " Illegal value of ORDER = " << order << "\n";
8027  std::exit ( 1 );
8028  }
8029 
8030  cc = 1.7724538509 * r8_gamma ( ( double ) ( order ) )
8031  / std::pow ( 2.0, order - 1 );
8032 
8033  s = std::pow ( 2.0 * ( double ) ( order ) + 1.0, 1.0 / 6.0 );
8034 
8035  for ( i = 0; i < ( order + 1 ) / 2; i++ )
8036  {
8037  if ( i == 0 )
8038  {
8039  x0 = s * s * s - 1.85575 / s;
8040  }
8041  else if ( i == 1 )
8042  {
8043  x0 = x0 - 1.14 * std::pow ( ( double ) ( order ), 0.426 ) / x0;
8044  }
8045  else if ( i == 2 )
8046  {
8047  x0 = 1.86 * x0 - 0.86 * x[0];
8048  }
8049  else if ( i == 3 )
8050  {
8051  x0 = 1.91 * x0 - 0.91 * x[1];
8052  }
8053  else
8054  {
8055  x0 = 2.0 * x0 - x[i-2];
8056  }
8057 
8058  hermite_ss_root ( &x0, order, &dp2, &p1 );
8059 
8060  x[i] = x0;
8061  w[i] = ( cc / dp2 ) / p1;
8062 
8063  x[order-i-1] = -x0;
8064  w[order-i-1] = w[i];
8065  }
8066 //
8067 // Reverse the order of the abscissas.
8068 //
8069  for ( i = 1; i <= order/2; i++ )
8070  {
8071  temp = x[i-1];
8072  x[i-1] = x[order-i];
8073  x[order-i] = temp;
8074  }
8075 
8076  if ( ( order % 2 ) == 1 )
8077  {
8078  x[(order-1)/2] = 0.0;
8079  }
8080 
8081  return;
8082 }
8083 //**************************************************************************80
8084 
8085 void SandiaRules::hermite_ss_recur ( double *p2, double *dp2, double *p1, double x, int order )
8086 
8087 //**************************************************************************80
8088 //
8089 // Purpose:
8090 //
8091 // HERMITE_SS_RECUR finds the value and derivative of a Hermite polynomial.
8092 //
8093 // Licensing:
8094 //
8095 // This code is distributed under the GNU LGPL license.
8096 //
8097 // Modified:
8098 //
8099 // 19 April 2011
8100 //
8101 // Author:
8102 //
8103 // Original FORTRAN77 version by Arthur Stroud, Don Secrest.
8104 // C++ version by John Burkardt.
8105 //
8106 // Reference:
8107 //
8108 // Arthur Stroud, Don Secrest,
8109 // Gaussian Quadrature Formulas,
8110 // Prentice Hall, 1966,
8111 // LC: QA299.4G3S7.
8112 //
8113 // Parameters:
8114 //
8115 // Output, double *P2, the value of H(ORDER)(X).
8116 //
8117 // Output, double *DP2, the value of H'(ORDER)(X).
8118 //
8119 // Output, double *P1, the value of H(ORDER-1)(X).
8120 //
8121 // Input, double X, the point at which polynomials are evaluated.
8122 //
8123 // Input, int ORDER, the order of the polynomial.
8124 //
8125 {
8126  int i;
8127  double dq0;
8128  double dq1;
8129  double dq2;
8130  double q0;
8131  double q1;
8132  double q2;
8133 
8134  q1 = 1.0;
8135  dq1 = 0.0;
8136 
8137  q2 = x;
8138  dq2 = 1.0;
8139 
8140  for ( i = 2; i <= order; i++ )
8141  {
8142  q0 = q1;
8143  dq0 = dq1;
8144 
8145  q1 = q2;
8146  dq1 = dq2;
8147 
8148  q2 = x * q1 - 0.5 * ( ( double ) ( i ) - 1.0 ) * q0;
8149  dq2 = x * dq1 + q1 - 0.5 * ( ( double ) ( i ) - 1.0 ) * dq0;
8150  }
8151 
8152  *p2 = q2;
8153  *dp2 = dq2;
8154  *p1 = q1;
8155 
8156  return;
8157 }
8158 //**************************************************************************80
8159 
8160 void SandiaRules::hermite_ss_root ( double *x, int order, double *dp2, double *p1 )
8161 
8162 //**************************************************************************80
8163 //
8164 // Purpose:
8165 //
8166 // HERMITE_SS_ROOT improves an approximate root of a Hermite polynomial.
8167 //
8168 // Licensing:
8169 //
8170 // This code is distributed under the GNU LGPL license.
8171 //
8172 // Modified:
8173 //
8174 // 19 April 2011
8175 //
8176 // Author:
8177 //
8178 // Original FORTRAN77 version by Arthur Stroud, Don Secrest.
8179 // C++ version by John Burkardt.
8180 //
8181 // Reference:
8182 //
8183 // Arthur Stroud, Don Secrest,
8184 // Gaussian Quadrature Formulas,
8185 // Prentice Hall, 1966,
8186 // LC: QA299.4G3S7.
8187 //
8188 // Parameters:
8189 //
8190 // Input/output, double *X, the approximate root, which
8191 // should be improved on output.
8192 //
8193 // Input, int ORDER, the order of the Hermite polynomial.
8194 //
8195 // Output, double *DP2, the value of H'(ORDER)(X).
8196 //
8197 // Output, double *P1, the value of H(ORDER-1)(X).
8198 //
8199 {
8200  double d;
8201  double eps;
8202  double p2;
8203  int step;
8204  int step_max = 10;
8205 
8206  eps = r8_epsilon ( );
8207 
8208  for ( step = 1; step <= step_max; step++ )
8209  {
8210  hermite_ss_recur ( &p2, dp2, p1, *x, order );
8211 
8212  d = p2 / ( *dp2 );
8213  *x = *x - d;
8214 
8215  if ( r8_abs ( d ) <= eps * ( r8_abs ( *x ) + 1.0 ) )
8216  {
8217  return;
8218  }
8219  }
8220  return;
8221 }
8222 //**************************************************************************80
8223 
8224 int SandiaRules::i4_choose ( int n, int k )
8225 
8226 //**************************************************************************80
8227 //
8228 // Purpose:
8229 //
8230 // I4_CHOOSE computes the binomial coefficient C(N,K).
8231 //
8232 // Discussion:
8233 //
8234 // The value is calculated in such a way as to avoid SandiaRules::overflow and
8235 // roundoff. The calculation is done in integer arithmetic.
8236 //
8237 // The formula used is:
8238 //
8239 // C(N,K) = N! / ( K! * (N-K)! )
8240 //
8241 // Licensing:
8242 //
8243 // This code is distributed under the GNU LGPL license.
8244 //
8245 // Modified:
8246 //
8247 // 09 November 2007
8248 //
8249 // Author:
8250 //
8251 // John Burkardt
8252 //
8253 // Reference:
8254 //
8255 // ML Wolfson, HV Wright,
8256 // Algorithm 160:
8257 // Combinatorial of M Things Taken N at a Time,
8258 // Communications of the ACM,
8259 // Volume 6, Number 4, April 1963, page 161.
8260 //
8261 // Parameters:
8262 //
8263 // Input, int N, K, the values of N and K.
8264 //
8265 // Output, int I4_CHOOSE, the number of combinations of N
8266 // things taken K at a time.
8267 //
8268 {
8269  int i;
8270  int mn;
8271  int mx;
8272  int value;
8273 
8274  mn = i4_min ( k, n - k );
8275 
8276  if ( mn < 0 )
8277  {
8278  value = 0;
8279  }
8280  else if ( mn == 0 )
8281  {
8282  value = 1;
8283  }
8284  else
8285  {
8286  mx = i4_max ( k, n - k );
8287  value = mx + 1;
8288 
8289  for ( i = 2; i <= mn; i++ )
8290  {
8291  value = ( value * ( mx + i ) ) / i;
8292  }
8293  }
8294 
8295  return value;
8296 }
8297 //**************************************************************************80
8298 
8300 
8301 //**************************************************************************80
8302 //
8303 // Purpose:
8304 //
8305 // I4_LOG_2 returns the integer part of the logarithm base 2 of an I4.
8306 //
8307 // Example:
8308 //
8309 // I I4_LOG_10
8310 // ----- --------
8311 // 0 0
8312 // 1 0
8313 // 2 1
8314 // 3 1
8315 // 4 2
8316 // 5 2
8317 // 7 2
8318 // 8 3
8319 // 9 3
8320 // 1000 9
8321 // 1024 10
8322 //
8323 // Discussion:
8324 //
8325 // I4_LOG_2 ( I ) + 1 is the number of binary digits in I.
8326 //
8327 // Licensing:
8328 //
8329 // This code is distributed under the GNU LGPL license.
8330 //
8331 // Modified:
8332 //
8333 // 04 January 2004
8334 //
8335 // Author:
8336 //
8337 // John Burkardt
8338 //
8339 // Parameters:
8340 //
8341 // Input, int I, the number whose logarithm base 2 is desired.
8342 //
8343 // Output, int I4_LOG_2, the integer part of the logarithm base 2 of
8344 // the absolute value of X.
8345 //
8346 {
8347  int i_abs;
8348  int two_pow;
8349  int value;
8350 
8351  if ( i == 0 )
8352  {
8353  value = 0;
8354  }
8355  else
8356  {
8357  value = 0;
8358  two_pow = 2;
8359 
8360  i_abs = std::abs ( i );
8361 
8362  while ( two_pow <= i_abs )
8363  {
8364  value = value + 1;
8365  two_pow = two_pow * 2;
8366  }
8367  }
8368 
8369  return value;
8370 }
8371 //**************************************************************************80
8372 
8373 int SandiaRules::i4_max ( int i1, int i2 )
8374 
8375 //**************************************************************************80
8376 //
8377 // Purpose:
8378 //
8379 // I4_MAX returns the maximum of two I4's.
8380 //
8381 // Licensing:
8382 //
8383 // This code is distributed under the GNU LGPL license.
8384 //
8385 // Modified:
8386 //
8387 // 13 October 1998
8388 //
8389 // Author:
8390 //
8391 // John Burkardt
8392 //
8393 // Parameters:
8394 //
8395 // Input, int I1, I2, are two integers to be compared.
8396 //
8397 // Output, int I4_MAX, the larger of I1 and I2.
8398 //
8399 {
8400  int value;
8401 
8402  if ( i2 < i1 )
8403  {
8404  value = i1;
8405  }
8406  else
8407  {
8408  value = i2;
8409  }
8410  return value;
8411 }
8412 //**************************************************************************80
8413 
8414 int SandiaRules::i4_min ( int i1, int i2 )
8415 
8416 //**************************************************************************80
8417 //
8418 // Purpose:
8419 //
8420 // I4_MIN returns the minimum of two I4's.
8421 //
8422 // Licensing:
8423 //
8424 // This code is distributed under the GNU LGPL license.
8425 //
8426 // Modified:
8427 //
8428 // 13 October 1998
8429 //
8430 // Author:
8431 //
8432 // John Burkardt
8433 //
8434 // Parameters:
8435 //
8436 // Input, int I1, I2, two integers to be compared.
8437 //
8438 // Output, int I4_MIN, the smaller of I1 and I2.
8439 //
8440 {
8441  int value;
8442 
8443  if ( i1 < i2 )
8444  {
8445  value = i1;
8446  }
8447  else
8448  {
8449  value = i2;
8450  }
8451  return value;
8452 }
8453 //**************************************************************************80
8454 
8455 int SandiaRules::i4_power ( int i, int j )
8456 
8457 //**************************************************************************80
8458 //
8459 // Purpose:
8460 //
8461 // I4_POWER returns the value of I^J.
8462 //
8463 // Licensing:
8464 //
8465 // This code is distributed under the GNU LGPL license.
8466 //
8467 // Modified:
8468 //
8469 // 01 April 2004
8470 //
8471 // Author:
8472 //
8473 // John Burkardt
8474 //
8475 // Parameters:
8476 //
8477 // Input, int I, J, the base and the power. J should be nonnegative.
8478 //
8479 // Output, int I4_POWER, the value of I^J.
8480 //
8481 {
8482  int k;
8483  int value;
8484 
8485  if ( j < 0 )
8486  {
8487  if ( i == 1 )
8488  {
8489  value = 1;
8490  }
8491  else if ( i == 0 )
8492  {
8493  std::cerr << "\n";
8494  std::cerr << "I4_POWER - Fatal error!\n";
8495  std::cerr << " I^J requested, with I = 0 and J negative.\n";
8496  std::exit ( 1 );
8497  }
8498  else
8499  {
8500  value = 0;
8501  }
8502  }
8503  else if ( j == 0 )
8504  {
8505  if ( i == 0 )
8506  {
8507  std::cerr << "\n";
8508  std::cerr << "I4_POWER - Fatal error!\n";
8509  std::cerr << " I^J requested, with I = 0 and J = 0.\n";
8510  std::exit ( 1 );
8511  }
8512  else
8513  {
8514  value = 1;
8515  }
8516  }
8517  else if ( j == 1 )
8518  {
8519  value = i;
8520  }
8521  else
8522  {
8523  value = 1;
8524  for ( k = 1; k <= j; k++ )
8525  {
8526  value = value * i;
8527  }
8528  }
8529  return value;
8530 }
8531 //**************************************************************************80
8532 
8533 void SandiaRules::i4mat_copy ( int m, int n, int a1[], int a2[] )
8534 
8535 //**************************************************************************80
8536 //
8537 // Purpose:
8538 //
8539 // I4MAT_COPY copies one I4MAT to another.
8540 //
8541 // Discussion:
8542 //
8543 // An I4MAT is an MxN array of I4's, stored by (I,J) -> [I+J*M].
8544 //
8545 // Licensing:
8546 //
8547 // This code is distributed under the GNU LGPL license.
8548 //
8549 // Modified:
8550 //
8551 // 27 August 2008
8552 //
8553 // Author:
8554 //
8555 // John Burkardt
8556 //
8557 // Parameters:
8558 //
8559 // Input, int M, N, the number of rows and columns.
8560 //
8561 // Input, int A1[M*N], the matrix to be copied.
8562 //
8563 // Output, int A2[M*N], the copy of A1.
8564 //
8565 {
8566  int i;
8567  int j;
8568 
8569  for ( j = 0; j < n; j++ )
8570  {
8571  for ( i = 0; i < m; i++ )
8572  {
8573  a2[i+j*m] = a1[i+j*m];
8574  }
8575  }
8576  return;
8577 }
8578 //**************************************************************************80
8579 
8580 int *SandiaRules::i4mat_copy_new ( int m, int n, int a1[] )
8581 
8582 //**************************************************************************80
8583 //
8584 // Purpose:
8585 //
8586 // I4MAT_COPY_NEW copies an I4MAT to a "new" I4MAT.
8587 //
8588 // Discussion:
8589 //
8590 // An I4MAT is an MxN array of I4's, stored by (I,J) -> [I+J*M].
8591 //
8592 // Licensing:
8593 //
8594 // This code is distributed under the GNU LGPL license.
8595 //
8596 // Modified:
8597 //
8598 // 27 August 2008
8599 //
8600 // Author:
8601 //
8602 // John Burkardt
8603 //
8604 // Parameters:
8605 //
8606 // Input, int M, N, the number of rows and columns.
8607 //
8608 // Input, int A1[M*N], the matrix to be copied.
8609 //
8610 // Output, int I4MAT_COPY_NEW[M*N], the copy of A1.
8611 //
8612 {
8613  int *a2;
8614  int i;
8615  int j;
8616 
8617  a2 = new int[m*n];
8618 
8619  for ( j = 0; j < n; j++ )
8620  {
8621  for ( i = 0; i < m; i++ )
8622  {
8623  a2[i+j*m] = a1[i+j*m];
8624  }
8625  }
8626  return a2;
8627 }
8628 //**************************************************************************80
8629 
8630 void SandiaRules::i4mat_transpose_print ( int m, int n, int a[], std::string title )
8631 
8632 //**************************************************************************80
8633 //
8634 // Purpose:
8635 //
8636 // I4MAT_TRANSPOSE_PRINT prints an I4MAT, transposed.
8637 //
8638 // Discussion:
8639 //
8640 // An I4MAT is an MxN array of I4's, stored by (I,J) -> [I+J*M].
8641 //
8642 // Licensing:
8643 //
8644 // This code is distributed under the GNU LGPL license.
8645 //
8646 // Modified:
8647 //
8648 // 31 January 2005
8649 //
8650 // Author:
8651 //
8652 // John Burkardt
8653 //
8654 // Parameters:
8655 //
8656 // Input, int M, the number of rows in A.
8657 //
8658 // Input, int N, the number of columns in A.
8659 //
8660 // Input, int A[M*N], the M by N matrix.
8661 //
8662 // Input, string TITLE, a title.
8663 //
8664 {
8665  i4mat_transpose_print_some ( m, n, a, 1, 1, m, n, title );
8666 
8667  return;
8668 }
8669 //**************************************************************************80
8670 
8671 void SandiaRules::i4mat_transpose_print_some ( int m, int n, int a[], int ilo, int jlo,
8672  int ihi, int jhi, std::string title )
8673 
8674 //**************************************************************************80
8675 //
8676 // Purpose:
8677 //
8678 // I4MAT_TRANSPOSE_PRINT_SOME prints some of an I4MAT, transposed.
8679 //
8680 // Discussion:
8681 //
8682 // An I4MAT is an MxN array of I4's, stored by (I,J) -> [I+J*M].
8683 //
8684 // Licensing:
8685 //
8686 // This code is distributed under the GNU LGPL license.
8687 //
8688 // Modified:
8689 //
8690 // 14 June 2005
8691 //
8692 // Author:
8693 //
8694 // John Burkardt
8695 //
8696 // Parameters:
8697 //
8698 // Input, int M, the number of rows of the matrix.
8699 // M must be positive.
8700 //
8701 // Input, int N, the number of columns of the matrix.
8702 // N must be positive.
8703 //
8704 // Input, int A[M*N], the matrix.
8705 //
8706 // Input, int ILO, JLO, IHI, JHI, designate the first row and
8707 // column, and the last row and column to be printed.
8708 //
8709 // Input, string TITLE, a title.
8710 //
8711 {
8712 # define INCX 10
8713 
8714  int i;
8715  int i2hi;
8716  int i2lo;
8717  int j;
8718  int j2hi;
8719  int j2lo;
8720 
8721  std::cout << "\n";
8722  std::cout << title << "\n";
8723 //
8724 // Print the columns of the matrix, in strips of INCX.
8725 //
8726  for ( i2lo = ilo; i2lo <= ihi; i2lo = i2lo + INCX )
8727  {
8728  i2hi = i2lo + INCX - 1;
8729  i2hi = i4_min ( i2hi, m );
8730  i2hi = i4_min ( i2hi, ihi );
8731 
8732  std::cout << "\n";
8733 //
8734 // For each row I in the current range...
8735 //
8736 // Write the header.
8737 //
8738  std::cout << " Row: ";
8739  for ( i = i2lo; i <= i2hi; i++ )
8740  {
8741  std::cout << std::setw(6) << i - 1 << " ";
8742  }
8743  std::cout << "\n";
8744  std::cout << " Col\n";
8745  std::cout << "\n";
8746 //
8747 // Determine the range of the rows in this strip.
8748 //
8749  j2lo = i4_max ( jlo, 1 );
8750  j2hi = i4_min ( jhi, n );
8751 
8752  for ( j = j2lo; j <= j2hi; j++ )
8753  {
8754 //
8755 // Print out (up to INCX) entries in column J, that lie in the current strip.
8756 //
8757  std::cout << std::setw(5) << j - 1 << ":";
8758  for ( i = i2lo; i <= i2hi; i++ )
8759  {
8760  std::cout << std::setw(6) << a[i-1+(j-1)*m] << " ";
8761  }
8762  std::cout << "\n";
8763  }
8764  }
8765 
8766  return;
8767 # undef INCX
8768 }
8769 //**************************************************************************80
8770 
8771 void SandiaRules::i4mat_write ( std::string output_filename, int m, int n, int table[] )
8772 
8773 //**************************************************************************80
8774 //
8775 // Purpose:
8776 //
8777 // I4MAT_WRITE writes an I4MAT file.
8778 //
8779 // Licensing:
8780 //
8781 // This code is distributed under the GNU LGPL license.
8782 //
8783 // Modified:
8784 //
8785 // 01 June 2009
8786 //
8787 // Author:
8788 //
8789 // John Burkardt
8790 //
8791 // Parameters:
8792 //
8793 // Input, string OUTPUT_FILENAME, the output filename.
8794 //
8795 // Input, int M, the spatial dimension.
8796 //
8797 // Input, int N, the number of points.
8798 //
8799 // Input, int TABLE[M*N], the table data.
8800 //
8801 {
8802  int i;
8803  int j;
8804  std::ofstream output;
8805 //
8806 // Open the file.
8807 //
8808  output.open ( output_filename.c_str ( ) );
8809 
8810  if ( !output )
8811  {
8812  std::cerr << "\n";
8813  std::cerr << "I4MAT_WRITE - Fatal error!\n";
8814  std::cerr << " Could not open the output file.\n";
8815  return;
8816  }
8817 //
8818 // Write the data.
8819 //
8820  for ( j = 0; j < n; j++ )
8821  {
8822  for ( i = 0; i < m; i++ )
8823  {
8824  output << std::setw(10) << table[i+j*m] << " ";
8825  }
8826  output << "\n";
8827  }
8828 //
8829 // Close the file.
8830 //
8831  output.close ( );
8832 
8833  return;
8834 }
8835 //**************************************************************************80
8836 
8837 int *SandiaRules::i4vec_add_new ( int n, int a[], int b[] )
8838 
8839 //**************************************************************************80
8840 //
8841 // Purpose:
8842 //
8843 // I4VEC_ADD_NEW computes C = A + B for I4VEC's.
8844 //
8845 // Discussion:
8846 //
8847 // An I4VEC is a vector of I4's.
8848 //
8849 // Licensing:
8850 //
8851 // This code is distributed under the GNU LGPL license.
8852 //
8853 // Modified:
8854 //
8855 // 28 April 2010
8856 //
8857 // Author:
8858 //
8859 // John Burkardt
8860 //
8861 // Parameters:
8862 //
8863 // Input, int N, the number of entries.
8864 //
8865 // Input, int A[N], the first vector.
8866 //
8867 // Input, int B[N], the second vector.
8868 //
8869 // Output, int I4VEC_ADD_NEW[N], the sum of the vectors.
8870 //
8871 {
8872  int *c;
8873  int i;
8874 
8875  c = new int[n];
8876 
8877  for ( i = 0; i < n; i++ )
8878  {
8879  c[i] = a[i] + b[i];
8880  }
8881  return c;
8882 }
8883 //**************************************************************************80
8884 
8885 bool i4vec_any_lt ( int n, int a[], int b[] )
8886 
8887 //**************************************************************************80
8888 //
8889 // Purpose:
8890 //
8891 // I4VEC_ANY_LT: ( any ( A < B ) ) for I4VEC's.
8892 //
8893 // Discussion:
8894 //
8895 // An I4VEC is a vector of I4's.
8896 //
8897 // Licensing:
8898 //
8899 // This code is distributed under the GNU LGPL license.
8900 //
8901 // Modified:
8902 //
8903 // 28 April 2010
8904 //
8905 // Author:
8906 //
8907 // John Burkardt
8908 //
8909 // Parameters:
8910 //
8911 // Input, int N, the number of entries.
8912 //
8913 // Input, int A[N], the first vector.
8914 //
8915 // Input, int B[N], the second vector.
8916 //
8917 // Output, bool I4VEC_ANY_LT is TRUE if any entry
8918 // of A is less than the corresponding entry of B.
8919 //
8920 {
8921  int i;
8922  bool value;
8923 
8924  for ( i = 0; i < n; i++ )
8925  {
8926  if ( a[i] < b[i] )
8927  {
8928  value = true;
8929  return value;
8930  }
8931  }
8932  value = false;
8933 
8934  return value;
8935 }
8936 //**************************************************************************80
8937 
8938 void SandiaRules::i4vec_copy ( int n, int a1[], int a2[] )
8939 
8940 //**************************************************************************80
8941 //
8942 // Purpose:
8943 //
8944 // I4VEC_COPY copies an I4VEC.
8945 //
8946 // Discussion:
8947 //
8948 // An I4VEC is a vector of I4's.
8949 //
8950 // Licensing:
8951 //
8952 // This code is distributed under the GNU LGPL license.
8953 //
8954 // Modified:
8955 //
8956 // 25 April 2007
8957 //
8958 // Author:
8959 //
8960 // John Burkardt
8961 //
8962 // Parameters:
8963 //
8964 // Input, int N, the number of entries in the vectors.
8965 //
8966 // Input, int A1[N], the vector to be copied.
8967 //
8968 // Output, int A2[N], the copy of A1.
8969 //
8970 {
8971  int i;
8972 
8973  for ( i = 0; i < n; i++ )
8974  {
8975  a2[i] = a1[i];
8976  }
8977  return;
8978 }
8979 //**************************************************************************80
8980 
8981 int *SandiaRules::i4vec_copy_new ( int n, int a1[] )
8982 
8983 //**************************************************************************80
8984 //
8985 // Purpose:
8986 //
8987 // I4VEC_COPY_NEW copies an I4VEC to a "new" I4VEC.
8988 //
8989 // Discussion:
8990 //
8991 // An I4VEC is a vector of I4's.
8992 //
8993 // Licensing:
8994 //
8995 // This code is distributed under the GNU LGPL license.
8996 //
8997 // Modified:
8998 //
8999 // 04 July 2008
9000 //
9001 // Author:
9002 //
9003 // John Burkardt
9004 //
9005 // Parameters:
9006 //
9007 // Input, int N, the number of entries in the vectors.
9008 //
9009 // Input, int A1[N], the vector to be copied.
9010 //
9011 // Output, int I4VEC_COPY_NEW[N], the copy of A1.
9012 //
9013 {
9014  int *a2;
9015  int i;
9016 
9017  a2 = new int[n];
9018 
9019  for ( i = 0; i < n; i++ )
9020  {
9021  a2[i] = a1[i];
9022  }
9023  return a2;
9024 }
9025 //**************************************************************************80
9026 
9027 void SandiaRules::i4vec_min_mv ( int m, int n, int u[], int v[], int w[] )
9028 
9029 //**************************************************************************80
9030 //
9031 // Purpose:
9032 //
9033 // I4VEC_MIN_MV determines U(1:N) /\ V for vectors U and a single vector V.
9034 //
9035 // Discussion:
9036 //
9037 // For two vectors U and V, each of length M, we define
9038 //
9039 // ( U /\ V ) (I) = min ( U(I), V(I) ).
9040 //
9041 // Licensing:
9042 //
9043 // This code is distributed under the GNU LGPL license.
9044 //
9045 // Modified:
9046 //
9047 // 12 January 2011
9048 //
9049 // Author:
9050 //
9051 // John Burkardt
9052 //
9053 // Parameters:
9054 //
9055 // Input, int M, the dimension of the vectors.
9056 //
9057 // Input, int N, the number of vectors in U.
9058 //
9059 // Input, int U[M*N], N vectors, each of length M.
9060 //
9061 // Input, int V[M], a vector of length M.
9062 //
9063 // Output, int W[M*N], the value of U /\ W.
9064 //
9065 {
9066  int i;
9067  int j;
9068 
9069  for ( j = 0; j < n; j++ )
9070  {
9071  for ( i = 0; i < m; i++ )
9072  {
9073  w[i+j*m] = i4_min ( u[i+j*m], v[i] );
9074  }
9075  }
9076  return;
9077 }
9078 //**************************************************************************80
9079 
9080 void SandiaRules::i4vec_print ( int n, int a[], std::string title )
9081 
9082 //**************************************************************************80
9083 //
9084 // Purpose:
9085 //
9086 // I4VEC_PRINT prints an I4VEC.
9087 //
9088 // Discussion:
9089 //
9090 // An I4VEC is a vector of I4's.
9091 //
9092 // Licensing:
9093 //
9094 // This code is distributed under the GNU LGPL license.
9095 //
9096 // Modified:
9097 //
9098 // 14 November 2003
9099 //
9100 // Author:
9101 //
9102 // John Burkardt
9103 //
9104 // Parameters:
9105 //
9106 // Input, int N, the number of components of the vector.
9107 //
9108 // Input, int A[N], the vector to be printed.
9109 //
9110 // Input, string TITLE, a title.
9111 //
9112 {
9113  int i;
9114 
9115  std::cout << "\n";
9116  std::cout << title << "\n";
9117  std::cout << "\n";
9118  for ( i = 0; i < n; i++ )
9119  {
9120  std::cout << " " << std::setw(8) << i
9121  << ": " << std::setw(8) << a[i] << "\n";
9122  }
9123  return;
9124 }
9125 //**************************************************************************80
9126 
9127 int SandiaRules::i4vec_product ( int n, int a[] )
9128 
9129 //**************************************************************************80
9130 //
9131 // Purpose:
9132 //
9133 // I4VEC_PRODUCT multiplies the entries of an I4VEC.
9134 //
9135 // Discussion:
9136 //
9137 // An I4VEC is a vector of integer values.
9138 //
9139 // Example:
9140 //
9141 // Input:
9142 //
9143 // A = ( 1, 2, 3, 4 )
9144 //
9145 // Output:
9146 //
9147 // I4VEC_PRODUCT = 24
9148 //
9149 // Licensing:
9150 //
9151 // This code is distributed under the GNU LGPL license.
9152 //
9153 // Modified:
9154 //
9155 // 17 May 2003
9156 //
9157 // Author:
9158 //
9159 // John Burkardt
9160 //
9161 // Parameters:
9162 //
9163 // Input, int N, the number of entries in the vector.
9164 //
9165 // Input, int A[N], the vector
9166 //
9167 // Output, int I4VEC_PRODUCT, the product of the entries of A.
9168 //
9169 {
9170  int i;
9171  int product;
9172 
9173  product = 1;
9174  for ( i = 0; i < n; i++ )
9175  {
9176  product = product * a[i];
9177  }
9178 
9179  return product;
9180 }
9181 //**************************************************************************80
9182 
9183 int SandiaRules::i4vec_sum ( int n, int a[] )
9184 
9185 //**************************************************************************80
9186 //
9187 // Purpose:
9188 //
9189 // I4VEC_SUM sums the entries of an I4VEC.
9190 //
9191 // Discussion:
9192 //
9193 // An I4VEC is a vector of I4's.
9194 //
9195 // Example:
9196 //
9197 // Input:
9198 //
9199 // A = ( 1, 2, 3, 4 )
9200 //
9201 // Output:
9202 //
9203 // I4VEC_SUM = 10
9204 //
9205 // Licensing:
9206 //
9207 // This code is distributed under the GNU LGPL license.
9208 //
9209 // Modified:
9210 //
9211 // 04 June 2009
9212 //
9213 // Author:
9214 //
9215 // John Burkardt
9216 //
9217 // Parameters:
9218 //
9219 // Input, int N, the number of entries in the vector.
9220 //
9221 // Input, int A[N], the vector to be summed.
9222 //
9223 // Output, int I4VEC_SUM, the sum of the entries of A.
9224 //
9225 {
9226  int i;
9227  int sum;
9228 
9229  sum = 0;
9230  for ( i = 0; i < n; i++ )
9231  {
9232  sum = sum + a[i];
9233  }
9234 
9235  return sum;
9236 }
9237 //**************************************************************************80
9238 
9239 void SandiaRules::i4vec_zero ( int n, int a[] )
9240 
9241 //**************************************************************************80
9242 //
9243 // Purpose:
9244 //
9245 // I4VEC_ZERO zeroes an I4VEC.
9246 //
9247 // Discussion:
9248 //
9249 // An I4VEC is a vector of I4's.
9250 //
9251 // Licensing:
9252 //
9253 // This code is distributed under the GNU LGPL license.
9254 //
9255 // Modified:
9256 //
9257 // 01 August 2005
9258 //
9259 // Author:
9260 //
9261 // John Burkardt
9262 //
9263 // Parameters:
9264 //
9265 // Input, int N, the number of entries in the vector.
9266 //
9267 // Output, int A[N], a vector of zeroes.
9268 //
9269 {
9270  int i;
9271 
9272  for ( i = 0; i < n; i++ )
9273  {
9274  a[i] = 0;
9275  }
9276  return;
9277 }
9278 //**************************************************************************80
9279 
9281 
9282 //**************************************************************************80
9283 //
9284 // Purpose:
9285 //
9286 // I4VEC_ZERO_NEW creates and zeroes an I4VEC.
9287 //
9288 // Discussion:
9289 //
9290 // An I4VEC is a vector of I4's.
9291 //
9292 // Licensing:
9293 //
9294 // This code is distributed under the GNU LGPL license.
9295 //
9296 // Modified:
9297 //
9298 // 11 July 2008
9299 //
9300 // Author:
9301 //
9302 // John Burkardt
9303 //
9304 // Parameters:
9305 //
9306 // Input, int N, the number of entries in the vector.
9307 //
9308 // Output, int I4VEC_ZERO_NEW[N], a vector of zeroes.
9309 //
9310 {
9311  int *a;
9312  int i;
9313 
9314  a = new int[n];
9315 
9316  for ( i = 0; i < n; i++ )
9317  {
9318  a[i] = 0;
9319  }
9320  return a;
9321 }
9322 //**************************************************************************80
9323 
9324 void SandiaRules::imtqlx ( int n, double d[], double e[], double z[] )
9325 
9326 //**************************************************************************80
9327 //
9328 // Purpose:
9329 //
9330 // IMTQLX diagonalizes a symmetric tridiagonal matrix.
9331 //
9332 // Discussion:
9333 //
9334 // This routine is a slightly modified version of the EISPACK routine to
9335 // perform the implicit QL algorithm on a symmetric tridiagonal matrix.
9336 //
9337 // The authors thank the authors of EISPACK for permission to use this
9338 // routine.
9339 //
9340 // It has been modified to produce the product Q' * Z, where Z is an input
9341 // vector and Q is the orthogonal matrix diagonalizing the input matrix.
9342 // The changes consist (essentially) of applying the orthogonal transformations
9343 // directly to Z as they are generated.
9344 //
9345 // Licensing:
9346 //
9347 // This code is distributed under the GNU LGPL license.
9348 //
9349 // Modified:
9350 //
9351 // 08 January 2010
9352 //
9353 // Author:
9354 //
9355 // Original FORTRAN77 version by Sylvan Elhay, Jaroslav Kautsky.
9356 // C++ version by John Burkardt.
9357 //
9358 // Reference:
9359 //
9360 // Sylvan Elhay, Jaroslav Kautsky,
9361 // Algorithm 655: IQPACK, FORTRAN Subroutines for the Weights of
9362 // Interpolatory Quadrature,
9363 // ACM Transactions on Mathematical Software,
9364 // Volume 13, Number 4, December 1987, pages 399-415.
9365 //
9366 // Roger Martin, James Wilkinson,
9367 // The Implicit QL Algorithm,
9368 // Numerische Mathematik,
9369 // Volume 12, Number 5, December 1968, pages 377-383.
9370 //
9371 // Parameters:
9372 //
9373 // Input, int N, the order of the matrix.
9374 //
9375 // Input/output, double D(N), the diagonal entries of the matrix.
9376 // On output, the information in D has been overwritten.
9377 //
9378 // Input/output, double E(N), the subdiagonal entries of the
9379 // matrix, in entries E(1) through E(N-1). On output, the information in
9380 // E has been overwritten.
9381 //
9382 // Input/output, double Z(N). On input, a vector. On output,
9383 // the value of Q' * Z, where Q is the matrix that diagonalizes the
9384 // input symmetric tridiagonal matrix.
9385 //
9386 {
9387  double b;
9388  double c;
9389  double f;
9390  double g;
9391  int i;
9392  int ii;
9393  int itn = 30;
9394  int j;
9395  int k;
9396  int l;
9397  int m;
9398  int mml;
9399  double p;
9400  double prec;
9401  double r;
9402  double s;
9403 
9404  prec = r8_epsilon ( );
9405 
9406  if ( n == 1 )
9407  {
9408  return;
9409  }
9410 
9411  e[n-1] = 0.0;
9412 
9413  for ( l = 1; l <= n; l++ )
9414  {
9415  j = 0;
9416  for ( ; ; )
9417  {
9418  for ( m = l; m <= n; m++ )
9419  {
9420  if ( m == n )
9421  {
9422  break;
9423  }
9424 
9425  if ( r8_abs ( e[m-1] ) <=
9426  prec * ( r8_abs ( d[m-1] ) + r8_abs ( d[m] ) ) )
9427  {
9428  break;
9429  }
9430  }
9431  p = d[l-1];
9432  if ( m == l )
9433  {
9434  break;
9435  }
9436  if ( itn <= j )
9437  {
9438  std::cerr << "\n";
9439  std::cerr << "IMTQLX - Fatal error!\n";
9440  std::cerr << " Iteration limit exceeded\n";
9441  std::exit ( 1 );
9442  }
9443  j = j + 1;
9444  g = ( d[l] - p ) / ( 2.0 * e[l-1] );
9445  r = std::sqrt ( g * g + 1.0 );
9446  g = d[m-1] - p + e[l-1] / ( g + r8_abs ( r ) * r8_sign ( g ) );
9447  s = 1.0;
9448  c = 1.0;
9449  p = 0.0;
9450  mml = m - l;
9451 
9452  for ( ii = 1; ii <= mml; ii++ )
9453  {
9454  i = m - ii;
9455  f = s * e[i-1];
9456  b = c * e[i-1];
9457 
9458  if ( r8_abs ( g ) <= r8_abs ( f ) )
9459  {
9460  c = g / f;
9461  r = std::sqrt ( c * c + 1.0 );
9462  e[i] = f * r;
9463  s = 1.0 / r;
9464  c = c * s;
9465  }
9466  else
9467  {
9468  s = f / g;
9469  r = std::sqrt ( s * s + 1.0 );
9470  e[i] = g * r;
9471  c = 1.0 / r;
9472  s = s * c;
9473  }
9474  g = d[i] - p;
9475  r = ( d[i-1] - g ) * s + 2.0 * c * b;
9476  p = s * r;
9477  d[i] = g + p;
9478  g = c * r - b;
9479  f = z[i];
9480  z[i] = s * z[i-1] + c * f;
9481  z[i-1] = c * z[i-1] - s * f;
9482  }
9483  d[l-1] = d[l-1] - p;
9484  e[l-1] = g;
9485  e[m-1] = 0.0;
9486  }
9487  }
9488 //
9489 // Sorting.
9490 //
9491  for ( ii = 2; ii <= m; ii++ )
9492  {
9493  i = ii - 1;
9494  k = i;
9495  p = d[i-1];
9496 
9497  for ( j = ii; j <= n; j++ )
9498  {
9499  if ( d[j-1] < p )
9500  {
9501  k = j;
9502  p = d[j-1];
9503  }
9504  }
9505 
9506  if ( k != i )
9507  {
9508  d[k-1] = d[i-1];
9509  d[i-1] = p;
9510  p = z[i-1];
9511  z[i-1] = z[k-1];
9512  z[k-1] = p;
9513  }
9514  }
9515  return;
9516 }
9517 //**************************************************************************80
9518 
9519 void SandiaRules::jacobi_compute ( int n, double alpha, double beta, double x[],
9520  double w[] )
9521 
9522 //**************************************************************************80
9523 //
9524 // Purpose:
9525 //
9526 // JACOBI_COMPUTE: Elhay-Kautsky method for Gauss-Jacobi quadrature rule.
9527 //
9528 // Discussion:
9529 //
9530 // The integral:
9531 //
9532 // Integral ( -1 <= X <= 1 ) (1-X)**ALPHA * (1+X)**BETA * F(X) dX
9533 //
9534 // The quadrature rule:
9535 //
9536 // Sum ( 1 <= I <= ORDER ) WEIGHT(I) * F ( XTAB(I) )
9537 //
9538 // Licensing:
9539 //
9540 // This code is distributed under the GNU LGPL license.
9541 //
9542 // Modified:
9543 //
9544 // 30 April 2011
9545 //
9546 // Author:
9547 //
9548 // Original FORTRAN77 version by Sylvan Elhay, Jaroslav Kautsky.
9549 // C++ version by John Burkardt.
9550 //
9551 // Reference:
9552 //
9553 // Sylvan Elhay, Jaroslav Kautsky,
9554 // Algorithm 655: IQPACK, FORTRAN Subroutines for the Weights of
9555 // Interpolatory Quadrature,
9556 // ACM Transactions on Mathematical Software,
9557 // Volume 13, Number 4, December 1987, pages 399-415.
9558 //
9559 // Parameters:
9560 //
9561 // Input, int N, the order.
9562 //
9563 // Input, double ALPHA, BETA, the exponents of (1-X) and
9564 // (1+X) in the quadrature rule. For simple Gauss-Legendre quadrature,
9565 // set ALPHA = BETA = 0.0. -1.0 < ALPHA and -1.0 < BETA are required.
9566 //
9567 // Output, double X[N], the abscissas.
9568 //
9569 // Output, double W[N], the weights.
9570 //
9571 {
9572  double abi;
9573  double *bj;
9574  int i;
9575  double i_r8;
9576  double zemu;
9577 //
9578 // Define the zero-th moment.
9579 //
9580  zemu = std::pow ( 2.0, alpha + beta + 1.0 )
9581  * r8_gamma ( alpha + 1.0 )
9582  * r8_gamma ( beta + 1.0 )
9583  / r8_gamma ( 2.0 + alpha + beta );
9584 //
9585 // Define the Jacobi matrix.
9586 //
9587  bj = new double[n];
9588 
9589  x[0] = ( beta - alpha ) / ( 2.0 + alpha + beta );
9590 
9591  bj[0] = 4.0 * ( 1.0 + alpha ) * ( 1.0 + beta )
9592  / ( ( 3.0 + alpha + beta )
9593  * ( 2.0 + alpha + beta ) * ( 2.0 + alpha + beta ) );
9594 
9595  for ( i = 1; i < n; i++ )
9596  {
9597  i_r8 = ( double ) ( i + 1 );
9598  abi = 2.0 * i_r8 + alpha + beta;
9599  x[i] = ( beta + alpha ) * ( beta - alpha ) / ( ( abi - 2.0 ) * abi );
9600  bj[i] = 4.0 * i_r8 * ( i_r8 + alpha ) * ( i_r8 + beta )
9601  * ( i_r8 + alpha + beta )
9602  / ( ( abi - 1.0 ) * ( abi + 1.0 ) * abi * abi );
9603  }
9604 
9605  for ( i = 0; i < n; i++ )
9606  {
9607  bj[i] = std::sqrt ( bj[i] );
9608  }
9609 
9610  w[0] = std::sqrt ( zemu );
9611 
9612  for ( i = 1; i < n; i++ )
9613  {
9614  w[i] = 0.0;
9615  }
9616 //
9617 // Diagonalize the Jacobi matrix.
9618 //
9619  imtqlx ( n, x, bj, w );
9620 
9621  for ( i = 0; i < n; i++ )
9622  {
9623  w[i] = w[i] * w[i];
9624  }
9625 
9626  delete [] bj;
9627 
9628  return;
9629 }
9630 //**************************************************************************80
9631 
9632 void SandiaRules::jacobi_compute_np ( int order, int np, double p[], double x[], double w[] )
9633 
9634 //**************************************************************************80
9635 //
9636 // Purpose:
9637 //
9638 // JACOBI_COMPUTE_NP computes a Jacobi quadrature rule.
9639 //
9640 // Discussion:
9641 //
9642 // The integral:
9643 //
9644 // Integral ( -1 <= X <= 1 ) (1-X)^ALPHA * (1+X)^BETA * F(X) dX
9645 //
9646 // The quadrature rule:
9647 //
9648 // Sum ( 1 <= I <= ORDER ) W(I) * F ( X(I) )
9649 //
9650 // Thanks to Xu Xiang of Fudan University for pointing out that
9651 // an earlier implementation of this routine was incorrect!
9652 //
9653 // Licensing:
9654 //
9655 // This code is distributed under the GNU LGPL license.
9656 //
9657 // Modified:
9658 //
9659 // 22 June 2009
9660 //
9661 // Author:
9662 //
9663 // Original FORTRAN77 version by Arthur Stroud, Don Secrest.
9664 // C++ version by John Burkardt.
9665 //
9666 // Reference:
9667 //
9668 // Arthur Stroud, Don Secrest,
9669 // Gaussian Quadrature Formulas,
9670 // Prentice Hall, 1966,
9671 // LC: QA299.4G3S7.
9672 //
9673 // Parameters:
9674 //
9675 // Input, int ORDER, the order.
9676 // 1 <= ORDER.
9677 //
9678 // Input, int NP, the number of parameters.
9679 //
9680 // Input, double P[NP], parameter values.
9681 // P[0] = ALPHA, the exponent of (1-X)
9682 // P[1] = BETA, the exponent of (1+X).
9683 // -1.0 < ALPHA and -1.0 < BETA are required.
9684 //
9685 // Output, double X[ORDER], the abscissas.
9686 //
9687 // Output, double W[ORDER], the weights.
9688 //
9689 {
9690  double alpha;
9691  double beta;
9692 
9693  alpha = p[0];
9694  beta = p[1];
9695 
9696  jacobi_compute ( order, alpha, beta, x, w );
9697 
9698  return;
9699 }
9700 //**************************************************************************80
9701 
9702 void SandiaRules::jacobi_compute_points ( int order, double alpha, double beta,
9703  double x[] )
9704 
9705 //**************************************************************************80
9706 //
9707 // Purpose:
9708 //
9709 // JACOBI_COMPUTE_POINTS computes Jacobi quadrature points.
9710 //
9711 // Licensing:
9712 //
9713 // This code is distributed under the GNU LGPL license.
9714 //
9715 // Modified:
9716 //
9717 // 14 October 2008
9718 //
9719 // Author:
9720 //
9721 // John Burkardt
9722 //
9723 // Parameters:
9724 //
9725 // Input, int ORDER, the order.
9726 //
9727 // Input, double ALPHA, BETA, the exponents of the (1-X) and (1+X) factors.
9728 //
9729 // Output, double X[ORDER], the abscissas.
9730 //
9731 {
9732  double *w;
9733 
9734  w = new double[order];
9735 
9736  jacobi_compute ( order, alpha, beta, x, w );
9737 
9738  delete [] w;
9739 
9740  return;
9741 }
9742 //**************************************************************************80
9743 
9744 void SandiaRules::jacobi_compute_points_np ( int order, int np, double p[], double x[] )
9745 
9746 //**************************************************************************80
9747 //
9748 // Purpose:
9749 //
9750 // JACOBI_COMPUTE_POINTS_NP computes Jacobi quadrature points.
9751 //
9752 // Licensing:
9753 //
9754 // This code is distributed under the GNU LGPL license.
9755 //
9756 // Modified:
9757 //
9758 // 22 June 2009
9759 //
9760 // Author:
9761 //
9762 // John Burkardt
9763 //
9764 // Parameters:
9765 //
9766 // Input, int ORDER, the order.
9767 //
9768 // Input, int NP, the number of parameters.
9769 //
9770 // Input, double P[NP], parameter values.
9771 // P[0] = ALPHA, the exponent of (1-X)
9772 // P[1] = BETA, the exponent of (1+X).
9773 // -1.0 < ALPHA and -1.0 < BETA are required.
9774 //
9775 // Output, double X[ORDER], the abscissas.
9776 //
9777 {
9778  double alpha;
9779  double beta;
9780 
9781  alpha = p[0];
9782  beta = p[1];
9783 
9784  jacobi_compute_points ( order, alpha, beta, x );
9785 
9786  return;
9787 }
9788 //**************************************************************************80
9789 
9790 void SandiaRules::jacobi_compute_weights ( int order, double alpha, double beta,
9791  double w[] )
9792 
9793 //**************************************************************************80
9794 //
9795 // Purpose:
9796 //
9797 // JACOBI_COMPUTE_WEIGHTS computes Jacobi quadrature weights.
9798 //
9799 // Licensing:
9800 //
9801 // This code is distributed under the GNU LGPL license.
9802 //
9803 // Modified:
9804 //
9805 // 14 October 2008
9806 //
9807 // Author:
9808 //
9809 // John Burkardt
9810 //
9811 // Parameters:
9812 //
9813 // Input, int ORDER, the order.
9814 //
9815 // Input, double ALPHA, BETA, the exponents of the (1-X) and (1+X) factors.
9816 //
9817 // Output, double W[ORDER], the weights.
9818 //
9819 {
9820  double *x;
9821 
9822  x = new double[order];
9823 
9824  jacobi_compute ( order, alpha, beta, x, w );
9825 
9826  delete [] x;
9827 
9828  return;
9829 }
9830 //**************************************************************************80
9831 
9832 void SandiaRules::jacobi_compute_weights_np ( int order, int np, double p[], double w[] )
9833 
9834 //**************************************************************************80
9835 //
9836 // Purpose:
9837 //
9838 // JACOBI_COMPUTE_WEIGHTS_NP computes Jacobi quadrature weights.
9839 //
9840 // Licensing:
9841 //
9842 // This code is distributed under the GNU LGPL license.
9843 //
9844 // Modified:
9845 //
9846 // 22 June 2009
9847 //
9848 // Author:
9849 //
9850 // John Burkardt
9851 //
9852 // Parameters:
9853 //
9854 // Input, int ORDER, the order.
9855 //
9856 // Input, int NP, the number of parameters.
9857 //
9858 // Input, double P[NP], parameter values.
9859 // P[0] = ALPHA, the exponent of (1-X)
9860 // P[1] = BETA, the exponent of (1+X).
9861 // -1.0 < ALPHA and -1.0 < BETA are required.
9862 //
9863 // Output, double W[ORDER], the weights.
9864 //
9865 {
9866  double alpha;
9867  double beta;
9868 
9869  alpha = p[0];
9870  beta = p[1];
9871 
9872  jacobi_compute_weights ( order, alpha, beta, w );
9873 
9874  return;
9875 }
9876 //**************************************************************************80
9877 
9878 double SandiaRules::jacobi_integral ( int expon, double alpha, double beta )
9879 
9880 //**************************************************************************80
9881 //
9882 // Purpose:
9883 //
9884 // JACOBI_INTEGRAL integrates a monomial with Jacobi weight.
9885 //
9886 // Discussion:
9887 //
9888 // VALUE = Integral ( -1 <= X <= +1 ) x^EXPON (1-x)^ALPHA (1+x)^BETA dx
9889 //
9890 // Licensing:
9891 //
9892 // This code is distributed under the GNU LGPL license.
9893 //
9894 // Modified:
9895 //
9896 // 08 September 2007
9897 //
9898 // Author:
9899 //
9900 // John Burkardt
9901 //
9902 // Parameters:
9903 //
9904 // Input, int EXPON, the exponent.
9905 //
9906 // Input, double ALPHA, the exponent of (1-X) in the weight factor.
9907 //
9908 // Input, double BETA, the exponent of (1+X) in the weight factor.
9909 //
9910 // Output, double JACOBI_INTEGRAL, the value of the integral.
9911 //
9912 {
9913  double arg1;
9914  double arg2;
9915  double arg3;
9916  double arg4;
9917  double c;
9918  double s;
9919  double value;
9920  double value1;
9921  double value2;
9922 
9923  c = ( double ) ( expon );
9924 
9925  if ( ( expon % 2 ) == 0 )
9926  {
9927  s = +1.0;
9928  }
9929  else
9930  {
9931  s = -1.0;
9932  }
9933 
9934  arg1 = - alpha;
9935  arg2 = 1.0 + c;
9936  arg3 = 2.0 + beta + c;
9937  arg4 = - 1.0;
9938 
9939  value1 = r8_hyper_2f1 ( arg1, arg2, arg3, arg4 );
9940 
9941  arg1 = - beta;
9942  arg2 = 1.0 + c;
9943  arg3 = 2.0 + alpha + c;
9944  arg4 = - 1.0;
9945 
9946  value2 = r8_hyper_2f1 ( arg1, arg2, arg3, arg4 );
9947 
9948  value = r8_gamma ( 1.0 + c ) * (
9949  s * r8_gamma ( 1.0 + beta ) * value1
9950  / r8_gamma ( 2.0 + beta + c )
9951  + r8_gamma ( 1.0 + alpha ) * value2
9952  / r8_gamma ( 2.0 + alpha + c ) );
9953 
9954  return value;
9955 }
9956 //**************************************************************************80
9957 
9958 void SandiaRules::jacobi_ss_compute ( int order, double alpha, double beta, double x[],
9959  double w[] )
9960 
9961 //**************************************************************************80
9962 //
9963 // Purpose:
9964 //
9965 // JACOBI_SS_COMPUTE computes a Jacobi quadrature rule.
9966 //
9967 // Discussion:
9968 //
9969 // The integral:
9970 //
9971 // Integral ( -1 <= X <= 1 ) (1-X)^ALPHA * (1+X)^BETA * F(X) dX
9972 //
9973 // The quadrature rule:
9974 //
9975 // Sum ( 1 <= I <= ORDER ) W(I) * F ( X(I) )
9976 //
9977 // Thanks to Xu Xiang of Fudan University for pointing out that
9978 // an earlier implementation of this routine was incorrect!
9979 //
9980 // Licensing:
9981 //
9982 // This code is distributed under the GNU LGPL license.
9983 //
9984 // Modified:
9985 //
9986 // 18 February 2008
9987 //
9988 // Author:
9989 //
9990 // Original FORTRAN77 version by Arthur Stroud, Don Secrest.
9991 // C++ version by John Burkardt.
9992 //
9993 // Reference:
9994 //
9995 // Arthur Stroud, Don Secrest,
9996 // Gaussian Quadrature Formulas,
9997 // Prentice Hall, 1966,
9998 // LC: QA299.4G3S7.
9999 //
10000 // Parameters:
10001 //
10002 // Input, int ORDER, the order.
10003 // 1 <= ORDER.
10004 //
10005 // Input, double ALPHA, BETA, the exponents of (1-X) and
10006 // (1+X) in the quadrature rule. For simple Legendre quadrature,
10007 // set ALPHA = BETA = 0.0. -1.0 < ALPHA and -1.0 < BETA are required.
10008 //
10009 // Output, double X[ORDER], the abscissas.
10010 //
10011 // Output, double W[ORDER], the weights.
10012 //
10013 {
10014  double an;
10015  double *b;
10016  double bn;
10017  double *c;
10018  double cc;
10019  double delta;
10020  double dp2;
10021  int i;
10022  double p1;
10023  double prod;
10024  double r1;
10025  double r2;
10026  double r3;
10027  double temp;
10028  double x0;
10029 
10030  if ( order < 1 )
10031  {
10032  std::cerr << "\n";
10033  std::cerr << "JACOBI_SS_COMPUTE - Fatal error!\n";
10034  std::cerr << " Illegal value of ORDER = " << order << "\n";
10035  std::exit ( 1 );
10036  }
10037 
10038  b = new double[order];
10039  c = new double[order];
10040 //
10041 // Check ALPHA and BETA.
10042 //
10043  if ( alpha <= -1.0 )
10044  {
10045  std::cerr << "\n";
10046  std::cerr << "JACOBI_SS_COMPUTE - Fatal error!\n";
10047  std::cerr << " -1.0 < ALPHA is required.\n";
10048  std::exit ( 1 );
10049  }
10050 
10051  if ( beta <= -1.0 )
10052  {
10053  std::cerr << "\n";
10054  std::cerr << "JACOBI_SS_COMPUTE - Fatal error!\n";
10055  std::cerr << " -1.0 < BETA is required.\n";
10056  std::exit ( 1 );
10057  }
10058 //
10059 // Set the recursion coefficients.
10060 //
10061  for ( i = 1; i <= order; i++ )
10062  {
10063  if ( alpha + beta == 0.0 || beta - alpha == 0.0 )
10064  {
10065  b[i-1] = 0.0;
10066  }
10067  else
10068  {
10069  b[i-1] = ( alpha + beta ) * ( beta - alpha ) /
10070  ( ( alpha + beta + ( double ) ( 2 * i ) )
10071  * ( alpha + beta + ( double ) ( 2 * i - 2 ) ) );
10072  }
10073 
10074  if ( i == 1 )
10075  {
10076  c[i-1] = 0.0;
10077  }
10078  else
10079  {
10080  c[i-1] = 4.0 * ( double ) ( i - 1 )
10081  * ( alpha + ( double ) ( i - 1 ) )
10082  * ( beta + ( double ) ( i - 1 ) )
10083  * ( alpha + beta + ( double ) ( i - 1 ) ) /
10084  ( ( alpha + beta + ( double ) ( 2 * i - 1 ) )
10085  * std::pow ( alpha + beta + ( double ) ( 2 * i - 2 ), 2 )
10086  * ( alpha + beta + ( double ) ( 2 * i - 3 ) ) );
10087  }
10088  }
10089 
10090  delta = r8_gamma ( alpha + 1.0 )
10091  * r8_gamma ( beta + 1.0 )
10092  / r8_gamma ( alpha + beta + 2.0 );
10093 
10094  prod = 1.0;
10095  for ( i = 2; i <= order; i++ )
10096  {
10097  prod = prod * c[i-1];
10098  }
10099  cc = delta * std::pow ( 2.0, alpha + beta + 1.0 ) * prod;
10100 
10101  for ( i = 1; i <= order; i++ )
10102  {
10103  if ( i == 1 )
10104  {
10105  an = alpha / ( double ) ( order );
10106  bn = beta / ( double ) ( order );
10107 
10108  r1 = ( 1.0 + alpha )
10109  * ( 2.78 / ( 4.0 + ( double ) ( order * order ) )
10110  + 0.768 * an / ( double ) ( order ) );
10111 
10112  r2 = 1.0 + 1.48 * an + 0.96 * bn
10113  + 0.452 * an * an + 0.83 * an * bn;
10114 
10115  x0 = ( r2 - r1 ) / r2;
10116  }
10117  else if ( i == 2 )
10118  {
10119  r1 = ( 4.1 + alpha ) /
10120  ( ( 1.0 + alpha ) * ( 1.0 + 0.156 * alpha ) );
10121 
10122  r2 = 1.0 + 0.06 * ( ( double ) ( order ) - 8.0 ) *
10123  ( 1.0 + 0.12 * alpha ) / ( double ) ( order );
10124 
10125  r3 = 1.0 + 0.012 * beta *
10126  ( 1.0 + 0.25 * r8_abs ( alpha ) ) / ( double ) ( order );
10127 
10128  x0 = x0 - r1 * r2 * r3 * ( 1.0 - x0 );
10129  }
10130  else if ( i == 3 )
10131  {
10132  r1 = ( 1.67 + 0.28 * alpha ) / ( 1.0 + 0.37 * alpha );
10133 
10134  r2 = 1.0 + 0.22 * ( ( double ) ( order ) - 8.0 )
10135  / ( double ) ( order );
10136 
10137  r3 = 1.0 + 8.0 * beta /
10138  ( ( 6.28 + beta ) * ( double ) ( order * order ) );
10139 
10140  x0 = x0 - r1 * r2 * r3 * ( x[0] - x0 );
10141  }
10142  else if ( i < order - 1 )
10143  {
10144  x0 = 3.0 * x[i-2] - 3.0 * x[i-3] + x[i-4];
10145  }
10146  else if ( i == order - 1 )
10147  {
10148  r1 = ( 1.0 + 0.235 * beta ) / ( 0.766 + 0.119 * beta );
10149 
10150  r2 = 1.0 / ( 1.0 + 0.639
10151  * ( ( double ) ( order ) - 4.0 )
10152  / ( 1.0 + 0.71 * ( ( double ) ( order ) - 4.0 ) ) );
10153 
10154  r3 = 1.0 / ( 1.0 + 20.0 * alpha / ( ( 7.5 + alpha ) *
10155  ( double ) ( order * order ) ) );
10156 
10157  x0 = x0 + r1 * r2 * r3 * ( x0 - x[i-3] );
10158  }
10159  else if ( i == order )
10160  {
10161  r1 = ( 1.0 + 0.37 * beta ) / ( 1.67 + 0.28 * beta );
10162 
10163  r2 = 1.0 /
10164  ( 1.0 + 0.22 * ( ( double ) ( order ) - 8.0 )
10165  / ( double ) ( order ) );
10166 
10167  r3 = 1.0 / ( 1.0 + 8.0 * alpha /
10168  ( ( 6.28 + alpha ) * ( double ) ( order * order ) ) );
10169 
10170  x0 = x0 + r1 * r2 * r3 * ( x0 - x[i-3] );
10171  }
10172 
10173  jacobi_ss_root ( &x0, order, alpha, beta, &dp2, &p1, b, c );
10174 
10175  x[i-1] = x0;
10176  w[i-1] = cc / ( dp2 * p1 );
10177  }
10178 //
10179 // Reverse the order of the values.
10180 //
10181  for ( i = 1; i <= order/2; i++ )
10182  {
10183  temp = x[i-1];
10184  x[i-1] = x[order-i];
10185  x[order-i] = temp;
10186  }
10187 
10188  for ( i = 1; i <=order/2; i++ )
10189  {
10190  temp = w[i-1];
10191  w[i-1] = w[order-i];
10192  w[order-i] = temp;
10193  }
10194 
10195  delete [] b;
10196  delete [] c;
10197 
10198  return;
10199 }
10200 //**************************************************************************80
10201 
10202 void SandiaRules::jacobi_ss_recur ( double *p2, double *dp2, double *p1, double x, int order,
10203  double alpha, double beta, double b[], double c[] )
10204 
10205 //**************************************************************************80
10206 //
10207 // Purpose:
10208 //
10209 // JACOBI_SS_RECUR evaluates a Jacobi polynomial.
10210 //
10211 // Licensing:
10212 //
10213 // This code is distributed under the GNU LGPL license.
10214 //
10215 // Modified:
10216 //
10217 // 18 February 2008
10218 //
10219 // Author:
10220 //
10221 // Original FORTRAN77 version by Arthur Stroud, Don Secrest.
10222 // C++ version by John Burkardt.
10223 //
10224 // Reference:
10225 //
10226 // Arthur Stroud, Don Secrest,
10227 // Gaussian Quadrature Formulas,
10228 // Prentice Hall, 1966,
10229 // LC: QA299.4G3S7.
10230 //
10231 // Parameters:
10232 //
10233 // Output, double *P2, the value of J(ORDER)(X).
10234 //
10235 // Output, double *DP2, the value of J'(ORDER)(X).
10236 //
10237 // Output, double *P1, the value of J(ORDER-1)(X).
10238 //
10239 // Input, double X, the point at which polynomials are evaluated.
10240 //
10241 // Input, int ORDER, the order of the polynomial.
10242 //
10243 // Input, double ALPHA, BETA, the exponents of (1-X) and
10244 // (1+X) in the quadrature rule.
10245 //
10246 // Input, double B[ORDER], C[ORDER], the recursion coefficients.
10247 //
10248 {
10249  double dp0;
10250  double dp1;
10251  int i;
10252  double p0;
10253 
10254  *p1 = 1.0;
10255  dp1 = 0.0;
10256 
10257  *p2 = x + ( alpha - beta ) / ( alpha + beta + 2.0 );
10258  *dp2 = 1.0;
10259 
10260  for ( i = 2; i <= order; i++ )
10261  {
10262  p0 = *p1;
10263  dp0 = dp1;
10264 
10265  *p1 = *p2;
10266  dp1 = *dp2;
10267 
10268  *p2 = ( x - b[i-1] ) * ( *p1 ) - c[i-1] * p0;
10269  *dp2 = ( x - b[i-1] ) * dp1 + ( *p1 ) - c[i-1] * dp0;
10270  }
10271  return;
10272 }
10273 //**************************************************************************80
10274 
10275 void SandiaRules::jacobi_ss_root ( double *x, int order, double alpha, double beta,
10276  double *dp2, double *p1, double b[], double c[] )
10277 
10278 //**************************************************************************80
10279 //
10280 // Purpose:
10281 //
10282 // JACOBI_SS_ROOT improves an approximate root of a Jacobi polynomial.
10283 //
10284 // Licensing:
10285 //
10286 // This code is distributed under the GNU LGPL license.
10287 //
10288 // Modified:
10289 //
10290 // 18 February 2008
10291 //
10292 // Author:
10293 //
10294 // Original FORTRAN77 version by Arthur Stroud, Don Secrest.
10295 // C++ version by John Burkardt.
10296 //
10297 // Reference:
10298 //
10299 // Arthur Stroud, Don Secrest,
10300 // Gaussian Quadrature Formulas,
10301 // Prentice Hall, 1966,
10302 // LC: QA299.4G3S7.
10303 //
10304 // Parameters:
10305 //
10306 // Input/output, double *X, the approximate root, which
10307 // should be improved on output.
10308 //
10309 // Input, int ORDER, the order of the polynomial.
10310 //
10311 // Input, double ALPHA, BETA, the exponents of (1-X) and
10312 // (1+X) in the quadrature rule.
10313 //
10314 // Output, double *DP2, the value of J'(ORDER)(X).
10315 //
10316 // Output, double *P1, the value of J(ORDER-1)(X).
10317 //
10318 // Input, double B[ORDER], C[ORDER], the recursion coefficients.
10319 //
10320 {
10321  double d;
10322  double eps;
10323  double p2;
10324  int step;
10325  int step_max = 10;
10326 
10327  eps = r8_epsilon ( );
10328 
10329  for ( step = 1; step <= step_max; step++ )
10330  {
10331  jacobi_ss_recur ( &p2, dp2, p1, *x, order, alpha, beta, b, c );
10332 
10333  d = p2 / ( *dp2 );
10334  *x = *x - d;
10335 
10336  if ( r8_abs ( d ) <= eps * ( r8_abs ( *x ) + 1.0 ) )
10337  {
10338  return;
10339  }
10340  }
10341  return;
10342 }
10343 //**************************************************************************80
10344 
10345 void SandiaRules::laguerre_compute ( int n, double x[], double w[] )
10346 
10347 //**************************************************************************80
10348 //
10349 // Purpose:
10350 //
10351 // LAGUERRE_COMPUTE: Laguerre quadrature rule by the Elhay-Kautsky method.
10352 //
10353 // Licensing:
10354 //
10355 // This code is distributed under the GNU LGPL license.
10356 //
10357 // Modified:
10358 //
10359 // 23 April 2011
10360 //
10361 // Author:
10362 //
10363 // Original FORTRAN77 version by Sylvan Elhay, Jaroslav Kautsky.
10364 // C++ version by John Burkardt.
10365 //
10366 // Reference:
10367 //
10368 // Sylvan Elhay, Jaroslav Kautsky,
10369 // Algorithm 655: IQPACK, FORTRAN Subroutines for the Weights of
10370 // Interpolatory Quadrature,
10371 // ACM Transactions on Mathematical Software,
10372 // Volume 13, Number 4, December 1987, pages 399-415.
10373 //
10374 // Parameters:
10375 //
10376 // Input, int N, the order.
10377 //
10378 // Output, double X[N], the abscissas.
10379 //
10380 // Output, double W[N], the weights.
10381 //
10382 {
10383  double *bj;
10384  int i;
10385  double zemu;
10386 //
10387 // Define the zero-th moment.
10388 //
10389  zemu = 1.0;
10390 //
10391 // Define the Jacobi matrix.
10392 //
10393  bj = new double[n];
10394 
10395  for ( i = 0; i < n; i++ )
10396  {
10397  bj[i] = ( double ) ( i + 1 );
10398  }
10399 
10400  for ( i = 0; i < n; i++ )
10401  {
10402  x[i] = ( double ) ( 2 * i + 1 );
10403  }
10404 
10405  w[0] = std::sqrt ( zemu );
10406 
10407  for ( i = 1; i < n; i++ )
10408  {
10409  w[i] = 0.0;
10410  }
10411 //
10412 // Diagonalize the Jacobi matrix.
10413 //
10414  imtqlx ( n, x, bj, w );
10415 
10416  for ( i = 0; i < n; i++ )
10417  {
10418  w[i] = w[i] * w[i];
10419  }
10420 
10421  delete [] bj;
10422 
10423  return;
10424 }
10425 //**************************************************************************80
10426 
10427 void SandiaRules::laguerre_compute_np ( int order, int np, double p[], double x[],
10428  double w[] )
10429 
10430 //**************************************************************************80
10431 //
10432 // Purpose:
10433 //
10434 // LAGUERRE_COMPUTE_NP computes a Laguerre quadrature rule.
10435 //
10436 // Discussion:
10437 //
10438 // The integral:
10439 //
10440 // Integral ( 0 <= X < +oo ) exp ( - X ) * F(X) dX
10441 //
10442 // The quadrature rule:
10443 //
10444 // Sum ( 1 <= I <= ORDER ) W(I) * F ( X(I) )
10445 //
10446 // The integral:
10447 //
10448 // Integral ( A <= X < +oo ) F(X) dX
10449 //
10450 // The quadrature rule:
10451 //
10452 // Sum ( 1 <= I <= ORDER ) W(I) * exp ( X(I) ) * F ( X(I) )
10453 //
10454 // Licensing:
10455 //
10456 // This code is distributed under the GNU LGPL license.
10457 //
10458 // Modified:
10459 //
10460 // 22 June 2009
10461 //
10462 // Author:
10463 //
10464 // Original FORTRAN77 version by Arthur Stroud, Don Secrest.
10465 // C++ version by John Burkardt.
10466 //
10467 // Reference:
10468 //
10469 // Arthur Stroud, Don Secrest,
10470 // Gaussian Quadrature Formulas,
10471 // Prentice Hall, 1966,
10472 // LC: QA299.4G3S7.
10473 //
10474 // Parameters:
10475 //
10476 // Input, int ORDER, the order.
10477 // 1 <= ORDER.
10478 //
10479 // Input, int NP, the number of parameters.
10480 //
10481 // Input, double P[NP], parameters which are not needed by this function.
10482 //
10483 // Output, double X[ORDER], the abscissas.
10484 //
10485 // Output, double W[ORDER], the weights.
10486 //
10487 {
10488  laguerre_compute ( order, x, w );
10489 
10490  return;
10491 }
10492 //**************************************************************************80
10493 
10494 void SandiaRules::laguerre_compute_points ( int order, double x[] )
10495 
10496 //**************************************************************************80
10497 //
10498 // Purpose:
10499 //
10500 // LAGUERRE_COMPUTE_POINTS computes Laguerre quadrature points.
10501 //
10502 // Licensing:
10503 //
10504 // This code is distributed under the GNU LGPL license.
10505 //
10506 // Modified:
10507 //
10508 // 13 June 2009
10509 //
10510 // Author:
10511 //
10512 // John Burkardt
10513 //
10514 // Parameters:
10515 //
10516 // Input, int ORDER, the order.
10517 //
10518 // Output, double X[ORDER], the abscissas.
10519 //
10520 {
10521  double *w;
10522 
10523  w = new double[order];
10524 
10525  laguerre_compute ( order, x, w );
10526 
10527  delete [] w;
10528 
10529  return;
10530 }
10531 //**************************************************************************80
10532 
10533 void SandiaRules::laguerre_compute_points_np ( int order, int np, double p[], double x[] )
10534 
10535 //**************************************************************************80
10536 //
10537 // Purpose:
10538 //
10539 // LAGUERRE_COMPUTE_POINTS_NP computes Laguerre quadrature points.
10540 //
10541 // Licensing:
10542 //
10543 // This code is distributed under the GNU LGPL license.
10544 //
10545 // Modified:
10546 //
10547 // 22 June 2009
10548 //
10549 // Author:
10550 //
10551 // John Burkardt
10552 //
10553 // Parameters:
10554 //
10555 // Input, int ORDER, the order.
10556 //
10557 // Input, int NP, the number of parameters.
10558 //
10559 // Input, double P[NP], parameters which are not needed by this function.
10560 //
10561 // Output, double X[ORDER], the abscissas.
10562 //
10563 {
10564  laguerre_compute_points ( order, x );
10565 
10566  return;
10567 }
10568 //**************************************************************************80
10569 
10570 void SandiaRules::laguerre_compute_weights ( int order, double w[] )
10571 
10572 //**************************************************************************80
10573 //
10574 // Purpose:
10575 //
10576 // LAGUERRE_COMPUTE_WEIGHTS computes Laguerre quadrature weights.
10577 //
10578 // Licensing:
10579 //
10580 // This code is distributed under the GNU LGPL license.
10581 //
10582 // Modified:
10583 //
10584 // 13 June 2009
10585 //
10586 // Author:
10587 //
10588 // John Burkardt
10589 //
10590 // Parameters:
10591 //
10592 // Input, int ORDER, the order.
10593 //
10594 // Output, double W[ORDER], the weights.
10595 //
10596 {
10597  double *x;
10598 
10599  x = new double[order];
10600 
10601  laguerre_compute ( order, x, w );
10602 
10603  delete [] x;
10604 
10605  return;
10606 }
10607 //**************************************************************************80
10608 
10609 void SandiaRules::laguerre_compute_weights_np ( int order, int np, double p[], double w[] )
10610 
10611 //**************************************************************************80
10612 //
10613 // Purpose:
10614 //
10615 // LAGUERRE_COMPUTE_WEIGHTS_NP computes Laguerre quadrature weights.
10616 //
10617 // Licensing:
10618 //
10619 // This code is distributed under the GNU LGPL license.
10620 //
10621 // Modified:
10622 //
10623 // 22 June 2009
10624 //
10625 // Author:
10626 //
10627 // John Burkardt
10628 //
10629 // Parameters:
10630 //
10631 // Input, int ORDER, the order.
10632 //
10633 // Input, int NP, the number of parameters.
10634 //
10635 // Input, double P[NP], parameters which are not needed by this function.
10636 //
10637 // Output, double W[ORDER], the weights.
10638 //
10639 {
10640  laguerre_compute_weights ( order, w );
10641 
10642  return;
10643 }
10644 //**************************************************************************80
10645 
10647 
10648 //**************************************************************************80
10649 //
10650 // Purpose:
10651 //
10652 // LAGUERRE_INTEGRAL evaluates a monomial Laguerre integral.
10653 //
10654 // Discussion:
10655 //
10656 // The integral:
10657 //
10658 // integral ( 0 <= x < +oo ) x^n * exp ( -x ) dx
10659 //
10660 // Licensing:
10661 //
10662 // This code is distributed under the GNU LGPL license.
10663 //
10664 // Modified:
10665 //
10666 // 19 February 2008
10667 //
10668 // Author:
10669 //
10670 // John Burkardt
10671 //
10672 // Parameters:
10673 //
10674 // Input, int EXPON, the exponent.
10675 // 0 <= EXPON.
10676 //
10677 // Output, double EXACT, the value of the integral.
10678 //
10679 {
10680  double exact;
10681 
10682  exact = r8_factorial ( expon );
10683 
10684  return exact;
10685 }
10686 //**************************************************************************80
10687 
10688 void SandiaRules::laguerre_lookup ( int n, double x[], double w[] )
10689 
10690 //**************************************************************************80
10691 //
10692 // Purpose:
10693 //
10694 // LAGUERRE_LOOKUP looks up abscissas and weights for Laguerre quadrature.
10695 //
10696 // Discussion:
10697 //
10698 // The abscissas are the zeroes of the Laguerre polynomial L(N)(X).
10699 //
10700 // The integral:
10701 //
10702 // Integral ( 0 <= X < +oo ) exp ( -X ) * F(X) dX
10703 //
10704 // The quadrature rule:
10705 //
10706 // Sum ( 1 <= I <= N ) W(I) * f ( X(I) )
10707 //
10708 // The integral:
10709 //
10710 // Integral ( 0 <= X < +oo ) F(X) dX
10711 //
10712 // The quadrature rule:
10713 //
10714 // Sum ( 1 <= I <= N ) W(I) * exp ( X(I) ) * f ( X(I) )
10715 //
10716 // Mathematica can numerically estimate the abscissas for the
10717 // n-th order polynomial to p digits of precision by the command:
10718 //
10719 // NSolve [ LaguerreL[n,x] == 0, x, p ]
10720 //
10721 // Licensing:
10722 //
10723 // This code is distributed under the GNU LGPL license.
10724 //
10725 // Modified:
10726 //
10727 // 27 April 2010
10728 //
10729 // Author:
10730 //
10731 // John Burkardt
10732 //
10733 // Reference:
10734 //
10735 // Milton Abramowitz, Irene Stegun,
10736 // Handbook of Mathematical Functions,
10737 // National Bureau of Standards, 1964,
10738 // ISBN: 0-486-61272-4,
10739 // LC: QA47.A34.
10740 //
10741 // Vladimir Krylov,
10742 // Approximate Calculation of Integrals,
10743 // Dover, 2006,
10744 // ISBN: 0486445798,
10745 // LC: QA311.K713.
10746 //
10747 // Arthur Stroud, Don Secrest,
10748 // Gaussian Quadrature Formulas,
10749 // Prentice Hall, 1966,
10750 // LC: QA299.4G3S7.
10751 //
10752 // Stephen Wolfram,
10753 // The Mathematica Book,
10754 // Fourth Edition,
10755 // Cambridge University Press, 1999,
10756 // ISBN: 0-521-64314-7,
10757 // LC: QA76.95.W65.
10758 //
10759 // Daniel Zwillinger, editor,
10760 // CRC Standard Mathematical Tables and Formulae,
10761 // 30th Edition,
10762 // CRC Press, 1996,
10763 // ISBN: 0-8493-2479-3.
10764 //
10765 // Parameters:
10766 //
10767 // Input, int N, the order.
10768 // N must be between 1 and 20.
10769 //
10770 // Output, double X[N], the abscissas.
10771 //
10772 // Output, double W[N], the weights.
10773 //
10774 {
10775  laguerre_lookup_points ( n, x );
10776 
10777  laguerre_lookup_weights ( n, w );
10778 
10779  return;
10780 }
10781 //**************************************************************************80
10782 
10783 void SandiaRules::laguerre_lookup_points ( int n, double x[] )
10784 
10785 //**************************************************************************80
10786 //
10787 // Purpose:
10788 //
10789 // LAGUERRE_LOOKUP_POINTS looks up abscissas for Laguerre quadrature.
10790 //
10791 // Licensing:
10792 //
10793 // This code is distributed under the GNU LGPL license.
10794 //
10795 // Modified:
10796 //
10797 // 27 April 2010
10798 //
10799 // Author:
10800 //
10801 // John Burkardt
10802 //
10803 // Reference:
10804 //
10805 // Milton Abramowitz, Irene Stegun,
10806 // Handbook of Mathematical Functions,
10807 // National Bureau of Standards, 1964,
10808 // ISBN: 0-486-61272-4,
10809 // LC: QA47.A34.
10810 //
10811 // Vladimir Krylov,
10812 // Approximate Calculation of Integrals,
10813 // Dover, 2006,
10814 // ISBN: 0486445798,
10815 // LC: QA311.K713.
10816 //
10817 // Arthur Stroud, Don Secrest,
10818 // Gaussian Quadrature Formulas,
10819 // Prentice Hall, 1966,
10820 // LC: QA299.4G3S7.
10821 //
10822 // Stephen Wolfram,
10823 // The Mathematica Book,
10824 // Fourth Edition,
10825 // Cambridge University Press, 1999,
10826 // ISBN: 0-521-64314-7,
10827 // LC: QA76.95.W65.
10828 //
10829 // Daniel Zwillinger, editor,
10830 // CRC Standard Mathematical Tables and Formulae,
10831 // 30th Edition,
10832 // CRC Press, 1996,
10833 // ISBN: 0-8493-2479-3.
10834 //
10835 // Parameters:
10836 //
10837 // Input, int N, the order.
10838 // N must be between 1 and 20.
10839 //
10840 // Output, double X[N], the abscissas.
10841 //
10842 {
10843  if ( n == 1 )
10844  {
10845  x[0] = 1.00000000000000000000000000000E+00;
10846  }
10847  else if ( n == 2 )
10848  {
10849  x[0] = 0.585786437626904951198311275790E+00;
10850  x[1] = 3.41421356237309504880168872421E+00;
10851  }
10852  else if ( n == 3 )
10853  {
10854  x[0] = 0.415774556783479083311533873128E+00;
10855  x[1] = 2.29428036027904171982205036136E+00;
10856  x[2] = 6.28994508293747919686641576551E+00;
10857  }
10858  else if ( n == 4 )
10859  {
10860  x[0] = 0.322547689619392311800361459104E+00;
10861  x[1] = 1.74576110115834657568681671252E+00;
10862  x[2] = 4.53662029692112798327928538496E+00;
10863  x[3] = 9.39507091230113312923353644342E+00;
10864  }
10865  else if ( n == 5 )
10866  {
10867  x[0] = 0.263560319718140910203061943361E+00;
10868  x[1] = 1.41340305910651679221840798019E+00;
10869  x[2] = 3.59642577104072208122318658878E+00;
10870  x[3] = 7.08581000585883755692212418111E+00;
10871  x[4] = 12.6408008442757826594332193066E+00;
10872  }
10873  else if ( n == 6 )
10874  {
10875  x[0] = 0.222846604179260689464354826787E+00;
10876  x[1] = 1.18893210167262303074315092194E+00;
10877  x[2] = 2.99273632605931407769132528451E+00;
10878  x[3] = 5.77514356910451050183983036943E+00;
10879  x[4] = 9.83746741838258991771554702994E+00;
10880  x[5] = 15.9828739806017017825457915674E+00;
10881  }
10882  else if ( n == 7 )
10883  {
10884  x[0] = 0.193043676560362413838247885004E+00;
10885  x[1] = 1.02666489533919195034519944317E+00;
10886  x[2] = 2.56787674495074620690778622666E+00;
10887  x[3] = 4.90035308452648456810171437810E+00;
10888  x[4] = 8.18215344456286079108182755123E+00;
10889  x[5] = 12.7341802917978137580126424582E+00;
10890  x[6] = 19.3957278622625403117125820576E+00;
10891  }
10892  else if ( n == 8 )
10893  {
10894  x[0] = 0.170279632305100999788861856608E+00;
10895  x[1] = 0.903701776799379912186020223555E+00;
10896  x[2] = 2.25108662986613068930711836697E+00;
10897  x[3] = 4.26670017028765879364942182690E+00;
10898  x[4] = 7.04590540239346569727932548212E+00;
10899  x[5] = 10.7585160101809952240599567880E+00;
10900  x[6] = 15.7406786412780045780287611584E+00;
10901  x[7] = 22.8631317368892641057005342974E+00;
10902  }
10903  else if ( n == 9 )
10904  {
10905  x[0] = 0.152322227731808247428107073127E+00;
10906  x[1] = 0.807220022742255847741419210952E+00;
10907  x[2] = 2.00513515561934712298303324701E+00;
10908  x[3] = 3.78347397333123299167540609364E+00;
10909  x[4] = 6.20495677787661260697353521006E+00;
10910  x[5] = 9.37298525168757620180971073215E+00;
10911  x[6] = 13.4662369110920935710978818397E+00;
10912  x[7] = 18.8335977889916966141498992996E+00;
10913  x[8] = 26.3740718909273767961410072937E+00;
10914  }
10915  else if ( n == 10 )
10916  {
10917  x[0] = 0.137793470540492430830772505653E+00;
10918  x[1] = 0.729454549503170498160373121676E+00;
10919  x[2] = 1.80834290174031604823292007575E+00;
10920  x[3] = 3.40143369785489951448253222141E+00;
10921  x[4] = 5.55249614006380363241755848687E+00;
10922  x[5] = 8.33015274676449670023876719727E+00;
10923  x[6] = 11.8437858379000655649185389191E+00;
10924  x[7] = 16.2792578313781020995326539358E+00;
10925  x[8] = 21.9965858119807619512770901956E+00;
10926  x[9] = 29.9206970122738915599087933408E+00;
10927  }
10928  else if ( n == 11 )
10929  {
10930  x[0] = 0.125796442187967522675794577516E+00;
10931  x[1] = 0.665418255839227841678127839420E+00;
10932  x[2] = 1.64715054587216930958700321365E+00;
10933  x[3] = 3.09113814303525495330195934259E+00;
10934  x[4] = 5.02928440157983321236999508366E+00;
10935  x[5] = 7.50988786380661681941099714450E+00;
10936  x[6] = 10.6059509995469677805559216457E+00;
10937  x[7] = 14.4316137580641855353200450349E+00;
10938  x[8] = 19.1788574032146786478174853989E+00;
10939  x[9] = 25.2177093396775611040909447797E+00;
10940  x[10] = 33.4971928471755372731917259395E+00;
10941  }
10942  else if ( n == 12 )
10943  {
10944  x[0] = 0.115722117358020675267196428240E+00;
10945  x[1] = 0.611757484515130665391630053042E+00;
10946  x[2] = 1.51261026977641878678173792687E+00;
10947  x[3] = 2.83375133774350722862747177657E+00;
10948  x[4] = 4.59922763941834848460572922485E+00;
10949  x[5] = 6.84452545311517734775433041849E+00;
10950  x[6] = 9.62131684245686704391238234923E+00;
10951  x[7] = 13.0060549933063477203460524294E+00;
10952  x[8] = 17.1168551874622557281840528008E+00;
10953  x[9] = 22.1510903793970056699218950837E+00;
10954  x[10] = 28.4879672509840003125686072325E+00;
10955  x[11] = 37.0991210444669203366389142764E+00;
10956  }
10957  else if ( n == 13 )
10958  {
10959  x[0] = 0.107142388472252310648493376977E+00;
10960  x[1] = 0.566131899040401853406036347177E+00;
10961  x[2] = 1.39856433645101971792750259921E+00;
10962  x[3] = 2.61659710840641129808364008472E+00;
10963  x[4] = 4.23884592901703327937303389926E+00;
10964  x[5] = 6.29225627114007378039376523025E+00;
10965  x[6] = 8.81500194118697804733348868036E+00;
10966  x[7] = 11.8614035888112425762212021880E+00;
10967  x[8] = 15.5107620377037527818478532958E+00;
10968  x[9] = 19.8846356638802283332036594634E+00;
10969  x[10] = 25.1852638646777580842970297823E+00;
10970  x[11] = 31.8003863019472683713663283526E+00;
10971  x[12] = 40.7230086692655795658979667001E+00;
10972  }
10973  else if ( n == 14 )
10974  {
10975  x[0] = 0.0997475070325975745736829452514E+00;
10976  x[1] = 0.526857648851902896404583451502E+00;
10977  x[2] = 1.30062912125149648170842022116E+00;
10978  x[3] = 2.43080107873084463616999751038E+00;
10979  x[4] = 3.93210282229321888213134366778E+00;
10980  x[5] = 5.82553621830170841933899983898E+00;
10981  x[6] = 8.14024014156514503005978046052E+00;
10982  x[7] = 10.9164995073660188408130510904E+00;
10983  x[8] = 14.2108050111612886831059780825E+00;
10984  x[9] = 18.1048922202180984125546272083E+00;
10985  x[10] = 22.7233816282696248232280886985E+00;
10986  x[11] = 28.2729817232482056954158923218E+00;
10987  x[12] = 35.1494436605924265828643121364E+00;
10988  x[13] = 44.3660817111174230416312423666E+00;
10989  }
10990  else if ( n == 15 )
10991  {
10992  x[0] = 0.0933078120172818047629030383672E+00;
10993  x[1] = 0.492691740301883908960101791412E+00;
10994  x[2] = 1.21559541207094946372992716488E+00;
10995  x[3] = 2.26994952620374320247421741375E+00;
10996  x[4] = 3.66762272175143727724905959436E+00;
10997  x[5] = 5.42533662741355316534358132596E+00;
10998  x[6] = 7.56591622661306786049739555812E+00;
10999  x[7] = 10.1202285680191127347927394568E+00;
11000  x[8] = 13.1302824821757235640991204176E+00;
11001  x[9] = 16.6544077083299578225202408430E+00;
11002  x[10] = 20.7764788994487667729157175676E+00;
11003  x[11] = 25.6238942267287801445868285977E+00;
11004  x[12] = 31.4075191697539385152432196202E+00;
11005  x[13] = 38.5306833064860094162515167595E+00;
11006  x[14] = 48.0260855726857943465734308508E+00;
11007  }
11008  else if ( n == 16 )
11009  {
11010  x[0] = 0.0876494104789278403601980973401E+00;
11011  x[1] = 0.462696328915080831880838260664E+00;
11012  x[2] = 1.14105777483122685687794501811E+00;
11013  x[3] = 2.12928364509838061632615907066E+00;
11014  x[4] = 3.43708663389320664523510701675E+00;
11015  x[5] = 5.07801861454976791292305830814E+00;
11016  x[6] = 7.07033853504823413039598947080E+00;
11017  x[7] = 9.43831433639193878394724672911E+00;
11018  x[8] = 12.2142233688661587369391246088E+00;
11019  x[9] = 15.4415273687816170767647741622E+00;
11020  x[10] = 19.1801568567531348546631409497E+00;
11021  x[11] = 23.5159056939919085318231872752E+00;
11022  x[12] = 28.5787297428821403675206137099E+00;
11023  x[13] = 34.5833987022866258145276871778E+00;
11024  x[14] = 41.9404526476883326354722330252E+00;
11025  x[15] = 51.7011603395433183643426971197E+00;
11026  }
11027  else if ( n == 17 )
11028  {
11029  x[0] = 0.0826382147089476690543986151980E+00;
11030  x[1] = 0.436150323558710436375959029847E+00;
11031  x[2] = 1.07517657751142857732980316755E+00;
11032  x[3] = 2.00519353164923224070293371933E+00;
11033  x[4] = 3.23425612404744376157380120696E+00;
11034  x[5] = 4.77351351370019726480932076262E+00;
11035  x[6] = 6.63782920536495266541643929703E+00;
11036  x[7] = 8.84668551116980005369470571184E+00;
11037  x[8] = 11.4255293193733525869726151469E+00;
11038  x[9] = 14.4078230374813180021982874959E+00;
11039  x[10] = 17.8382847307011409290658752412E+00;
11040  x[11] = 21.7782682577222653261749080522E+00;
11041  x[12] = 26.3153178112487997766149598369E+00;
11042  x[13] = 31.5817716804567331343908517497E+00;
11043  x[14] = 37.7960938374771007286092846663E+00;
11044  x[15] = 45.3757165339889661829258363215E+00;
11045  x[16] = 55.3897517898396106640900199790E+00;
11046  }
11047  else if ( n == 18 )
11048  {
11049  x[0] = 0.0781691666697054712986747615334E+00;
11050  x[1] = 0.412490085259129291039101536536E+00;
11051  x[2] = 1.01652017962353968919093686187E+00;
11052  x[3] = 1.89488850996976091426727831954E+00;
11053  x[4] = 3.05435311320265975115241130719E+00;
11054  x[5] = 4.50420553888989282633795571455E+00;
11055  x[6] = 6.25672507394911145274209116326E+00;
11056  x[7] = 8.32782515660563002170470261564E+00;
11057  x[8] = 10.7379900477576093352179033397E+00;
11058  x[9] = 13.5136562075550898190863812108E+00;
11059  x[10] = 16.6893062819301059378183984163E+00;
11060  x[11] = 20.3107676262677428561313764553E+00;
11061  x[12] = 24.4406813592837027656442257980E+00;
11062  x[13] = 29.1682086625796161312980677805E+00;
11063  x[14] = 34.6279270656601721454012429438E+00;
11064  x[15] = 41.0418167728087581392948614284E+00;
11065  x[16] = 48.8339227160865227486586093290E+00;
11066  x[17] = 59.0905464359012507037157810181E+00;
11067  }
11068  else if ( n == 19 )
11069  {
11070  x[0] = 0.0741587837572050877131369916024E+00;
11071  x[1] = 0.391268613319994607337648350299E+00;
11072  x[2] = 0.963957343997958058624878377130E+00;
11073  x[3] = 1.79617558206832812557725825252E+00;
11074  x[4] = 2.89365138187378399116494713237E+00;
11075  x[5] = 4.26421553962776647436040018167E+00;
11076  x[6] = 5.91814156164404855815360191408E+00;
11077  x[7] = 7.86861891533473373105668358176E+00;
11078  x[8] = 10.1324237168152659251627415800E+00;
11079  x[9] = 12.7308814638423980045092979656E+00;
11080  x[10] = 15.6912783398358885454136069861E+00;
11081  x[11] = 19.0489932098235501532136429732E+00;
11082  x[12] = 22.8508497608294829323930586693E+00;
11083  x[13] = 27.1606693274114488789963947149E+00;
11084  x[14] = 32.0691222518622423224362865906E+00;
11085  x[15] = 37.7129058012196494770647508283E+00;
11086  x[16] = 44.3173627958314961196067736013E+00;
11087  x[17] = 52.3129024574043831658644222420E+00;
11088  x[18] = 62.8024231535003758413504690673E+00;
11089  }
11090  else if ( n == 20 )
11091  {
11092  x[0] = 0.0705398896919887533666890045842E+00;
11093  x[1] = 0.372126818001611443794241388761E+00;
11094  x[2] = 0.916582102483273564667716277074E+00;
11095  x[3] = 1.70730653102834388068768966741E+00;
11096  x[4] = 2.74919925530943212964503046049E+00;
11097  x[5] = 4.04892531385088692237495336913E+00;
11098  x[6] = 5.61517497086161651410453988565E+00;
11099  x[7] = 7.45901745367106330976886021837E+00;
11100  x[8] = 9.59439286958109677247367273428E+00;
11101  x[9] = 12.0388025469643163096234092989E+00;
11102  x[10] = 14.8142934426307399785126797100E+00;
11103  x[11] = 17.9488955205193760173657909926E+00;
11104  x[12] = 21.4787882402850109757351703696E+00;
11105  x[13] = 25.4517027931869055035186774846E+00;
11106  x[14] = 29.9325546317006120067136561352E+00;
11107  x[15] = 35.0134342404790000062849359067E+00;
11108  x[16] = 40.8330570567285710620295677078E+00;
11109  x[17] = 47.6199940473465021399416271529E+00;
11110  x[18] = 55.8107957500638988907507734445E+00;
11111  x[19] = 66.5244165256157538186403187915E+00;
11112  }
11113  else
11114  {
11115  std::cerr << "\n";
11116  std::cerr << "LAGUERRE_LOOKUP_POINTS - Fatal error!\n";
11117  std::cerr << " Illegal value of N = " << n << "\n";
11118  std::cerr << " Legal values are 1 through 20.\n";
11119  std::exit ( 1 );
11120  }
11121 
11122  return;
11123 }
11124 //**************************************************************************80
11125 
11126 void SandiaRules::laguerre_lookup_weights ( int n, double w[] )
11127 
11128 //**************************************************************************80
11129 //
11130 // Purpose:
11131 //
11132 // LAGUERRE_LOOKUP_WEIGHTS looks up weights for Laguerre quadrature.
11133 //
11134 // Licensing:
11135 //
11136 // This code is distributed under the GNU LGPL license.
11137 //
11138 // Modified:
11139 //
11140 // 27 April 2010
11141 //
11142 // Author:
11143 //
11144 // John Burkardt
11145 //
11146 // Reference:
11147 //
11148 // Milton Abramowitz, Irene Stegun,
11149 // Handbook of Mathematical Functions,
11150 // National Bureau of Standards, 1964,
11151 // ISBN: 0-486-61272-4,
11152 // LC: QA47.A34.
11153 //
11154 // Vladimir Krylov,
11155 // Approximate Calculation of Integrals,
11156 // Dover, 2006,
11157 // ISBN: 0486445798,
11158 // LC: QA311.K713.
11159 //
11160 // Arthur Stroud, Don Secrest,
11161 // Gaussian Quadrature Formulas,
11162 // Prentice Hall, 1966,
11163 // LC: QA299.4G3S7.
11164 //
11165 // Stephen Wolfram,
11166 // The Mathematica Book,
11167 // Fourth Edition,
11168 // Cambridge University Press, 1999,
11169 // ISBN: 0-521-64314-7,
11170 // LC: QA76.95.W65.
11171 //
11172 // Daniel Zwillinger, editor,
11173 // CRC Standard Mathematical Tables and Formulae,
11174 // 30th Edition,
11175 // CRC Press, 1996,
11176 // ISBN: 0-8493-2479-3.
11177 //
11178 // Parameters:
11179 //
11180 // Input, int N, the order.
11181 // N must be between 1 and 20.
11182 //
11183 // Output, double W[N], the weights.
11184 //
11185 {
11186  if ( n == 1 )
11187  {
11188  w[0] = 1.00000000000000000000000000000E+00;
11189  }
11190  else if ( n == 2 )
11191  {
11192  w[0] = 0.85355339059327376220042218105E+00;
11193  w[1] = 0.146446609406726237799577818948E+00;
11194  }
11195  else if ( n == 3 )
11196  {
11197  w[0] = 0.71109300992917301544959019114E+00;
11198  w[1] = 0.27851773356924084880144488846E+00;
11199  w[2] = 0.010389256501586135748964920401E+00;
11200  }
11201  else if ( n == 4 )
11202  {
11203  w[0] = 0.60315410434163360163596602382E+00;
11204  w[1] = 0.35741869243779968664149201746E+00;
11205  w[2] = 0.03888790851500538427243816816E+00;
11206  w[3] = 0.0005392947055613274501037905676E+00;
11207  }
11208  else if ( n == 5 )
11209  {
11210  w[0] = 0.52175561058280865247586092879E+00;
11211  w[1] = 0.3986668110831759274541333481E+00;
11212  w[2] = 0.0759424496817075953876533114E+00;
11213  w[3] = 0.00361175867992204845446126257E+00;
11214  w[4] = 0.00002336997238577622789114908455E+00;
11215  }
11216  else if ( n == 6 )
11217  {
11218  w[0] = 0.45896467394996359356828487771E+00;
11219  w[1] = 0.4170008307721209941133775662E+00;
11220  w[2] = 0.1133733820740449757387061851E+00;
11221  w[3] = 0.01039919745314907489891330285E+00;
11222  w[4] = 0.000261017202814932059479242860E+00;
11223  w[5] = 8.98547906429621238825292053E-07;
11224  }
11225  else if ( n == 7 )
11226  {
11227  w[0] = 0.40931895170127390213043288002E+00;
11228  w[1] = 0.4218312778617197799292810054E+00;
11229  w[2] = 0.1471263486575052783953741846E+00;
11230  w[3] = 0.0206335144687169398657056150E+00;
11231  w[4] = 0.00107401014328074552213195963E+00;
11232  w[5] = 0.0000158654643485642012687326223E+00;
11233  w[6] = 3.17031547899558056227132215E-08;
11234  }
11235  else if ( n == 8 )
11236  {
11237  w[0] = 0.36918858934163752992058283938E+00;
11238  w[1] = 0.4187867808143429560769785813E+00;
11239  w[2] = 0.175794986637171805699659867E+00;
11240  w[3] = 0.033343492261215651522132535E+00;
11241  w[4] = 0.0027945362352256725249389241E+00;
11242  w[5] = 0.00009076508773358213104238501E+00;
11243  w[6] = 8.4857467162725315448680183E-07;
11244  w[7] = 1.04800117487151038161508854E-09;
11245  }
11246  else if ( n == 9 )
11247  {
11248  w[0] = 0.336126421797962519673467717606E+00;
11249  w[1] = 0.411213980423984387309146942793E+00;
11250  w[2] = 0.199287525370885580860575607212E+00;
11251  w[3] = 0.0474605627656515992621163600479E+00;
11252  w[4] = 0.00559962661079458317700419900556E+00;
11253  w[5] = 0.000305249767093210566305412824291E+00;
11254  w[6] = 6.59212302607535239225572284875E-06;
11255  w[7] = 4.1107693303495484429024104033E-08;
11256  w[8] = 3.29087403035070757646681380323E-11;
11257  }
11258  else if ( n == 10 )
11259  {
11260  w[0] = 0.30844111576502014154747083468E+00;
11261  w[1] = 0.4011199291552735515157803099E+00;
11262  w[2] = 0.218068287611809421588648523E+00;
11263  w[3] = 0.062087456098677747392902129E+00;
11264  w[4] = 0.009501516975181100553839072E+00;
11265  w[5] = 0.0007530083885875387754559644E+00;
11266  w[6] = 0.00002825923349599565567422564E+00;
11267  w[7] = 4.249313984962686372586577E-07;
11268  w[8] = 1.839564823979630780921535E-09;
11269  w[9] = 9.911827219609008558377547E-13;
11270  }
11271  else if ( n == 11 )
11272  {
11273  w[0] = 0.28493321289420060505605102472E+00;
11274  w[1] = 0.3897208895278493779375535080E+00;
11275  w[2] = 0.232781831848991333940223796E+00;
11276  w[3] = 0.076564453546196686400854179E+00;
11277  w[4] = 0.014393282767350695091863919E+00;
11278  w[5] = 0.001518880846484873069847776E+00;
11279  w[6] = 0.0000851312243547192259720424E+00;
11280  w[7] = 2.29240387957450407857683E-06;
11281  w[8] = 2.48635370276779587373391E-08;
11282  w[9] = 7.71262693369132047028153E-11;
11283  w[10] = 2.883775868323623861597778E-14;
11284  }
11285  else if ( n == 12 )
11286  {
11287  w[0] = 0.26473137105544319034973889206E+00;
11288  w[1] = 0.3777592758731379820244905567E+00;
11289  w[2] = 0.244082011319877564254870818E+00;
11290  w[3] = 0.09044922221168093072750549E+00;
11291  w[4] = 0.02010238115463409652266129E+00;
11292  w[5] = 0.002663973541865315881054158E+00;
11293  w[6] = 0.000203231592662999392121433E+00;
11294  w[7] = 8.3650558568197987453363E-06;
11295  w[8] = 1.66849387654091026116990E-07;
11296  w[9] = 1.34239103051500414552392E-09;
11297  w[10] = 3.06160163503502078142408E-12;
11298  w[11] = 8.148077467426241682473119E-16;
11299  }
11300  else if ( n == 13 )
11301  {
11302  w[0] = 0.24718870842996262134624918596E+00;
11303  w[1] = 0.3656888229005219453067175309E+00;
11304  w[2] = 0.252562420057658502356824289E+00;
11305  w[3] = 0.10347075802418370511421863E+00;
11306  w[4] = 0.02643275441556161577815877E+00;
11307  w[5] = 0.00422039604025475276555209E+00;
11308  w[6] = 0.000411881770472734774892473E+00;
11309  w[7] = 0.0000235154739815532386882897E+00;
11310  w[8] = 7.3173116202490991040105E-07;
11311  w[9] = 1.10884162570398067979151E-08;
11312  w[10] = 6.7708266922058988406462E-11;
11313  w[11] = 1.15997995990507606094507E-13;
11314  w[12] = 2.245093203892758415991872E-17;
11315  }
11316  else if ( n == 14 )
11317  {
11318  w[0] = 0.23181557714486497784077486110E+00;
11319  w[1] = 0.3537846915975431518023313013E+00;
11320  w[2] = 0.258734610245428085987320561E+00;
11321  w[3] = 0.11548289355692321008730499E+00;
11322  w[4] = 0.03319209215933736003874996E+00;
11323  w[5] = 0.00619286943700661021678786E+00;
11324  w[6] = 0.00073989037786738594242589E+00;
11325  w[7] = 0.000054907194668416983785733E+00;
11326  w[8] = 2.4095857640853774967578E-06;
11327  w[9] = 5.801543981676495180886E-08;
11328  w[10] = 6.819314692484974119616E-10;
11329  w[11] = 3.2212077518948479398089E-12;
11330  w[12] = 4.2213524405165873515980E-15;
11331  w[13] = 6.05237502228918880839871E-19;
11332  }
11333  else if ( n == 15 )
11334  {
11335  w[0] = 0.21823488594008688985641323645E+00;
11336  w[1] = 0.3422101779228833296389489568E+00;
11337  w[2] = 0.263027577941680097414812275E+00;
11338  w[3] = 0.12642581810593053584303055E+00;
11339  w[4] = 0.04020686492100091484158548E+00;
11340  w[5] = 0.00856387780361183836391576E+00;
11341  w[6] = 0.00121243614721425207621921E+00;
11342  w[7] = 0.00011167439234425194199258E+00;
11343  w[8] = 6.459926762022900924653E-06;
11344  w[9] = 2.226316907096272630332E-07;
11345  w[10] = 4.227430384979365007351E-09;
11346  w[11] = 3.921897267041089290385E-11;
11347  w[12] = 1.4565152640731264063327E-13;
11348  w[13] = 1.4830270511133013354616E-16;
11349  w[14] = 1.60059490621113323104998E-20;
11350  }
11351  else if ( n == 16 )
11352  {
11353  w[0] = 0.20615171495780099433427363674E+00;
11354  w[1] = 0.3310578549508841659929830987E+00;
11355  w[2] = 0.265795777644214152599502021E+00;
11356  w[3] = 0.13629693429637753997554751E+00;
11357  w[4] = 0.0473289286941252189780623E+00;
11358  w[5] = 0.0112999000803394532312490E+00;
11359  w[6] = 0.0018490709435263108642918E+00;
11360  w[7] = 0.00020427191530827846012602E+00;
11361  w[8] = 0.00001484458687398129877135E+00;
11362  w[9] = 6.828319330871199564396E-07;
11363  w[10] = 1.881024841079673213882E-08;
11364  w[11] = 2.862350242973881619631E-10;
11365  w[12] = 2.127079033224102967390E-12;
11366  w[13] = 6.297967002517867787174E-15;
11367  w[14] = 5.050473700035512820402E-18;
11368  w[15] = 4.1614623703728551904265E-22;
11369  }
11370  else if ( n == 17 )
11371  {
11372  w[0] = 0.19533220525177083214592729770E+00;
11373  w[1] = 0.3203753572745402813366256320E+00;
11374  w[2] = 0.267329726357171097238809604E+00;
11375  w[3] = 0.14512985435875862540742645E+00;
11376  w[4] = 0.0544369432453384577793806E+00;
11377  w[5] = 0.0143572977660618672917767E+00;
11378  w[6] = 0.0026628247355727725684324E+00;
11379  w[7] = 0.0003436797271562999206118E+00;
11380  w[8] = 0.00003027551783782870109437E+00;
11381  w[9] = 1.768515053231676895381E-06;
11382  w[10] = 6.57627288681043332199E-08;
11383  w[11] = 1.469730932159546790344E-09;
11384  w[12] = 1.81691036255544979555E-11;
11385  w[13] = 1.095401388928687402976E-13;
11386  w[14] = 2.617373882223370421551E-16;
11387  w[15] = 1.6729356931461546908502E-19;
11388  w[16] = 1.06562631627404278815253E-23;
11389  }
11390  else if ( n == 18 )
11391  {
11392  w[0] = 0.18558860314691880562333775228E+00;
11393  w[1] = 0.3101817663702252936495975957E+00;
11394  w[2] = 0.267866567148536354820854395E+00;
11395  w[3] = 0.15297974746807490655384308E+00;
11396  w[4] = 0.0614349178609616527076780E+00;
11397  w[5] = 0.0176872130807729312772600E+00;
11398  w[6] = 0.0036601797677599177980266E+00;
11399  w[7] = 0.0005406227870077353231284E+00;
11400  w[8] = 0.0000561696505121423113818E+00;
11401  w[9] = 4.01530788370115755859E-06;
11402  w[10] = 1.91466985667567497969E-07;
11403  w[11] = 5.8360952686315941292E-09;
11404  w[12] = 1.07171126695539012773E-10;
11405  w[13] = 1.08909871388883385562E-12;
11406  w[14] = 5.38666474837830887608E-15;
11407  w[15] = 1.049865978035703408779E-17;
11408  w[16] = 5.405398451631053643566E-21;
11409  w[17] = 2.6916532692010286270838E-25;
11410  }
11411  else if ( n == 19 )
11412  {
11413  w[0] = 0.17676847491591250225103547981E+00;
11414  w[1] = 0.3004781436072543794821568077E+00;
11415  w[2] = 0.267599547038175030772695441E+00;
11416  w[3] = 0.15991337213558021678551215E+00;
11417  w[4] = 0.0682493799761491134552355E+00;
11418  w[5] = 0.0212393076065443249244062E+00;
11419  w[6] = 0.0048416273511483959672501E+00;
11420  w[7] = 0.0008049127473813667665946E+00;
11421  w[8] = 0.0000965247209315350170843E+00;
11422  w[9] = 8.20730525805103054409E-06;
11423  w[10] = 4.8305667247307725394E-07;
11424  w[11] = 1.90499136112328569994E-08;
11425  w[12] = 4.8166846309280615577E-10;
11426  w[13] = 7.3482588395511443768E-12;
11427  w[14] = 6.2022753875726163989E-14;
11428  w[15] = 2.54143084301542272372E-16;
11429  w[16] = 4.07886129682571235007E-19;
11430  w[17] = 1.707750187593837061004E-22;
11431  w[18] = 6.715064649908189959990E-27;
11432  }
11433  else if ( n == 20 )
11434  {
11435  w[0] = 0.168746801851113862149223899689E+00;
11436  w[1] = 0.291254362006068281716795323812E+00;
11437  w[2] = 0.266686102867001288549520868998E+00;
11438  w[3] = 0.166002453269506840031469127816E+00;
11439  w[4] = 0.0748260646687923705400624639615E+00;
11440  w[5] = 0.0249644173092832210728227383234E+00;
11441  w[6] = 0.00620255084457223684744754785395E+00;
11442  w[7] = 0.00114496238647690824203955356969E+00;
11443  w[8] = 0.000155741773027811974779809513214E+00;
11444  w[9] = 0.0000154014408652249156893806714048E+00;
11445  w[10] = 1.08648636651798235147970004439E-06;
11446  w[11] = 5.33012090955671475092780244305E-08;
11447  w[12] = 1.7579811790505820035778763784E-09;
11448  w[13] = 3.72550240251232087262924585338E-11;
11449  w[14] = 4.76752925157819052449488071613E-13;
11450  w[15] = 3.37284424336243841236506064991E-15;
11451  w[16] = 1.15501433950039883096396247181E-17;
11452  w[17] = 1.53952214058234355346383319667E-20;
11453  w[18] = 5.28644272556915782880273587683E-24;
11454  w[19] = 1.65645661249902329590781908529E-28;
11455  }
11456  else
11457  {
11458  std::cerr << "\n";
11459  std::cerr << "LAGUERRE_LOOKUP_WEIGHTS - Fatal error!\n";
11460  std::cerr << " Illegal value of N = " << n << "\n";
11461  std::cerr << " Legal values are 1 through 20.\n";
11462  std::exit ( 1 );
11463  }
11464 
11465  return;
11466 }
11467 //**************************************************************************80
11468 
11469 void SandiaRules::laguerre_ss_compute ( int order, double x[], double w[] )
11470 
11471 //**************************************************************************80
11472 //
11473 // Purpose:
11474 //
11475 // LAGUERRE_SS_COMPUTE computes a Laguerre quadrature rule.
11476 //
11477 // Discussion:
11478 //
11479 // The integral:
11480 //
11481 // Integral ( 0 <= X < +oo ) exp ( - X ) * F(X) dX
11482 //
11483 // The quadrature rule:
11484 //
11485 // Sum ( 1 <= I <= ORDER ) W(I) * F ( X(I) )
11486 //
11487 // The integral:
11488 //
11489 // Integral ( A <= X < +oo ) F(X) dX
11490 //
11491 // The quadrature rule:
11492 //
11493 // Sum ( 1 <= I <= ORDER ) W(I) * exp ( X(I) ) * F ( X(I) )
11494 //
11495 // Licensing:
11496 //
11497 // This code is distributed under the GNU LGPL license.
11498 //
11499 // Modified:
11500 //
11501 // 23 April 2011
11502 //
11503 // Author:
11504 //
11505 // Original FORTRAN77 version by Arthur Stroud, Don Secrest.
11506 // C++ version by John Burkardt.
11507 //
11508 // Reference:
11509 //
11510 // Arthur Stroud, Don Secrest,
11511 // Gaussian Quadrature Formulas,
11512 // Prentice Hall, 1966,
11513 // LC: QA299.4G3S7.
11514 //
11515 // Parameters:
11516 //
11517 // Input, int ORDER, the order.
11518 // 1 <= ORDER.
11519 //
11520 // Output, double X[ORDER], the abscissas.
11521 //
11522 // Output, double W[ORDER], the weights.
11523 //
11524 {
11525  double *b;
11526  double *c;
11527  //double cc;
11528  double dp2;
11529  int i;
11530  int j;
11531  double p1;
11532  double prod;
11533  double r1;
11534  double x0;
11535 
11536  if ( order < 1 )
11537  {
11538  std::cerr << "\n";
11539  std::cerr << "LAGUERRE_COMPUTE - Fatal error!\n";
11540  std::cerr << " Illegal value of ORDER = " << order << "\n";
11541  std::exit ( 1 );
11542  }
11543 
11544  b = new double[order];
11545  c = new double[order];
11546 //
11547 // Set the recursion coefficients.
11548 //
11549  for ( i = 0; i < order; i++ )
11550  {
11551  b[i] = ( double ) ( 2 * i + 1 );
11552  }
11553 
11554  for ( i = 0; i < order; i++ )
11555  {
11556  c[i] = ( double ) ( i * i );
11557  }
11558  prod = 1.0;
11559  for ( i = 1; i < order; i++ )
11560  {
11561  prod = prod * c[i];
11562  }
11563  //cc = prod;
11564 
11565  for ( i = 0; i < order; i++ )
11566  {
11567 //
11568 // Compute an estimate for the root.
11569 //
11570  if ( i == 0 )
11571  {
11572  x0 = 3.0 / ( 1.0 + 2.4 * ( double ) ( order ) );
11573  }
11574  else if ( i == 1 )
11575  {
11576  x0 = x0 + 15.0 / ( 1.0 + 2.5 * ( double ) ( order ) );
11577  }
11578  else
11579  {
11580  r1 = ( 1.0 + 2.55 * ( double ) ( i - 1 ) )
11581  / ( 1.9 * ( double ) ( i - 1 ) );
11582 
11583  x0 = x0 + r1 * ( x0 - x[i-2] );
11584  }
11585 //
11586 // Use iteration to find the root.
11587 //
11588  laguerre_ss_root ( &x0, order, &dp2, &p1, b, c );
11589 //
11590 // Set the abscissa and weight.
11591 //
11592  x[i] = x0;
11593 //
11594 // Because of the huge values involved, this calculation breaks down
11595 // for ORDER = 127.
11596 //
11597 // It was originally w[i] = ( cc / dp2 ) / p1, which breaks down sooner.
11598 //
11599  w[i] = ( 1.0 / dp2 );
11600  for ( j = 2; j <= order; j++ )
11601  {
11602  w[i] = w[i] * ( double ) ( j - 1 );
11603  }
11604  w[i] = w[i] / p1;
11605  for ( j = 2; j <= order; j++ )
11606  {
11607  w[i] = w[i] * ( double ) ( j - 1 );
11608  }
11609 
11610 // w[i] = ( cc / dp2 ) / p1;
11611  }
11612 
11613  delete [] b;
11614  delete [] c;
11615 
11616  return;
11617 }
11618 //**************************************************************************80
11619 
11620 void SandiaRules::laguerre_ss_recur ( double *p2, double *dp2, double *p1, double x,
11621  int order, double b[], double c[] )
11622 
11623 //**************************************************************************80
11624 //
11625 // Purpose:
11626 //
11627 // LAGUERRE_SS_RECUR evaluates a Laguerre polynomial.
11628 //
11629 // Licensing:
11630 //
11631 // This code is distributed under the GNU LGPL license.
11632 //
11633 // Modified:
11634 //
11635 // 23 April 2011
11636 //
11637 // Author:
11638 //
11639 // Original FORTRAN77 version by Arthur Stroud, Don Secrest.
11640 // C++ version by John Burkardt.
11641 //
11642 // Reference:
11643 //
11644 // Arthur Stroud, Don Secrest,
11645 // Gaussian Quadrature Formulas,
11646 // Prentice Hall, 1966,
11647 // LC: QA299.4G3S7.
11648 //
11649 // Parameters:
11650 //
11651 // Output, double *P2, the value of L(ORDER)(X).
11652 //
11653 // Output, double *DP2, the value of L'(ORDER)(X).
11654 //
11655 // Output, double *P1, the value of L(ORDER-1)(X).
11656 //
11657 // Input, double X, the point at which polynomials are evaluated.
11658 //
11659 // Input, int ORDER, the order of the polynomial.
11660 //
11661 // Input, double B[ORDER], C[ORDER], the recursion coefficients.
11662 //
11663 {
11664  double dp0;
11665  double dp1;
11666  int i;
11667  double p0;
11668 
11669  *p1 = 1.0;
11670  dp1 = 0.0;
11671 
11672  *p2 = x - 1.0;
11673  *dp2 = 1.0;
11674 
11675  for ( i = 1; i < order; i++ )
11676  {
11677  p0 = *p1;
11678  dp0 = dp1;
11679 
11680  *p1 = *p2;
11681  dp1 = *dp2;
11682 
11683  *p2 = ( x - b[i] ) * ( *p1 ) - c[i] * p0;
11684  *dp2 = ( x - b[i] ) * dp1 + ( *p1 ) - c[i] * dp0;
11685  }
11686 
11687  return;
11688 }
11689 //**************************************************************************80
11690 
11691 void SandiaRules::laguerre_ss_root ( double *x, int order, double *dp2, double *p1,
11692  double b[], double c[] )
11693 
11694 //**************************************************************************80
11695 //
11696 // Purpose:
11697 //
11698 // LAGUERRE_SS_ROOT improves a root of a Laguerre polynomial.
11699 //
11700 // Licensing:
11701 //
11702 // This code is distributed under the GNU LGPL license.
11703 //
11704 // Modified:
11705 //
11706 // 23 April 2011
11707 //
11708 // Author:
11709 //
11710 // Original FORTRAN77 version by Arthur Stroud, Don Secrest.
11711 // C++ version by John Burkardt.
11712 //
11713 // Reference:
11714 //
11715 // Arthur Stroud, Don Secrest,
11716 // Gaussian Quadrature Formulas,
11717 // Prentice Hall, 1966,
11718 // LC: QA299.4G3S7.
11719 //
11720 // Parameters:
11721 //
11722 // Input/output, double *X, the approximate root, which
11723 // should be improved on output.
11724 //
11725 // Input, int ORDER, the order of the polynomial.
11726 //
11727 // Output, double *DP2, the value of L'(ORDER)(X).
11728 //
11729 // Output, double *P1, the value of L(ORDER-1)(X).
11730 //
11731 // Input, double B[ORDER], C[ORDER], the recursion coefficients.
11732 //
11733 {
11734  double d;
11735  double eps;
11736  double p2;
11737  int step;
11738  int step_max = 10;
11739 
11740  eps = r8_epsilon ( );
11741 
11742  for ( step = 1; step <= step_max; step++ )
11743  {
11744  laguerre_ss_recur ( &p2, dp2, p1, *x, order, b, c );
11745 
11746  d = p2 / ( *dp2 );
11747  *x = *x - d;
11748 
11749  if ( r8_abs ( d ) <= eps * ( r8_abs ( *x ) + 1.0 ) )
11750  {
11751  break;
11752  }
11753  }
11754 
11755  return;
11756 }
11757 //**************************************************************************80
11758 
11759 void SandiaRules::legendre_compute ( int n, double x[], double w[] )
11760 
11761 //**************************************************************************80
11762 //
11763 // Purpose:
11764 //
11765 // LEGENDRE_COMPUTE: Legendre quadrature rule by the Elhay-Kautsky method.
11766 //
11767 // Licensing:
11768 //
11769 // This code is distributed under the GNU LGPL license.
11770 //
11771 // Modified:
11772 //
11773 // 19 April 2011
11774 //
11775 // Author:
11776 //
11777 // Original FORTRAN77 version by Sylvan Elhay, Jaroslav Kautsky.
11778 // C++ version by John Burkardt.
11779 //
11780 // Reference:
11781 //
11782 // Sylvan Elhay, Jaroslav Kautsky,
11783 // Algorithm 655: IQPACK, FORTRAN Subroutines for the Weights of
11784 // Interpolatory Quadrature,
11785 // ACM Transactions on Mathematical Software,
11786 // Volume 13, Number 4, December 1987, pages 399-415.
11787 //
11788 // Parameters:
11789 //
11790 // Input, int N, the order.
11791 //
11792 // Output, double X[N], the abscissas.
11793 //
11794 // Output, double W[N], the weights.
11795 //
11796 {
11797  double *bj;
11798  int i;
11799  double zemu;
11800 //
11801 // Define the zero-th moment.
11802 //
11803  zemu = 2.0;
11804 //
11805 // Define the Jacobi matrix.
11806 //
11807  bj = new double[n];
11808 
11809  for ( i = 0; i < n; i++ )
11810  {
11811  bj[i] = ( double ) ( ( i + 1 ) * ( i + 1 ) )
11812  / ( double ) ( 4 * ( i + 1 ) * ( i + 1 ) - 1 );
11813  bj[i] = std::sqrt ( bj[i] );
11814  }
11815 
11816  for ( i = 0; i < n; i++ )
11817  {
11818  x[i] = 0.0;
11819  }
11820 
11821  w[0] = std::sqrt ( zemu );
11822 
11823  for ( i = 1; i < n; i++ )
11824  {
11825  w[i] = 0.0;
11826  }
11827 //
11828 // Diagonalize the Jacobi matrix.
11829 //
11830  imtqlx ( n, x, bj, w );
11831 
11832  for ( i = 0; i < n; i++ )
11833  {
11834  w[i] = w[i] * w[i];
11835  }
11836 
11837  delete [] bj;
11838 
11839  return;
11840 }
11841 //**************************************************************************80
11842 
11843 void SandiaRules::legendre_compute_np ( int n, int np, double p[], double x[], double w[] )
11844 
11845 //**************************************************************************80
11846 //
11847 // Purpose:
11848 //
11849 // LEGENDRE_COMPUTE_NP computes a Legendre quadrature rule.
11850 //
11851 // Discussion:
11852 //
11853 // The integral:
11854 //
11855 // Integral ( -1 <= X <= 1 ) F(X) dX
11856 //
11857 // The quadrature rule:
11858 //
11859 // Sum ( 1 <= I <= N ) W(I) * F ( X(I) )
11860 //
11861 // Licensing:
11862 //
11863 // This code is distributed under the GNU LGPL license.
11864 //
11865 // Modified:
11866 //
11867 // 22 June 2009
11868 //
11869 // Author:
11870 //
11871 // Original FORTRAN77 version by Philip Davis, Philip Rabinowitz.
11872 // C++ version by John Burkardt.
11873 //
11874 // Reference:
11875 //
11876 // Philip Davis, Philip Rabinowitz,
11877 // Methods of Numerical Integration,
11878 // Second Edition,
11879 // Dover, 2007,
11880 // ISBN: 0486453391,
11881 // LC: QA299.3.D28.
11882 //
11883 // Parameters:
11884 //
11885 // Input, int N, the order.
11886 // 1 <= N.
11887 //
11888 // Input, int NP, the number of parameters.
11889 //
11890 // Input, double P[NP], parameters which are not needed by this function.
11891 //
11892 // Output, double X[N], the abscissas.
11893 //
11894 // Output, double W[N], the weights.
11895 //
11896 {
11897  legendre_compute ( n, x, w );
11898 
11899  return;
11900 }
11901 //**************************************************************************80
11902 
11903 void SandiaRules::legendre_compute_points ( int n, double x[] )
11904 
11905 //**************************************************************************80
11906 //
11907 // Purpose:
11908 //
11909 // LEGENDRE_COMPUTE_POINTS computes Legendre quadrature points.
11910 //
11911 // Licensing:
11912 //
11913 // This code is distributed under the GNU LGPL license.
11914 //
11915 // Modified:
11916 //
11917 // 13 June 2009
11918 //
11919 // Author:
11920 //
11921 // John Burkardt
11922 //
11923 // Parameters:
11924 //
11925 // Input, int N, the order.
11926 //
11927 // Output, double X[N], the abscissas.
11928 //
11929 {
11930  double *w;
11931 
11932  w= new double[n];
11933 
11934  legendre_compute ( n, x, w );
11935 
11936  delete [] w;
11937 
11938  return;
11939 }
11940 //**************************************************************************80
11941 
11942 void SandiaRules::legendre_compute_points_np ( int n, int np, double p[], double x[] )
11943 
11944 //**************************************************************************80
11945 //
11946 // Purpose:
11947 //
11948 // LEGENDRE_COMPUTE_POINTS_NP computes Legendre quadrature points.
11949 //
11950 // Licensing:
11951 //
11952 // This code is distributed under the GNU LGPL license.
11953 //
11954 // Modified:
11955 //
11956 // 22 June 2009
11957 //
11958 // Author:
11959 //
11960 // John Burkardt
11961 //
11962 // Parameters:
11963 //
11964 // Input, int N, the order.
11965 //
11966 // Input, int NP, the number of parameters.
11967 //
11968 // Input, double P[NP], parameters which are not needed by this function.
11969 //
11970 // Output, double X[N], the abscissas.
11971 //
11972 {
11973  legendre_compute_points ( n, x );
11974 
11975  return;
11976 }
11977 //**************************************************************************80
11978 
11979 void SandiaRules::legendre_compute_weights ( int n, double w[] )
11980 
11981 //**************************************************************************80
11982 //
11983 // Purpose:
11984 //
11985 // LEGENDRE_COMPUTE_WEIGHTS computes Legendre quadrature weights.
11986 //
11987 // Licensing:
11988 //
11989 // This code is distributed under the GNU LGPL license.
11990 //
11991 // Modified:
11992 //
11993 // 13 June 2009
11994 //
11995 // Author:
11996 //
11997 // John Burkardt
11998 //
11999 // Parameters:
12000 //
12001 // Input, int N, the order.
12002 //
12003 // Output, double W[N], the weights.
12004 //
12005 {
12006  double *x;
12007 
12008  x = new double[n];
12009 
12010  legendre_compute ( n, x, w );
12011 
12012  delete [] x;
12013 
12014  return;
12015 }
12016 //**************************************************************************80
12017 
12018 void SandiaRules::legendre_compute_weights_np ( int n, int np, double p[], double w[] )
12019 
12020 //**************************************************************************80
12021 //
12022 // Purpose:
12023 //
12024 // LEGENDRE_COMPUTE_WEIGHTS_NP computes Legendre quadrature weights.
12025 //
12026 // Licensing:
12027 //
12028 // This code is distributed under the GNU LGPL license.
12029 //
12030 // Modified:
12031 //
12032 // 22 June 2009
12033 //
12034 // Author:
12035 //
12036 // John Burkardt
12037 //
12038 // Parameters:
12039 //
12040 // Input, int N, the order.
12041 //
12042 // Input, int NP, the number of parameters.
12043 //
12044 // Input, double P[NP], parameters which are not needed by this function.
12045 //
12046 // Output, double W[N], the weights.
12047 //
12048 {
12049  legendre_compute_weights ( n, w );
12050 
12051  return;
12052 }
12053 //**************************************************************************80
12054 
12055 void SandiaRules::legendre_dr_compute ( int n, double x[], double w[] )
12056 
12057 //**************************************************************************80
12058 //
12059 // Purpose:
12060 //
12061 // LEGENDRE_DR_COMPUTE computes a Legendre quadrature rule.
12062 //
12063 // Discussion:
12064 //
12065 // The integral:
12066 //
12067 // Integral ( -1 <= X <= 1 ) F(X) dX
12068 //
12069 // The quadrature rule:
12070 //
12071 // Sum ( 1 <= I <= N ) W(I) * F ( X(I) )
12072 //
12073 // Licensing:
12074 //
12075 // This code is distributed under the GNU LGPL license.
12076 //
12077 // Modified:
12078 //
12079 // 13 June 2009
12080 //
12081 // Author:
12082 //
12083 // Original FORTRAN77 version by Philip Davis, Philip Rabinowitz.
12084 // C++ version by John Burkardt.
12085 //
12086 // Reference:
12087 //
12088 // Philip Davis, Philip Rabinowitz,
12089 // Methods of Numerical Integration,
12090 // Second Edition,
12091 // Dover, 2007,
12092 // ISBN: 0486453391,
12093 // LC: QA299.3.D28.
12094 //
12095 // Parameters:
12096 //
12097 // Input, int N, the order.
12098 // 1 <= N.
12099 //
12100 // Output, double X[N], the abscissas.
12101 //
12102 // Output, double W[N], the weights.
12103 //
12104 {
12105  double d1;
12106  double d2pn;
12107  double d3pn;
12108  double d4pn;
12109  double dp;
12110  double dpn;
12111  double e1;
12112  double fx;
12113  double h;
12114  int i;
12115  int iback;
12116  int k;
12117  int m;
12118  int mp1mi;
12119  int ncopy;
12120  int nmove;
12121  double p;
12122  double pi = 3.141592653589793;
12123  double pk;
12124  double pkm1;
12125  double pkp1;
12126  double t;
12127  double u;
12128  double v;
12129  double x0;
12130  double xtemp;
12131 
12132  if ( n < 1 )
12133  {
12134  std::cerr << "\n";
12135  std::cerr << "LEGENDRE_DR_COMPUTE - Fatal error!\n";
12136  std::cerr << " Illegal value of N = " << n << "\n";
12137  std::exit ( 1 );
12138  }
12139 
12140  e1 = ( double ) ( n * ( n + 1 ) );
12141 
12142  m = ( n + 1 ) / 2;
12143 
12144  for ( i = 1; i <= m; i++ )
12145  {
12146  mp1mi = m + 1 - i;
12147 
12148  t = ( double ) ( 4 * i - 1 ) * pi / ( double ) ( 4 * n + 2 );
12149 
12150  x0 = std::cos ( t ) * ( 1.0 - ( 1.0 - 1.0 / ( double ) ( n ) )
12151  / ( double ) ( 8 * n * n ) );
12152 
12153  pkm1 = 1.0;
12154  pk = x0;
12155 
12156  for ( k = 2; k <= n; k++ )
12157  {
12158  pkp1 = 2.0 * x0 * pk - pkm1 - ( x0 * pk - pkm1 ) / ( double ) ( k );
12159  pkm1 = pk;
12160  pk = pkp1;
12161  }
12162 
12163  d1 = ( double ) ( n ) * ( pkm1 - x0 * pk );
12164 
12165  dpn = d1 / ( 1.0 - x0 * x0 );
12166 
12167  d2pn = ( 2.0 * x0 * dpn - e1 * pk ) / ( 1.0 - x0 * x0 );
12168 
12169  d3pn = ( 4.0 * x0 * d2pn + ( 2.0 - e1 ) * dpn ) / ( 1.0 - x0 * x0 );
12170 
12171  d4pn = ( 6.0 * x0 * d3pn + ( 6.0 - e1 ) * d2pn ) / ( 1.0 - x0 * x0 );
12172 
12173  u = pk / dpn;
12174  v = d2pn / dpn;
12175 //
12176 // Initial approximation H:
12177 //
12178  h = -u * ( 1.0 + 0.5 * u * ( v + u * ( v * v - d3pn / ( 3.0 * dpn ) ) ) );
12179 //
12180 // Refine H using one step of Newton's method:
12181 //
12182  p = pk + h * ( dpn + 0.5 * h * ( d2pn + h / 3.0
12183  * ( d3pn + 0.25 * h * d4pn ) ) );
12184 
12185  dp = dpn + h * ( d2pn + 0.5 * h * ( d3pn + h * d4pn / 3.0 ) );
12186 
12187  h = h - p / dp;
12188 
12189  xtemp = x0 + h;
12190 
12191  x[mp1mi-1] = xtemp;
12192 
12193  fx = d1 - h * e1 * ( pk + 0.5 * h * ( dpn + h / 3.0
12194  * ( d2pn + 0.25 * h * ( d3pn + 0.2 * h * d4pn ) ) ) );
12195 
12196  w[mp1mi-1] = 2.0 * ( 1.0 - xtemp * xtemp ) / ( fx * fx );
12197  }
12198 
12199  if ( ( n % 2 ) == 1 )
12200  {
12201  x[0] = 0.0;
12202  }
12203 //
12204 // Shift the data up.
12205 //
12206  nmove = ( n + 1 ) / 2;
12207  ncopy = n - nmove;
12208 
12209  for ( i = 1; i <= nmove; i++ )
12210  {
12211  iback = n + 1 - i;
12212  x[iback-1] = x[iback-ncopy-1];
12213  w[iback-1] = w[iback-ncopy-1];
12214  }
12215 //
12216 // Reflect values for the negative abscissas.
12217 //
12218  for ( i = 1; i <= n - nmove; i++ )
12219  {
12220  x[i-1] = - x[n-i];
12221  w[i-1] = w[n-i];
12222  }
12223 
12224  return;
12225 }
12226 //**************************************************************************80
12227 
12229 
12230 //**************************************************************************80
12231 //
12232 // Purpose:
12233 //
12234 // LEGENDRE_INTEGRAL evaluates a monomial Legendre integral.
12235 //
12236 // Discussion:
12237 //
12238 // The integral:
12239 //
12240 // integral ( -1 <= x <= +1 ) x^n dx
12241 //
12242 // Licensing:
12243 //
12244 // This code is distributed under the GNU LGPL license.
12245 //
12246 // Modified:
12247 //
12248 // 19 February 2008
12249 //
12250 // Author:
12251 //
12252 // John Burkardt
12253 //
12254 // Parameters:
12255 //
12256 // Input, int EXPON, the exponent.
12257 //
12258 // Output, double LEGENDRE_INTEGRAL, the value of the exact integral.
12259 //
12260 {
12261  double exact;
12262 //
12263 // Get the exact value of the integral.
12264 //
12265  if ( ( expon % 2 ) == 0 )
12266  {
12267  exact = 2.0 / ( double ) ( expon + 1 );
12268  }
12269  else
12270  {
12271  exact = 0.0;
12272  }
12273 
12274  return exact;
12275 }
12276 //**************************************************************************80
12277 
12278 void SandiaRules::legendre_lookup ( int n, double x[], double w[] )
12279 
12280 //**************************************************************************80
12281 //
12282 // Purpose:
12283 //
12284 // LEGENDRE_LOOKUP looks up abscissas and weights for Gauss-Legendre quadrature.
12285 //
12286 // Licensing:
12287 //
12288 // This code is distributed under the GNU LGPL license.
12289 //
12290 // Modified:
12291 //
12292 // 27 April 2010
12293 //
12294 // Author:
12295 //
12296 // John Burkardt
12297 //
12298 // Reference:
12299 //
12300 // Milton Abramowitz, Irene Stegun,
12301 // Handbook of Mathematical Functions,
12302 // National Bureau of Standards, 1964,
12303 // ISBN: 0-486-61272-4,
12304 // LC: QA47.A34.
12305 //
12306 // Vladimir Krylov,
12307 // Approximate Calculation of Integrals,
12308 // Dover, 2006,
12309 // ISBN: 0486445798.
12310 // LC: QA311.K713.
12311 //
12312 // Arthur Stroud, Don Secrest,
12313 // Gaussian Quadrature Formulas,
12314 // Prentice Hall, 1966,
12315 // LC: QA299.4G3S7.
12316 //
12317 // Stephen Wolfram,
12318 // The Mathematica Book,
12319 // Fourth Edition,
12320 // Cambridge University Press, 1999,
12321 // ISBN: 0-521-64314-7,
12322 // LC: QA76.95.W65.
12323 //
12324 // Daniel Zwillinger, editor,
12325 // CRC Standard Mathematical Tables and Formulae,
12326 // 30th Edition,
12327 // CRC Press, 1996,
12328 // ISBN: 0-8493-2479-3,
12329 // LC: QA47.M315.
12330 //
12331 // Parameters:
12332 //
12333 // Input, int N, the order.
12334 // N must be between 1 and 33.
12335 //
12336 // Output, double X[N], the abscissas.
12337 //
12338 // Output, double W[N], the abscissas.
12339 //
12340 {
12341  legendre_lookup_points ( n, x );
12342 
12343  legendre_lookup_weights ( n, w );
12344 
12345  return;
12346 }
12347 //**************************************************************************80
12348 
12349 void SandiaRules::legendre_lookup_points ( int n, double x[] )
12350 
12351 //**************************************************************************80
12352 //
12353 // Purpose:
12354 //
12355 // LEGENDRE_LOOKUP_POINTS looks up abscissas for Gauss-Legendre quadrature.
12356 //
12357 // Licensing:
12358 //
12359 // This code is distributed under the GNU LGPL license.
12360 //
12361 // Modified:
12362 //
12363 // 27 April 2010
12364 //
12365 // Author:
12366 //
12367 // John Burkardt
12368 //
12369 // Reference:
12370 //
12371 // Milton Abramowitz, Irene Stegun,
12372 // Handbook of Mathematical Functions,
12373 // National Bureau of Standards, 1964,
12374 // ISBN: 0-486-61272-4,
12375 // LC: QA47.A34.
12376 //
12377 // Vladimir Krylov,
12378 // Approximate Calculation of Integrals,
12379 // Dover, 2006,
12380 // ISBN: 0486445798.
12381 // LC: QA311.K713.
12382 //
12383 // Arthur Stroud, Don Secrest,
12384 // Gaussian Quadrature Formulas,
12385 // Prentice Hall, 1966,
12386 // LC: QA299.4G3S7.
12387 //
12388 // Stephen Wolfram,
12389 // The Mathematica Book,
12390 // Fourth Edition,
12391 // Cambridge University Press, 1999,
12392 // ISBN: 0-521-64314-7,
12393 // LC: QA76.95.W65.
12394 //
12395 // Daniel Zwillinger, editor,
12396 // CRC Standard Mathematical Tables and Formulae,
12397 // 30th Edition,
12398 // CRC Press, 1996,
12399 // ISBN: 0-8493-2479-3,
12400 // LC: QA47.M315.
12401 //
12402 // Parameters:
12403 //
12404 // Input, int N, the order.
12405 // N must be between 1 and 33.
12406 //
12407 // Output, double X[N], the abscissas.
12408 //
12409 {
12410  if ( n == 1 )
12411  {
12412  x[0] = 0.000000000000000000000000000000;
12413  }
12414  else if ( n == 2 )
12415  {
12416  x[0] = -0.577350269189625764509148780502;
12417  x[1] = 0.577350269189625764509148780502;
12418  }
12419  else if ( n == 3 )
12420  {
12421  x[0] = -0.774596669241483377035853079956;
12422  x[1] = 0.000000000000000000000000000000;
12423  x[2] = 0.774596669241483377035853079956;
12424  }
12425  else if ( n == 4 )
12426  {
12427  x[0] = -0.861136311594052575223946488893;
12428  x[1] = -0.339981043584856264802665759103;
12429  x[2] = 0.339981043584856264802665759103;
12430  x[3] = 0.861136311594052575223946488893;
12431  }
12432  else if ( n == 5 )
12433  {
12434  x[0] = -0.906179845938663992797626878299;
12435  x[1] = -0.538469310105683091036314420700;
12436  x[2] = 0.000000000000000000000000000000;
12437  x[3] = 0.538469310105683091036314420700;
12438  x[4] = 0.906179845938663992797626878299;
12439  }
12440  else if ( n == 6 )
12441  {
12442  x[0] = -0.932469514203152027812301554494;
12443  x[1] = -0.661209386466264513661399595020;
12444  x[2] = -0.238619186083196908630501721681;
12445  x[3] = 0.238619186083196908630501721681;
12446  x[4] = 0.661209386466264513661399595020;
12447  x[5] = 0.932469514203152027812301554494;
12448  }
12449  else if ( n == 7 )
12450  {
12451  x[0] = -0.949107912342758524526189684048;
12452  x[1] = -0.741531185599394439863864773281;
12453  x[2] = -0.405845151377397166906606412077;
12454  x[3] = 0.000000000000000000000000000000;
12455  x[4] = 0.405845151377397166906606412077;
12456  x[5] = 0.741531185599394439863864773281;
12457  x[6] = 0.949107912342758524526189684048;
12458  }
12459  else if ( n == 8 )
12460  {
12461  x[0] = -0.960289856497536231683560868569;
12462  x[1] = -0.796666477413626739591553936476;
12463  x[2] = -0.525532409916328985817739049189;
12464  x[3] = -0.183434642495649804939476142360;
12465  x[4] = 0.183434642495649804939476142360;
12466  x[5] = 0.525532409916328985817739049189;
12467  x[6] = 0.796666477413626739591553936476;
12468  x[7] = 0.960289856497536231683560868569;
12469  }
12470  else if ( n == 9 )
12471  {
12472  x[0] = -0.968160239507626089835576203;
12473  x[1] = -0.836031107326635794299429788;
12474  x[2] = -0.613371432700590397308702039;
12475  x[3] = -0.324253423403808929038538015;
12476  x[4] = 0.000000000000000000000000000;
12477  x[5] = 0.324253423403808929038538015;
12478  x[6] = 0.613371432700590397308702039;
12479  x[7] = 0.836031107326635794299429788;
12480  x[8] = 0.968160239507626089835576203;
12481  }
12482  else if ( n == 10 )
12483  {
12484  x[0] = -0.973906528517171720077964012;
12485  x[1] = -0.865063366688984510732096688;
12486  x[2] = -0.679409568299024406234327365;
12487  x[3] = -0.433395394129247190799265943;
12488  x[4] = -0.148874338981631210884826001;
12489  x[5] = 0.148874338981631210884826001;
12490  x[6] = 0.433395394129247190799265943;
12491  x[7] = 0.679409568299024406234327365;
12492  x[8] = 0.865063366688984510732096688;
12493  x[9] = 0.973906528517171720077964012;
12494  }
12495  else if ( n == 11 )
12496  {
12497  x[0] = -0.978228658146056992803938001;
12498  x[1] = -0.887062599768095299075157769;
12499  x[2] = -0.730152005574049324093416252;
12500  x[3] = -0.519096129206811815925725669;
12501  x[4] = -0.269543155952344972331531985;
12502  x[5] = 0.000000000000000000000000000;
12503  x[6] = 0.269543155952344972331531985;
12504  x[7] = 0.519096129206811815925725669;
12505  x[8] = 0.730152005574049324093416252;
12506  x[9] = 0.887062599768095299075157769;
12507  x[10] = 0.978228658146056992803938001;
12508  }
12509  else if ( n == 12 )
12510  {
12511  x[0] = -0.981560634246719250690549090;
12512  x[1] = -0.904117256370474856678465866;
12513  x[2] = -0.769902674194304687036893833;
12514  x[3] = -0.587317954286617447296702419;
12515  x[4] = -0.367831498998180193752691537;
12516  x[5] = -0.125233408511468915472441369;
12517  x[6] = 0.125233408511468915472441369;
12518  x[7] = 0.367831498998180193752691537;
12519  x[8] = 0.587317954286617447296702419;
12520  x[9] = 0.769902674194304687036893833;
12521  x[10] = 0.904117256370474856678465866;
12522  x[11] = 0.981560634246719250690549090;
12523  }
12524  else if ( n == 13 )
12525  {
12526  x[0] = -0.984183054718588149472829449;
12527  x[1] = -0.917598399222977965206547837;
12528  x[2] = -0.801578090733309912794206490;
12529  x[3] = -0.642349339440340220643984607;
12530  x[4] = -0.448492751036446852877912852;
12531  x[5] = -0.230458315955134794065528121;
12532  x[6] = 0.000000000000000000000000000;
12533  x[7] = 0.230458315955134794065528121;
12534  x[8] = 0.448492751036446852877912852;
12535  x[9] = 0.642349339440340220643984607;
12536  x[10] = 0.80157809073330991279420649;
12537  x[11] = 0.91759839922297796520654784;
12538  x[12] = 0.98418305471858814947282945;
12539  }
12540  else if ( n == 14 )
12541  {
12542  x[0] = -0.986283808696812338841597267;
12543  x[1] = -0.928434883663573517336391139;
12544  x[2] = -0.827201315069764993189794743;
12545  x[3] = -0.687292904811685470148019803;
12546  x[4] = -0.515248636358154091965290719;
12547  x[5] = -0.319112368927889760435671824;
12548  x[6] = -0.108054948707343662066244650;
12549  x[7] = 0.108054948707343662066244650;
12550  x[8] = 0.31911236892788976043567182;
12551  x[9] = 0.51524863635815409196529072;
12552  x[10] = 0.68729290481168547014801980;
12553  x[11] = 0.82720131506976499318979474;
12554  x[12] = 0.92843488366357351733639114;
12555  x[13] = 0.98628380869681233884159727;
12556  }
12557  else if ( n == 15 )
12558  {
12559  x[0] = -0.987992518020485428489565719;
12560  x[1] = -0.937273392400705904307758948;
12561  x[2] = -0.848206583410427216200648321;
12562  x[3] = -0.724417731360170047416186055;
12563  x[4] = -0.570972172608538847537226737;
12564  x[5] = -0.394151347077563369897207371;
12565  x[6] = -0.201194093997434522300628303;
12566  x[7] = 0.00000000000000000000000000;
12567  x[8] = 0.20119409399743452230062830;
12568  x[9] = 0.39415134707756336989720737;
12569  x[10] = 0.57097217260853884753722674;
12570  x[11] = 0.72441773136017004741618605;
12571  x[12] = 0.84820658341042721620064832;
12572  x[13] = 0.93727339240070590430775895;
12573  x[14] = 0.98799251802048542848956572;
12574  }
12575  else if ( n == 16 )
12576  {
12577  x[0] = -0.989400934991649932596154173;
12578  x[1] = -0.944575023073232576077988416;
12579  x[2] = -0.865631202387831743880467898;
12580  x[3] = -0.755404408355003033895101195;
12581  x[4] = -0.617876244402643748446671764;
12582  x[5] = -0.458016777657227386342419443;
12583  x[6] = -0.281603550779258913230460501;
12584  x[7] = -0.09501250983763744018531934;
12585  x[8] = 0.09501250983763744018531934;
12586  x[9] = 0.28160355077925891323046050;
12587  x[10] = 0.45801677765722738634241944;
12588  x[11] = 0.61787624440264374844667176;
12589  x[12] = 0.75540440835500303389510119;
12590  x[13] = 0.86563120238783174388046790;
12591  x[14] = 0.94457502307323257607798842;
12592  x[15] = 0.98940093499164993259615417;
12593  }
12594  else if ( n == 17 )
12595  {
12596  x[0] = -0.990575475314417335675434020;
12597  x[1] = -0.950675521768767761222716958;
12598  x[2] = -0.880239153726985902122955694;
12599  x[3] = -0.781514003896801406925230056;
12600  x[4] = -0.657671159216690765850302217;
12601  x[5] = -0.512690537086476967886246569;
12602  x[6] = -0.35123176345387631529718552;
12603  x[7] = -0.17848418149584785585067749;
12604  x[8] = 0.00000000000000000000000000;
12605  x[9] = 0.17848418149584785585067749;
12606  x[10] = 0.35123176345387631529718552;
12607  x[11] = 0.51269053708647696788624657;
12608  x[12] = 0.65767115921669076585030222;
12609  x[13] = 0.78151400389680140692523006;
12610  x[14] = 0.88023915372698590212295569;
12611  x[15] = 0.95067552176876776122271696;
12612  x[16] = 0.99057547531441733567543402;
12613  }
12614  else if ( n == 18 )
12615  {
12616  x[0] = -0.991565168420930946730016005;
12617  x[1] = -0.955823949571397755181195893;
12618  x[2] = -0.892602466497555739206060591;
12619  x[3] = -0.803704958972523115682417455;
12620  x[4] = -0.691687043060353207874891081;
12621  x[5] = -0.55977083107394753460787155;
12622  x[6] = -0.41175116146284264603593179;
12623  x[7] = -0.25188622569150550958897285;
12624  x[8] = -0.08477501304173530124226185;
12625  x[9] = 0.08477501304173530124226185;
12626  x[10] = 0.25188622569150550958897285;
12627  x[11] = 0.41175116146284264603593179;
12628  x[12] = 0.55977083107394753460787155;
12629  x[13] = 0.69168704306035320787489108;
12630  x[14] = 0.80370495897252311568241746;
12631  x[15] = 0.89260246649755573920606059;
12632  x[16] = 0.95582394957139775518119589;
12633  x[17] = 0.99156516842093094673001600;
12634  }
12635  else if ( n == 19 )
12636  {
12637  x[0] = -0.992406843843584403189017670;
12638  x[1] = -0.960208152134830030852778841;
12639  x[2] = -0.903155903614817901642660929;
12640  x[3] = -0.822714656537142824978922487;
12641  x[4] = -0.72096617733522937861709586;
12642  x[5] = -0.60054530466168102346963816;
12643  x[6] = -0.46457074137596094571726715;
12644  x[7] = -0.31656409996362983199011733;
12645  x[8] = -0.16035864564022537586809612;
12646  x[9] = 0.00000000000000000000000000;
12647  x[10] = 0.16035864564022537586809612;
12648  x[11] = 0.31656409996362983199011733;
12649  x[12] = 0.46457074137596094571726715;
12650  x[13] = 0.60054530466168102346963816;
12651  x[14] = 0.72096617733522937861709586;
12652  x[15] = 0.82271465653714282497892249;
12653  x[16] = 0.90315590361481790164266093;
12654  x[17] = 0.96020815213483003085277884;
12655  x[18] = 0.99240684384358440318901767;
12656  }
12657  else if ( n == 20 )
12658  {
12659  x[0] = -0.993128599185094924786122388;
12660  x[1] = -0.963971927277913791267666131;
12661  x[2] = -0.912234428251325905867752441;
12662  x[3] = -0.83911697182221882339452906;
12663  x[4] = -0.74633190646015079261430507;
12664  x[5] = -0.63605368072651502545283670;
12665  x[6] = -0.51086700195082709800436405;
12666  x[7] = -0.37370608871541956067254818;
12667  x[8] = -0.22778585114164507808049620;
12668  x[9] = -0.07652652113349733375464041;
12669  x[10] = 0.07652652113349733375464041;
12670  x[11] = 0.22778585114164507808049620;
12671  x[12] = 0.37370608871541956067254818;
12672  x[13] = 0.51086700195082709800436405;
12673  x[14] = 0.63605368072651502545283670;
12674  x[15] = 0.74633190646015079261430507;
12675  x[16] = 0.83911697182221882339452906;
12676  x[17] = 0.91223442825132590586775244;
12677  x[18] = 0.96397192727791379126766613;
12678  x[19] = 0.99312859918509492478612239;
12679  }
12680  else if ( n == 21 )
12681  {
12682  x[ 0] = -0.99375217062038950026024204;
12683  x[ 1] = -0.96722683856630629431662221;
12684  x[ 2] = -0.92009933415040082879018713;
12685  x[ 3] = -0.85336336458331728364725064;
12686  x[ 4] = -0.76843996347567790861587785;
12687  x[ 5] = -0.66713880419741231930596667;
12688  x[ 6] = -0.55161883588721980705901880;
12689  x[ 7] = -0.42434212020743878357366889;
12690  x[ 8] = -0.28802131680240109660079252;
12691  x[9] = -0.14556185416089509093703098;
12692  x[10] = 0.00000000000000000000000000;
12693  x[11] = +0.14556185416089509093703098;
12694  x[12] = +0.28802131680240109660079252;
12695  x[13] = +0.42434212020743878357366889;
12696  x[14] = +0.55161883588721980705901880;
12697  x[15] = +0.66713880419741231930596667;
12698  x[16] = +0.76843996347567790861587785;
12699  x[17] = +0.85336336458331728364725064;
12700  x[18] = +0.92009933415040082879018713;
12701  x[19] = +0.96722683856630629431662221;
12702  x[20] = +0.99375217062038950026024204;
12703  }
12704  else if ( n == 22 )
12705  {
12706  x[0] = -0.99429458548239929207303142;
12707  x[1] = -0.97006049783542872712395099;
12708  x[2] = -0.92695677218717400052069294;
12709  x[3] = -0.86581257772030013653642564;
12710  x[4] = -0.78781680597920816200427796;
12711  x[5] = -0.69448726318668278005068984;
12712  x[6] = -0.58764040350691159295887693;
12713  x[7] = -0.46935583798675702640633071;
12714  x[8] = -0.34193582089208422515814742;
12715  x[9] = -0.20786042668822128547884653;
12716  x[10] = -0.06973927331972222121384180;
12717  x[11] = 0.06973927331972222121384180;
12718  x[12] = 0.20786042668822128547884653;
12719  x[13] = 0.34193582089208422515814742;
12720  x[14] = 0.46935583798675702640633071;
12721  x[15] = 0.58764040350691159295887693;
12722  x[16] = 0.69448726318668278005068984;
12723  x[17] = 0.78781680597920816200427796;
12724  x[18] = 0.86581257772030013653642564;
12725  x[19] = 0.92695677218717400052069294;
12726  x[20] = 0.97006049783542872712395099;
12727  x[21] = 0.99429458548239929207303142;
12728  }
12729  else if ( n == 23 )
12730  {
12731  x[0] = -0.99476933499755212352392572;
12732  x[1] = -0.97254247121811523195602408;
12733  x[2] = -0.93297108682601610234919699;
12734  x[3] = -0.87675235827044166737815689;
12735  x[4] = -0.80488840161883989215111841;
12736  x[5] = -0.71866136313195019446162448;
12737  x[6] = -0.61960987576364615638509731;
12738  x[7] = -0.50950147784600754968979305;
12739  x[8] = -0.39030103803029083142148887;
12740  x[9] = -0.26413568097034493053386954;
12741  x[10] = -0.13325682429846611093174268;
12742  x[11] = 0.00000000000000000000000000;
12743  x[12] = 0.13325682429846611093174268;
12744  x[13] = 0.26413568097034493053386954;
12745  x[14] = 0.39030103803029083142148887;
12746  x[15] = 0.50950147784600754968979305;
12747  x[16] = 0.61960987576364615638509731;
12748  x[17] = 0.71866136313195019446162448;
12749  x[18] = 0.80488840161883989215111841;
12750  x[19] = 0.87675235827044166737815689;
12751  x[20] = 0.93297108682601610234919699;
12752  x[21] = 0.97254247121811523195602408;
12753  x[22] = 0.99476933499755212352392572;
12754  }
12755  else if ( n == 24 )
12756  {
12757  x[0] = -0.99518721999702136017999741;
12758  x[1] = -0.97472855597130949819839199;
12759  x[2] = -0.93827455200273275852364900;
12760  x[3] = -0.88641552700440103421315434;
12761  x[4] = -0.82000198597390292195394987;
12762  x[5] = -0.74012419157855436424382810;
12763  x[6] = -0.64809365193697556925249579;
12764  x[7] = -0.54542147138883953565837562;
12765  x[8] = -0.43379350762604513848708423;
12766  x[9] = -0.31504267969616337438679329;
12767  x[10] = -0.19111886747361630915863982;
12768  x[11] = -0.06405689286260562608504308;
12769  x[12] = 0.06405689286260562608504308;
12770  x[13] = 0.19111886747361630915863982;
12771  x[14] = 0.31504267969616337438679329;
12772  x[15] = 0.43379350762604513848708423;
12773  x[16] = 0.54542147138883953565837562;
12774  x[17] = 0.64809365193697556925249579;
12775  x[18] = 0.74012419157855436424382810;
12776  x[19] = 0.82000198597390292195394987;
12777  x[20] = 0.88641552700440103421315434;
12778  x[21] = 0.93827455200273275852364900;
12779  x[22] = 0.97472855597130949819839199;
12780  x[23] = 0.99518721999702136017999741;
12781  }
12782  else if ( n == 25 )
12783  {
12784  x[0] = -0.99555696979049809790878495;
12785  x[1] = -0.97666392145951751149831539;
12786  x[2] = -0.94297457122897433941401117;
12787  x[3] = -0.89499199787827536885104201;
12788  x[4] = -0.83344262876083400142102111;
12789  x[5] = -0.75925926303735763057728287;
12790  x[6] = -0.67356636847346836448512063;
12791  x[7] = -0.57766293024122296772368984;
12792  x[8] = -0.47300273144571496052218212;
12793  x[9] = -0.36117230580938783773582173;
12794  x[10] = -0.24386688372098843204519036;
12795  x[11] = -0.12286469261071039638735982;
12796  x[12] = 0.00000000000000000000000000;
12797  x[13] = 0.12286469261071039638735982;
12798  x[14] = 0.24386688372098843204519036;
12799  x[15] = 0.36117230580938783773582173;
12800  x[16] = 0.47300273144571496052218212;
12801  x[17] = 0.57766293024122296772368984;
12802  x[18] = 0.67356636847346836448512063;
12803  x[19] = 0.75925926303735763057728287;
12804  x[20] = 0.83344262876083400142102111;
12805  x[21] = 0.89499199787827536885104201;
12806  x[22] = 0.94297457122897433941401117;
12807  x[23] = 0.97666392145951751149831539;
12808  x[24] = 0.99555696979049809790878495;
12809  }
12810  else if ( n == 26 )
12811  {
12812  x[0] = -0.99588570114561692900321696;
12813  x[1] = -0.97838544595647099110058035;
12814  x[2] = -0.94715906666171425013591528;
12815  x[3] = -0.90263786198430707421766560;
12816  x[4] = -0.84544594278849801879750706;
12817  x[5] = -0.77638594882067885619296725;
12818  x[6] = -0.69642726041995726486381391;
12819  x[7] = -0.60669229301761806323197875;
12820  x[8] = -0.50844071482450571769570306;
12821  x[9] = -0.40305175512348630648107738;
12822  x[10] = -0.29200483948595689514283538;
12823  x[11] = -0.17685882035689018396905775;
12824  x[12] = -0.05923009342931320709371858;
12825  x[13] = 0.05923009342931320709371858;
12826  x[14] = 0.17685882035689018396905775;
12827  x[15] = 0.29200483948595689514283538;
12828  x[16] = 0.40305175512348630648107738;
12829  x[17] = 0.50844071482450571769570306;
12830  x[18] = 0.60669229301761806323197875;
12831  x[19] = 0.69642726041995726486381391;
12832  x[20] = 0.77638594882067885619296725;
12833  x[21] = 0.84544594278849801879750706;
12834  x[22] = 0.90263786198430707421766560;
12835  x[23] = 0.94715906666171425013591528;
12836  x[24] = 0.97838544595647099110058035;
12837  x[25] = 0.99588570114561692900321696;
12838  }
12839  else if ( n == 27 )
12840  {
12841  x[0] = -0.99617926288898856693888721;
12842  x[1] = -0.97992347596150122285587336;
12843  x[2] = -0.95090055781470500685190803;
12844  x[3] = -0.90948232067749110430064502;
12845  x[4] = -0.85620790801829449030273722;
12846  x[5] = -0.79177163907050822714439734;
12847  x[6] = -0.71701347373942369929481621;
12848  x[7] = -0.63290797194649514092773464;
12849  x[8] = -0.54055156457945689490030094;
12850  x[9] = -0.44114825175002688058597416;
12851  x[10] = -0.33599390363850889973031903;
12852  x[11] = -0.22645936543953685885723911;
12853  x[12] = -0.11397258560952996693289498;
12854  x[13] = 0.00000000000000000000000000;
12855  x[14] = 0.11397258560952996693289498;
12856  x[15] = 0.22645936543953685885723911;
12857  x[16] = 0.33599390363850889973031903;
12858  x[17] = 0.44114825175002688058597416;
12859  x[18] = 0.54055156457945689490030094;
12860  x[19] = 0.63290797194649514092773464;
12861  x[20] = 0.71701347373942369929481621;
12862  x[21] = 0.79177163907050822714439734;
12863  x[22] = 0.85620790801829449030273722;
12864  x[23] = 0.90948232067749110430064502;
12865  x[24] = 0.95090055781470500685190803;
12866  x[25] = 0.97992347596150122285587336;
12867  x[26] = 0.99617926288898856693888721;
12868  }
12869  else if ( n == 28 )
12870  {
12871  x[0] = -0.99644249757395444995043639;
12872  x[1] = -0.98130316537087275369455995;
12873  x[2] = -0.95425928062893819725410184;
12874  x[3] = -0.91563302639213207386968942;
12875  x[4] = -0.86589252257439504894225457;
12876  x[5] = -0.80564137091717917144788596;
12877  x[6] = -0.73561087801363177202814451;
12878  x[7] = -0.65665109403886496121989818;
12879  x[8] = -0.56972047181140171930800328;
12880  x[9] = -0.47587422495511826103441185;
12881  x[10] = -0.37625151608907871022135721;
12882  x[11] = -0.27206162763517807767682636;
12883  x[12] = -0.16456928213338077128147178;
12884  x[13] = -0.05507928988403427042651653;
12885  x[14] = 0.05507928988403427042651653;
12886  x[15] = 0.16456928213338077128147178;
12887  x[16] = 0.27206162763517807767682636;
12888  x[17] = 0.37625151608907871022135721;
12889  x[18] = 0.47587422495511826103441185;
12890  x[19] = 0.56972047181140171930800328;
12891  x[20] = 0.65665109403886496121989818;
12892  x[21] = 0.73561087801363177202814451;
12893  x[22] = 0.80564137091717917144788596;
12894  x[23] = 0.86589252257439504894225457;
12895  x[24] = 0.91563302639213207386968942;
12896  x[25] = 0.95425928062893819725410184;
12897  x[26] = 0.98130316537087275369455995;
12898  x[27] = 0.99644249757395444995043639;
12899  }
12900  else if ( n == 29 )
12901  {
12902  x[0] = -0.99667944226059658616319153;
12903  x[1] = -0.98254550526141317487092602;
12904  x[2] = -0.95728559577808772579820804;
12905  x[3] = -0.92118023295305878509375344;
12906  x[4] = -0.87463780492010279041779342;
12907  x[5] = -0.81818548761525244498957221;
12908  x[6] = -0.75246285173447713391261008;
12909  x[7] = -0.67821453760268651515618501;
12910  x[8] = -0.59628179713822782037958621;
12911  x[9] = -0.50759295512422764210262792;
12912  x[10] = -0.41315288817400866389070659;
12913  x[11] = -0.31403163786763993494819592;
12914  x[12] = -0.21135228616600107450637573;
12915  x[13] = -0.10627823013267923017098239;
12916  x[14] = 0.00000000000000000000000000;
12917  x[15] = 0.10627823013267923017098239;
12918  x[16] = 0.21135228616600107450637573;
12919  x[17] = 0.31403163786763993494819592;
12920  x[18] = 0.41315288817400866389070659;
12921  x[19] = 0.50759295512422764210262792;
12922  x[20] = 0.59628179713822782037958621;
12923  x[21] = 0.67821453760268651515618501;
12924  x[22] = 0.75246285173447713391261008;
12925  x[23] = 0.81818548761525244498957221;
12926  x[24] = 0.87463780492010279041779342;
12927  x[25] = 0.92118023295305878509375344;
12928  x[26] = 0.95728559577808772579820804;
12929  x[27] = 0.98254550526141317487092602;
12930  x[28] = 0.99667944226059658616319153;
12931  }
12932  else if ( n == 30 )
12933  {
12934  x[0] = -0.99689348407464954027163005;
12935  x[1] = -0.98366812327974720997003258;
12936  x[2] = -0.96002186496830751221687103;
12937  x[3] = -0.92620004742927432587932428;
12938  x[4] = -0.88256053579205268154311646;
12939  x[5] = -0.82956576238276839744289812;
12940  x[6] = -0.76777743210482619491797734;
12941  x[7] = -0.69785049479331579693229239;
12942  x[8] = -0.62052618298924286114047756;
12943  x[9] = -0.53662414814201989926416979;
12944  x[10] = -0.44703376953808917678060990;
12945  x[11] = -0.35270472553087811347103721;
12946  x[12] = -0.25463692616788984643980513;
12947  x[13] = -0.15386991360858354696379467;
12948  x[14] = -0.05147184255531769583302521;
12949  x[15] = 0.05147184255531769583302521;
12950  x[16] = 0.15386991360858354696379467;
12951  x[17] = 0.25463692616788984643980513;
12952  x[18] = 0.35270472553087811347103721;
12953  x[19] = 0.44703376953808917678060990;
12954  x[20] = 0.53662414814201989926416979;
12955  x[21] = 0.62052618298924286114047756;
12956  x[22] = 0.69785049479331579693229239;
12957  x[23] = 0.76777743210482619491797734;
12958  x[24] = 0.82956576238276839744289812;
12959  x[25] = 0.88256053579205268154311646;
12960  x[26] = 0.92620004742927432587932428;
12961  x[27] = 0.96002186496830751221687103;
12962  x[28] = 0.98366812327974720997003258;
12963  x[29] = 0.99689348407464954027163005;
12964  }
12965  else if ( n == 31 )
12966  {
12967  x[0] = -0.99708748181947707405562655;
12968  x[1] = -0.98468590966515248400246517;
12969  x[2] = -0.96250392509294966178905240;
12970  x[3] = -0.93075699789664816495694576;
12971  x[4] = -0.88976002994827104337419201;
12972  x[5] = -0.83992032014626734008690454;
12973  x[6] = -0.78173314841662494040636002;
12974  x[7] = -0.71577678458685328390597087;
12975  x[8] = -0.64270672292426034618441820;
12976  x[9] = -0.56324916140714926272094492;
12977  x[10] = -0.47819378204490248044059404;
12978  x[11] = -0.38838590160823294306135146;
12979  x[12] = -0.29471806998170161661790390;
12980  x[13] = -0.19812119933557062877241300;
12981  x[14] = -0.09955531215234152032517479;
12982  x[15] = 0.00000000000000000000000000;
12983  x[16] = 0.09955531215234152032517479;
12984  x[17] = 0.19812119933557062877241300;
12985  x[18] = 0.29471806998170161661790390;
12986  x[19] = 0.38838590160823294306135146;
12987  x[20] = 0.47819378204490248044059404;
12988  x[21] = 0.56324916140714926272094492;
12989  x[22] = 0.64270672292426034618441820;
12990  x[23] = 0.71577678458685328390597087;
12991  x[24] = 0.78173314841662494040636002;
12992  x[25] = 0.83992032014626734008690454;
12993  x[26] = 0.88976002994827104337419201;
12994  x[27] = 0.93075699789664816495694576;
12995  x[28] = 0.96250392509294966178905240;
12996  x[29] = 0.98468590966515248400246517;
12997  x[30] = 0.99708748181947707405562655;
12998  }
12999  else if ( n == 32 )
13000  {
13001  x[0] = -0.99726386184948156354498113;
13002  x[1] = -0.98561151154526833540017504;
13003  x[2] = -0.96476225558750643077381193;
13004  x[3] = -0.93490607593773968917091913;
13005  x[4] = -0.89632115576605212396530724;
13006  x[5] = -0.84936761373256997013369300;
13007  x[6] = -0.79448379596794240696309730;
13008  x[7] = -0.73218211874028968038742667;
13009  x[8] = -0.66304426693021520097511517;
13010  x[9] = -0.58771575724076232904074548;
13011  x[10] = -0.50689990893222939002374747;
13012  x[11] = -0.42135127613063534536411944;
13013  x[12] = -0.33186860228212764977991681;
13014  x[13] = -0.23928736225213707454460321;
13015  x[14] = -0.14447196158279649348518637;
13016  x[15] = -0.04830766568773831623481257;
13017  x[16] = 0.04830766568773831623481257;
13018  x[17] = 0.14447196158279649348518637;
13019  x[18] = 0.23928736225213707454460321;
13020  x[19] = 0.33186860228212764977991681;
13021  x[20] = 0.42135127613063534536411944;
13022  x[21] = 0.50689990893222939002374747;
13023  x[22] = 0.58771575724076232904074548;
13024  x[23] = 0.66304426693021520097511517;
13025  x[24] = 0.73218211874028968038742667;
13026  x[25] = 0.79448379596794240696309730;
13027  x[26] = 0.84936761373256997013369300;
13028  x[27] = 0.89632115576605212396530724;
13029  x[28] = 0.93490607593773968917091913;
13030  x[29] = 0.96476225558750643077381193;
13031  x[30] = 0.98561151154526833540017504;
13032  x[31] = 0.99726386184948156354498113;
13033  }
13034  else if ( n == 33 )
13035  {
13036  x[0] = -0.99742469424645521726616802;
13037  x[1] = -0.98645572623064248811037570;
13038  x[2] = -0.96682290968999276892837771;
13039  x[3] = -0.93869437261116835035583512;
13040  x[4] = -0.90231676774343358304053133;
13041  x[5] = -0.85800965267650406464306148;
13042  x[6] = -0.80616235627416658979620087;
13043  x[7] = -0.74723049644956215785905512;
13044  x[8] = -0.68173195996974278626821595;
13045  x[9] = -0.61024234583637902730728751;
13046  x[10] = -0.53338990478634764354889426;
13047  x[11] = -0.45185001727245069572599328;
13048  x[12] = -0.36633925774807334107022062;
13049  x[13] = -0.27760909715249702940324807;
13050  x[14] = -0.18643929882799157233579876;
13051  x[15] = -0.09363106585473338567074292;
13052  x[16] = 0.00000000000000000000000000;
13053  x[17] = 0.09363106585473338567074292;
13054  x[18] = 0.18643929882799157233579876;
13055  x[19] = 0.27760909715249702940324807;
13056  x[20] = 0.36633925774807334107022062;
13057  x[21] = 0.45185001727245069572599328;
13058  x[22] = 0.53338990478634764354889426;
13059  x[23] = 0.61024234583637902730728751;
13060  x[24] = 0.68173195996974278626821595;
13061  x[25] = 0.74723049644956215785905512;
13062  x[26] = 0.80616235627416658979620087;
13063  x[27] = 0.85800965267650406464306148;
13064  x[28] = 0.90231676774343358304053133;
13065  x[29] = 0.93869437261116835035583512;
13066  x[30] = 0.96682290968999276892837771;
13067  x[31] = 0.98645572623064248811037570;
13068  x[32] = 0.99742469424645521726616802;
13069  }
13070  else
13071  {
13072  std::cerr << "\n";
13073  std::cerr << "LEGENDRE_LOOKUP_POINTS - Fatal error!\n";
13074  std::cerr << " Illegal value of N = " << n << "\n";
13075  std::cerr << " Legal values are 1 through 33.\n";
13076  std::exit ( 1 );
13077  }
13078  return;
13079 }
13080 //**************************************************************************80
13081 
13082 void SandiaRules::legendre_lookup_weights ( int n, double w[] )
13083 
13084 //**************************************************************************80
13085 //
13086 // Purpose:
13087 //
13088 // LEGENDRE_LOOKUP_WEIGHTS looks up weights for Gauss-Legendre quadrature.
13089 //
13090 // Licensing:
13091 //
13092 // This code is distributed under the GNU LGPL license.
13093 //
13094 // Modified:
13095 //
13096 // 27 April 2010
13097 //
13098 // Author:
13099 //
13100 // John Burkardt
13101 //
13102 // Reference:
13103 //
13104 // Milton Abramowitz, Irene Stegun,
13105 // Handbook of Mathematical Functions,
13106 // National Bureau of Standards, 1964,
13107 // ISBN: 0-486-61272-4,
13108 // LC: QA47.A34.
13109 //
13110 // Vladimir Krylov,
13111 // Approximate Calculation of Integrals,
13112 // Dover, 2006,
13113 // ISBN: 0486445798.
13114 // LC: QA311.K713.
13115 //
13116 // Arthur Stroud, Don Secrest,
13117 // Gaussian Quadrature Formulas,
13118 // Prentice Hall, 1966,
13119 // LC: QA299.4G3S7.
13120 //
13121 // Stephen Wolfram,
13122 // The Mathematica Book,
13123 // Fourth Edition,
13124 // Cambridge University Press, 1999,
13125 // ISBN: 0-521-64314-7,
13126 // LC: QA76.95.W65.
13127 //
13128 // Daniel Zwillinger, editor,
13129 // CRC Standard Mathematical Tables and Formulae,
13130 // 30th Edition,
13131 // CRC Press, 1996,
13132 // ISBN: 0-8493-2479-3,
13133 // LC: QA47.M315.
13134 //
13135 // Parameters:
13136 //
13137 // Input, int N, the order.
13138 // N must be between 1 and 33.
13139 //
13140 // Output, double W[N], the weights.
13141 //
13142 {
13143  if ( n == 1 )
13144  {
13145  w[0] = 2.000000000000000000000000000000;
13146  }
13147  else if ( n == 2 )
13148  {
13149  w[0] = 1.000000000000000000000000000000;
13150  w[1] = 1.000000000000000000000000000000;
13151  }
13152  else if ( n == 3 )
13153  {
13154  w[0] = 0.555555555555555555555555555556;
13155  w[1] = 0.888888888888888888888888888889;
13156  w[2] = 0.555555555555555555555555555556;
13157  }
13158  else if ( n == 4 )
13159  {
13160  w[0] = 0.347854845137453857373063949222;
13161  w[1] = 0.652145154862546142626936050778;
13162  w[2] = 0.652145154862546142626936050778;
13163  w[3] = 0.347854845137453857373063949222;
13164  }
13165  else if ( n == 5 )
13166  {
13167  w[0] = 0.236926885056189087514264040720;
13168  w[1] = 0.478628670499366468041291514836;
13169  w[2] = 0.568888888888888888888888888889;
13170  w[3] = 0.478628670499366468041291514836;
13171  w[4] = 0.236926885056189087514264040720;
13172  }
13173  else if ( n == 6 )
13174  {
13175  w[0] = 0.171324492379170345040296142173;
13176  w[1] = 0.360761573048138607569833513838;
13177  w[2] = 0.467913934572691047389870343990;
13178  w[3] = 0.467913934572691047389870343990;
13179  w[4] = 0.360761573048138607569833513838;
13180  w[5] = 0.171324492379170345040296142173;
13181  }
13182  else if ( n == 7 )
13183  {
13184  w[0] = 0.129484966168869693270611432679;
13185  w[1] = 0.279705391489276667901467771424;
13186  w[2] = 0.381830050505118944950369775489;
13187  w[3] = 0.417959183673469387755102040816;
13188  w[4] = 0.381830050505118944950369775489;
13189  w[5] = 0.279705391489276667901467771424;
13190  w[6] = 0.129484966168869693270611432679;
13191  }
13192  else if ( n == 8 )
13193  {
13194  w[0] = 0.101228536290376259152531354310;
13195  w[1] = 0.222381034453374470544355994426;
13196  w[2] = 0.313706645877887287337962201987;
13197  w[3] = 0.362683783378361982965150449277;
13198  w[4] = 0.362683783378361982965150449277;
13199  w[5] = 0.313706645877887287337962201987;
13200  w[6] = 0.222381034453374470544355994426;
13201  w[7] = 0.101228536290376259152531354310;
13202  }
13203  else if ( n == 9 )
13204  {
13205  w[0] = 0.081274388361574411971892158111;
13206  w[1] = 0.18064816069485740405847203124;
13207  w[2] = 0.26061069640293546231874286942;
13208  w[3] = 0.31234707704000284006863040658;
13209  w[4] = 0.33023935500125976316452506929;
13210  w[5] = 0.31234707704000284006863040658;
13211  w[6] = 0.26061069640293546231874286942;
13212  w[7] = 0.18064816069485740405847203124;
13213  w[8] = 0.081274388361574411971892158111;
13214  }
13215  else if ( n == 10 )
13216  {
13217  w[0] = 0.066671344308688137593568809893;
13218  w[1] = 0.14945134915058059314577633966;
13219  w[2] = 0.21908636251598204399553493423;
13220  w[3] = 0.26926671930999635509122692157;
13221  w[4] = 0.29552422471475287017389299465;
13222  w[5] = 0.29552422471475287017389299465;
13223  w[6] = 0.26926671930999635509122692157;
13224  w[7] = 0.21908636251598204399553493423;
13225  w[8] = 0.14945134915058059314577633966;
13226  w[9] = 0.066671344308688137593568809893;
13227  }
13228  else if ( n == 11 )
13229  {
13230  w[0] = 0.055668567116173666482753720443;
13231  w[1] = 0.12558036946490462463469429922;
13232  w[2] = 0.18629021092773425142609764143;
13233  w[3] = 0.23319376459199047991852370484;
13234  w[4] = 0.26280454451024666218068886989;
13235  w[5] = 0.27292508677790063071448352834;
13236  w[6] = 0.26280454451024666218068886989;
13237  w[7] = 0.23319376459199047991852370484;
13238  w[8] = 0.18629021092773425142609764143;
13239  w[9] = 0.12558036946490462463469429922;
13240  w[10] = 0.055668567116173666482753720443;
13241  }
13242  else if ( n == 12 )
13243  {
13244  w[0] = 0.047175336386511827194615961485;
13245  w[1] = 0.10693932599531843096025471819;
13246  w[2] = 0.16007832854334622633465252954;
13247  w[3] = 0.20316742672306592174906445581;
13248  w[4] = 0.23349253653835480876084989892;
13249  w[5] = 0.24914704581340278500056243604;
13250  w[6] = 0.24914704581340278500056243604;
13251  w[7] = 0.23349253653835480876084989892;
13252  w[8] = 0.20316742672306592174906445581;
13253  w[9] = 0.16007832854334622633465252954;
13254  w[10] = 0.10693932599531843096025471819;
13255  w[11] = 0.047175336386511827194615961485;
13256  }
13257  else if ( n == 13 )
13258  {
13259  w[0] = 0.040484004765315879520021592201;
13260  w[1] = 0.092121499837728447914421775954;
13261  w[2] = 0.13887351021978723846360177687;
13262  w[3] = 0.17814598076194573828004669200;
13263  w[4] = 0.20781604753688850231252321931;
13264  w[5] = 0.22628318026289723841209018604;
13265  w[6] = 0.23255155323087391019458951527;
13266  w[7] = 0.22628318026289723841209018604;
13267  w[8] = 0.20781604753688850231252321931;
13268  w[9] = 0.17814598076194573828004669200;
13269  w[10] = 0.13887351021978723846360177687;
13270  w[11] = 0.092121499837728447914421775954;
13271  w[12] = 0.040484004765315879520021592201;
13272  }
13273  else if ( n == 14 )
13274  {
13275  w[0] = 0.035119460331751863031832876138;
13276  w[1] = 0.08015808715976020980563327706;
13277  w[2] = 0.12151857068790318468941480907;
13278  w[3] = 0.15720316715819353456960193862;
13279  w[4] = 0.18553839747793781374171659013;
13280  w[5] = 0.20519846372129560396592406566;
13281  w[6] = 0.21526385346315779019587644332;
13282  w[7] = 0.21526385346315779019587644332;
13283  w[8] = 0.20519846372129560396592406566;
13284  w[9] = 0.18553839747793781374171659013;
13285  w[10] = 0.15720316715819353456960193862;
13286  w[11] = 0.12151857068790318468941480907;
13287  w[12] = 0.08015808715976020980563327706;
13288  w[13] = 0.035119460331751863031832876138;
13289  }
13290  else if ( n == 15 )
13291  {
13292  w[0] = 0.030753241996117268354628393577;
13293  w[1] = 0.070366047488108124709267416451;
13294  w[2] = 0.107159220467171935011869546686;
13295  w[3] = 0.13957067792615431444780479451;
13296  w[4] = 0.16626920581699393355320086048;
13297  w[5] = 0.18616100001556221102680056187;
13298  w[6] = 0.19843148532711157645611832644;
13299  w[7] = 0.20257824192556127288062019997;
13300  w[8] = 0.19843148532711157645611832644;
13301  w[9] = 0.18616100001556221102680056187;
13302  w[10] = 0.16626920581699393355320086048;
13303  w[11] = 0.13957067792615431444780479451;
13304  w[12] = 0.107159220467171935011869546686;
13305  w[13] = 0.070366047488108124709267416451;
13306  w[14] = 0.030753241996117268354628393577;
13307  }
13308  else if ( n == 16 )
13309  {
13310  w[0] = 0.027152459411754094851780572456;
13311  w[1] = 0.062253523938647892862843836994;
13312  w[2] = 0.09515851168249278480992510760;
13313  w[3] = 0.12462897125553387205247628219;
13314  w[4] = 0.14959598881657673208150173055;
13315  w[5] = 0.16915651939500253818931207903;
13316  w[6] = 0.18260341504492358886676366797;
13317  w[7] = 0.18945061045506849628539672321;
13318  w[8] = 0.18945061045506849628539672321;
13319  w[9] = 0.18260341504492358886676366797;
13320  w[10] = 0.16915651939500253818931207903;
13321  w[11] = 0.14959598881657673208150173055;
13322  w[12] = 0.12462897125553387205247628219;
13323  w[13] = 0.09515851168249278480992510760;
13324  w[14] = 0.062253523938647892862843836994;
13325  w[15] = 0.027152459411754094851780572456;
13326  }
13327  else if ( n == 17 )
13328  {
13329  w[0] = 0.024148302868547931960110026288;
13330  w[1] = 0.055459529373987201129440165359;
13331  w[2] = 0.085036148317179180883535370191;
13332  w[3] = 0.111883847193403971094788385626;
13333  w[4] = 0.13513636846852547328631998170;
13334  w[5] = 0.15404576107681028808143159480;
13335  w[6] = 0.16800410215645004450997066379;
13336  w[7] = 0.17656270536699264632527099011;
13337  w[8] = 0.17944647035620652545826564426;
13338  w[9] = 0.17656270536699264632527099011;
13339  w[10] = 0.16800410215645004450997066379;
13340  w[11] = 0.15404576107681028808143159480;
13341  w[12] = 0.13513636846852547328631998170;
13342  w[13] = 0.111883847193403971094788385626;
13343  w[14] = 0.085036148317179180883535370191;
13344  w[15] = 0.055459529373987201129440165359;
13345  w[16] = 0.024148302868547931960110026288;
13346  }
13347  else if ( n == 18 )
13348  {
13349  w[0] = 0.021616013526483310313342710266;
13350  w[1] = 0.049714548894969796453334946203;
13351  w[2] = 0.07642573025488905652912967762;
13352  w[3] = 0.10094204410628716556281398492;
13353  w[4] = 0.12255520671147846018451912680;
13354  w[5] = 0.14064291467065065120473130375;
13355  w[6] = 0.15468467512626524492541800384;
13356  w[7] = 0.16427648374583272298605377647;
13357  w[8] = 0.16914238296314359184065647013;
13358  w[9] = 0.16914238296314359184065647013;
13359  w[10] = 0.16427648374583272298605377647;
13360  w[11] = 0.15468467512626524492541800384;
13361  w[12] = 0.14064291467065065120473130375;
13362  w[13] = 0.12255520671147846018451912680;
13363  w[14] = 0.10094204410628716556281398492;
13364  w[15] = 0.07642573025488905652912967762;
13365  w[16] = 0.049714548894969796453334946203;
13366  w[17] = 0.021616013526483310313342710266;
13367  }
13368  else if ( n == 19 )
13369  {
13370  w[0] = 0.019461788229726477036312041464;
13371  w[1] = 0.044814226765699600332838157402;
13372  w[2] = 0.069044542737641226580708258006;
13373  w[3] = 0.091490021622449999464462094124;
13374  w[4] = 0.111566645547333994716023901682;
13375  w[5] = 0.12875396253933622767551578486;
13376  w[6] = 0.14260670217360661177574610944;
13377  w[7] = 0.15276604206585966677885540090;
13378  w[8] = 0.15896884339395434764995643946;
13379  w[9] = 0.16105444984878369597916362532;
13380  w[10] = 0.15896884339395434764995643946;
13381  w[11] = 0.15276604206585966677885540090;
13382  w[12] = 0.14260670217360661177574610944;
13383  w[13] = 0.12875396253933622767551578486;
13384  w[14] = 0.111566645547333994716023901682;
13385  w[15] = 0.091490021622449999464462094124;
13386  w[16] = 0.069044542737641226580708258006;
13387  w[17] = 0.044814226765699600332838157402;
13388  w[18] = 0.019461788229726477036312041464;
13389  }
13390  else if ( n == 20 )
13391  {
13392  w[0] = 0.017614007139152118311861962352;
13393  w[1] = 0.040601429800386941331039952275;
13394  w[2] = 0.062672048334109063569506535187;
13395  w[3] = 0.08327674157670474872475814322;
13396  w[4] = 0.10193011981724043503675013548;
13397  w[5] = 0.11819453196151841731237737771;
13398  w[6] = 0.13168863844917662689849449975;
13399  w[7] = 0.14209610931838205132929832507;
13400  w[8] = 0.14917298647260374678782873700;
13401  w[9] = 0.15275338713072585069808433195;
13402  w[10] = 0.15275338713072585069808433195;
13403  w[11] = 0.14917298647260374678782873700;
13404  w[12] = 0.14209610931838205132929832507;
13405  w[13] = 0.13168863844917662689849449975;
13406  w[14] = 0.11819453196151841731237737771;
13407  w[15] = 0.10193011981724043503675013548;
13408  w[16] = 0.08327674157670474872475814322;
13409  w[17] = 0.062672048334109063569506535187;
13410  w[18] = 0.040601429800386941331039952275;
13411  w[19] = 0.017614007139152118311861962352;
13412  }
13413  else if ( n == 21 )
13414  {
13415  w[ 0] = 0.016017228257774333324224616858;
13416  w[ 1] = 0.036953789770852493799950668299;
13417  w[ 2] = 0.057134425426857208283635826472;
13418  w[ 3] = 0.076100113628379302017051653300;
13419  w[ 4] = 0.093444423456033861553289741114;
13420  w[ 5] = 0.108797299167148377663474578070;
13421  w[ 6] = 0.12183141605372853419536717713;
13422  w[ 7] = 0.13226893863333746178105257450;
13423  w[ 8] = 0.13988739479107315472213342387;
13424  w[9] = 0.14452440398997005906382716655;
13425  w[10] = 0.14608113364969042719198514768;
13426  w[11] = 0.14452440398997005906382716655;
13427  w[12] = 0.13988739479107315472213342387;
13428  w[13] = 0.13226893863333746178105257450;
13429  w[14] = 0.12183141605372853419536717713;
13430  w[15] = 0.108797299167148377663474578070;
13431  w[16] = 0.093444423456033861553289741114;
13432  w[17] = 0.076100113628379302017051653300;
13433  w[18] = 0.057134425426857208283635826472;
13434  w[19] = 0.036953789770852493799950668299;
13435  w[20] = 0.016017228257774333324224616858;
13436  }
13437  else if ( n == 22 )
13438  {
13439  w[0] = 0.014627995298272200684991098047;
13440  w[1] = 0.033774901584814154793302246866;
13441  w[2] = 0.052293335152683285940312051273;
13442  w[3] = 0.06979646842452048809496141893;
13443  w[4] = 0.08594160621706772741444368137;
13444  w[5] = 0.10041414444288096493207883783;
13445  w[6] = 0.11293229608053921839340060742;
13446  w[7] = 0.12325237681051242428556098615;
13447  w[8] = 0.13117350478706237073296499253;
13448  w[9] = 0.13654149834601517135257383123;
13449  w[10] = 0.13925187285563199337541024834;
13450  w[11] = 0.13925187285563199337541024834;
13451  w[12] = 0.13654149834601517135257383123;
13452  w[13] = 0.13117350478706237073296499253;
13453  w[14] = 0.12325237681051242428556098615;
13454  w[15] = 0.11293229608053921839340060742;
13455  w[16] = 0.10041414444288096493207883783;
13456  w[17] = 0.08594160621706772741444368137;
13457  w[18] = 0.06979646842452048809496141893;
13458  w[19] = 0.052293335152683285940312051273;
13459  w[20] = 0.033774901584814154793302246866;
13460  w[21] = 0.014627995298272200684991098047;
13461  }
13462  else if ( n == 23 )
13463  {
13464  w[0] = 0.013411859487141772081309493459;
13465  w[1] = 0.030988005856979444310694219642;
13466  w[2] = 0.048037671731084668571641071632;
13467  w[3] = 0.064232421408525852127169615159;
13468  w[4] = 0.079281411776718954922892524742;
13469  w[5] = 0.092915766060035147477018617370;
13470  w[6] = 0.104892091464541410074086185015;
13471  w[7] = 0.11499664022241136494164351293;
13472  w[8] = 0.12304908430672953046757840067;
13473  w[9] = 0.12890572218808214997859533940;
13474  w[10] = 0.13246203940469661737164246470;
13475  w[11] = 0.13365457218610617535145711055;
13476  w[12] = 0.13246203940469661737164246470;
13477  w[13] = 0.12890572218808214997859533940;
13478  w[14] = 0.12304908430672953046757840067;
13479  w[15] = 0.11499664022241136494164351293;
13480  w[16] = 0.104892091464541410074086185015;
13481  w[17] = 0.092915766060035147477018617370;
13482  w[18] = 0.079281411776718954922892524742;
13483  w[19] = 0.064232421408525852127169615159;
13484  w[20] = 0.048037671731084668571641071632;
13485  w[21] = 0.030988005856979444310694219642;
13486  w[22] = 0.013411859487141772081309493459;
13487  }
13488  else if ( n == 24 )
13489  {
13490  w[0] = 0.012341229799987199546805667070;
13491  w[1] = 0.028531388628933663181307815952;
13492  w[2] = 0.044277438817419806168602748211;
13493  w[3] = 0.059298584915436780746367758500;
13494  w[4] = 0.07334648141108030573403361525;
13495  w[5] = 0.08619016153195327591718520298;
13496  w[6] = 0.09761865210411388826988066446;
13497  w[7] = 0.10744427011596563478257734245;
13498  w[8] = 0.11550566805372560135334448391;
13499  w[9] = 0.12167047292780339120446315348;
13500  w[10] = 0.12583745634682829612137538251;
13501  w[11] = 0.12793819534675215697405616522;
13502  w[12] = 0.12793819534675215697405616522;
13503  w[13] = 0.12583745634682829612137538251;
13504  w[14] = 0.12167047292780339120446315348;
13505  w[15] = 0.11550566805372560135334448391;
13506  w[16] = 0.10744427011596563478257734245;
13507  w[17] = 0.09761865210411388826988066446;
13508  w[18] = 0.08619016153195327591718520298;
13509  w[19] = 0.07334648141108030573403361525;
13510  w[20] = 0.059298584915436780746367758500;
13511  w[21] = 0.044277438817419806168602748211;
13512  w[22] = 0.028531388628933663181307815952;
13513  w[23] = 0.012341229799987199546805667070;
13514  }
13515  else if ( n == 25 )
13516  {
13517  w[0] = 0.0113937985010262879479029641132;
13518  w[1] = 0.026354986615032137261901815295;
13519  w[2] = 0.040939156701306312655623487712;
13520  w[3] = 0.054904695975835191925936891541;
13521  w[4] = 0.068038333812356917207187185657;
13522  w[5] = 0.080140700335001018013234959669;
13523  w[6] = 0.091028261982963649811497220703;
13524  w[7] = 0.100535949067050644202206890393;
13525  w[8] = 0.108519624474263653116093957050;
13526  w[9] = 0.11485825914571164833932554587;
13527  w[10] = 0.11945576353578477222817812651;
13528  w[11] = 0.12224244299031004168895951895;
13529  w[12] = 0.12317605372671545120390287308;
13530  w[13] = 0.12224244299031004168895951895;
13531  w[14] = 0.11945576353578477222817812651;
13532  w[15] = 0.11485825914571164833932554587;
13533  w[16] = 0.108519624474263653116093957050;
13534  w[17] = 0.100535949067050644202206890393;
13535  w[18] = 0.091028261982963649811497220703;
13536  w[19] = 0.080140700335001018013234959669;
13537  w[20] = 0.068038333812356917207187185657;
13538  w[21] = 0.054904695975835191925936891541;
13539  w[22] = 0.040939156701306312655623487712;
13540  w[23] = 0.026354986615032137261901815295;
13541  w[24] = 0.0113937985010262879479029641132;
13542  }
13543  else if ( n == 26 )
13544  {
13545  w[0] = 0.010551372617343007155651187685;
13546  w[1] = 0.024417851092631908789615827520;
13547  w[2] = 0.037962383294362763950303141249;
13548  w[3] = 0.050975825297147811998319900724;
13549  w[4] = 0.063274046329574835539453689907;
13550  w[5] = 0.07468414976565974588707579610;
13551  w[6] = 0.08504589431348523921044776508;
13552  w[7] = 0.09421380035591414846366488307;
13553  w[8] = 0.10205916109442542323841407025;
13554  w[9] = 0.10847184052857659065657942673;
13555  w[10] = 0.11336181654631966654944071844;
13556  w[11] = 0.11666044348529658204466250754;
13557  w[12] = 0.11832141527926227651637108570;
13558  w[13] = 0.11832141527926227651637108570;
13559  w[14] = 0.11666044348529658204466250754;
13560  w[15] = 0.11336181654631966654944071844;
13561  w[16] = 0.10847184052857659065657942673;
13562  w[17] = 0.10205916109442542323841407025;
13563  w[18] = 0.09421380035591414846366488307;
13564  w[19] = 0.08504589431348523921044776508;
13565  w[20] = 0.07468414976565974588707579610;
13566  w[21] = 0.063274046329574835539453689907;
13567  w[22] = 0.050975825297147811998319900724;
13568  w[23] = 0.037962383294362763950303141249;
13569  w[24] = 0.024417851092631908789615827520;
13570  w[25] = 0.010551372617343007155651187685;
13571  }
13572  else if ( n == 27 )
13573  {
13574  w[0] = 0.0097989960512943602611500550912;
13575  w[1] = 0.022686231596180623196034206447;
13576  w[2] = 0.035297053757419711022578289305;
13577  w[3] = 0.047449412520615062704096710114;
13578  w[4] = 0.058983536859833599110300833720;
13579  w[5] = 0.069748823766245592984322888357;
13580  w[6] = 0.079604867773057771263074959010;
13581  w[7] = 0.088423158543756950194322802854;
13582  w[8] = 0.096088727370028507565652646558;
13583  w[9] = 0.102501637817745798671247711533;
13584  w[10] = 0.107578285788533187212162984427;
13585  w[11] = 0.111252488356845192672163096043;
13586  w[12] = 0.113476346108965148620369948092;
13587  w[13] = 0.11422086737895698904504573690;
13588  w[14] = 0.113476346108965148620369948092;
13589  w[15] = 0.111252488356845192672163096043;
13590  w[16] = 0.107578285788533187212162984427;
13591  w[17] = 0.102501637817745798671247711533;
13592  w[18] = 0.096088727370028507565652646558;
13593  w[19] = 0.088423158543756950194322802854;
13594  w[20] = 0.079604867773057771263074959010;
13595  w[21] = 0.069748823766245592984322888357;
13596  w[22] = 0.058983536859833599110300833720;
13597  w[23] = 0.047449412520615062704096710114;
13598  w[24] = 0.035297053757419711022578289305;
13599  w[25] = 0.022686231596180623196034206447;
13600  w[26] = 0.0097989960512943602611500550912;
13601  }
13602  else if ( n == 28 )
13603  {
13604  w[0] = 0.009124282593094517738816153923;
13605  w[1] = 0.021132112592771259751500380993;
13606  w[2] = 0.032901427782304379977630819171;
13607  w[3] = 0.044272934759004227839587877653;
13608  w[4] = 0.055107345675716745431482918227;
13609  w[5] = 0.06527292396699959579339756678;
13610  w[6] = 0.07464621423456877902393188717;
13611  w[7] = 0.08311341722890121839039649824;
13612  w[8] = 0.09057174439303284094218603134;
13613  w[9] = 0.09693065799792991585048900610;
13614  w[10] = 0.10211296757806076981421663851;
13615  w[11] = 0.10605576592284641791041643700;
13616  w[12] = 0.10871119225829413525357151930;
13617  w[13] = 0.11004701301647519628237626560;
13618  w[14] = 0.11004701301647519628237626560;
13619  w[15] = 0.10871119225829413525357151930;
13620  w[16] = 0.10605576592284641791041643700;
13621  w[17] = 0.10211296757806076981421663851;
13622  w[18] = 0.09693065799792991585048900610;
13623  w[19] = 0.09057174439303284094218603134;
13624  w[20] = 0.08311341722890121839039649824;
13625  w[21] = 0.07464621423456877902393188717;
13626  w[22] = 0.06527292396699959579339756678;
13627  w[23] = 0.055107345675716745431482918227;
13628  w[24] = 0.044272934759004227839587877653;
13629  w[25] = 0.032901427782304379977630819171;
13630  w[26] = 0.021132112592771259751500380993;
13631  w[27] = 0.009124282593094517738816153923;
13632  }
13633  else if ( n == 29 )
13634  {
13635  w[0] = 0.0085169038787464096542638133022;
13636  w[1] = 0.019732085056122705983859801640;
13637  w[2] = 0.030740492202093622644408525375;
13638  w[3] = 0.041402062518682836104830010114;
13639  w[4] = 0.051594826902497923912594381180;
13640  w[5] = 0.061203090657079138542109848024;
13641  w[6] = 0.070117933255051278569581486949;
13642  w[7] = 0.078238327135763783828144888660;
13643  w[8] = 0.085472257366172527545344849297;
13644  w[9] = 0.091737757139258763347966411077;
13645  w[10] = 0.096963834094408606301900074883;
13646  w[11] = 0.101091273759914966121820546907;
13647  w[12] = 0.104073310077729373913328471285;
13648  w[13] = 0.105876155097320941406591327852;
13649  w[14] = 0.10647938171831424424651112691;
13650  w[15] = 0.105876155097320941406591327852;
13651  w[16] = 0.104073310077729373913328471285;
13652  w[17] = 0.101091273759914966121820546907;
13653  w[18] = 0.096963834094408606301900074883;
13654  w[19] = 0.091737757139258763347966411077;
13655  w[20] = 0.085472257366172527545344849297;
13656  w[21] = 0.078238327135763783828144888660;
13657  w[22] = 0.070117933255051278569581486949;
13658  w[23] = 0.061203090657079138542109848024;
13659  w[24] = 0.051594826902497923912594381180;
13660  w[25] = 0.041402062518682836104830010114;
13661  w[26] = 0.030740492202093622644408525375;
13662  w[27] = 0.019732085056122705983859801640;
13663  w[28] = 0.0085169038787464096542638133022;
13664  }
13665  else if ( n == 30 )
13666  {
13667  w[0] = 0.007968192496166605615465883475;
13668  w[1] = 0.018466468311090959142302131912;
13669  w[2] = 0.028784707883323369349719179611;
13670  w[3] = 0.038799192569627049596801936446;
13671  w[4] = 0.048402672830594052902938140423;
13672  w[5] = 0.057493156217619066481721689402;
13673  w[6] = 0.06597422988218049512812851512;
13674  w[7] = 0.07375597473770520626824385002;
13675  w[8] = 0.08075589522942021535469493846;
13676  w[9] = 0.08689978720108297980238753072;
13677  w[10] = 0.09212252223778612871763270709;
13678  w[11] = 0.09636873717464425963946862635;
13679  w[12] = 0.09959342058679526706278028210;
13680  w[13] = 0.10176238974840550459642895217;
13681  w[14] = 0.10285265289355884034128563671;
13682  w[15] = 0.10285265289355884034128563671;
13683  w[16] = 0.10176238974840550459642895217;
13684  w[17] = 0.09959342058679526706278028210;
13685  w[18] = 0.09636873717464425963946862635;
13686  w[19] = 0.09212252223778612871763270709;
13687  w[20] = 0.08689978720108297980238753072;
13688  w[21] = 0.08075589522942021535469493846;
13689  w[22] = 0.07375597473770520626824385002;
13690  w[23] = 0.06597422988218049512812851512;
13691  w[24] = 0.057493156217619066481721689402;
13692  w[25] = 0.048402672830594052902938140423;
13693  w[26] = 0.038799192569627049596801936446;
13694  w[27] = 0.028784707883323369349719179611;
13695  w[28] = 0.018466468311090959142302131912;
13696  w[29] = 0.007968192496166605615465883475;
13697  }
13698  else if ( n == 31 )
13699  {
13700  w[0] = 0.0074708315792487758586968750322;
13701  w[1] = 0.017318620790310582463157996087;
13702  w[2] = 0.027009019184979421800608708092;
13703  w[3] = 0.036432273912385464024392010468;
13704  w[4] = 0.045493707527201102902315857895;
13705  w[5] = 0.054103082424916853711666259087;
13706  w[6] = 0.062174786561028426910343543687;
13707  w[7] = 0.069628583235410366167756126255;
13708  w[8] = 0.076390386598776616426357674901;
13709  w[9] = 0.082392991761589263903823367432;
13710  w[10] = 0.087576740608477876126198069695;
13711  w[11] = 0.091890113893641478215362871607;
13712  w[12] = 0.095290242912319512807204197488;
13713  w[13] = 0.097743335386328725093474010979;
13714  w[14] = 0.099225011226672307874875514429;
13715  w[15] = 0.09972054479342645142753383373;
13716  w[16] = 0.099225011226672307874875514429;
13717  w[17] = 0.097743335386328725093474010979;
13718  w[18] = 0.095290242912319512807204197488;
13719  w[19] = 0.091890113893641478215362871607;
13720  w[20] = 0.087576740608477876126198069695;
13721  w[21] = 0.082392991761589263903823367432;
13722  w[22] = 0.076390386598776616426357674901;
13723  w[23] = 0.069628583235410366167756126255;
13724  w[24] = 0.062174786561028426910343543687;
13725  w[25] = 0.054103082424916853711666259087;
13726  w[26] = 0.045493707527201102902315857895;
13727  w[27] = 0.036432273912385464024392010468;
13728  w[28] = 0.027009019184979421800608708092;
13729  w[29] = 0.017318620790310582463157996087;
13730  w[30] = 0.0074708315792487758586968750322;
13731  }
13732  else if ( n == 32 )
13733  {
13734  w[0] = 0.007018610009470096600407063739;
13735  w[1] = 0.016274394730905670605170562206;
13736  w[2] = 0.025392065309262059455752589789;
13737  w[3] = 0.034273862913021433102687732252;
13738  w[4] = 0.042835898022226680656878646606;
13739  w[5] = 0.050998059262376176196163244690;
13740  w[6] = 0.058684093478535547145283637300;
13741  w[7] = 0.06582222277636184683765006371;
13742  w[8] = 0.07234579410884850622539935648;
13743  w[9] = 0.07819389578707030647174091883;
13744  w[10] = 0.08331192422694675522219907460;
13745  w[11] = 0.08765209300440381114277146275;
13746  w[12] = 0.09117387869576388471286857711;
13747  w[13] = 0.09384439908080456563918023767;
13748  w[14] = 0.09563872007927485941908200220;
13749  w[15] = 0.09654008851472780056676483006;
13750  w[16] = 0.09654008851472780056676483006;
13751  w[17] = 0.09563872007927485941908200220;
13752  w[18] = 0.09384439908080456563918023767;
13753  w[19] = 0.09117387869576388471286857711;
13754  w[20] = 0.08765209300440381114277146275;
13755  w[21] = 0.08331192422694675522219907460;
13756  w[22] = 0.07819389578707030647174091883;
13757  w[23] = 0.07234579410884850622539935648;
13758  w[24] = 0.06582222277636184683765006371;
13759  w[25] = 0.058684093478535547145283637300;
13760  w[26] = 0.050998059262376176196163244690;
13761  w[27] = 0.042835898022226680656878646606;
13762  w[28] = 0.034273862913021433102687732252;
13763  w[29] = 0.025392065309262059455752589789;
13764  w[30] = 0.016274394730905670605170562206;
13765  w[31] = 0.007018610009470096600407063739;
13766  }
13767  else if ( n == 33 )
13768  {
13769  w[0] = 0.0066062278475873780586492352085;
13770  w[1] = 0.015321701512934676127945768534;
13771  w[2] = 0.023915548101749480350533257529;
13772  w[3] = 0.032300358632328953281561447250;
13773  w[4] = 0.040401541331669591563409790527;
13774  w[5] = 0.048147742818711695670146880138;
13775  w[6] = 0.055470846631663561284944495439;
13776  w[7] = 0.062306482530317480031627725771;
13777  w[8] = 0.068594572818656712805955073015;
13778  w[9] = 0.074279854843954149342472175919;
13779  w[10] = 0.079312364794886738363908384942;
13780  w[11] = 0.083647876067038707613928014518;
13781  w[12] = 0.087248287618844337607281670945;
13782  w[13] = 0.090081958660638577239743705500;
13783  w[14] = 0.092123986643316846213240977717;
13784  w[15] = 0.093356426065596116160999126274;
13785  w[16] = 0.09376844616020999656730454155;
13786  w[17] = 0.093356426065596116160999126274;
13787  w[18] = 0.092123986643316846213240977717;
13788  w[19] = 0.090081958660638577239743705500;
13789  w[20] = 0.087248287618844337607281670945;
13790  w[21] = 0.083647876067038707613928014518;
13791  w[22] = 0.079312364794886738363908384942;
13792  w[23] = 0.074279854843954149342472175919;
13793  w[24] = 0.068594572818656712805955073015;
13794  w[25] = 0.062306482530317480031627725771;
13795  w[26] = 0.055470846631663561284944495439;
13796  w[27] = 0.048147742818711695670146880138;
13797  w[28] = 0.040401541331669591563409790527;
13798  w[29] = 0.032300358632328953281561447250;
13799  w[30] = 0.023915548101749480350533257529;
13800  w[31] = 0.015321701512934676127945768534;
13801  w[32] = 0.0066062278475873780586492352085;
13802  }
13803  else
13804  {
13805  std::cerr << "\n";
13806  std::cerr << "LEGENDRE_LOOKUP_WEIGHTS - Fatal error!\n";
13807  std::cerr << " Illegal value of N = " << n << "\n";
13808  std::cerr << " Legal values are 1 through 33.\n";
13809  std::exit ( 1 );
13810  }
13811  return;
13812 }
13813 //**************************************************************************80
13814 
13815 double *SandiaRules::legendre_zeros ( int order )
13816 
13817 //**************************************************************************80
13818 //
13819 // Purpose:
13820 //
13821 // LEGENDRE_ZEROS returns the zeros of the Legendre polynomial of degree N.
13822 //
13823 // Licensing:
13824 //
13825 // This code is distributed under the GNU LGPL license.
13826 //
13827 // Modified:
13828 //
13829 // 17 June 2011
13830 //
13831 // Author:
13832 //
13833 // Original FORTRAN77 version by Philip Davis, Philip Rabinowitz.
13834 // C++ version by John Burkardt.
13835 //
13836 // Reference:
13837 //
13838 // Philip Davis, Philip Rabinowitz,
13839 // Methods of Numerical Integration,
13840 // Second Edition,
13841 // Dover, 2007,
13842 // ISBN: 0486453391,
13843 // LC: QA299.3.D28.
13844 //
13845 // Parameters:
13846 //
13847 // Input, int ORDER, the order.
13848 // ORDER must be greater than 0.
13849 //
13850 // Output, double LEGENDRE_ZEROS[ORDER], the zeros.
13851 //
13852 {
13853  double d1;
13854  double d2pn;
13855  double d3pn;
13856  double d4pn;
13857  double dp;
13858  double dpn;
13859  double e1;
13860  //double fx;
13861  double h;
13862  int i;
13863  int iback;
13864  int k;
13865  int m;
13866  int mp1mi;
13867  int ncopy;
13868  int nmove;
13869  double p;
13870  double pi = 3.141592653589793;
13871  double pk;
13872  double pkm1;
13873  double pkp1;
13874  double t;
13875  double u;
13876  double v;
13877  double x0;
13878  double *xtab;
13879  double xtemp;
13880 
13881  xtab = new double[order];
13882 
13883  e1 = ( double ) ( order * ( order + 1 ) );
13884 
13885  m = ( order + 1 ) / 2;
13886 
13887  for ( i = 1; i <= m; i++ )
13888  {
13889  mp1mi = m + 1 - i;
13890 
13891  t = ( double ) ( 4 * i - 1 ) * pi / ( double ) ( 4 * order + 2 );
13892 
13893  x0 = std::cos ( t ) * ( 1.0 - ( 1.0 - 1.0 / ( double ) ( order ) )
13894  / ( double ) ( 8 * order * order ) );
13895 
13896  pkm1 = 1.0;
13897  pk = x0;
13898 
13899  for ( k = 2; k <= order; k++ )
13900  {
13901  pkp1 = 2.0 * x0 * pk - pkm1 - ( x0 * pk - pkm1 ) / ( double ) ( k );
13902  pkm1 = pk;
13903  pk = pkp1;
13904  }
13905 
13906  d1 = ( double ) ( order ) * ( pkm1 - x0 * pk );
13907 
13908  dpn = d1 / ( 1.0 - x0 * x0 );
13909 
13910  d2pn = ( 2.0 * x0 * dpn - e1 * pk ) / ( 1.0 - x0 * x0 );
13911 
13912  d3pn = ( 4.0 * x0 * d2pn + ( 2.0 - e1 ) * dpn ) / ( 1.0 - x0 * x0 );
13913 
13914  d4pn = ( 6.0 * x0 * d3pn + ( 6.0 - e1 ) * d2pn ) / ( 1.0 - x0 * x0 );
13915 
13916  u = pk / dpn;
13917  v = d2pn / dpn;
13918 //
13919 // Initial approximation H:
13920 //
13921  h = - u * ( 1.0 + 0.5 * u * ( v + u * ( v * v - d3pn / ( 3.0 * dpn ) ) ) );
13922 //
13923 // Refine H using one step of Newton's method:
13924 //
13925  p = pk + h * ( dpn + 0.5 * h * ( d2pn + h / 3.0
13926  * ( d3pn + 0.25 * h * d4pn ) ) );
13927 
13928  dp = dpn + h * ( d2pn + 0.5 * h * ( d3pn + h * d4pn / 3.0 ) );
13929 
13930  h = h - p / dp;
13931 
13932  xtemp = x0 + h;
13933 
13934  xtab[mp1mi-1] = xtemp;
13935 
13936  //fx = d1 - h * e1 * ( pk + 0.5 * h * ( dpn + h / 3.0
13937  // * ( d2pn + 0.25 * h * ( d3pn + 0.2 * h * d4pn ) ) ) );
13938  }
13939 
13940  if ( ( order % 2 ) == 1 )
13941  {
13942  xtab[0] = 0.0;
13943  }
13944 //
13945 // Shift the data up.
13946 //
13947  nmove = ( order + 1 ) / 2;
13948  ncopy = order - nmove;
13949 
13950  for ( i = 1; i <= nmove; i++ )
13951  {
13952  iback = order + 1 - i;
13953  xtab[iback-1] = xtab[iback-ncopy-1];
13954  }
13955 //
13956 // Reflect values for the negative abscissas.
13957 //
13958  for ( i = 1; i <= order - nmove; i++ )
13959  {
13960  xtab[i-1] = - xtab[order-i];
13961  }
13962 
13963  return xtab;
13964 }
13965 //**************************************************************************80
13966 
13967 void SandiaRules::level_growth_to_order ( int dim_num, int level[], int rule[],
13968  int growth[], int order[] )
13969 
13970 //**************************************************************************80
13971 //
13972 // Purpose:
13973 //
13974 // LEVEL_GROWTH_TO_ORDER: convert Level and Growth to Order.
13975 //
13976 // Discussion:
13977 //
13978 // This function is given level, rule, and growth information
13979 // for each dimension of a quadrature rule, and determines the
13980 // corresponding order of the rule in each dimension.
13981 //
13982 // This is a revised version of LEVEL_GROWTH_TO_ORDER.
13983 //
13984 // In particular, it revises the interpretation of the RULE vector as
13985 // far as the values 10, 11, and 12 are concerned.
13986 //
13987 // Licensing:
13988 //
13989 // This code is distributed under the GNU LGPL license.
13990 //
13991 // Modified:
13992 //
13993 // 16 October 2011
13994 //
13995 // Author:
13996 //
13997 // John Burkardt
13998 //
13999 // Parameters:
14000 //
14001 // Input, int DIM_NUM, the spatial dimension.
14002 //
14003 // Input, int LEVEL[DIM_NUM], the 1D levels.
14004 //
14005 // Input, int RULE[DIM_NUM], the rule in each dimension.
14006 // 1, "CC", Clenshaw Curtis, Closed Fully Nested.
14007 // 2, "F2", Fejer Type 2, Open Fully Nested.
14008 // 3, "GP", Gauss Patterson, Open Fully Nested.
14009 // 4, "GL", Gauss Legendre, Open Weakly Nested.
14010 // 5, "GH", Gauss Hermite, Open Weakly Nested.
14011 // 6, "GGH", Generalized Gauss Hermite, Open Weakly Nested.
14012 // 7, "LG", Gauss Laguerre, Open Non Nested.
14013 // 8, "GLG", Generalized Gauss Laguerre, Open Non Nested.
14014 // 9, "GJ", Gauss Jacobi, Open Non Nested.
14015 // 10, "HGK", Hermite Genz-Keister, Open Fully Nested.
14016 // 11, "UO", User supplied Open, presumably Non Nested.
14017 // 12, "UC", User supplied Closed, presumably Non Nested.
14018 //
14019 // Input, int GROWTH[DIM_NUM], the desired growth in each dimension.
14020 // 0, "DF", default growth associated with this quadrature rule;
14021 // 1, "SL", slow linear, L+1;
14022 // 2 "SO", slow linear odd, O=1+2((L+1)/2)
14023 // 3, "ML", moderate linear, 2L+1;
14024 // 4, "SE", slow exponential;
14025 // 5, "ME", moderate exponential;
14026 // 6, "FE", full exponential.
14027 //
14028 // Output, int ORDER[DIM_NUM], the 1D orders (number of points).
14029 //
14030 {
14031  int dim;
14032  int l;
14033  int o;
14034  static int o_hgk[6] = { 1, 3, 9, 19, 35, 43 };
14035  int p;
14036  static int p_hgk[6] = { 1, 5, 15, 29, 51, 67 };
14037 //
14038 // Check the input.
14039 //
14040  for ( dim = 0; dim < dim_num; dim++ )
14041  {
14042  if ( level[dim] < 0 )
14043  {
14044  std::cerr << "\n";
14045  std::cerr << "LEVEL_GROWTH_TO_ORDER - Fatal error!\n";
14046  std::cerr << " Negative value of LEVEL[DIM]!\n";
14047  std::cerr << " LEVEL[" << dim << "] = " << level[dim] << "\n";
14048  std::exit ( 1 );
14049  }
14050 
14051  if ( rule[dim] < 1 || 12 < rule[dim] )
14052  {
14053  std::cerr << "\n";
14054  std::cerr << "LEVEL_GROWTH_TO_ORDER - Fatal error!\n";
14055  std::cerr << " Illegal value of RULE[DIM]!\n";
14056  std::cerr << " RULE[" << dim << "] = " << rule[dim] << "\n";
14057  std::exit ( 1 );
14058  }
14059 
14060  if ( growth[dim] < 0 || 6 < growth[dim] )
14061  {
14062  std::cerr << "\n";
14063  std::cerr << "LEVEL_GROWTH_TO_ORDER - Fatal error!\n";
14064  std::cerr << " Illegal value of GROWTH[DIM]!\n";
14065  std::cerr << " GROWTH[" << dim << "] = " << growth[dim] << "\n";
14066  std::exit ( 1 );
14067  }
14068  }
14069 //
14070 // Compute the order vector.
14071 //
14072  for ( dim = 0; dim < dim_num; dim++ )
14073  {
14074 //
14075 // CC
14076 // Default is Moderate Exponential Growth.
14077 //
14078  if ( rule[dim] == 1 )
14079  {
14080  if ( growth[dim] == 1 )
14081  {
14082  o = level[dim] + 1;
14083  }
14084  else if ( growth[dim] == 2 )
14085  {
14086  o = 2 * ( ( level[dim] + 1 ) / 2 ) + 1;
14087  }
14088  else if ( growth[dim] == 3 )
14089  {
14090  o = 2 * level[dim] + 1;
14091  }
14092  else if ( growth[dim] == 4 )
14093  {
14094  if ( level[dim] == 0 )
14095  {
14096  o = 1;
14097  }
14098  else
14099  {
14100  o = 2;
14101  while ( o < 2 * level[dim] + 1 )
14102  {
14103  o = 2 * ( o - 1 ) + 1;
14104  }
14105  }
14106  }
14107  else if ( growth[dim] == 5 || growth[dim] == 0 )
14108  {
14109  if ( level[dim] == 0 )
14110  {
14111  o = 1;
14112  }
14113  else
14114  {
14115  o = 2;
14116  while ( o < 4 * level[dim] + 1 )
14117  {
14118  o = 2 * ( o - 1 ) + 1;
14119  }
14120  }
14121  }
14122  else if ( growth[dim] == 6 )
14123  {
14124  if ( level[dim] == 0 )
14125  {
14126  o = 1;
14127  }
14128  else
14129  {
14130  o = i4_power ( 2, level[dim] ) + 1;
14131  }
14132  }
14133  }
14134 //
14135 // F2
14136 // Default is Moderate Exponential Growth.
14137 //
14138  else if ( rule[dim] == 2 )
14139  {
14140  if ( growth[dim] == 1 )
14141  {
14142  o = level[dim] + 1;
14143  }
14144  else if ( growth[dim] == 2 )
14145  {
14146  o = 2 * ( ( level[dim] + 1 ) / 2 ) + 1;
14147  }
14148  else if ( growth[dim] == 3 )
14149  {
14150  o = 2 * level[dim] + 1;
14151  }
14152  else if ( growth[dim] == 4 )
14153  {
14154  o = 1;
14155  while ( o < 2 * level[dim] + 1 )
14156  {
14157  o = 2 * o + 1;
14158  }
14159  }
14160  else if ( growth[dim] == 5 || growth[dim] == 0 )
14161  {
14162  o = 1;
14163  while ( o < 4 * level[dim] + 1 )
14164  {
14165  o = 2 * o + 1;
14166  }
14167  }
14168  else if ( growth[dim] == 6 )
14169  {
14170  o = i4_power ( 2, level[dim] + 1 ) - 1;
14171  }
14172  }
14173 //
14174 // GP
14175 // Default is Moderate Exponential Growth.
14176 //
14177  else if ( rule[dim] == 3 )
14178  {
14179  if ( growth[dim] == 1 )
14180  {
14181  std::cerr << "\n";
14182  std::cerr << "LEVEL_GROWTH_TO_ORDER - Fatal error!\n";
14183  std::cerr << " Growth rate 1 for rule 3 not available!\n";
14184  std::exit ( 1 );
14185  }
14186  else if ( growth[dim] == 2 )
14187  {
14188  std::cerr << "\n";
14189  std::cerr << "LEVEL_GROWTH_TO_ORDER - Fatal error!\n";
14190  std::cerr << " Growth rate 2 for rule 3 not available!\n";
14191  std::exit ( 1 );
14192  }
14193  else if ( growth[dim] == 3 )
14194  {
14195  std::cerr << "\n";
14196  std::cerr << "LEVEL_GROWTH_TO_ORDER - Fatal error!\n";
14197  std::cerr << " Growth rate 3 for rule 3 not available!\n";
14198  std::exit ( 1 );
14199  }
14200  else if ( growth[dim] == 4 )
14201  {
14202  if ( level[dim] == 0 )
14203  {
14204  o = 1;
14205  }
14206  else
14207  {
14208  p = 5;
14209  o = 3;
14210  while ( p < 2 * level[dim] + 1 )
14211  {
14212  p = 2 * p + 1;
14213  o = 2 * o + 1;
14214  }
14215  }
14216  }
14217  else if ( growth[dim] == 5 || growth[dim] == 0 )
14218  {
14219  if ( level[dim] == 0 )
14220  {
14221  o = 1;
14222  }
14223  else
14224  {
14225  p = 5;
14226  o = 3;
14227  while ( p < 4 * level[dim] + 1 )
14228  {
14229  p = 2 * p + 1;
14230  o = 2 * o + 1;
14231  }
14232  }
14233  }
14234  else if ( growth[dim] == 6 )
14235  {
14236  o = i4_power ( 2, level[dim] + 1 ) - 1;
14237  }
14238  }
14239 //
14240 // GL
14241 // Default is Moderate Linear Growth.
14242 //
14243  else if ( rule[dim] == 4 )
14244  {
14245  if ( growth[dim] == 1 )
14246  {
14247  o = level[dim] + 1;
14248  }
14249  else if ( growth[dim] == 2 )
14250  {
14251  o = 2 * ( ( level[dim] + 1 ) / 2 ) + 1;
14252  }
14253  else if ( growth[dim] == 3 || growth[dim] == 0 )
14254  {
14255  o = 2 * level[dim] + 1;
14256  }
14257  else if ( growth[dim] == 4 )
14258  {
14259  o = 1;
14260  while ( 2 * o - 1 < 2 * level[dim] + 1 )
14261  {
14262  o = 2 * o + 1;
14263  }
14264  }
14265  else if ( growth[dim] == 5 )
14266  {
14267  o = 1;
14268  while ( 2 * o - 1 < 4 * level[dim] + 1 )
14269  {
14270  o = 2 * o + 1;
14271  }
14272  }
14273  else if ( growth[dim] == 6 )
14274  {
14275  o = i4_power ( 2, level[dim] + 1 ) - 1;
14276  }
14277  }
14278 //
14279 // GH
14280 // Default is Moderate Linear Growth.
14281 //
14282  else if ( rule[dim] == 5 )
14283  {
14284  if ( growth[dim] == 1 )
14285  {
14286  o = level[dim] + 1;
14287  }
14288  else if ( growth[dim] == 2 )
14289  {
14290  o = 2 * ( ( level[dim] + 1 ) / 2 ) + 1;
14291  }
14292  else if ( growth[dim] == 3 || growth[dim] == 0 )
14293  {
14294  o = 2 * level[dim] + 1;
14295  }
14296  else if ( growth[dim] == 4 )
14297  {
14298  o = 1;
14299  while ( 2 * o - 1 < 2 * level[dim] + 1 )
14300  {
14301  o = 2 * o + 1;
14302  }
14303  }
14304  else if ( growth[dim] == 5 )
14305  {
14306  o = 1;
14307  while ( 2 * o - 1 < 4 * level[dim] + 1 )
14308  {
14309  o = 2 * o + 1;
14310  }
14311  }
14312  else if ( growth[dim] == 6 )
14313  {
14314  o = i4_power ( 2, level[dim] + 1 ) - 1;
14315  }
14316  }
14317 //
14318 // GGH
14319 // Default is Moderate Linear Growth.
14320 //
14321  else if ( rule[dim] == 6 )
14322  {
14323  if ( growth[dim] == 1 )
14324  {
14325  o = level[dim] + 1;
14326  }
14327  else if ( growth[dim] == 2 )
14328  {
14329  o = 2 * ( ( level[dim] + 1 ) / 2 ) + 1;
14330  }
14331  else if ( growth[dim] == 3 || growth[dim] == 0 )
14332  {
14333  o = 2 * level[dim] + 1;
14334  }
14335  else if ( growth[dim] == 4 )
14336  {
14337  o = 1;
14338  while ( 2 * o - 1 < 2 * level[dim] + 1 )
14339  {
14340  o = 2 * o + 1;
14341  }
14342  }
14343  else if ( growth[dim] == 5 )
14344  {
14345  o = 1;
14346  while ( 2 * o - 1 < 4 * level[dim] + 1 )
14347  {
14348  o = 2 * o + 1;
14349  }
14350  }
14351  else if ( growth[dim] == 6 )
14352  {
14353  o = i4_power ( 2, level[dim] + 1 ) - 1;
14354  }
14355  }
14356 //
14357 // LG
14358 // Default is Moderate Linear Growth.
14359 //
14360  else if ( rule[dim] == 7 )
14361  {
14362  if ( growth[dim] == 1 )
14363  {
14364  o = level[dim] + 1;
14365  }
14366  else if ( growth[dim] == 2 )
14367  {
14368  o = 2 * ( ( level[dim] + 1 ) / 2 ) + 1;
14369  }
14370  else if ( growth[dim] == 3 || growth[dim] == 0 )
14371  {
14372  o = 2 * level[dim] + 1;
14373  }
14374  else if ( growth[dim] == 4 )
14375  {
14376  o = 1;
14377  while ( 2 * o - 1 < 2 * level[dim] + 1 )
14378  {
14379  o = 2 * o + 1;
14380  }
14381  }
14382  else if ( growth[dim] == 5 )
14383  {
14384  o = 1;
14385  while ( 2 * o - 1 < 4 * level[dim] + 1 )
14386  {
14387  o = 2 * o + 1;
14388  }
14389  }
14390  else if ( growth[dim] == 6 )
14391  {
14392  o = i4_power ( 2, level[dim] + 1 ) - 1;
14393  }
14394  }
14395 //
14396 // GLG
14397 // Default is Moderate Linear Growth.
14398 //
14399  else if ( rule[dim] == 8 )
14400  {
14401  if ( growth[dim] == 1 )
14402  {
14403  o = level[dim] + 1;
14404  }
14405  else if ( growth[dim] == 2 )
14406  {
14407  o = 2 * ( ( level[dim] + 1 ) / 2 ) + 1;
14408  }
14409  else if ( growth[dim] == 3 || growth[dim] == 0 )
14410  {
14411  o = 2 * level[dim] + 1;
14412  }
14413  else if ( growth[dim] == 4 )
14414  {
14415  o = 1;
14416  while ( 2 * o - 1 < 2 * level[dim] + 1 )
14417  {
14418  o = 2 * o + 1;
14419  }
14420  }
14421  else if ( growth[dim] == 5 )
14422  {
14423  o = 1;
14424  while ( 2 * o - 1 < 4 * level[dim] + 1 )
14425  {
14426  o = 2 * o + 1;
14427  }
14428  }
14429  else if ( growth[dim] == 6 )
14430  {
14431  o = i4_power ( 2, level[dim] + 1 ) - 1;
14432  }
14433  }
14434 //
14435 // GJ
14436 // Default is Moderate Linear Growth.
14437 //
14438  else if ( rule[dim] == 9 )
14439  {
14440  if ( growth[dim] == 1 )
14441  {
14442  o = level[dim] + 1;
14443  }
14444  else if ( growth[dim] == 2 )
14445  {
14446  o = 2 * ( ( level[dim] + 1 ) / 2 ) + 1;
14447  }
14448  else if ( growth[dim] == 3 || growth[dim] == 0 )
14449  {
14450  o = 2 * level[dim] + 1;
14451  }
14452  else if ( growth[dim] == 4 )
14453  {
14454  o = 1;
14455  while ( 2 * o - 1 < 2 * level[dim] + 1 )
14456  {
14457  o = 2 * o + 1;
14458  }
14459  }
14460  else if ( growth[dim] == 5 )
14461  {
14462  o = 1;
14463  while ( 2 * o - 1 < 4 * level[dim] + 1 )
14464  {
14465  o = 2 * o + 1;
14466  }
14467  }
14468  else if ( growth[dim] == 6 )
14469  {
14470  o = i4_power ( 2, level[dim] + 1 ) - 1;
14471  }
14472  }
14473 //
14474 // HGK
14475 // Default is Moderate Exponential Growth.
14476 // Exponential growth is interpreted to mean simply take successive rules.
14477 //
14478  else if ( rule[dim] == 10 )
14479  {
14480  if ( growth[dim] == 1 )
14481  {
14482  std::cerr << "\n";
14483  std::cerr << "LEVEL_GROWTH_TO_ORDER - Fatal error!\n";
14484  std::cerr << " Growth rate 1 for rule 10 not available!\n";
14485  std::exit ( 1 );
14486  }
14487  else if ( growth[dim] == 2 )
14488  {
14489  std::cerr << "\n";
14490  std::cerr << "LEVEL_GROWTH_TO_ORDER - Fatal error!\n";
14491  std::cerr << " Growth rate 2 for rule 10 not available!\n";
14492  std::exit ( 1 );
14493  }
14494  else if ( growth[dim] == 3 )
14495  {
14496  std::cerr << "\n";
14497  std::cerr << "LEVEL_GROWTH_TO_ORDER - Fatal error!\n";
14498  std::cerr << " Growth rate 3 for rule 10 not available!\n";
14499  std::exit ( 1 );
14500  }
14501  else if ( growth[dim] == 4 )
14502  {
14503  l = 0;
14504  p = p_hgk[l];
14505  o = o_hgk[l];
14506  while ( p < 2 * level[dim] + 1 )
14507  {
14508  l = l + 1;
14509  if ( 5 < l )
14510  {
14511  std::cerr << "\n";
14512  std::cerr << "LEVEL_GROWTH_TO_ORDER - Fatal error!\n";
14513  std::cerr << " Hermite Genz-Keister maximum level exceeded.\n";
14514  std::exit ( 1 );
14515  }
14516  p = p_hgk[l];
14517  o = o_hgk[l];
14518  }
14519  }
14520  else if ( growth[dim] == 5 || growth[dim] == 0 )
14521  {
14522  l = 0;
14523  p = p_hgk[l];
14524  o = o_hgk[l];
14525  while ( p < 4 * level[dim] + 1 )
14526  {
14527  l = l + 1;
14528  if ( 5 < l )
14529  {
14530  std::cerr << "\n";
14531  std::cerr << "LEVEL_GROWTH_TO_ORDER - Fatal error!\n";
14532  std::cerr << " Hermite Genz-Keister maximum level exceeded.\n";
14533  std::exit ( 1 );
14534  }
14535  p = p_hgk[l];
14536  o = o_hgk[l];
14537  }
14538  }
14539  else if ( growth[dim] == 6 )
14540  {
14541  l = level[dim];
14542  l = i4_max ( l, 0 );
14543  if ( 5 < l )
14544  {
14545  std::cerr << "\n";
14546  std::cerr << "LEVEL_GROWTH_TO_ORDER - Fatal error!\n";
14547  std::cerr << " Hermite Genz-Keister maximum level exceeded.\n";
14548  std::exit ( 1 );
14549  }
14550  o = o_hgk[l];
14551  }
14552  }
14553 //
14554 // UO
14555 // Default is Moderate Linear Growth.
14556 // We assume the rule is of OPEN type and that it
14557 // has a precision typical of Gauss rules.
14558 //
14559  else if ( rule[dim] == 11 )
14560  {
14561  if ( growth[dim] == 1 )
14562  {
14563  o = level[dim] + 1;
14564  }
14565  else if ( growth[dim] == 2 )
14566  {
14567  o = 2 * ( ( level[dim] + 1 ) / 2 ) + 1;
14568  }
14569  else if ( growth[dim] == 3 || growth[dim] == 0 )
14570  {
14571  o = 2 * level[dim] + 1;
14572  }
14573  else if ( growth[dim] == 4 )
14574  {
14575  o = 1;
14576  while ( 2 * o - 1 < 2 * level[dim] + 1 )
14577  {
14578  o = 2 * o + 1;
14579  }
14580  }
14581  else if ( growth[dim] == 5 )
14582  {
14583  o = 1;
14584  while ( 2 * o - 1 < 4 * level[dim] + 1 )
14585  {
14586  o = 2 * o + 1;
14587  }
14588  }
14589  else if ( growth[dim] == 6 )
14590  {
14591  o = i4_power ( 2, level[dim] + 1 ) - 1;
14592  }
14593  }
14594 //
14595 // UC
14596 // Default is Moderate Linear Growth.
14597 // We assume the rule is of CLOSED type and that it
14598 // has a precision typical of Clenshaw-Curtis rules.
14599 //
14600  else if ( rule[dim] == 12 )
14601  {
14602  if ( growth[dim] == 1 )
14603  {
14604  o = level[dim] + 1;
14605  }
14606  else if ( growth[dim] == 2 )
14607  {
14608  o = 2 * ( ( level[dim] + 1 ) / 2 ) + 1;
14609  }
14610  else if ( growth[dim] == 3 || growth[dim] == 0 )
14611  {
14612  o = 2 * level[dim] + 1;
14613  }
14614  else if ( growth[dim] == 4 )
14615  {
14616  if ( level[dim] == 0 )
14617  {
14618  o = 1;
14619  }
14620  else
14621  {
14622  o = 2;
14623  while ( o < 2 * level[dim] + 1 )
14624  {
14625  o = 2 * ( o - 1 ) + 1;
14626  }
14627  }
14628  }
14629  else if ( growth[dim] == 5 )
14630  {
14631  if ( level[dim] == 0 )
14632  {
14633  o = 1;
14634  }
14635  else
14636  {
14637  o = 2;
14638  while ( o < 4 * level[dim] + 1 )
14639  {
14640  o = 2 * ( o - 1 ) + 1;
14641  }
14642  }
14643  }
14644  else if ( growth[dim] == 6 )
14645  {
14646  if ( level[dim] == 0 )
14647  {
14648  o = 1;
14649  }
14650  else
14651  {
14652  o = i4_power ( 2, level[dim] ) + 1;
14653  }
14654  }
14655  }
14656  order[dim] = o;
14657  }
14658  return;
14659 }
14660 //**************************************************************************80
14661 
14662 void SandiaRules::level_to_order_default ( int dim_num, int level[], int rule[],
14663  int order[] )
14664 
14665 //**************************************************************************80
14666 //
14667 // Purpose:
14668 //
14669 // LEVEL_TO_ORDER_DEFAULT: default growth.
14670 //
14671 // Discussion:
14672 //
14673 // This function uses:
14674 //
14675 // * exponential growth rates for fully nested quadrature rules,
14676 // ( "CC", "F2", "GP");
14677 //
14678 // * linear growth rates for other rules.
14679 // ( "GL", "GH", "GGH", "LG", "GLG", "GJ", "GW" ).
14680 //
14681 // * slow exponential growth alternative for fully nested rules:
14682 // ("CC_SE", "F2_SE", "GP_SE").
14683 //
14684 // * moderate exponential growth alternative for fully nested rules:
14685 // ("CC_ME", "F2_ME", "GP_ME").
14686 //
14687 // Licensing:
14688 //
14689 // This code is distributed under the GNU LGPL license.
14690 //
14691 // Modified:
14692 //
14693 // 07 March 2011
14694 //
14695 // Author:
14696 //
14697 // John Burkardt
14698 //
14699 // Parameters:
14700 //
14701 // Input, int DIM_NUM, the spatial dimension.
14702 //
14703 // Input, int LEVEL[DIM_NUM], the 1D levels.
14704 //
14705 // Input, int RULE[DIM_NUM], the rule in each dimension.
14706 // 1, "CC", Clenshaw Curtis, Closed Fully Nested rule.
14707 // 2, "F2", Fejer Type 2, Open Fully Nested rule.
14708 // 3, "GP", Gauss Patterson, Open Fully Nested rule.
14709 // 4, "GL", Gauss Legendre, Open Weakly Nested rule.
14710 // 5, "GH", Gauss Hermite, Open Weakly Nested rule.
14711 // 6, "GGH", Generalized Gauss Hermite, Open Weakly Nested rule.
14712 // 7, "LG", Gauss Laguerre, Open Non Nested rule.
14713 // 8, "GLG", Generalized Gauss Laguerre, Open Non Nested rule.
14714 // 9, "GJ", Gauss Jacobi, Open Non Nested rule.
14715 // 10, "GW", Golub Welsch, (presumed) Open Non Nested rule.
14716 // 11, "CC_SE", Clenshaw Curtis Slow Exponential, Closed Fully Nested rule.
14717 // 12, "F2_SE", Fejer Type 2 Slow Exponential, Open Fully Nested rule.
14718 // 13, "GP_SE", Gauss Patterson Slow Exponential, Open Fully Nested rule.
14719 // 14, "CC_ME", Clenshaw Curtis Moderate Exponential, Closed Fully Nested rule.
14720 // 15, "F2_ME", Fejer Type 2 Moderate Exponential, Open Fully Nested rule.
14721 // 16, "GP_ME", Gauss Patterson Moderate Exponential, Open Fully Nested rule.
14722 // 17, "CCN", Clenshaw Curtis Nested, Linear, Closed Fully Nested rule.
14723 //
14724 // Output, int ORDER[DIM_NUM], the 1D orders (number of points).
14725 //
14726 {
14727  int dim;
14728  int o;
14729  int p;
14730 
14731  for ( dim = 0; dim < dim_num; dim++ )
14732  {
14733  if ( level[dim] < 0 )
14734  {
14735  std::cerr << "\n";
14736  std::cerr << "LEVEL_TO_ORDER_DEFAULT - Fatal error!\n";
14737  std::cerr << " Negative value of LEVEL[DIM]!\n";
14738  std::cerr << " LEVEL[" << dim << "] = " << level[dim] << "\n";
14739  std::exit ( 1 );
14740  }
14741  else if ( rule[dim] == 1 )
14742  {
14743  if ( level[dim] == 0 )
14744  {
14745  order[dim] = 1;
14746  }
14747  else
14748  {
14749  order[dim] = i4_power ( 2, level[dim] ) + 1;
14750  }
14751  }
14752  else if ( rule[dim] == 2 )
14753  {
14754  order[dim] = i4_power ( 2, level[dim] + 1 ) - 1;
14755  }
14756  else if ( rule[dim] == 3 )
14757  {
14758  order[dim] = i4_power ( 2, level[dim] + 1 ) - 1;
14759  }
14760  else if ( rule[dim] == 4 )
14761  {
14762  order[dim] = 2 * level[dim] + 1;
14763  }
14764  else if ( rule[dim] == 5 )
14765  {
14766  order[dim] = 2 * level[dim] + 1;
14767  }
14768  else if ( rule[dim] == 6 )
14769  {
14770  order[dim] = 2 * level[dim] + 1;
14771  }
14772  else if ( rule[dim] == 7 )
14773  {
14774  order[dim] = 2 * level[dim] + 1;
14775  }
14776  else if ( rule[dim] == 8 )
14777  {
14778  order[dim] = 2 * level[dim] + 1;
14779  }
14780  else if ( rule[dim] == 9 )
14781  {
14782  order[dim] = 2 * level[dim] + 1;
14783  }
14784  else if ( rule[dim] == 10 )
14785  {
14786  order[dim] = 2 * level[dim] + 1;
14787  }
14788  else if ( rule[dim] == 11 )
14789  {
14790  if ( level[dim] == 0 )
14791  {
14792  o = 1;
14793  }
14794  else
14795  {
14796  o = 2;
14797  while ( o < 2 * level[dim] + 1 )
14798  {
14799  o = 2 * ( o - 1 ) + 1;
14800  }
14801  }
14802  order[dim] = o;
14803  }
14804  else if ( rule[dim] == 12 )
14805  {
14806  o = 1;
14807  while ( o < 2 * level[dim] + 1 )
14808  {
14809  o = 2 * o + 1;
14810  }
14811  order[dim] = o;
14812  }
14813  else if ( rule[dim] == 13 )
14814  {
14815  if ( level[dim] == 0 )
14816  {
14817  order[dim] = 1;
14818  }
14819  else
14820  {
14821  p = 5;
14822  o = 3;
14823  while ( p < 2 * level[dim] + 1 )
14824  {
14825  p = 2 * p + 1;
14826  o = 2 * o + 1;
14827  }
14828  order[dim] = o;
14829  }
14830  }
14831  else if ( rule[dim] == 14 )
14832  {
14833  if ( level[dim] == 0 )
14834  {
14835  o = 1;
14836  }
14837  else
14838  {
14839  o = 2;
14840  while ( o < 4 * level[dim] + 1 )
14841  {
14842  o = 2 * ( o - 1 ) + 1;
14843  }
14844  }
14845  order[dim] = o;
14846  }
14847  else if ( rule[dim] == 15 )
14848  {
14849  o = 1;
14850  while ( o < 4 * level[dim] + 1 )
14851  {
14852  o = 2 * o + 1;
14853  }
14854  order[dim] = o;
14855  }
14856  else if ( rule[dim] == 16 )
14857  {
14858  if ( level[dim] == 0 )
14859  {
14860  order[dim] = 1;
14861  }
14862  else
14863  {
14864  p = 5;
14865  o = 3;
14866  while ( p < 4 * level[dim] + 1 )
14867  {
14868  p = 2 * p + 1;
14869  o = 2 * o + 1;
14870  }
14871  order[dim] = o;
14872  }
14873  }
14874  else if ( rule[dim] == 17 )
14875  {
14876  order[dim] = 2 * level[dim] + 1;
14877  }
14878  else
14879  {
14880  std::cerr << "\n";
14881  std::cerr << "LEVEL_TO_ORDER_DEFAULT - Fatal error!\n";
14882  std::cerr << " Unexpected value of RULE["
14883  << dim << "] = " << rule[dim] << ".\n";
14884  std::exit ( 1 );
14885  }
14886  }
14887  return;
14888 }
14889 //**************************************************************************80
14890 
14891 void SandiaRules::level_to_order_exponential ( int dim_num, int level[], int rule[],
14892  int order[] )
14893 
14894 //**************************************************************************80
14895 //
14896 // Purpose:
14897 //
14898 // LEVEL_TO_ORDER_EXPONENTIAL: exponential growth.
14899 //
14900 // Discussion:
14901 //
14902 // The user must preallocate space for the output array ORDER.
14903 //
14904 // Closed rules:
14905 //
14906 // O(0) = 1
14907 // O(L) = 2^L + 1;
14908 //
14909 // O = 1, 3, 5, 9, 17, 33, ...
14910 //
14911 // Open rules:
14912 //
14913 // O(L) = 2^(L+1) - 1;
14914 //
14915 // O = 1, 3, 7, 15, 31, 63, ...
14916 //
14917 // Licensing:
14918 //
14919 // This code is distributed under the GNU LGPL license.
14920 //
14921 // Modified:
14922 //
14923 // 07 March 2011
14924 //
14925 // Author:
14926 //
14927 // John Burkardt
14928 //
14929 // Parameters:
14930 //
14931 // Input, int DIM_NUM, the spatial dimension.
14932 //
14933 // Input, int LEVEL[DIM_NUM], the 1D levels.
14934 //
14935 // Input, int RULE[DIM_NUM], the rule in each dimension.
14936 // 1, "CC", Clenshaw Curtis, Closed Fully Nested rule.
14937 // 2, "F2", Fejer Type 2, Open Fully Nested rule.
14938 // 3, "GP", Gauss Patterson, Open Fully Nested rule.
14939 // 4, "GL", Gauss Legendre, Open Weakly Nested rule.
14940 // 5, "GH", Gauss Hermite, Open Weakly Nested rule.
14941 // 6, "GGH", Generalized Gauss Hermite, Open Weakly Nested rule.
14942 // 7, "LG", Gauss Laguerre, Open Non Nested rule.
14943 // 8, "GLG", Generalized Gauss Laguerre, Open Non Nested rule.
14944 // 9, "GJ", Gauss Jacobi, Open Non Nested rule.
14945 // 10, "GW", Golub Welsch, (presumed) Open Non Nested rule.
14946 // 11, "CC_SE", Clenshaw Curtis Slow Exponential, Closed Fully Nested rule.
14947 // 12, "F2_SE", Fejer Type 2 Slow Exponential, Open Fully Nested rule.
14948 // 13, "GP_SE", Gauss Patterson Slow Exponential, Open Fully Nested rule.
14949 // 14, "CC_ME", Clenshaw Curtis Moderate Exponential, Closed Fully Nested rule.
14950 // 15, "F2_ME", Fejer Type 2 Moderate Exponential, Open Fully Nested rule.
14951 // 16, "GP_ME", Gauss Patterson Moderate Exponential, Open Fully Nested rule.
14952 // 17, "CCN", Clenshaw Curtis Nested, Linear, Closed Fully Nested rule.
14953 //
14954 // Output, int ORDER[DIM_NUM], the 1D orders (number of points).
14955 //
14956 {
14957  int dim;
14958 
14959  for ( dim = 0; dim < dim_num; dim++ )
14960  {
14961  if ( level[dim] < 0 )
14962  {
14963  std::cerr << "\n";
14964  std::cerr << "LEVEL_TO_ORDER_EXPONENTIAL - Fatal error!\n";
14965  std::cerr << " Negative value of LEVEL[DIM]!\n";
14966  std::cerr << " LEVEL[" << dim << "] = " << level[dim] << "\n";
14967  std::exit ( 1 );
14968  }
14969  else if ( rule[dim] == 1 )
14970  {
14971  if ( level[dim] == 0 )
14972  {
14973  order[dim] = 1;
14974  }
14975  else
14976  {
14977  order[dim] = i4_power ( 2, level[dim] ) + 1;
14978  }
14979  }
14980  else if ( rule[dim] == 2 )
14981  {
14982  order[dim] = i4_power ( 2, level[dim] + 1 ) - 1;
14983  }
14984  else if ( rule[dim] == 3 )
14985  {
14986  order[dim] = i4_power ( 2, level[dim] + 1 ) - 1;
14987  }
14988  else if ( rule[dim] == 4 )
14989  {
14990  order[dim] = i4_power ( 2, level[dim] + 1 ) - 1;
14991  }
14992  else if ( rule[dim] == 5 )
14993  {
14994  order[dim] = i4_power ( 2, level[dim] + 1 ) - 1;
14995  }
14996  else if ( rule[dim] == 6 )
14997  {
14998  order[dim] = i4_power ( 2, level[dim] + 1 ) - 1;
14999  }
15000  else if ( rule[dim] == 7 )
15001  {
15002  order[dim] = i4_power ( 2, level[dim] + 1 ) - 1;
15003  }
15004  else if ( rule[dim] == 8 )
15005  {
15006  order[dim] = i4_power ( 2, level[dim] + 1 ) - 1;
15007  }
15008  else if ( rule[dim] == 9 )
15009  {
15010  order[dim] = i4_power ( 2, level[dim] + 1 ) - 1;
15011  }
15012  else if ( rule[dim] == 10 )
15013  {
15014  order[dim] = i4_power ( 2, level[dim] + 1 ) - 1;
15015  }
15016  else if ( rule[dim] == 11 )
15017  {
15018  if ( level[dim] == 0 )
15019  {
15020  order[dim] = 1;
15021  }
15022  else
15023  {
15024  order[dim] = i4_power ( 2, level[dim] ) + 1;
15025  }
15026  }
15027  else if ( rule[dim] == 12 )
15028  {
15029  order[dim] = i4_power ( 2, level[dim] + 1 ) - 1;
15030  }
15031  else if ( rule[dim] == 13 )
15032  {
15033  order[dim] = i4_power ( 2, level[dim] + 1 ) - 1;
15034  }
15035  else if ( rule[dim] == 14 )
15036  {
15037  if ( level[dim] == 0 )
15038  {
15039  order[dim] = 1;
15040  }
15041  else
15042  {
15043  order[dim] = i4_power ( 2, level[dim] ) + 1;
15044  }
15045  }
15046  else if ( rule[dim] == 15 )
15047  {
15048  order[dim] = i4_power ( 2, level[dim] + 1 ) - 1;
15049  }
15050  else if ( rule[dim] == 16 )
15051  {
15052  order[dim] = i4_power ( 2, level[dim] + 1 ) - 1;
15053  }
15054  else if ( rule[dim] == 17 )
15055  {
15056  order[dim] = i4_power ( 2, level[dim] + 1 );
15057  }
15058  else
15059  {
15060  std::cerr << "\n";
15061  std::cerr << "LEVEL_TO_ORDER_EXPONENTIAL - Fatal error!\n";
15062  std::cerr << " Unexpected value of RULE["
15063  << dim << "] = " << rule[dim] << ".\n";
15064  std::exit ( 1 );
15065  }
15066  }
15067  return;
15068 }
15069 //**************************************************************************80
15070 
15071 void SandiaRules::level_to_order_exponential_slow ( int dim_num, int level[], int rule[],
15072  int order[] )
15073 
15074 //**************************************************************************80
15075 //
15076 // Purpose:
15077 //
15078 // LEVEL_TO_ORDER_EXPONENTIAL_SLOW: slow exponential growth;
15079 //
15080 // Discussion:
15081 //
15082 // We seek a sequence of quadrature rules with two opposing constraints:
15083 // * a measured rise in polynomial precision with increasing level;
15084 // * a control on the increase in (new) points per level;
15085 //
15086 // Essentially, we are trying to keep some of the advantages of nesting,
15087 // while moderating the cost of the explosive growth in order that occurs
15088 // due to the repeated order doubling of nesting.
15089 //
15090 // We wish the number of points at a given level L to be "about" 2 * L + 1,
15091 // but we also wish the rules to be completely nested.
15092 //
15093 // One way to do this is to start with a nested family of rules, whose
15094 // order will tend to grow exponentially (doubling from one to the next),
15095 // but simply to REPEAT each rule as many times as possible. We move to
15096 // the next rule only when the desired precision 2 * L + 1 exceeds the
15097 // precision of the current rule.
15098 //
15099 // For both the Clenshaw Curtis and Fejer Type 2 rules, the order and
15100 // precision are the same if the order is odd. That is, an 11 point rule
15101 // will integrate exactly all polynomials up to and including degree 11.
15102 //
15103 // For Gauss Patterson rules, the relationship between order and precision
15104 // is somewhat more complicated. For that rule, we take the philosophy
15105 // that at each level L, we wish to choose the rule of smallest order
15106 // so that the precision of 2 * L + 1 is guaranteed.
15107 //
15108 // L 2*L+1 CC Order F2 Order GP Order/Precision
15109 //
15110 // 0 1 1 1 1/1
15111 // 1 3 3 3 3/5
15112 // 2 5 5 7 3/5
15113 // 3 7 9 7 7/11
15114 // 4 9 9 15 7/11
15115 // 5 11 17 15 7/11
15116 // 6 13 17 15 15/23
15117 // 7 15 17 15 15/23
15118 // 8 17 17 31 15/23
15119 // 9 19 33 31 15/23
15120 // 10 21 33 31 15/23
15121 // 11 23 33 31 15/23
15122 // 12 25 33 31 31/47
15123 // 13 27 33 31 31/47
15124 // 14 29 33 31 31/47
15125 // 15 31 33 31 31/47
15126 // 16 33 33 63 31/47
15127 // 17 35 65 63 31/47
15128 // 18 37 65 63 31/47
15129 // 19 39 65 63 31/47
15130 // 20 41 65 63 31/47
15131 //
15132 // Licensing:
15133 //
15134 // This code is distributed under the GNU LGPL license.
15135 //
15136 // Modified:
15137 //
15138 // 07 March 2011
15139 //
15140 // Author:
15141 //
15142 // John Burkardt
15143 //
15144 // Reference:
15145 //
15146 // Knut Petras,
15147 // Smolyak Cubature of Given Polynomial Degree with Few Nodes
15148 // for Increasing Dimension,
15149 // Numerische Mathematik,
15150 // Volume 93, Number 4, February 2003, pages 729-753.
15151 //
15152 // Parameters:
15153 //
15154 // Input, int DIM_NUM, the spatial dimension.
15155 //
15156 // Input, int LEVEL[DIM_NUM], the 1D levels.
15157 //
15158 // Input, int RULE[DIM_NUM], the rule in each dimension.
15159 // 1, "CC", Clenshaw Curtis, Closed Fully Nested rule.
15160 // 2, "F2", Fejer Type 2, Open Fully Nested rule.
15161 // 3, "GP", Gauss Patterson, Open Fully Nested rule.
15162 // 4, "GL", Gauss Legendre, Open Weakly Nested rule.
15163 // 5, "GH", Gauss Hermite, Open Weakly Nested rule.
15164 // 6, "GGH", Generalized Gauss Hermite, Open Weakly Nested rule.
15165 // 7, "LG", Gauss Laguerre, Open Non Nested rule.
15166 // 8, "GLG", Generalized Gauss Laguerre, Open Non Nested rule.
15167 // 9, "GJ", Gauss Jacobi, Open Non Nested rule.
15168 // 10, "GW", Golub Welsch, (presumed) Open Non Nested rule.
15169 // 11, "CC_SE", Clenshaw Curtis Slow Exponential, Closed Fully Nested rule.
15170 // 12, "F2_SE", Fejer Type 2 Slow Exponential, Open Fully Nested rule.
15171 // 13, "GP_SE", Gauss Patterson Slow Exponential, Open Fully Nested rule.
15172 // 14, "CC_ME", Clenshaw Curtis Moderate Exponential, Closed Fully Nested rule.
15173 // 15, "F2_ME", Fejer Type 2 Moderate Exponential, Open Fully Nested rule.
15174 // 16, "GP_ME", Gauss Patterson Moderate Exponential, Open Fully Nested rule.
15175 // 17, "CCN", Clenshaw Curtis Nested, Linear, Closed Fully Nested rule.
15176 //
15177 // Output, int ORDER[DIM_NUM], the 1D orders (number of points).
15178 //
15179 {
15180  int dim;
15181  int o;
15182  int p;
15183 
15184  for ( dim = 0; dim < dim_num; dim++ )
15185  {
15186  if ( level[dim] < 0 )
15187  {
15188  std::cerr << "\n";
15189  std::cerr << "LEVEL_TO_ORDER_EXPONENTIAL_SLOW - Fatal error!\n";
15190  std::cerr << " Negative value of LEVEL[DIM]!\n";
15191  std::cerr << " LEVEL[" << dim << "] = " << level[dim] << "\n";
15192  std::exit ( 1 );
15193  }
15194  }
15195 
15196  for ( dim = 0; dim < dim_num; dim++ )
15197  {
15198  if ( rule[dim] == 1 || rule[dim] == 11 || rule[dim] == 14 || rule[dim] == 17 )
15199  {
15200  if ( level[dim] == 0 )
15201  {
15202  o = 1;
15203  }
15204  else
15205  {
15206  o = 2;
15207  while ( o < 2 * level[dim] + 1 )
15208  {
15209  o = 2 * ( o - 1 ) + 1;
15210  }
15211  }
15212  }
15213  else if ( rule[dim] == 3 || rule[dim] == 13 || rule[dim] == 16 )
15214  {
15215  if ( level[dim] == 0 )
15216  {
15217  o = 1;
15218  }
15219  else
15220  {
15221  p = 5;
15222  o = 3;
15223  while ( p < 2 * level[dim] + 1 )
15224  {
15225  p = 2 * p + 1;
15226  o = 2 * o + 1;
15227  }
15228  }
15229  }
15230  else
15231  {
15232  o = 1;
15233  while ( o < 2 * level[dim] + 1 )
15234  {
15235  o = 2 * o + 1;
15236  }
15237  }
15238  order[dim] = o;
15239  }
15240 
15241  return;
15242 }
15243 //**************************************************************************80
15244 
15245 void SandiaRules::level_to_order_linear ( int dim_num, int level[], int rule[],
15246  int order[] )
15247 
15248 //**************************************************************************80
15249 //
15250 // Purpose:
15251 //
15252 // LEVEL_TO_ORDER_LINEAR: linear growth.
15253 //
15254 // Discussion:
15255 //
15256 // The user must preallocate space for the output array ORDER.
15257 //
15258 // O(L) = 2 * L + 1;
15259 //
15260 // O = 1, 3, 5, 7, 9, ...
15261 //
15262 // Licensing:
15263 //
15264 // This code is distributed under the GNU LGPL license.
15265 //
15266 // Modified:
15267 //
15268 // 07 March 2011
15269 //
15270 // Author:
15271 //
15272 // John Burkardt
15273 //
15274 // Parameters:
15275 //
15276 // Input, int DIM_NUM, the spatial dimension.
15277 //
15278 // Input, int LEVEL[DIM_NUM], the 1D levels.
15279 //
15280 // Input, int RULE[DIM_NUM], the rule in each dimension.
15281 // 1, "CC", Clenshaw Curtis, Closed Fully Nested rule.
15282 // 2, "F2", Fejer Type 2, Open Fully Nested rule.
15283 // 3, "GP", Gauss Patterson, Open Fully Nested rule.
15284 // 4, "GL", Gauss Legendre, Open Weakly Nested rule.
15285 // 5, "GH", Gauss Hermite, Open Weakly Nested rule.
15286 // 6, "GGH", Generalized Gauss Hermite, Open Weakly Nested rule.
15287 // 7, "LG", Gauss Laguerre, Open Non Nested rule.
15288 // 8, "GLG", Generalized Gauss Laguerre, Open Non Nested rule.
15289 // 9, "GJ", Gauss Jacobi, Open Non Nested rule.
15290 // 10, "GW", Golub Welsch, (presumed) Open Non Nested rule.
15291 // 11, "CC_SE", Clenshaw Curtis Slow Exponential, Closed Fully Nested rule.
15292 // 12, "F2_SE", Fejer Type 2 Slow Exponential, Open Fully Nested rule.
15293 // 13, "GP_SE", Gauss Patterson Slow Exponential, Open Fully Nested rule.
15294 // 14, "CC_ME", Clenshaw Curtis Moderate Exponential, Closed Fully Nested rule.
15295 // 15, "F2_ME", Fejer Type 2 Moderate Exponential, Open Fully Nested rule.
15296 // 16, "GP_ME", Gauss Patterson Moderate Exponential, Open Fully Nested rule.
15297 // 17, "CCN", Clenshaw Curtis Nested, Linear, Closed Fully Nested rule.
15298 //
15299 // Output, int ORDER[DIM_NUM], the 1D orders (number of points).
15300 //
15301 {
15302  int dim;
15303 
15304  for ( dim = 0; dim < dim_num; dim++ )
15305  {
15306  if ( level[dim] < 0 )
15307  {
15308  std::cerr << "\n";
15309  std::cerr << "LEVEL_TO_ORDER_LINEAR - Fatal error!\n";
15310  std::cerr << " Negative value of LEVEL[DIM]!\n";
15311  std::cerr << " LEVEL[" << dim << "] = " << level[dim] << "\n";
15312  std::exit ( 1 );
15313  }
15314  }
15315 
15316  for ( dim = 0; dim < dim_num; dim++ )
15317  {
15318  order[dim] = 2 * level[dim] + 1;
15319  }
15320 
15321  return;
15322 }
15323 
15324 //****************************************************************************80
15325 
15326 int SandiaRules::level_to_order_exp_cc ( int level, int growth )
15327 
15328 //****************************************************************************80
15329 //
15330 // Purpose:
15331 //
15332 // LEVEL_TO_ORDER_EXP_CC is used for Clenshaw-Curtis type rules.
15333 //
15334 // Discussion:
15335 //
15336 // Rules of this type are assumed to be closed (including both endpoints
15337 // except for the level 0 rule) and having a precision
15338 // behavior typical of Clenshaw Curtis rules, namely, the ORDER-point
15339 // rule is exact for polynomials of degree less than ORDER, and if
15340 // ORDER is odd, then the exactness includes polynomials of degree ORDER
15341 // as well.
15342 //
15343 // LEVEL ORDER ORDER ORDER
15344 // G = 0 G = 1 G = 2
15345 // ----- ----- ----- -----
15346 // 0 1 1 1
15347 // 1 3 5 3
15348 // 2 5 9 5
15349 // 3 9 17 9
15350 // 4 9 17 17
15351 // 5 17 33 33
15352 // 6 17 33 65
15353 // 7 17 33 129
15354 // 8 17 33 257
15355 //
15356 // Licensing:
15357 //
15358 // This code is distributed under the GNU LGPL license.
15359 //
15360 // Modified:
15361 //
15362 // 31 December 2011
15363 //
15364 // Author:
15365 //
15366 // John Burkardt
15367 //
15368 // Parameters:
15369 //
15370 // Input, int LEVEL, the level of the rule.
15371 //
15372 // Input, int GROWTH, the growth policy:
15373 // 0, slow growth;
15374 // 1, moderate growth;
15375 // 2, full growth.
15376 //
15377 // Output, int LEVEL_TO_ORDER_EXP_CC, the order of the rule.
15378 //
15379 {
15380  int o;
15381 //
15382 // Slow exponential growth.
15383 //
15384  if ( growth == 0 )
15385  {
15386  if ( level == 0 )
15387  {
15388  o = 1;
15389  }
15390  else
15391  {
15392  o = 2;
15393  while ( o < 2 * level + 1 )
15394  {
15395  o = 2 * ( o - 1 ) + 1;
15396  }
15397  }
15398  }
15399 //
15400 // Moderate Exponential Growth.
15401 //
15402  else if ( growth == 1 )
15403  {
15404  if ( level == 0 )
15405  {
15406  o = 1;
15407  }
15408  else
15409  {
15410  o = 2;
15411  while ( o < 4 * level + 1 )
15412  {
15413  o = 2 * ( o - 1 ) + 1;
15414  }
15415  }
15416  }
15417 //
15418 // Full Exponential Growth.
15419 //
15420  else if ( growth == 2 )
15421  {
15422  if ( level == 0 )
15423  {
15424  o = 1;
15425  }
15426  else
15427  {
15428  o = i4_power ( 2, level ) + 1;
15429  }
15430  }
15431  else
15432  {
15433  std::cerr << "\n";
15434  std::cerr << "LEVEL_TO_ORDER_EXP_CC - Fatal error!\n";
15435  std::cerr << " Illegal value of GROWTH = " << growth << "\n";
15436  std::exit ( 1 );
15437  }
15438  return o;
15439 }
15440 //****************************************************************************80
15441 
15442 int SandiaRules::level_to_order_exp_f2 ( int level, int growth )
15443 
15444 //****************************************************************************80
15445 //
15446 // Purpose:
15447 //
15448 // LEVEL_TO_ORDER_EXP_F2 is used for Fejer 2 type rules.
15449 //
15450 // Discussion:
15451 //
15452 // Rules of this type are assumed to be open (not including either endpoint)
15453 // and having a precision behavior typical of Fejer Type 2
15454 // rules, namely, the ORDER-point rule is exact for polynomials of degree
15455 // less than ORDER, and if ORDER is odd, then the exactness includes
15456 // polynomials of degree ORDER as well.
15457 //
15458 // LEVEL ORDER ORDER ORDER
15459 // G = 0 G = 1 G = 2
15460 //
15461 // 0 1 1 1
15462 // 1 3 7 3
15463 // 2 7 15 7
15464 // 3 7 15 15
15465 // 4 15 31 31
15466 // 5 15 31 63
15467 // 6 15 31 127
15468 // 7 15 31 255
15469 // 8 31 63 511
15470 //
15471 // Licensing:
15472 //
15473 // This code is distributed under the GNU LGPL license.
15474 //
15475 // Modified:
15476 //
15477 // 31 December 2011
15478 //
15479 // Author:
15480 //
15481 // John Burkardt
15482 //
15483 // Parameters:
15484 //
15485 // Input, int LEVEL, the level of the rule.
15486 //
15487 // Input, int GROWTH, the growth policy:
15488 // 0, slow growth;
15489 // 1, moderate growth;
15490 // 2, full growth.
15491 //
15492 // Output, int LEVEL_TO_ORDER_EXP_F2, the order of the rule.
15493 //
15494 {
15495  int o;
15496 //
15497 // Slow exponential growth.
15498 //
15499  if ( growth == 0 )
15500  {
15501  if ( level == 0 )
15502  {
15503  o = 1;
15504  }
15505  else
15506  {
15507  o = 1;
15508  while ( o < 2 * level + 1 )
15509  {
15510  o = 2 * o + 1;
15511  }
15512  }
15513  }
15514 //
15515 // Moderate Exponential Growth.
15516 //
15517  else if ( growth == 1 )
15518  {
15519  if ( level == 0 )
15520  {
15521  o = 1;
15522  }
15523  else
15524  {
15525  o = 1;
15526  while ( o < 4 * level + 1 )
15527  {
15528  o = 2 * o + 1;
15529  }
15530  }
15531  }
15532 //
15533 // Full Exponential Growth.
15534 //
15535  else if ( growth == 2 )
15536  {
15537  if ( level == 0 )
15538  {
15539  o = 1;
15540  }
15541  else
15542  {
15543  o = i4_power ( 2, level + 1 ) - 1;
15544  }
15545  }
15546  else
15547  {
15548  std::cerr << "\n";
15549  std::cerr << "LEVEL_TO_ORDER_EXP_F2 - Fatal error!\n";
15550  std::cerr << " Illegal value of GROWTH = " << growth << "\n";
15551  std::exit ( 1 );
15552  }
15553  return o;
15554 }
15555 //****************************************************************************80
15556 
15557 int SandiaRules::level_to_order_exp_gauss ( int level, int growth )
15558 
15559 //****************************************************************************80
15560 //
15561 // Purpose:
15562 //
15563 // LEVEL_TO_ORDER_EXP_GAUSS is used for Gauss type rules.
15564 //
15565 // Discussion:
15566 //
15567 // Rules of this type are assumed to be open (not including either endpoint),
15568 // and having a precision behavior typical of Gauss rules, namely, the
15569 // ORDER-point rule is exact for polynomials of degree less than 2 * ORDER.
15570 //
15571 // LEVEL ORDER ORDER ORDER
15572 // G = 0 G = 1 G = 2
15573 //
15574 // 0 1 1 1
15575 // 1 3 3 3
15576 // 2 3 7 7
15577 // 3 7 7 15
15578 // 4 7 15 31
15579 // 5 7 15 63
15580 // 6 7 15 127
15581 // 7 15 15 255
15582 // 8 15 31 511
15583 //
15584 // Licensing:
15585 //
15586 // This code is distributed under the GNU LGPL license.
15587 //
15588 // Modified:
15589 //
15590 // 31 December 2011
15591 //
15592 // Author:
15593 //
15594 // John Burkardt
15595 //
15596 // Parameters:
15597 //
15598 // Input, int LEVEL, the level of the rule.
15599 //
15600 // Input, int GROWTH, the growth policy:
15601 // 0, slow growth;
15602 // 1, moderate growth;
15603 // 2, full growth.
15604 //
15605 // Output, int LEVEL_TO_ORDER_EXP_GAUSS, the order of the rule.
15606 //
15607 {
15608  int o;
15609 //
15610 // Slow exponential growth.
15611 //
15612  if ( growth == 0 )
15613  {
15614  if ( level == 0 )
15615  {
15616  o = 1;
15617  }
15618  else
15619  {
15620  o = 1;
15621  while ( 2 * o - 1 < 2 * level + 1 )
15622  {
15623  o = 2 * o + 1;
15624  }
15625  }
15626  }
15627 //
15628 // Moderate Exponential Growth.
15629 //
15630  else if ( growth == 1 )
15631  {
15632  if ( level == 0 )
15633  {
15634  o = 1;
15635  }
15636  else
15637  {
15638  o = 1;
15639  while ( 2 * o - 1 < 4 * level + 1 )
15640  {
15641  o = 2 * o + 1;
15642  }
15643  }
15644  }
15645 //
15646 // Full Exponential Growth.
15647 //
15648  else if ( growth == 2 )
15649  {
15650  if ( level == 0 )
15651  {
15652  o = 1;
15653  }
15654  else
15655  {
15656  o = i4_power ( 2, level + 1 ) - 1;
15657  }
15658  }
15659  else
15660  {
15661  std::cerr << "\n";
15662  std::cerr << "LEVEL_TO_ORDER_EXP_GAUSS - Fatal error!\n";
15663  std::cerr << " Illegal value of GROWTH = " << growth << "\n";
15664  std::exit ( 1 );
15665  }
15666 
15667  return o;
15668 }
15669 //****************************************************************************80
15670 
15671 int SandiaRules::level_to_order_exp_gp ( int level, int growth )
15672 
15673 //****************************************************************************80
15674 //
15675 // Purpose:
15676 //
15677 // LEVEL_TO_ORDER_EXP_GP is used for Gauss-Patterson type rules.
15678 //
15679 // Discussion:
15680 //
15681 // Rules of this type are assumed to be open (not including either endpoint)
15682 // and having a precision behavior typical of Gauss Patterson rules.
15683 //
15684 // Note that there are onlly 9 rules in the family, and so it is possible to
15685 // specify input for which the function will fail.
15686 //
15687 // LEVEL ORDER ORDER ORDER
15688 // G = 0 G = 1 G = 2
15689 //
15690 // 0 1 1 1
15691 // 1 3 3 3
15692 // 2 3 7 7
15693 // 3 7 15 15
15694 // 4 7 15 31
15695 // 5 7 15 63
15696 // 6 15 31 127
15697 // 7 15 31 255
15698 // 8 15 31 511
15699 //
15700 // Licensing:
15701 //
15702 // This code is distributed under the GNU LGPL license.
15703 //
15704 // Modified:
15705 //
15706 // 31 December 2011
15707 //
15708 // Author:
15709 //
15710 // John Burkardt
15711 //
15712 // Parameters:
15713 //
15714 // Input, int LEVEL, the level of the rule.
15715 //
15716 // Input, int GROWTH, the growth policy:
15717 // 0, slow growth;
15718 // 1, moderate growth;
15719 // 2, full growth.
15720 //
15721 // Output, int LEVEL_TO_ORDER_EXP_GP, the order of the rule.
15722 //
15723 {
15724  int o;
15725  int p;
15726 //
15727 // Slow exponential growth.
15728 //
15729  if ( growth == 0 )
15730  {
15731  if ( level == 0 )
15732  {
15733  o = 1;
15734  }
15735  else
15736  {
15737  p = 5;
15738  o = 3;
15739  while ( p < 2 * level + 1 )
15740  {
15741  p = 2 * p + 1;
15742  o = 2 * o + 1;
15743  if ( 511 < o )
15744  {
15745  std::cerr << "\n";
15746  std::cerr << "LEVEL_TO_ORDER_EXP_GP - Fatal error!\n";
15747  std::cerr << " Request for unavailable Patterson rule.\n";
15748  std::exit ( 1 );
15749  }
15750  }
15751  }
15752  }
15753 //
15754 // Moderate Exponential Growth.
15755 //
15756  else if ( growth == 1 )
15757  {
15758  if ( level == 0 )
15759  {
15760  o = 1;
15761  }
15762  else
15763  {
15764  p = 5;
15765  o = 3;
15766  while ( p < 4 * level + 1 )
15767  {
15768  p = 2 * p + 1;
15769  o = 2 * o + 1;
15770  if ( 511 < o )
15771  {
15772  std::cerr << "\n";
15773  std::cerr << "LEVEL_TO_ORDER_EXP_GP - Fatal error!\n";
15774  std::cerr << " Request for unavailable Patterson rule.\n";
15775  std::exit ( 1 );
15776  }
15777  }
15778  }
15779  }
15780 //
15781 // Full Exponential Growth.
15782 //
15783  else if ( growth == 2 )
15784  {
15785  if ( level == 0 )
15786  {
15787  o = 1;
15788  }
15789  else
15790  {
15791  o = i4_power ( 2, level + 1 ) - 1;
15792  if ( 511 < o )
15793  {
15794  std::cerr << "\n";
15795  std::cerr << "LEVEL_TO_ORDER_EXP_GP - Fatal error!\n";
15796  std::cerr << " Request for unavailable Patterson rule.\n";
15797  std::exit ( 1 );
15798  }
15799  }
15800  }
15801  else
15802  {
15803  std::cerr << "\n";
15804  std::cerr << "LEVEL_TO_ORDER_EXP_GP - Fatal error!\n";
15805  std::cerr << " Illegal value of GROWTH = " << growth << "\n";
15806  std::exit ( 1 );
15807  }
15808 
15809  return o;
15810 }
15811 //****************************************************************************80
15812 
15813 int SandiaRules::level_to_order_exp_hgk ( int level, int growth )
15814 
15815 //****************************************************************************80
15816 //
15817 // Purpose:
15818 //
15819 // LEVEL_TO_ORDER_EXP_HGK is used for Hermite Genz-Keister type rules.
15820 //
15821 // Discussion:
15822 //
15823 // Rules of this type are assumed to be open (not including either endpoint)
15824 // and having a precision behavior typical of Hermite Genz-Keister rules.
15825 //
15826 // Note that there are only 6 rules in the family, and so it is possible to
15827 // specify input for which the function will fail.
15828 //
15829 // LEVEL ORDER ORDER ORDER
15830 // G = 0 G = 1 G = 2
15831 //
15832 // 0 1 1 1
15833 // 1 3 3 3
15834 // 2 3 9 9
15835 // 3 9 9 19
15836 // 4 9 19 35
15837 // 5 9 19 43
15838 // 6 9 19 --
15839 // 7 9 19 --
15840 // 8 19 35 --
15841 //
15842 // Licensing:
15843 //
15844 // This code is distributed under the GNU LGPL license.
15845 //
15846 // Modified:
15847 //
15848 // 31 December 2011
15849 //
15850 // Author:
15851 //
15852 // John Burkardt
15853 //
15854 // Parameters:
15855 //
15856 // Input, int LEVEL, the level of the rule.
15857 //
15858 // Input, int GROWTH, the growth policy:
15859 // 0, slow growth;
15860 // 1, moderate growth;
15861 // 2, full growth.
15862 //
15863 // Output, int LEVEL_TO_ORDER_EXP_HGK, the order of the rule.
15864 //
15865 {
15866  int l;
15867  int o;
15868  static int o_hgk[6] = { 1, 3, 9, 19, 35, 43 };
15869  int p;
15870  static int p_hgk[6] = { 1, 5, 15, 29, 51, 67 };
15871 //
15872 // Slow exponential growth.
15873 //
15874  if ( growth == 0 )
15875  {
15876  l = 0;
15877  p = p_hgk[l];
15878  o = o_hgk[l];
15879  while ( p < 2 * level + 1 )
15880  {
15881  l = l + 1;
15882  if ( 5 < l )
15883  {
15884  std::cerr << "\n";
15885  std::cerr << "LEVEL_TO_ORDER_EXP_HGK - Fatal error!\n";
15886  std::cerr << " Hermite Genz-Keister maximum level exceeded.\n";
15887  std::exit ( 1 );
15888  }
15889  p = p_hgk[l];
15890  o = o_hgk[l];
15891  }
15892  }
15893  else if ( growth == 1 )
15894  {
15895  l = 0;
15896  p = p_hgk[l];
15897  o = o_hgk[l];
15898  while ( p < 4 * level + 1 )
15899  {
15900  l = l + 1;
15901  if ( 5 < l )
15902  {
15903  std::cerr << "\n";
15904  std::cerr << "LEVEL_TO_ORDER_EXP_HGK - Fatal error!\n";
15905  std::cerr << " Hermite Genz-Keister maximum level exceeded.\n";
15906  std::exit ( 1 );
15907  }
15908  p = p_hgk[l];
15909  o = o_hgk[l];
15910  }
15911  }
15912  else if ( growth == 2 )
15913  {
15914  l = level;
15915  l = i4_max ( l, 0 );
15916  if ( 5 < l )
15917  {
15918  std::cerr << "\n";
15919  std::cerr << "LEVEL_TO_ORDER_EXP_HGK - Fatal error!\n";
15920  std::cerr << " Hermite Genz-Keister maximum level exceeded.\n";
15921  std::exit ( 1 );
15922  }
15923  o = o_hgk[l];
15924  }
15925  else
15926  {
15927  std::cerr << "\n";
15928  std::cerr << "LEVEL_TO_ORDER_EXP_HGK - Fatal error!\n";
15929  std::cerr << " Illegal value of GROWTH = " << growth << "\n";
15930  std::exit ( 1 );
15931  }
15932 
15933  return o;
15934 }
15935 //****************************************************************************80
15936 
15937 int SandiaRules::level_to_order_linear_nn ( int level, int growth )
15938 
15939 //****************************************************************************80
15940 //
15941 // Purpose:
15942 //
15943 // LEVEL_TO_ORDER_LINEAR_NN is used for non-nested Gauss type rules.
15944 //
15945 // Discussion:
15946 //
15947 // Rules of this type are assumed to be open (not including either endpoint),
15948 // non-nested, and having a precision behavior typical of Gauss rules.
15949 //
15950 // LEVEL ORDER ORDER
15951 // G = 0 G = 1
15952 //
15953 // 0 1 1
15954 // 1 2 3
15955 // 2 3 5
15956 // 3 4 7
15957 // 4 5 9
15958 // 5 6 11
15959 // 6 7 13
15960 // 7 8 15
15961 // 8 9 17
15962 //
15963 // Licensing:
15964 //
15965 // This code is distributed under the GNU LGPL license.
15966 //
15967 // Modified:
15968 //
15969 // 31 December 2011
15970 //
15971 // Author:
15972 //
15973 // John Burkardt
15974 //
15975 // Parameters:
15976 //
15977 // Input, int LEVEL, the level of the rule.
15978 //
15979 // Input, int GROWTH, the growth policy:
15980 // 0, slow growth;
15981 // 1, moderate growth;
15982 //
15983 // Output, int LEVEL_TO_ORDER_LINEAR_NN, the order of the rule.
15984 //
15985 {
15986  int o;
15987 //
15988 // Slow linear growth.
15989 //
15990  if ( growth == 0 )
15991  {
15992  o = level + 1;
15993  }
15994 //
15995 // Moderate linear growth.
15996 //
15997  else if ( growth == 1 )
15998  {
15999  o = 2 * level + 1;
16000  }
16001  else if ( growth == 2 )
16002  {
16003  o = 2 * level + 1;
16004  }
16005  else
16006  {
16007  std::cerr << "\n";
16008  std::cerr << "LEVEL_TO_ORDER_LINEAR_NN - Fatal error!\n";
16009  std::cerr << " Illegal value of GROWTH = " << growth << "\n";
16010  std::exit ( 1 );
16011  }
16012  return o;
16013 }
16014 //****************************************************************************80
16015 
16016 int SandiaRules::level_to_order_linear_wn ( int level, int growth )
16017 
16018 //****************************************************************************80
16019 //
16020 // Purpose:
16021 //
16022 // LEVEL_TO_ORDER_LINEAR_WN is used for weakly-nested Gauss type rules.
16023 //
16024 // Discussion:
16025 //
16026 // Rules of this type are assumed to be open (not including either endpoint),
16027 // nested, and having a precision behavior typical of Gauss rules.
16028 //
16029 // We assume the rules are to be generated with an odd number of points,
16030 // and that all the rules will share a single point, namely 0.
16031 //
16032 // Note that the "moderate growth" option for this function results in the
16033 // same values as the moderate growth option for LEVEL_TO_ORDER_LINEAR_NN.
16034 //
16035 // LEVEL ORDER ORDER
16036 // G = 0 G = 1
16037 //
16038 // 0 1 1
16039 // 1 3 3
16040 // 2 3 5
16041 // 3 5 7
16042 // 4 5 9
16043 // 5 7 11
16044 // 6 7 13
16045 // 7 9 15
16046 // 8 9 17
16047 //
16048 // Licensing:
16049 //
16050 // This code is distributed under the GNU LGPL license.
16051 //
16052 // Modified:
16053 //
16054 // 26 January 2012
16055 //
16056 // Author:
16057 //
16058 // John Burkardt
16059 //
16060 // Parameters:
16061 //
16062 // Input, int LEVEL, the level of the rule.
16063 //
16064 // Input, int GROWTH, the growth policy:
16065 // 0, slow growth;
16066 // 1, moderate growth;
16067 //
16068 // Output, int LEVEL_TO_ORDER_LINEAR_WN, the order of the rule.
16069 //
16070 {
16071  int o;
16072 //
16073 // Slow growth.
16074 //
16075  if ( growth == 0 )
16076  {
16077  o = 2 * ( ( level + 1 ) / 2 ) + 1;
16078  }
16079  else if ( growth == 1 )
16080  {
16081  o = 2 * level + 1;
16082  }
16083  else if ( growth == 2 )
16084  {
16085  o = 2 * level + 1;
16086  }
16087  else
16088  {
16089  std::cerr << "\n";
16090  std::cerr << "LEVEL_TO_ORDER_LINEAR_WN - Fatal error!\n";
16091  std::cerr << " Illegal value of GROWTH = " << growth << "\n";
16092  std::exit ( 1 );
16093  }
16094  return o;
16095 }
16096 
16097 //**************************************************************************80
16098 
16099 void SandiaRules::nc_compute ( int n, double x_min, double x_max, double x[], double w[] )
16100 
16101 //**************************************************************************80
16102 //
16103 // Purpose:
16104 //
16105 // NC_COMPUTE computes a Newton-Cotes quadrature rule.
16106 //
16107 // Discussion:
16108 //
16109 // For the interval [X_MIN,X_MAX], the Newton-Cotes quadrature rule
16110 // estimates
16111 //
16112 // Integral ( X_MIN <= X <= X_MAX ) F(X) dX
16113 //
16114 // using N abscissas X and weights W:
16115 //
16116 // Sum ( 1 <= I <= N ) W(I) * F ( X(I) ).
16117 //
16118 // For the CLOSED rule, the abscissas include the end points.
16119 // For the OPEN rule, the abscissas do not include the end points.
16120 //
16121 // Licensing:
16122 //
16123 // This code is distributed under the GNU LGPL license.
16124 //
16125 // Modified:
16126 //
16127 // 17 November 2009
16128 //
16129 // Author:
16130 //
16131 // John Burkardt
16132 //
16133 // Parameters:
16134 //
16135 // Input, int N, the order.
16136 //
16137 // Input, double X_MIN, X_MAX, the endpoints of the interval.
16138 //
16139 // Input, double X[N], the abscissas.
16140 //
16141 // Output, double W[N], the weights.
16142 //
16143 {
16144  double *d;
16145  int i;
16146  int j;
16147  int k;
16148  double yvala;
16149  double yvalb;
16150 
16151  d = new double[n];
16152 
16153  for ( i = 0; i < n; i++ )
16154  {
16155 //
16156 // Compute the Lagrange basis polynomial which is 1 at XTAB(I),
16157 // and zero at the other nodes.
16158 //
16159  for ( j = 0; j < n; j++ )
16160  {
16161  d[j] = 0.0;
16162  }
16163  d[i] = 1.0;
16164 
16165  for ( j = 2; j <= n; j++ )
16166  {
16167  for ( k = j; k <= n; k++ )
16168  {
16169  d[n+j-k-1] = ( d[n+j-k-1-1] - d[n+j-k-1] ) / ( x[n+1-k-1] - x[n+j-k-1] );
16170  }
16171  }
16172 
16173  for ( j = 1; j <= n - 1; j++ )
16174  {
16175  for ( k = 1; k <= n - j; k++ )
16176  {
16177  d[n-k-1] = d[n-k-1] - x[n-k-j] * d[n-k];
16178  }
16179  }
16180 //
16181 // Evaluate the antiderivative of the polynomial at the left and
16182 // right endpoints.
16183 //
16184  yvala = d[n-1] / ( double ) ( n );
16185  for ( j = n - 2; 0 <= j; j-- )
16186  {
16187  yvala = yvala * x_min + d[j] / ( double ) ( j + 1 );
16188  }
16189  yvala = yvala * x_min;
16190 
16191  yvalb = d[n-1] / ( double ) ( n );
16192  for ( j = n - 2; 0 <= j; j-- )
16193  {
16194  yvalb = yvalb * x_max + d[j] / ( double ) ( j + 1 );
16195  }
16196  yvalb = yvalb * x_max;
16197 
16198  w[i] = yvalb - yvala;
16199  }
16200 
16201  delete [] d;
16202 
16203  return;
16204 }
16205 //**************************************************************************80
16206 
16207 double *SandiaRules::nc_compute_new ( int n, double x_min, double x_max, double x[] )
16208 
16209 //**************************************************************************80
16210 //
16211 // Purpose:
16212 //
16213 // NC_COMPUTE_NEW computes a Newton-Cotes quadrature rule.
16214 //
16215 // Discussion:
16216 //
16217 // For the interval [X_MIN,X_MAX], the Newton-Cotes quadrature rule
16218 // estimates
16219 //
16220 // Integral ( X_MIN <= X <= X_MAX ) F(X) dX
16221 //
16222 // using N abscissas X and weights W:
16223 //
16224 // Sum ( 1 <= I <= N ) W(I) * F ( X(I) ).
16225 //
16226 // For the CLOSED rule, the abscissas include the end points.
16227 // For the OPEN rule, the abscissas do not include the end points.
16228 //
16229 // Licensing:
16230 //
16231 // This code is distributed under the GNU LGPL license.
16232 //
16233 // Modified:
16234 //
16235 // 17 November 2009
16236 //
16237 // Author:
16238 //
16239 // John Burkardt
16240 //
16241 // Parameters:
16242 //
16243 // Input, int N, the order.
16244 //
16245 // Input, double X_MIN, X_MAX, the endpoints of the interval.
16246 //
16247 // Input, double X[N], the abscissas.
16248 //
16249 // Output, double NC_COMPUTE_NEW[N], the weights.
16250 //
16251 {
16252  double *d;
16253  int i;
16254  int j;
16255  int k;
16256  double *w;
16257  double yvala;
16258  double yvalb;
16259 
16260  d = new double[n];
16261  w = new double[n];
16262 
16263  for ( i = 0; i < n; i++ )
16264  {
16265 //
16266 // Compute the Lagrange basis polynomial which is 1 at XTAB(I),
16267 // and zero at the other nodes.
16268 //
16269  for ( j = 0; j < n; j++ )
16270  {
16271  d[j] = 0.0;
16272  }
16273  d[i] = 1.0;
16274 
16275  for ( j = 2; j <= n; j++ )
16276  {
16277  for ( k = j; k <= n; k++ )
16278  {
16279  d[n+j-k-1] = ( d[n+j-k-1-1] - d[n+j-k-1] ) / ( x[n+1-k-1] - x[n+j-k-1] );
16280  }
16281  }
16282 
16283  for ( j = 1; j <= n - 1; j++ )
16284  {
16285  for ( k = 1; k <= n - j; k++ )
16286  {
16287  d[n-k-1] = d[n-k-1] - x[n-k-j] * d[n-k];
16288  }
16289  }
16290 //
16291 // Evaluate the antiderivative of the polynomial at the left and
16292 // right endpoints.
16293 //
16294  yvala = d[n-1] / ( double ) ( n );
16295  for ( j = n - 2; 0 <= j; j-- )
16296  {
16297  yvala = yvala * x_min + d[j] / ( double ) ( j + 1 );
16298  }
16299  yvala = yvala * x_min;
16300 
16301  yvalb = d[n-1] / ( double ) ( n );
16302  for ( j = n - 2; 0 <= j; j-- )
16303  {
16304  yvalb = yvalb * x_max + d[j] / ( double ) ( j + 1 );
16305  }
16306  yvalb = yvalb * x_max;
16307 
16308  w[i] = yvalb - yvala;
16309  }
16310 
16311  delete [] d;
16312 
16313  return w;
16314 }
16315 //**************************************************************************80
16316 
16317 void SandiaRules::ncc_compute_points ( int n, double x[] )
16318 
16319 //**************************************************************************80
16320 //
16321 // Purpose:
16322 //
16323 // NCC_COMPUTE_POINTS: points of a Newton-Cotes Closed quadrature rule.
16324 //
16325 // Licensing:
16326 //
16327 // This code is distributed under the GNU LGPL license.
16328 //
16329 // Modified:
16330 //
16331 // 16 November 2009
16332 //
16333 // Author:
16334 //
16335 // John Burkardt
16336 //
16337 // Parameters:
16338 //
16339 // Input, int N, the order.
16340 //
16341 // Output, double X[N], the abscissas.
16342 //
16343 {
16344  int i;
16345  double x_max = 1.0;
16346  double x_min = -1.0;
16347 
16348  if ( n == 1 )
16349  {
16350  x[0] = ( x_max + x_min ) / 2.0;
16351  }
16352  else
16353  {
16354  for ( i = 0; i < n; i++ )
16355  {
16356  x[i] = ( ( double ) ( n - i - 1 ) * x_min
16357  + ( double ) ( i ) * x_max )
16358  / ( double ) ( n - 1 );
16359  }
16360  }
16361  return;
16362 }
16363 //**************************************************************************80
16364 
16365 void SandiaRules::ncc_compute_weights ( int n, double w[] )
16366 
16367 //**************************************************************************80
16368 //
16369 // Purpose:
16370 //
16371 // NCC_COMPUTE_WEIGHTS: weights of a Newton-Cotes Closed quadrature rule.
16372 //
16373 // Licensing:
16374 //
16375 // This code is distributed under the GNU LGPL license.
16376 //
16377 // Modified:
16378 //
16379 // 16 November 2009
16380 //
16381 // Author:
16382 //
16383 // John Burkardt
16384 //
16385 // Parameters:
16386 //
16387 // Input, int N, the order.
16388 //
16389 // Output, double W[N], the weights.
16390 //
16391 {
16392  int i;
16393  double *x;
16394  double x_max = 1.0;
16395  double x_min = -1.0;
16396 
16397  if ( n == 1 )
16398  {
16399  w[0] = x_max - x_min;
16400  }
16401  else
16402  {
16403  x = new double[n];
16404 
16405  for ( i = 0; i < n; i++ )
16406  {
16407  x[i] = ( ( double ) ( n - i - 1 ) * x_min
16408  + ( double ) ( i ) * x_max )
16409  / ( double ) ( n - 1 );
16410  }
16411  nc_compute ( n, x_min, x_max, x, w );
16412 
16413  delete [] x;
16414  }
16415  return;
16416 }
16417 //**************************************************************************80
16418 
16419 void SandiaRules::nco_compute_points ( int n, double x[] )
16420 
16421 //**************************************************************************80
16422 //
16423 // Purpose:
16424 //
16425 // NCO_COMPUTE_POINTS: points for a Newton-Cotes Open quadrature rule.
16426 //
16427 // Licensing:
16428 //
16429 // This code is distributed under the GNU LGPL license.
16430 //
16431 // Modified:
16432 //
16433 // 17 November 2009
16434 //
16435 // Author:
16436 //
16437 // John Burkardt
16438 //
16439 // Parameters:
16440 //
16441 // Input, int N, the order.
16442 //
16443 // Output, double X[N], the abscissas.
16444 //
16445 {
16446  int i;
16447  double x_max = 1.0;
16448  double x_min = -1.0;
16449 
16450  for ( i = 0; i < n; i++ )
16451  {
16452  x[i] = ( ( double ) ( n - i ) * x_min
16453  + ( double ) ( + i + 1 ) * x_max )
16454  / ( double ) ( n + 1 );
16455  }
16456 
16457  return;
16458 }
16459 //**************************************************************************80
16460 
16461 void SandiaRules::nco_compute_weights ( int n, double w[] )
16462 
16463 //**************************************************************************80
16464 //
16465 // Purpose:
16466 //
16467 // NCO_COMPUTE_WEIGHTS: weights for a Newton-Cotes Open quadrature rule.
16468 //
16469 // Licensing:
16470 //
16471 // This code is distributed under the GNU LGPL license.
16472 //
16473 // Modified:
16474 //
16475 // 17 November 2009
16476 //
16477 // Author:
16478 //
16479 // John Burkardt
16480 //
16481 // Parameters:
16482 //
16483 // Input, int N, the order.
16484 //
16485 // Output, double W[N], the weights.
16486 //
16487 {
16488  //int i;
16489  double *x;
16490  double x_max = 1.0;
16491  double x_min = -1.0;
16492 
16493  x = new double[n];
16494 
16495  nco_compute_points ( n, x );
16496 
16497  nc_compute ( n, x_min, x_max, x, w );
16498 
16499  delete [] x;
16500 
16501  return;
16502 }
16503 //**************************************************************************80
16504 
16505 void SandiaRules::ncoh_compute_points ( int n, double x[] )
16506 
16507 //**************************************************************************80
16508 //
16509 // Purpose:
16510 //
16511 // NCOH_COMPUTE_POINTS computes points for a Newton-Cotes "open half" quadrature rule.
16512 //
16513 // Discussion:
16514 //
16515 // The input value N is used to define N equal subintervals of [-1,+1].
16516 // The I-th abscissa is the center of the I-th subinterval.
16517 //
16518 // Licensing:
16519 //
16520 // This code is distributed under the GNU LGPL license.
16521 //
16522 // Modified:
16523 //
16524 // 03 July 2011
16525 //
16526 // Author:
16527 //
16528 // John Burkardt
16529 //
16530 // Parameters:
16531 //
16532 // Input, int N, the order.
16533 //
16534 // Output, double X[N], the abscissas.
16535 //
16536 {
16537  int i;
16538  const double x_max = 1.0;
16539  const double x_min = -1.0;
16540 
16541  for ( i = 0; i < n; i++ )
16542  {
16543  x[i] = ( ( double ) ( 2 * n - 2 * i - 1 ) * x_min
16544  + ( double ) ( 2 * i + 1 ) * x_max )
16545  / ( double ) ( 2 * n );
16546  }
16547 
16548  return;
16549 }
16550 //**************************************************************************80
16551 
16552 void SandiaRules::ncoh_compute_weights ( int n, double w[] )
16553 
16554 //**************************************************************************80
16555 //
16556 // Purpose:
16557 //
16558 // NCOH_COMPUTE_WEIGHTS computes weights for a Newton-Cotes "open half" quadrature rule.
16559 //
16560 // Discussion:
16561 //
16562 // The input value N is used to define N equal subintervals of [-1,+1].
16563 // The I-th abscissa is the center of the I-th subinterval.
16564 //
16565 // Licensing:
16566 //
16567 // This code is distributed under the GNU LGPL license.
16568 //
16569 // Modified:
16570 //
16571 // 03 July 2011
16572 //
16573 // Author:
16574 //
16575 // John Burkardt
16576 //
16577 // Parameters:
16578 //
16579 // Input, int N, the order.
16580 //
16581 // Output, double W[N], the weights.
16582 //
16583 {
16584  //int i;
16585  double *x;
16586  const double x_max = 1.0;
16587  const double x_min = -1.0;
16588 
16589  x = new double[n];
16590 
16591  ncoh_compute_points ( n, x );
16592 
16593  nc_compute ( n, x_min, x_max, x, w );
16594 
16595  delete [] x;
16596 
16597  return;
16598 }
16599 //**************************************************************************80
16600 
16601 void SandiaRules::patterson_lookup ( int n, double x[], double w[] )
16602 
16603 //**************************************************************************80
16604 //
16605 // Purpose:
16606 //
16607 // PATTERSON_LOOKUP looks up Patterson quadrature points and weights.
16608 //
16609 // Discussion:
16610 //
16611 // Our convention is that the abscissas are numbered from left to right.
16612 //
16613 // The rule is defined on [-1,1],
16614 //
16615 // Licensing:
16616 //
16617 // This code is distributed under the GNU LGPL license.
16618 //
16619 // Modified:
16620 //
16621 // 11 February 2010
16622 //
16623 // Author:
16624 //
16625 // John Burkardt
16626 //
16627 // Reference:
16628 //
16629 // Prem Kythe, Michael Schaeferkotter,
16630 // Handbook of Computational Methods for Integration,
16631 // Chapman and Hall, 2004,
16632 // ISBN: 1-58488-428-2,
16633 // LC: QA299.3.K98.
16634 //
16635 // Thomas Patterson,
16636 // The Optimal Addition of Points to Quadrature Formulae,
16637 // Mathematics of Computation,
16638 // Volume 22, Number 104, October 1968, pages 847-856.
16639 //
16640 // Parameters:
16641 //
16642 // Input, int N, the order.
16643 // Legal values are 1, 3, 7, 15, 31, 63, 127, 255 and 511.
16644 //
16645 // Output, double X[N], the abscissas.
16646 //
16647 // Output, double W[N], the weights.
16648 //
16649 {
16650  patterson_lookup_points ( n, x );
16651  patterson_lookup_weights ( n, w );
16652 
16653  return;
16654 }
16655 //**************************************************************************80
16656 
16657 void SandiaRules::patterson_lookup_points ( int n, double x[] )
16658 
16659 //**************************************************************************80
16660 //
16661 // Purpose:
16662 //
16663 // PATTERSON_LOOKUP_POINTS looks up Patterson quadrature points.
16664 //
16665 // Discussion:
16666 //
16667 // Our convention is that the abscissas are numbered from left to right.
16668 //
16669 // The rule is defined on [-1,1],
16670 //
16671 // These rules constitute a nested family. The rules can integrate exactly
16672 // any polynomial of degree 1, 5, 11, 23, 47, 95, 191, 383 or 767,
16673 // respectively.
16674 //
16675 // The data for N = 511 was supplied by Dirk Laurie, and is derived
16676 // from a NAG Library function d01arf.
16677 //
16678 // Licensing:
16679 //
16680 // This code is distributed under the GNU LGPL license.
16681 //
16682 // Modified:
16683 //
16684 // 14 September 2011
16685 //
16686 // Author:
16687 //
16688 // John Burkardt
16689 //
16690 // Reference:
16691 //
16692 // Prem Kythe, Michael Schaeferkotter,
16693 // Handbook of Computational Methods for Integration,
16694 // Chapman and Hall, 2004,
16695 // ISBN: 1-58488-428-2,
16696 // LC: QA299.3.K98.
16697 //
16698 // NAG Library Documentation,
16699 // D01ARF,
16700 // The Numerical Algorithms Group.
16701 //
16702 // Thomas Patterson,
16703 // The Optimal Addition of Points to Quadrature Formulae,
16704 // Mathematics of Computation,
16705 // Volume 22, Number 104, October 1968, pages 847-856.
16706 //
16707 // Parameters:
16708 //
16709 // Input, int N, the order.
16710 // Legal values are 1, 3, 7, 15, 31, 63, 127, 255 and 511.
16711 //
16712 // Output, double X[N], the abscissas.
16713 //
16714 {
16715  static double x_001[1] =
16716  {
16717  0.0
16718  };
16719  static double x_003[3] =
16720  {
16721  -0.77459666924148337704,
16722  0.0,
16723  0.77459666924148337704
16724  };
16725  static double x_007[7] =
16726  {
16727  -0.96049126870802028342,
16728  -0.77459666924148337704,
16729  -0.43424374934680255800,
16730  0.0,
16731  0.43424374934680255800,
16732  0.77459666924148337704,
16733  0.96049126870802028342
16734  };
16735  static double x_015[15] =
16736  {
16737  -0.99383196321275502221,
16738  -0.96049126870802028342,
16739  -0.88845923287225699889,
16740  -0.77459666924148337704,
16741  -0.62110294673722640294,
16742  -0.43424374934680255800,
16743  -0.22338668642896688163,
16744  0.0,
16745  0.22338668642896688163,
16746  0.43424374934680255800,
16747  0.62110294673722640294,
16748  0.77459666924148337704,
16749  0.88845923287225699889,
16750  0.96049126870802028342,
16751  0.99383196321275502221
16752  };
16753  static double x_031[31] =
16754  {
16755  -0.99909812496766759766,
16756  -0.99383196321275502221,
16757  -0.98153114955374010687,
16758  -0.96049126870802028342,
16759  -0.92965485742974005667,
16760  -0.88845923287225699889,
16761  -0.83672593816886873550,
16762  -0.77459666924148337704,
16763  -0.70249620649152707861,
16764  -0.62110294673722640294,
16765  -0.53131974364437562397,
16766  -0.43424374934680255800,
16767  -0.33113539325797683309,
16768  -0.22338668642896688163,
16769  -0.11248894313318662575,
16770  0.0,
16771  0.11248894313318662575,
16772  0.22338668642896688163,
16773  0.33113539325797683309,
16774  0.43424374934680255800,
16775  0.53131974364437562397,
16776  0.62110294673722640294,
16777  0.70249620649152707861,
16778  0.77459666924148337704,
16779  0.83672593816886873550,
16780  0.88845923287225699889,
16781  0.92965485742974005667,
16782  0.96049126870802028342,
16783  0.98153114955374010687,
16784  0.99383196321275502221,
16785  0.99909812496766759766
16786  };
16787  static double x_063[63] =
16788  {
16789  -0.99987288812035761194,
16790  -0.99909812496766759766,
16791  -0.99720625937222195908,
16792  -0.99383196321275502221,
16793  -0.98868475754742947994,
16794  -0.98153114955374010687,
16795  -0.97218287474858179658,
16796  -0.96049126870802028342,
16797  -0.94634285837340290515,
16798  -0.92965485742974005667,
16799  -0.91037115695700429250,
16800  -0.88845923287225699889,
16801  -0.86390793819369047715,
16802  -0.83672593816886873550,
16803  -0.80694053195021761186,
16804  -0.77459666924148337704,
16805  -0.73975604435269475868,
16806  -0.70249620649152707861,
16807  -0.66290966002478059546,
16808  -0.62110294673722640294,
16809  -0.57719571005204581484,
16810  -0.53131974364437562397,
16811  -0.48361802694584102756,
16812  -0.43424374934680255800,
16813  -0.38335932419873034692,
16814  -0.33113539325797683309,
16815  -0.27774982202182431507,
16816  -0.22338668642896688163,
16817  -0.16823525155220746498,
16818  -0.11248894313318662575,
16819  -0.056344313046592789972,
16820  0.0,
16821  0.056344313046592789972,
16822  0.11248894313318662575,
16823  0.16823525155220746498,
16824  0.22338668642896688163,
16825  0.27774982202182431507,
16826  0.33113539325797683309,
16827  0.38335932419873034692,
16828  0.43424374934680255800,
16829  0.48361802694584102756,
16830  0.53131974364437562397,
16831  0.57719571005204581484,
16832  0.62110294673722640294,
16833  0.66290966002478059546,
16834  0.70249620649152707861,
16835  0.73975604435269475868,
16836  0.77459666924148337704,
16837  0.80694053195021761186,
16838  0.83672593816886873550,
16839  0.86390793819369047715,
16840  0.88845923287225699889,
16841  0.91037115695700429250,
16842  0.92965485742974005667,
16843  0.94634285837340290515,
16844  0.96049126870802028342,
16845  0.97218287474858179658,
16846  0.98153114955374010687,
16847  0.98868475754742947994,
16848  0.99383196321275502221,
16849  0.99720625937222195908,
16850  0.99909812496766759766,
16851  0.99987288812035761194
16852  };
16853  static double x_127[127] =
16854  {
16855  -0.99998243035489159858,
16856  -0.99987288812035761194,
16857  -0.99959879967191068325,
16858  -0.99909812496766759766,
16859  -0.99831663531840739253,
16860  -0.99720625937222195908,
16861  -0.99572410469840718851,
16862  -0.99383196321275502221,
16863  -0.99149572117810613240,
16864  -0.98868475754742947994,
16865  -0.98537149959852037111,
16866  -0.98153114955374010687,
16867  -0.97714151463970571416,
16868  -0.97218287474858179658,
16869  -0.96663785155841656709,
16870  -0.96049126870802028342,
16871  -0.95373000642576113641,
16872  -0.94634285837340290515,
16873  -0.93832039777959288365,
16874  -0.92965485742974005667,
16875  -0.92034002547001242073,
16876  -0.91037115695700429250,
16877  -0.89974489977694003664,
16878  -0.88845923287225699889,
16879  -0.87651341448470526974,
16880  -0.86390793819369047715,
16881  -0.85064449476835027976,
16882  -0.83672593816886873550,
16883  -0.82215625436498040737,
16884  -0.80694053195021761186,
16885  -0.79108493379984836143,
16886  -0.77459666924148337704,
16887  -0.75748396638051363793,
16888  -0.73975604435269475868,
16889  -0.72142308537009891548,
16890  -0.70249620649152707861,
16891  -0.68298743109107922809,
16892  -0.66290966002478059546,
16893  -0.64227664250975951377,
16894  -0.62110294673722640294,
16895  -0.59940393024224289297,
16896  -0.57719571005204581484,
16897  -0.55449513263193254887,
16898  -0.53131974364437562397,
16899  -0.50768775753371660215,
16900  -0.48361802694584102756,
16901  -0.45913001198983233287,
16902  -0.43424374934680255800,
16903  -0.40897982122988867241,
16904  -0.38335932419873034692,
16905  -0.35740383783153215238,
16906  -0.33113539325797683309,
16907  -0.30457644155671404334,
16908  -0.27774982202182431507,
16909  -0.25067873030348317661,
16910  -0.22338668642896688163,
16911  -0.19589750271110015392,
16912  -0.16823525155220746498,
16913  -0.14042423315256017459,
16914  -0.11248894313318662575,
16915  -0.084454040083710883710,
16916  -0.056344313046592789972,
16917  -0.028184648949745694339,
16918  0.0,
16919  0.028184648949745694339,
16920  0.056344313046592789972,
16921  0.084454040083710883710,
16922  0.11248894313318662575,
16923  0.14042423315256017459,
16924  0.16823525155220746498,
16925  0.19589750271110015392,
16926  0.22338668642896688163,
16927  0.25067873030348317661,
16928  0.27774982202182431507,
16929  0.30457644155671404334,
16930  0.33113539325797683309,
16931  0.35740383783153215238,
16932  0.38335932419873034692,
16933  0.40897982122988867241,
16934  0.43424374934680255800,
16935  0.45913001198983233287,
16936  0.48361802694584102756,
16937  0.50768775753371660215,
16938  0.53131974364437562397,
16939  0.55449513263193254887,
16940  0.57719571005204581484,
16941  0.59940393024224289297,
16942  0.62110294673722640294,
16943  0.64227664250975951377,
16944  0.66290966002478059546,
16945  0.68298743109107922809,
16946  0.70249620649152707861,
16947  0.72142308537009891548,
16948  0.73975604435269475868,
16949  0.75748396638051363793,
16950  0.77459666924148337704,
16951  0.79108493379984836143,
16952  0.80694053195021761186,
16953  0.82215625436498040737,
16954  0.83672593816886873550,
16955  0.85064449476835027976,
16956  0.86390793819369047715,
16957  0.87651341448470526974,
16958  0.88845923287225699889,
16959  0.89974489977694003664,
16960  0.91037115695700429250,
16961  0.92034002547001242073,
16962  0.92965485742974005667,
16963  0.93832039777959288365,
16964  0.94634285837340290515,
16965  0.95373000642576113641,
16966  0.96049126870802028342,
16967  0.96663785155841656709,
16968  0.97218287474858179658,
16969  0.97714151463970571416,
16970  0.98153114955374010687,
16971  0.98537149959852037111,
16972  0.98868475754742947994,
16973  0.99149572117810613240,
16974  0.99383196321275502221,
16975  0.99572410469840718851,
16976  0.99720625937222195908,
16977  0.99831663531840739253,
16978  0.99909812496766759766,
16979  0.99959879967191068325,
16980  0.99987288812035761194,
16981  0.99998243035489159858
16982  };
16983  static double x_255[255] =
16984  {
16985  -0.99999759637974846462,
16986  -0.99998243035489159858,
16987  -0.99994399620705437576,
16988  -0.99987288812035761194,
16989  -0.99976049092443204733,
16990  -0.99959879967191068325,
16991  -0.99938033802502358193,
16992  -0.99909812496766759766,
16993  -0.99874561446809511470,
16994  -0.99831663531840739253,
16995  -0.99780535449595727456,
16996  -0.99720625937222195908,
16997  -0.99651414591489027385,
16998  -0.99572410469840718851,
16999  -0.99483150280062100052,
17000  -0.99383196321275502221,
17001  -0.99272134428278861533,
17002  -0.99149572117810613240,
17003  -0.99015137040077015918,
17004  -0.98868475754742947994,
17005  -0.98709252795403406719,
17006  -0.98537149959852037111,
17007  -0.98351865757863272876,
17008  -0.98153114955374010687,
17009  -0.97940628167086268381,
17010  -0.97714151463970571416,
17011  -0.97473445975240266776,
17012  -0.97218287474858179658,
17013  -0.96948465950245923177,
17014  -0.96663785155841656709,
17015  -0.96364062156981213252,
17016  -0.96049126870802028342,
17017  -0.95718821610986096274,
17018  -0.95373000642576113641,
17019  -0.95011529752129487656,
17020  -0.94634285837340290515,
17021  -0.94241156519108305981,
17022  -0.93832039777959288365,
17023  -0.93406843615772578800,
17024  -0.92965485742974005667,
17025  -0.92507893290707565236,
17026  -0.92034002547001242073,
17027  -0.91543758715576504064,
17028  -0.91037115695700429250,
17029  -0.90514035881326159519,
17030  -0.89974489977694003664,
17031  -0.89418456833555902286,
17032  -0.88845923287225699889,
17033  -0.88256884024734190684,
17034  -0.87651341448470526974,
17035  -0.87029305554811390585,
17036  -0.86390793819369047715,
17037  -0.85735831088623215653,
17038  -0.85064449476835027976,
17039  -0.84376688267270860104,
17040  -0.83672593816886873550,
17041  -0.82952219463740140018,
17042  -0.82215625436498040737,
17043  -0.81462878765513741344,
17044  -0.80694053195021761186,
17045  -0.79909229096084140180,
17046  -0.79108493379984836143,
17047  -0.78291939411828301639,
17048  -0.77459666924148337704,
17049  -0.76611781930376009072,
17050  -0.75748396638051363793,
17051  -0.74869629361693660282,
17052  -0.73975604435269475868,
17053  -0.73066452124218126133,
17054  -0.72142308537009891548,
17055  -0.71203315536225203459,
17056  -0.70249620649152707861,
17057  -0.69281376977911470289,
17058  -0.68298743109107922809,
17059  -0.67301883023041847920,
17060  -0.66290966002478059546,
17061  -0.65266166541001749610,
17062  -0.64227664250975951377,
17063  -0.63175643771119423041,
17064  -0.62110294673722640294,
17065  -0.61031811371518640016,
17066  -0.59940393024224289297,
17067  -0.58836243444766254143,
17068  -0.57719571005204581484,
17069  -0.56590588542365442262,
17070  -0.55449513263193254887,
17071  -0.54296566649831149049,
17072  -0.53131974364437562397,
17073  -0.51955966153745702199,
17074  -0.50768775753371660215,
17075  -0.49570640791876146017,
17076  -0.48361802694584102756,
17077  -0.47142506587165887693,
17078  -0.45913001198983233287,
17079  -0.44673538766202847374,
17080  -0.43424374934680255800,
17081  -0.42165768662616330006,
17082  -0.40897982122988867241,
17083  -0.39621280605761593918,
17084  -0.38335932419873034692,
17085  -0.37042208795007823014,
17086  -0.35740383783153215238,
17087  -0.34430734159943802278,
17088  -0.33113539325797683309,
17089  -0.31789081206847668318,
17090  -0.30457644155671404334,
17091  -0.29119514851824668196,
17092  -0.27774982202182431507,
17093  -0.26424337241092676194,
17094  -0.25067873030348317661,
17095  -0.23705884558982972721,
17096  -0.22338668642896688163,
17097  -0.20966523824318119477,
17098  -0.19589750271110015392,
17099  -0.18208649675925219825,
17100  -0.16823525155220746498,
17101  -0.15434681148137810869,
17102  -0.14042423315256017459,
17103  -0.12647058437230196685,
17104  -0.11248894313318662575,
17105  -0.098482396598119202090,
17106  -0.084454040083710883710,
17107  -0.070406976042855179063,
17108  -0.056344313046592789972,
17109  -0.042269164765363603212,
17110  -0.028184648949745694339,
17111  -0.014093886410782462614,
17112  0.0,
17113  0.014093886410782462614,
17114  0.028184648949745694339,
17115  0.042269164765363603212,
17116  0.056344313046592789972,
17117  0.070406976042855179063,
17118  0.084454040083710883710,
17119  0.098482396598119202090,
17120  0.11248894313318662575,
17121  0.12647058437230196685,
17122  0.14042423315256017459,
17123  0.15434681148137810869,
17124  0.16823525155220746498,
17125  0.18208649675925219825,
17126  0.19589750271110015392,
17127  0.20966523824318119477,
17128  0.22338668642896688163,
17129  0.23705884558982972721,
17130  0.25067873030348317661,
17131  0.26424337241092676194,
17132  0.27774982202182431507,
17133  0.29119514851824668196,
17134  0.30457644155671404334,
17135  0.31789081206847668318,
17136  0.33113539325797683309,
17137  0.34430734159943802278,
17138  0.35740383783153215238,
17139  0.37042208795007823014,
17140  0.38335932419873034692,
17141  0.39621280605761593918,
17142  0.40897982122988867241,
17143  0.42165768662616330006,
17144  0.43424374934680255800,
17145  0.44673538766202847374,
17146  0.45913001198983233287,
17147  0.47142506587165887693,
17148  0.48361802694584102756,
17149  0.49570640791876146017,
17150  0.50768775753371660215,
17151  0.51955966153745702199,
17152  0.53131974364437562397,
17153  0.54296566649831149049,
17154  0.55449513263193254887,
17155  0.56590588542365442262,
17156  0.57719571005204581484,
17157  0.58836243444766254143,
17158  0.59940393024224289297,
17159  0.61031811371518640016,
17160  0.62110294673722640294,
17161  0.63175643771119423041,
17162  0.64227664250975951377,
17163  0.65266166541001749610,
17164  0.66290966002478059546,
17165  0.67301883023041847920,
17166  0.68298743109107922809,
17167  0.69281376977911470289,
17168  0.70249620649152707861,
17169  0.71203315536225203459,
17170  0.72142308537009891548,
17171  0.73066452124218126133,
17172  0.73975604435269475868,
17173  0.74869629361693660282,
17174  0.75748396638051363793,
17175  0.76611781930376009072,
17176  0.77459666924148337704,
17177  0.78291939411828301639,
17178  0.79108493379984836143,
17179  0.79909229096084140180,
17180  0.80694053195021761186,
17181  0.81462878765513741344,
17182  0.82215625436498040737,
17183  0.82952219463740140018,
17184  0.83672593816886873550,
17185  0.84376688267270860104,
17186  0.85064449476835027976,
17187  0.85735831088623215653,
17188  0.86390793819369047715,
17189  0.87029305554811390585,
17190  0.87651341448470526974,
17191  0.88256884024734190684,
17192  0.88845923287225699889,
17193  0.89418456833555902286,
17194  0.89974489977694003664,
17195  0.90514035881326159519,
17196  0.91037115695700429250,
17197  0.91543758715576504064,
17198  0.92034002547001242073,
17199  0.92507893290707565236,
17200  0.92965485742974005667,
17201  0.93406843615772578800,
17202  0.93832039777959288365,
17203  0.94241156519108305981,
17204  0.94634285837340290515,
17205  0.95011529752129487656,
17206  0.95373000642576113641,
17207  0.95718821610986096274,
17208  0.96049126870802028342,
17209  0.96364062156981213252,
17210  0.96663785155841656709,
17211  0.96948465950245923177,
17212  0.97218287474858179658,
17213  0.97473445975240266776,
17214  0.97714151463970571416,
17215  0.97940628167086268381,
17216  0.98153114955374010687,
17217  0.98351865757863272876,
17218  0.98537149959852037111,
17219  0.98709252795403406719,
17220  0.98868475754742947994,
17221  0.99015137040077015918,
17222  0.99149572117810613240,
17223  0.99272134428278861533,
17224  0.99383196321275502221,
17225  0.99483150280062100052,
17226  0.99572410469840718851,
17227  0.99651414591489027385,
17228  0.99720625937222195908,
17229  0.99780535449595727456,
17230  0.99831663531840739253,
17231  0.99874561446809511470,
17232  0.99909812496766759766,
17233  0.99938033802502358193,
17234  0.99959879967191068325,
17235  0.99976049092443204733,
17236  0.99987288812035761194,
17237  0.99994399620705437576,
17238  0.99998243035489159858,
17239  0.99999759637974846462
17240  };
17241  static double x_511[511] =
17242  {
17243  -0.999999672956734384381,
17244  -0.999997596379748464620,
17245  -0.999992298136257588028,
17246  -0.999982430354891598580,
17247  -0.999966730098486276883,
17248  -0.999943996207054375764,
17249  -0.999913081144678282800,
17250  -0.999872888120357611938,
17251  -0.999822363679787739196,
17252  -0.999760490924432047330,
17253  -0.999686286448317731776,
17254  -0.999598799671910683252,
17255  -0.999497112467187190535,
17256  -0.999380338025023581928,
17257  -0.999247618943342473599,
17258  -0.999098124967667597662,
17259  -0.998931050830810562236,
17260  -0.998745614468095114704,
17261  -0.998541055697167906027,
17262  -0.998316635318407392531,
17263  -0.998071634524930323302,
17264  -0.997805354495957274562,
17265  -0.997517116063472399965,
17266  -0.997206259372221959076,
17267  -0.996872143485260161299,
17268  -0.996514145914890273849,
17269  -0.996131662079315037786,
17270  -0.995724104698407188509,
17271  -0.995290903148810302261,
17272  -0.994831502800621000519,
17273  -0.994345364356723405931,
17274  -0.993831963212755022209,
17275  -0.993290788851684966211,
17276  -0.992721344282788615328,
17277  -0.992123145530863117683,
17278  -0.991495721178106132399,
17279  -0.990838611958294243677,
17280  -0.990151370400770159181,
17281  -0.989433560520240838716,
17282  -0.988684757547429479939,
17283  -0.987904547695124280467,
17284  -0.987092527954034067190,
17285  -0.986248305913007552681,
17286  -0.985371499598520371114,
17287  -0.984461737328814534596,
17288  -0.983518657578632728762,
17289  -0.982541908851080604251,
17290  -0.981531149553740106867,
17291  -0.980486047876721339416,
17292  -0.979406281670862683806,
17293  -0.978291538324758539526,
17294  -0.977141514639705714156,
17295  -0.975955916702011753129,
17296  -0.974734459752402667761,
17297  -0.973476868052506926773,
17298  -0.972182874748581796578,
17299  -0.970852221732792443256,
17300  -0.969484659502459231771,
17301  -0.968079947017759947964,
17302  -0.966637851558416567092,
17303  -0.965158148579915665979,
17304  -0.963640621569812132521,
17305  -0.962085061904651475741,
17306  -0.960491268708020283423,
17307  -0.958859048710200221356,
17308  -0.957188216109860962736,
17309  -0.955478592438183697574,
17310  -0.953730006425761136415,
17311  -0.951942293872573589498,
17312  -0.950115297521294876558,
17313  -0.948248866934137357063,
17314  -0.946342858373402905148,
17315  -0.944397134685866648591,
17316  -0.942411565191083059813,
17317  -0.940386025573669721370,
17318  -0.938320397779592883655,
17319  -0.936214569916450806625,
17320  -0.934068436157725787999,
17321  -0.931881896650953639345,
17322  -0.929654857429740056670,
17323  -0.927387230329536696843,
17324  -0.925078932907075652364,
17325  -0.922729888363349241523,
17326  -0.920340025470012420730,
17327  -0.917909278499077501636,
17328  -0.915437587155765040644,
17329  -0.912924896514370590080,
17330  -0.910371156957004292498,
17331  -0.907776324115058903624,
17332  -0.905140358813261595189,
17333  -0.902463227016165675048,
17334  -0.899744899776940036639,
17335  -0.896985353188316590376,
17336  -0.894184568335559022859,
17337  -0.891342531251319871666,
17338  -0.888459232872256998890,
17339  -0.885534668997285008926,
17340  -0.882568840247341906842,
17341  -0.879561752026556262568,
17342  -0.876513414484705269742,
17343  -0.873423842480859310192,
17344  -0.870293055548113905851,
17345  -0.867121077859315215614,
17346  -0.863907938193690477146,
17347  -0.860653669904299969802,
17348  -0.857358310886232156525,
17349  -0.854021903545468625813,
17350  -0.850644494768350279758,
17351  -0.847226135891580884381,
17352  -0.843766882672708601038,
17353  -0.840266795261030442350,
17354  -0.836725938168868735503,
17355  -0.833144380243172624728,
17356  -0.829522194637401400178,
17357  -0.825859458783650001088,
17358  -0.822156254364980407373,
17359  -0.818412667287925807395,
17360  -0.814628787655137413436,
17361  -0.810804709738146594361,
17362  -0.806940531950217611856,
17363  -0.803036356819268687782,
17364  -0.799092290960841401800,
17365  -0.795108445051100526780,
17366  -0.791084933799848361435,
17367  -0.787021875923539422170,
17368  -0.782919394118283016385,
17369  -0.778777615032822744702,
17370  -0.774596669241483377036,
17371  -0.770376691217076824278,
17372  -0.766117819303760090717,
17373  -0.761820195689839149173,
17374  -0.757483966380513637926,
17375  -0.753109281170558142523,
17376  -0.748696293616936602823,
17377  -0.744245161011347082309,
17378  -0.739756044352694758677,
17379  -0.735229108319491547663,
17380  -0.730664521242181261329,
17381  -0.726062455075389632685,
17382  -0.721423085370098915485,
17383  -0.716746591245747095767,
17384  -0.712033155362252034587,
17385  -0.707282963891961103412,
17386  -0.702496206491527078610,
17387  -0.697673076273711232906,
17388  -0.692813769779114702895,
17389  -0.687918486947839325756,
17390  -0.682987431091079228087,
17391  -0.678020808862644517838,
17392  -0.673018830230418479199,
17393  -0.667981708447749702165,
17394  -0.662909660024780595461,
17395  -0.657802904699713735422,
17396  -0.652661665410017496101,
17397  -0.647486168263572388782,
17398  -0.642276642509759513774,
17399  -0.637033320510492495071,
17400  -0.631756437711194230414,
17401  -0.626446232611719746542,
17402  -0.621102946737226402941,
17403  -0.615726824608992638014,
17404  -0.610318113715186400156,
17405  -0.604877064481584353319,
17406  -0.599403930242242892974,
17407  -0.593898967210121954393,
17408  -0.588362434447662541434,
17409  -0.582794593837318850840,
17410  -0.577195710052045814844,
17411  -0.571566050525742833992,
17412  -0.565905885423654422623,
17413  -0.560215487612728441818,
17414  -0.554495132631932548866,
17415  -0.548745098662529448608,
17416  -0.542965666498311490492,
17417  -0.537157119515795115982,
17418  -0.531319743644375623972,
17419  -0.525453827336442687395,
17420  -0.519559661537457021993,
17421  -0.513637539655988578507,
17422  -0.507687757533716602155,
17423  -0.501710613415391878251,
17424  -0.495706407918761460170,
17425  -0.489675444004456155436,
17426  -0.483618026945841027562,
17427  -0.477534464298829155284,
17428  -0.471425065871658876934,
17429  -0.465290143694634735858,
17430  -0.459130011989832332874,
17431  -0.452944987140767283784,
17432  -0.446735387662028473742,
17433  -0.440501534168875795783,
17434  -0.434243749346802558002,
17435  -0.427962357921062742583,
17436  -0.421657686626163300056,
17437  -0.415330064175321663764,
17438  -0.408979821229888672409,
17439  -0.402607290368737092671,
17440  -0.396212806057615939183,
17441  -0.389796704618470795479,
17442  -0.383359324198730346916,
17443  -0.376901004740559344802,
17444  -0.370422087950078230138,
17445  -0.363922917266549655269,
17446  -0.357403837831532152376,
17447  -0.350865196458001209011,
17448  -0.344307341599438022777,
17449  -0.337730623318886219621,
17450  -0.331135393257976833093,
17451  -0.324522004605921855207,
17452  -0.317890812068476683182,
17453  -0.311242171836871800300,
17454  -0.304576441556714043335,
17455  -0.297893980296857823437,
17456  -0.291195148518246681964,
17457  -0.284480308042725577496,
17458  -0.277749822021824315065,
17459  -0.271004054905512543536,
17460  -0.264243372410926761945,
17461  -0.257468141491069790481,
17462  -0.250678730303483176613,
17463  -0.243875508178893021593,
17464  -0.237058845589829727213,
17465  -0.230229114119222177156,
17466  -0.223386686428966881628,
17467  -0.216531936228472628081,
17468  -0.209665238243181194766,
17469  -0.202786968183064697557,
17470  -0.195897502711100153915,
17471  -0.188997219411721861059,
17472  -0.182086496759252198246,
17473  -0.175165714086311475707,
17474  -0.168235251552207464982,
17475  -0.161295490111305257361,
17476  -0.154346811481378108692,
17477  -0.147389598111939940054,
17478  -0.140424233152560174594,
17479  -0.133451100421161601344,
17480  -0.126470584372301966851,
17481  -0.119483070065440005133,
17482  -0.112488943133186625746,
17483  -0.105488589749541988533,
17484  -0.984823965981192020903E-01,
17485  -0.914707508403553909095E-01,
17486  -0.844540400837108837102E-01,
17487  -0.774326523498572825675E-01,
17488  -0.704069760428551790633E-01,
17489  -0.633773999173222898797E-01,
17490  -0.563443130465927899720E-01,
17491  -0.493081047908686267156E-01,
17492  -0.422691647653636032124E-01,
17493  -0.352278828084410232603E-01,
17494  -0.281846489497456943394E-01,
17495  -0.211398533783310883350E-01,
17496  -0.140938864107824626142E-01,
17497  -0.704713845933674648514E-02,
17498  +0.000000000000000000000,
17499  +0.704713845933674648514E-02,
17500  +0.140938864107824626142E-01,
17501  +0.211398533783310883350E-01,
17502  +0.281846489497456943394E-01,
17503  +0.352278828084410232603E-01,
17504  +0.422691647653636032124E-01,
17505  +0.493081047908686267156E-01,
17506  +0.563443130465927899720E-01,
17507  +0.633773999173222898797E-01,
17508  +0.704069760428551790633E-01,
17509  +0.774326523498572825675E-01,
17510  +0.844540400837108837102E-01,
17511  +0.914707508403553909095E-01,
17512  +0.984823965981192020903E-01,
17513  +0.105488589749541988533,
17514  +0.112488943133186625746,
17515  +0.119483070065440005133,
17516  +0.126470584372301966851,
17517  +0.133451100421161601344,
17518  +0.140424233152560174594,
17519  +0.147389598111939940054,
17520  +0.154346811481378108692,
17521  +0.161295490111305257361,
17522  +0.168235251552207464982,
17523  +0.175165714086311475707,
17524  +0.182086496759252198246,
17525  +0.188997219411721861059,
17526  +0.195897502711100153915,
17527  +0.202786968183064697557,
17528  +0.209665238243181194766,
17529  +0.216531936228472628081,
17530  +0.223386686428966881628,
17531  +0.230229114119222177156,
17532  +0.237058845589829727213,
17533  +0.243875508178893021593,
17534  +0.250678730303483176613,
17535  +0.257468141491069790481,
17536  +0.264243372410926761945,
17537  +0.271004054905512543536,
17538  +0.277749822021824315065,
17539  +0.284480308042725577496,
17540  +0.291195148518246681964,
17541  +0.297893980296857823437,
17542  +0.304576441556714043335,
17543  +0.311242171836871800300,
17544  +0.317890812068476683182,
17545  +0.324522004605921855207,
17546  +0.331135393257976833093,
17547  +0.337730623318886219621,
17548  +0.344307341599438022777,
17549  +0.350865196458001209011,
17550  +0.357403837831532152376,
17551  +0.363922917266549655269,
17552  +0.370422087950078230138,
17553  +0.376901004740559344802,
17554  +0.383359324198730346916,
17555  +0.389796704618470795479,
17556  +0.396212806057615939183,
17557  +0.402607290368737092671,
17558  +0.408979821229888672409,
17559  +0.415330064175321663764,
17560  +0.421657686626163300056,
17561  +0.427962357921062742583,
17562  +0.434243749346802558002,
17563  +0.440501534168875795783,
17564  +0.446735387662028473742,
17565  +0.452944987140767283784,
17566  +0.459130011989832332874,
17567  +0.465290143694634735858,
17568  +0.471425065871658876934,
17569  +0.477534464298829155284,
17570  +0.483618026945841027562,
17571  +0.489675444004456155436,
17572  +0.495706407918761460170,
17573  +0.501710613415391878251,
17574  +0.507687757533716602155,
17575  +0.513637539655988578507,
17576  +0.519559661537457021993,
17577  +0.525453827336442687395,
17578  +0.531319743644375623972,
17579  +0.537157119515795115982,
17580  +0.542965666498311490492,
17581  +0.548745098662529448608,
17582  +0.554495132631932548866,
17583  +0.560215487612728441818,
17584  +0.565905885423654422623,
17585  +0.571566050525742833992,
17586  +0.577195710052045814844,
17587  +0.582794593837318850840,
17588  +0.588362434447662541434,
17589  +0.593898967210121954393,
17590  +0.599403930242242892974,
17591  +0.604877064481584353319,
17592  +0.610318113715186400156,
17593  +0.615726824608992638014,
17594  +0.621102946737226402941,
17595  +0.626446232611719746542,
17596  +0.631756437711194230414,
17597  +0.637033320510492495071,
17598  +0.642276642509759513774,
17599  +0.647486168263572388782,
17600  +0.652661665410017496101,
17601  +0.657802904699713735422,
17602  +0.662909660024780595461,
17603  +0.667981708447749702165,
17604  +0.673018830230418479199,
17605  +0.678020808862644517838,
17606  +0.682987431091079228087,
17607  +0.687918486947839325756,
17608  +0.692813769779114702895,
17609  +0.697673076273711232906,
17610  +0.702496206491527078610,
17611  +0.707282963891961103412,
17612  +0.712033155362252034587,
17613  +0.716746591245747095767,
17614  +0.721423085370098915485,
17615  +0.726062455075389632685,
17616  +0.730664521242181261329,
17617  +0.735229108319491547663,
17618  +0.739756044352694758677,
17619  +0.744245161011347082309,
17620  +0.748696293616936602823,
17621  +0.753109281170558142523,
17622  +0.757483966380513637926,
17623  +0.761820195689839149173,
17624  +0.766117819303760090717,
17625  +0.770376691217076824278,
17626  +0.774596669241483377036,
17627  +0.778777615032822744702,
17628  +0.782919394118283016385,
17629  +0.787021875923539422170,
17630  +0.791084933799848361435,
17631  +0.795108445051100526780,
17632  +0.799092290960841401800,
17633  +0.803036356819268687782,
17634  +0.806940531950217611856,
17635  +0.810804709738146594361,
17636  +0.814628787655137413436,
17637  +0.818412667287925807395,
17638  +0.822156254364980407373,
17639  +0.825859458783650001088,
17640  +0.829522194637401400178,
17641  +0.833144380243172624728,
17642  +0.836725938168868735503,
17643  +0.840266795261030442350,
17644  +0.843766882672708601038,
17645  +0.847226135891580884381,
17646  +0.850644494768350279758,
17647  +0.854021903545468625813,
17648  +0.857358310886232156525,
17649  +0.860653669904299969802,
17650  +0.863907938193690477146,
17651  +0.867121077859315215614,
17652  +0.870293055548113905851,
17653  +0.873423842480859310192,
17654  +0.876513414484705269742,
17655  +0.879561752026556262568,
17656  +0.882568840247341906842,
17657  +0.885534668997285008926,
17658  +0.888459232872256998890,
17659  +0.891342531251319871666,
17660  +0.894184568335559022859,
17661  +0.896985353188316590376,
17662  +0.899744899776940036639,
17663  +0.902463227016165675048,
17664  +0.905140358813261595189,
17665  +0.907776324115058903624,
17666  +0.910371156957004292498,
17667  +0.912924896514370590080,
17668  +0.915437587155765040644,
17669  +0.917909278499077501636,
17670  +0.920340025470012420730,
17671  +0.922729888363349241523,
17672  +0.925078932907075652364,
17673  +0.927387230329536696843,
17674  +0.929654857429740056670,
17675  +0.931881896650953639345,
17676  +0.934068436157725787999,
17677  +0.936214569916450806625,
17678  +0.938320397779592883655,
17679  +0.940386025573669721370,
17680  +0.942411565191083059813,
17681  +0.944397134685866648591,
17682  +0.946342858373402905148,
17683  +0.948248866934137357063,
17684  +0.950115297521294876558,
17685  +0.951942293872573589498,
17686  +0.953730006425761136415,
17687  +0.955478592438183697574,
17688  +0.957188216109860962736,
17689  +0.958859048710200221356,
17690  +0.960491268708020283423,
17691  +0.962085061904651475741,
17692  +0.963640621569812132521,
17693  +0.965158148579915665979,
17694  +0.966637851558416567092,
17695  +0.968079947017759947964,
17696  +0.969484659502459231771,
17697  +0.970852221732792443256,
17698  +0.972182874748581796578,
17699  +0.973476868052506926773,
17700  +0.974734459752402667761,
17701  +0.975955916702011753129,
17702  +0.977141514639705714156,
17703  +0.978291538324758539526,
17704  +0.979406281670862683806,
17705  +0.980486047876721339416,
17706  +0.981531149553740106867,
17707  +0.982541908851080604251,
17708  +0.983518657578632728762,
17709  +0.984461737328814534596,
17710  +0.985371499598520371114,
17711  +0.986248305913007552681,
17712  +0.987092527954034067190,
17713  +0.987904547695124280467,
17714  +0.988684757547429479939,
17715  +0.989433560520240838716,
17716  +0.990151370400770159181,
17717  +0.990838611958294243677,
17718  +0.991495721178106132399,
17719  +0.992123145530863117683,
17720  +0.992721344282788615328,
17721  +0.993290788851684966211,
17722  +0.993831963212755022209,
17723  +0.994345364356723405931,
17724  +0.994831502800621000519,
17725  +0.995290903148810302261,
17726  +0.995724104698407188509,
17727  +0.996131662079315037786,
17728  +0.996514145914890273849,
17729  +0.996872143485260161299,
17730  +0.997206259372221959076,
17731  +0.997517116063472399965,
17732  +0.997805354495957274562,
17733  +0.998071634524930323302,
17734  +0.998316635318407392531,
17735  +0.998541055697167906027,
17736  +0.998745614468095114704,
17737  +0.998931050830810562236,
17738  +0.999098124967667597662,
17739  +0.999247618943342473599,
17740  +0.999380338025023581928,
17741  +0.999497112467187190535,
17742  +0.999598799671910683252,
17743  +0.999686286448317731776,
17744  +0.999760490924432047330,
17745  +0.999822363679787739196,
17746  +0.999872888120357611938,
17747  +0.999913081144678282800,
17748  +0.999943996207054375764,
17749  +0.999966730098486276883,
17750  +0.999982430354891598580,
17751  +0.999992298136257588028,
17752  +0.999997596379748464620,
17753  +0.999999672956734384381
17754  };
17755 
17756  if ( n == 1 )
17757  {
17758  r8vec_copy ( n, x_001, x );
17759  }
17760  else if ( n == 3 )
17761  {
17762  r8vec_copy ( n, x_003, x );
17763  }
17764  else if ( n == 7 )
17765  {
17766  r8vec_copy ( n, x_007, x );
17767  }
17768  else if ( n == 15 )
17769  {
17770  r8vec_copy ( n, x_015, x );
17771  }
17772  else if ( n == 31 )
17773  {
17774  r8vec_copy ( n, x_031, x );
17775  }
17776  else if ( n == 63 )
17777  {
17778  r8vec_copy ( n, x_063, x );
17779  }
17780  else if ( n == 127 )
17781  {
17782  r8vec_copy ( n, x_127, x );
17783  }
17784  else if ( n == 255 )
17785  {
17786  r8vec_copy ( n, x_255, x );
17787  }
17788  else if ( n == 511 )
17789  {
17790  r8vec_copy ( n, x_511, x );
17791  }
17792  else
17793  {
17794  std::cerr << "\n";
17795  std::cerr << "PATTERSON_LOOKUP_POINTS - Fatal error!\n";
17796  std::cerr << " Unexpected value of N = " << n << "\n";
17797  std::exit ( 1 );
17798  }
17799  return;
17800 }
17801 //**************************************************************************80
17802 
17803 void SandiaRules::patterson_lookup_points_np ( int n, int np, double p[], double x[] )
17804 
17805 //**************************************************************************80
17806 //
17807 // Purpose:
17808 //
17809 // PATTERSON_LOOKUP_POINTS_NP looks up Patterson quadrature points.
17810 //
17811 // Discussion:
17812 //
17813 // Our convention is that the abscissas are numbered from left to right.
17814 //
17815 // The rule is defined on [-1,1],
17816 //
17817 // Licensing:
17818 //
17819 // This code is distributed under the GNU LGPL license.
17820 //
17821 // Modified:
17822 //
17823 // 17 December 2009
17824 //
17825 // Author:
17826 //
17827 // John Burkardt
17828 //
17829 // Reference:
17830 //
17831 // Prem Kythe, Michael Schaeferkotter,
17832 // Handbook of Computational Methods for Integration,
17833 // Chapman and Hall, 2004,
17834 // ISBN: 1-58488-428-2,
17835 // LC: QA299.3.K98.
17836 //
17837 // Thomas Patterson,
17838 // The Optimal Addition of Points to Quadrature Formulae,
17839 // Mathematics of Computation,
17840 // Volume 22, Number 104, October 1968, pages 847-856.
17841 //
17842 // Parameters:
17843 //
17844 // Input, int N, the order.
17845 // Legal values are 1, 3, 7, 15, 31, 63, 127, 255 and 511.
17846 //
17847 // Input, int NP, the number of parameters.
17848 //
17849 // Input, double P[NP], parameters which are not needed by this function.
17850 //
17851 // Output, double X[N], the abscissas.
17852 //
17853 {
17854  patterson_lookup_points ( n, x );
17855 
17856  return;
17857 }
17858 //**************************************************************************80
17859 
17860 void SandiaRules::patterson_lookup_weights ( int n, double w[] )
17861 
17862 //**************************************************************************80
17863 //
17864 // Purpose:
17865 //
17866 // PATTERSON_LOOKUP_WEIGHTS looks up Patterson quadrature weights.
17867 //
17868 // Discussion:
17869 //
17870 // The allowed orders are 1, 3, 7, 15, 31, 63, 127, 255 and 511.
17871 //
17872 // The weights are positive, symmetric and should sum to 2.
17873 //
17874 // The user must preallocate space for the output array W.
17875 //
17876 // These rules constitute a nested family. The rules can integrate exactly
17877 // any polynomial of degree 1, 5, 11, 23, 47, 95, 191, 383 or 767,
17878 // respectively.
17879 //
17880 // The data for N = 511 was supplied by Dirk Laurie, and is derived
17881 // from a NAG Library function d01arf.
17882 //
17883 // Licensing:
17884 //
17885 // This code is distributed under the GNU LGPL license.
17886 //
17887 // Modified:
17888 //
17889 // 14 September 2011
17890 //
17891 // Author:
17892 //
17893 // John Burkardt
17894 //
17895 // Reference:
17896 //
17897 // Prem Kythe, Michael Schaeferkotter,
17898 // Handbook of Computational Methods for Integration,
17899 // Chapman and Hall, 2004,
17900 // ISBN: 1-58488-428-2,
17901 // LC: QA299.3.K98.
17902 //
17903 // NAG Library Documentation,
17904 // D01ARF,
17905 // The Numerical Algorithms Group.
17906 //
17907 // Thomas Patterson,
17908 // The Optimal Addition of Points to Quadrature Formulae,
17909 // Mathematics of Computation,
17910 // Volume 22, Number 104, October 1968, pages 847-856.
17911 //
17912 // Parameters:
17913 //
17914 // Input, int N, the order.
17915 // Legal values are 1, 3, 7, 15, 31, 63, 127, 255 or 511.
17916 //
17917 // Output, double W[N], the weights.
17918 //
17919 {
17920  static double w_001[1] =
17921  {
17922  2.0
17923  };
17924  static double w_003[3] =
17925  {
17926  0.555555555555555555556,
17927  0.888888888888888888889,
17928  0.555555555555555555556
17929  };
17930  static double w_007[7] =
17931  {
17932  0.104656226026467265194,
17933  0.268488089868333440729,
17934  0.401397414775962222905,
17935  0.450916538658474142345,
17936  0.401397414775962222905,
17937  0.268488089868333440729,
17938  0.104656226026467265194
17939  };
17940  static double w_015[15] =
17941  {
17942  0.0170017196299402603390,
17943  0.0516032829970797396969,
17944  0.0929271953151245376859,
17945  0.134415255243784220360,
17946  0.171511909136391380787,
17947  0.200628529376989021034,
17948  0.219156858401587496404,
17949  0.225510499798206687386,
17950  0.219156858401587496404,
17951  0.200628529376989021034,
17952  0.171511909136391380787,
17953  0.134415255243784220360,
17954  0.0929271953151245376859,
17955  0.0516032829970797396969,
17956  0.0170017196299402603390
17957  };
17958  static double w_031[31] =
17959  {
17960  0.00254478079156187441540,
17961  0.00843456573932110624631,
17962  0.0164460498543878109338,
17963  0.0258075980961766535646,
17964  0.0359571033071293220968,
17965  0.0464628932617579865414,
17966  0.0569795094941233574122,
17967  0.0672077542959907035404,
17968  0.0768796204990035310427,
17969  0.0857559200499903511542,
17970  0.0936271099812644736167,
17971  0.100314278611795578771,
17972  0.105669893580234809744,
17973  0.109578421055924638237,
17974  0.111956873020953456880,
17975  0.112755256720768691607,
17976  0.111956873020953456880,
17977  0.109578421055924638237,
17978  0.105669893580234809744,
17979  0.100314278611795578771,
17980  0.0936271099812644736167,
17981  0.0857559200499903511542,
17982  0.0768796204990035310427,
17983  0.0672077542959907035404,
17984  0.0569795094941233574122,
17985  0.0464628932617579865414,
17986  0.0359571033071293220968,
17987  0.0258075980961766535646,
17988  0.0164460498543878109338,
17989  0.00843456573932110624631,
17990  0.00254478079156187441540
17991  };
17992  static double w_063[63] =
17993  {
17994  0.000363221481845530659694,
17995  0.00126515655623006801137,
17996  0.00257904979468568827243,
17997  0.00421763044155885483908,
17998  0.00611550682211724633968,
17999  0.00822300795723592966926,
18000  0.0104982469096213218983,
18001  0.0129038001003512656260,
18002  0.0154067504665594978021,
18003  0.0179785515681282703329,
18004  0.0205942339159127111492,
18005  0.0232314466399102694433,
18006  0.0258696793272147469108,
18007  0.0284897547458335486125,
18008  0.0310735511116879648799,
18009  0.0336038771482077305417,
18010  0.0360644327807825726401,
18011  0.0384398102494555320386,
18012  0.0407155101169443189339,
18013  0.0428779600250077344929,
18014  0.0449145316536321974143,
18015  0.0468135549906280124026,
18016  0.0485643304066731987159,
18017  0.0501571393058995374137,
18018  0.0515832539520484587768,
18019  0.0528349467901165198621,
18020  0.0539054993352660639269,
18021  0.0547892105279628650322,
18022  0.0554814043565593639878,
18023  0.0559784365104763194076,
18024  0.0562776998312543012726,
18025  0.0563776283603847173877,
18026  0.0562776998312543012726,
18027  0.0559784365104763194076,
18028  0.0554814043565593639878,
18029  0.0547892105279628650322,
18030  0.0539054993352660639269,
18031  0.0528349467901165198621,
18032  0.0515832539520484587768,
18033  0.0501571393058995374137,
18034  0.0485643304066731987159,
18035  0.0468135549906280124026,
18036  0.0449145316536321974143,
18037  0.0428779600250077344929,
18038  0.0407155101169443189339,
18039  0.0384398102494555320386,
18040  0.0360644327807825726401,
18041  0.0336038771482077305417,
18042  0.0310735511116879648799,
18043  0.0284897547458335486125,
18044  0.0258696793272147469108,
18045  0.0232314466399102694433,
18046  0.0205942339159127111492,
18047  0.0179785515681282703329,
18048  0.0154067504665594978021,
18049  0.0129038001003512656260,
18050  0.0104982469096213218983,
18051  0.00822300795723592966926,
18052  0.00611550682211724633968,
18053  0.00421763044155885483908,
18054  0.00257904979468568827243,
18055  0.00126515655623006801137,
18056  0.000363221481845530659694
18057  };
18058  static double w_127[127] =
18059  {
18060  0.0000505360952078625176247,
18061  0.000180739564445388357820,
18062  0.000377746646326984660274,
18063  0.000632607319362633544219,
18064  0.000938369848542381500794,
18065  0.00128952408261041739210,
18066  0.00168114286542146990631,
18067  0.00210881524572663287933,
18068  0.00256876494379402037313,
18069  0.00305775341017553113613,
18070  0.00357289278351729964938,
18071  0.00411150397865469304717,
18072  0.00467105037211432174741,
18073  0.00524912345480885912513,
18074  0.00584344987583563950756,
18075  0.00645190005017573692280,
18076  0.00707248999543355546805,
18077  0.00770337523327974184817,
18078  0.00834283875396815770558,
18079  0.00898927578406413572328,
18080  0.00964117772970253669530,
18081  0.0102971169579563555237,
18082  0.0109557333878379016480,
18083  0.0116157233199551347270,
18084  0.0122758305600827700870,
18085  0.0129348396636073734547,
18086  0.0135915710097655467896,
18087  0.0142448773729167743063,
18088  0.0148936416648151820348,
18089  0.0155367755558439824399,
18090  0.0161732187295777199419,
18091  0.0168019385741038652709,
18092  0.0174219301594641737472,
18093  0.0180322163903912863201,
18094  0.0186318482561387901863,
18095  0.0192199051247277660193,
18096  0.0197954950480974994880,
18097  0.0203577550584721594669,
18098  0.0209058514458120238522,
18099  0.0214389800125038672465,
18100  0.0219563663053178249393,
18101  0.0224572658268160987071,
18102  0.0229409642293877487608,
18103  0.0234067774953140062013,
18104  0.0238540521060385400804,
18105  0.0242821652033365993580,
18106  0.0246905247444876769091,
18107  0.0250785696529497687068,
18108  0.0254457699654647658126,
18109  0.0257916269760242293884,
18110  0.0261156733767060976805,
18111  0.0264174733950582599310,
18112  0.0266966229274503599062,
18113  0.0269527496676330319634,
18114  0.0271855132296247918192,
18115  0.0273946052639814325161,
18116  0.0275797495664818730349,
18117  0.0277407021782796819939,
18118  0.0278772514766137016085,
18119  0.0279892182552381597038,
18120  0.0280764557938172466068,
18121  0.0281388499156271506363,
18122  0.0281763190330166021307,
18123  0.0281888141801923586938,
18124  0.0281763190330166021307,
18125  0.0281388499156271506363,
18126  0.0280764557938172466068,
18127  0.0279892182552381597038,
18128  0.0278772514766137016085,
18129  0.0277407021782796819939,
18130  0.0275797495664818730349,
18131  0.0273946052639814325161,
18132  0.0271855132296247918192,
18133  0.0269527496676330319634,
18134  0.0266966229274503599062,
18135  0.0264174733950582599310,
18136  0.0261156733767060976805,
18137  0.0257916269760242293884,
18138  0.0254457699654647658126,
18139  0.0250785696529497687068,
18140  0.0246905247444876769091,
18141  0.0242821652033365993580,
18142  0.0238540521060385400804,
18143  0.0234067774953140062013,
18144  0.0229409642293877487608,
18145  0.0224572658268160987071,
18146  0.0219563663053178249393,
18147  0.0214389800125038672465,
18148  0.0209058514458120238522,
18149  0.0203577550584721594669,
18150  0.0197954950480974994880,
18151  0.0192199051247277660193,
18152  0.0186318482561387901863,
18153  0.0180322163903912863201,
18154  0.0174219301594641737472,
18155  0.0168019385741038652709,
18156  0.0161732187295777199419,
18157  0.0155367755558439824399,
18158  0.0148936416648151820348,
18159  0.0142448773729167743063,
18160  0.0135915710097655467896,
18161  0.0129348396636073734547,
18162  0.0122758305600827700870,
18163  0.0116157233199551347270,
18164  0.0109557333878379016480,
18165  0.0102971169579563555237,
18166  0.00964117772970253669530,
18167  0.00898927578406413572328,
18168  0.00834283875396815770558,
18169  0.00770337523327974184817,
18170  0.00707248999543355546805,
18171  0.00645190005017573692280,
18172  0.00584344987583563950756,
18173  0.00524912345480885912513,
18174  0.00467105037211432174741,
18175  0.00411150397865469304717,
18176  0.00357289278351729964938,
18177  0.00305775341017553113613,
18178  0.00256876494379402037313,
18179  0.00210881524572663287933,
18180  0.00168114286542146990631,
18181  0.00128952408261041739210,
18182  0.000938369848542381500794,
18183  0.000632607319362633544219,
18184  0.000377746646326984660274,
18185  0.000180739564445388357820,
18186  0.0000505360952078625176247
18187  };
18188  static double w_255[255] =
18189  {
18190  0.69379364324108267170E-05,
18191  0.25157870384280661489E-04,
18192  0.53275293669780613125E-04,
18193  0.90372734658751149261E-04,
18194  0.13575491094922871973E-03,
18195  0.18887326450650491366E-03,
18196  0.24921240048299729402E-03,
18197  0.31630366082226447689E-03,
18198  0.38974528447328229322E-03,
18199  0.46918492424785040975E-03,
18200  0.55429531493037471492E-03,
18201  0.64476204130572477933E-03,
18202  0.74028280424450333046E-03,
18203  0.84057143271072246365E-03,
18204  0.94536151685852538246E-03,
18205  0.10544076228633167722E-02,
18206  0.11674841174299594077E-02,
18207  0.12843824718970101768E-02,
18208  0.14049079956551446427E-02,
18209  0.15288767050877655684E-02,
18210  0.16561127281544526052E-02,
18211  0.17864463917586498247E-02,
18212  0.19197129710138724125E-02,
18213  0.20557519893273465236E-02,
18214  0.21944069253638388388E-02,
18215  0.23355251860571608737E-02,
18216  0.24789582266575679307E-02,
18217  0.26245617274044295626E-02,
18218  0.27721957645934509940E-02,
18219  0.29217249379178197538E-02,
18220  0.30730184347025783234E-02,
18221  0.32259500250878684614E-02,
18222  0.33803979910869203823E-02,
18223  0.35362449977167777340E-02,
18224  0.36933779170256508183E-02,
18225  0.38516876166398709241E-02,
18226  0.40110687240750233989E-02,
18227  0.41714193769840788528E-02,
18228  0.43326409680929828545E-02,
18229  0.44946378920320678616E-02,
18230  0.46573172997568547773E-02,
18231  0.48205888648512683476E-02,
18232  0.49843645647655386012E-02,
18233  0.51485584789781777618E-02,
18234  0.53130866051870565663E-02,
18235  0.54778666939189508240E-02,
18236  0.56428181013844441585E-02,
18237  0.58078616599775673635E-02,
18238  0.59729195655081658049E-02,
18239  0.61379152800413850435E-02,
18240  0.63027734490857587172E-02,
18241  0.64674198318036867274E-02,
18242  0.66317812429018878941E-02,
18243  0.67957855048827733948E-02,
18244  0.69593614093904229394E-02,
18245  0.71224386864583871532E-02,
18246  0.72849479805538070639E-02,
18247  0.74468208324075910174E-02,
18248  0.76079896657190565832E-02,
18249  0.77683877779219912200E-02,
18250  0.79279493342948491103E-02,
18251  0.80866093647888599710E-02,
18252  0.82443037630328680306E-02,
18253  0.84009692870519326354E-02,
18254  0.85565435613076896192E-02,
18255  0.87109650797320868736E-02,
18256  0.88641732094824942641E-02,
18257  0.90161081951956431600E-02,
18258  0.91667111635607884067E-02,
18259  0.93159241280693950932E-02,
18260  0.94636899938300652943E-02,
18261  0.96099525623638830097E-02,
18262  0.97546565363174114611E-02,
18263  0.98977475240487497440E-02,
18264  0.10039172044056840798E-01,
18265  0.10178877529236079733E-01,
18266  0.10316812330947621682E-01,
18267  0.10452925722906011926E-01,
18268  0.10587167904885197931E-01,
18269  0.10719490006251933623E-01,
18270  0.10849844089337314099E-01,
18271  0.10978183152658912470E-01,
18272  0.11104461134006926537E-01,
18273  0.11228632913408049354E-01,
18274  0.11350654315980596602E-01,
18275  0.11470482114693874380E-01,
18276  0.11588074033043952568E-01,
18277  0.11703388747657003101E-01,
18278  0.11816385890830235763E-01,
18279  0.11927026053019270040E-01,
18280  0.12035270785279562630E-01,
18281  0.12141082601668299679E-01,
18282  0.12244424981611985899E-01,
18283  0.12345262372243838455E-01,
18284  0.12443560190714035263E-01,
18285  0.12539284826474884353E-01,
18286  0.12632403643542078765E-01,
18287  0.12722884982732382906E-01,
18288  0.12810698163877361967E-01,
18289  0.12895813488012114694E-01,
18290  0.12978202239537399286E-01,
18291  0.13057836688353048840E-01,
18292  0.13134690091960152836E-01,
18293  0.13208736697529129966E-01,
18294  0.13279951743930530650E-01,
18295  0.13348311463725179953E-01,
18296  0.13413793085110098513E-01,
18297  0.13476374833816515982E-01,
18298  0.13536035934956213614E-01,
18299  0.13592756614812395910E-01,
18300  0.13646518102571291428E-01,
18301  0.13697302631990716258E-01,
18302  0.13745093443001896632E-01,
18303  0.13789874783240936517E-01,
18304  0.13831631909506428676E-01,
18305  0.13870351089139840997E-01,
18306  0.13906019601325461264E-01,
18307  0.13938625738306850804E-01,
18308  0.13968158806516938516E-01,
18309  0.13994609127619079852E-01,
18310  0.14017968039456608810E-01,
18311  0.14038227896908623303E-01,
18312  0.14055382072649964277E-01,
18313  0.14069424957813575318E-01,
18314  0.14080351962553661325E-01,
18315  0.14088159516508301065E-01,
18316  0.14092845069160408355E-01,
18317  0.14094407090096179347E-01,
18318  0.14092845069160408355E-01,
18319  0.14088159516508301065E-01,
18320  0.14080351962553661325E-01,
18321  0.14069424957813575318E-01,
18322  0.14055382072649964277E-01,
18323  0.14038227896908623303E-01,
18324  0.14017968039456608810E-01,
18325  0.13994609127619079852E-01,
18326  0.13968158806516938516E-01,
18327  0.13938625738306850804E-01,
18328  0.13906019601325461264E-01,
18329  0.13870351089139840997E-01,
18330  0.13831631909506428676E-01,
18331  0.13789874783240936517E-01,
18332  0.13745093443001896632E-01,
18333  0.13697302631990716258E-01,
18334  0.13646518102571291428E-01,
18335  0.13592756614812395910E-01,
18336  0.13536035934956213614E-01,
18337  0.13476374833816515982E-01,
18338  0.13413793085110098513E-01,
18339  0.13348311463725179953E-01,
18340  0.13279951743930530650E-01,
18341  0.13208736697529129966E-01,
18342  0.13134690091960152836E-01,
18343  0.13057836688353048840E-01,
18344  0.12978202239537399286E-01,
18345  0.12895813488012114694E-01,
18346  0.12810698163877361967E-01,
18347  0.12722884982732382906E-01,
18348  0.12632403643542078765E-01,
18349  0.12539284826474884353E-01,
18350  0.12443560190714035263E-01,
18351  0.12345262372243838455E-01,
18352  0.12244424981611985899E-01,
18353  0.12141082601668299679E-01,
18354  0.12035270785279562630E-01,
18355  0.11927026053019270040E-01,
18356  0.11816385890830235763E-01,
18357  0.11703388747657003101E-01,
18358  0.11588074033043952568E-01,
18359  0.11470482114693874380E-01,
18360  0.11350654315980596602E-01,
18361  0.11228632913408049354E-01,
18362  0.11104461134006926537E-01,
18363  0.10978183152658912470E-01,
18364  0.10849844089337314099E-01,
18365  0.10719490006251933623E-01,
18366  0.10587167904885197931E-01,
18367  0.10452925722906011926E-01,
18368  0.10316812330947621682E-01,
18369  0.10178877529236079733E-01,
18370  0.10039172044056840798E-01,
18371  0.98977475240487497440E-02,
18372  0.97546565363174114611E-02,
18373  0.96099525623638830097E-02,
18374  0.94636899938300652943E-02,
18375  0.93159241280693950932E-02,
18376  0.91667111635607884067E-02,
18377  0.90161081951956431600E-02,
18378  0.88641732094824942641E-02,
18379  0.87109650797320868736E-02,
18380  0.85565435613076896192E-02,
18381  0.84009692870519326354E-02,
18382  0.82443037630328680306E-02,
18383  0.80866093647888599710E-02,
18384  0.79279493342948491103E-02,
18385  0.77683877779219912200E-02,
18386  0.76079896657190565832E-02,
18387  0.74468208324075910174E-02,
18388  0.72849479805538070639E-02,
18389  0.71224386864583871532E-02,
18390  0.69593614093904229394E-02,
18391  0.67957855048827733948E-02,
18392  0.66317812429018878941E-02,
18393  0.64674198318036867274E-02,
18394  0.63027734490857587172E-02,
18395  0.61379152800413850435E-02,
18396  0.59729195655081658049E-02,
18397  0.58078616599775673635E-02,
18398  0.56428181013844441585E-02,
18399  0.54778666939189508240E-02,
18400  0.53130866051870565663E-02,
18401  0.51485584789781777618E-02,
18402  0.49843645647655386012E-02,
18403  0.48205888648512683476E-02,
18404  0.46573172997568547773E-02,
18405  0.44946378920320678616E-02,
18406  0.43326409680929828545E-02,
18407  0.41714193769840788528E-02,
18408  0.40110687240750233989E-02,
18409  0.38516876166398709241E-02,
18410  0.36933779170256508183E-02,
18411  0.35362449977167777340E-02,
18412  0.33803979910869203823E-02,
18413  0.32259500250878684614E-02,
18414  0.30730184347025783234E-02,
18415  0.29217249379178197538E-02,
18416  0.27721957645934509940E-02,
18417  0.26245617274044295626E-02,
18418  0.24789582266575679307E-02,
18419  0.23355251860571608737E-02,
18420  0.21944069253638388388E-02,
18421  0.20557519893273465236E-02,
18422  0.19197129710138724125E-02,
18423  0.17864463917586498247E-02,
18424  0.16561127281544526052E-02,
18425  0.15288767050877655684E-02,
18426  0.14049079956551446427E-02,
18427  0.12843824718970101768E-02,
18428  0.11674841174299594077E-02,
18429  0.10544076228633167722E-02,
18430  0.94536151685852538246E-03,
18431  0.84057143271072246365E-03,
18432  0.74028280424450333046E-03,
18433  0.64476204130572477933E-03,
18434  0.55429531493037471492E-03,
18435  0.46918492424785040975E-03,
18436  0.38974528447328229322E-03,
18437  0.31630366082226447689E-03,
18438  0.24921240048299729402E-03,
18439  0.18887326450650491366E-03,
18440  0.13575491094922871973E-03,
18441  0.90372734658751149261E-04,
18442  0.53275293669780613125E-04,
18443  0.25157870384280661489E-04,
18444  0.69379364324108267170E-05
18445  };
18446  static double w_511[511] =
18447  {
18448  0.945715933950007048827E-06,
18449  0.345456507169149134898E-05,
18450  0.736624069102321668857E-05,
18451  0.125792781889592743525E-04,
18452  0.190213681905875816679E-04,
18453  0.266376412339000901358E-04,
18454  0.353751372055189588628E-04,
18455  0.451863674126296143105E-04,
18456  0.560319507856164252140E-04,
18457  0.678774554733972416227E-04,
18458  0.806899228014035293851E-04,
18459  0.944366322532705527066E-04,
18460  0.109085545645741522051E-03,
18461  0.124606200241498368482E-03,
18462  0.140970302204104791413E-03,
18463  0.158151830411132242924E-03,
18464  0.176126765545083195474E-03,
18465  0.194872642236641146532E-03,
18466  0.214368090034216937149E-03,
18467  0.234592462123925204879E-03,
18468  0.255525589595236862014E-03,
18469  0.277147657465187357459E-03,
18470  0.299439176850911730874E-03,
18471  0.322381020652862389664E-03,
18472  0.345954492129903871350E-03,
18473  0.370141402122251665232E-03,
18474  0.394924138246873704434E-03,
18475  0.420285716355361231823E-03,
18476  0.446209810101403247488E-03,
18477  0.472680758429262691232E-03,
18478  0.499683553312800484519E-03,
18479  0.527203811431658386125E-03,
18480  0.555227733977307579715E-03,
18481  0.583742058714979703847E-03,
18482  0.612734008012225209294E-03,
18483  0.642191235948505088403E-03,
18484  0.672101776960108194646E-03,
18485  0.702453997827572321358E-03,
18486  0.733236554224767912055E-03,
18487  0.764438352543882784191E-03,
18488  0.796048517297550871506E-03,
18489  0.828056364077226302608E-03,
18490  0.860451377808527848128E-03,
18491  0.893223195879324912340E-03,
18492  0.926361595613111283368E-03,
18493  0.959856485506936206261E-03,
18494  0.993697899638760857945E-03,
18495  0.102787599466367326179E-02,
18496  0.106238104885340071375E-02,
18497  0.109720346268191941940E-02,
18498  0.113233376051597664917E-02,
18499  0.116776259302858043685E-02,
18500  0.120348074001265964881E-02,
18501  0.123947911332878396534E-02,
18502  0.127574875977346947345E-02,
18503  0.131228086370221478128E-02,
18504  0.134906674928353113127E-02,
18505  0.138609788229672549700E-02,
18506  0.142336587141720519900E-02,
18507  0.146086246895890987689E-02,
18508  0.149857957106456636214E-02,
18509  0.153650921735128916170E-02,
18510  0.157464359003212166189E-02,
18511  0.161297501254393423070E-02,
18512  0.165149594771914570655E-02,
18513  0.169019899554346019117E-02,
18514  0.172907689054461607168E-02,
18515  0.176812249885838886701E-02,
18516  0.180732881501808930079E-02,
18517  0.184668895851282540913E-02,
18518  0.188619617015808475394E-02,
18519  0.192584380831993546204E-02,
18520  0.196562534503150547732E-02,
18521  0.200553436203751169944E-02,
18522  0.204556454679958293446E-02,
18523  0.208570968849203942640E-02,
18524  0.212596367401472533045E-02,
18525  0.216632048404649142727E-02,
18526  0.220677418916003329194E-02,
18527  0.224731894601603393082E-02,
18528  0.228794899365195972378E-02,
18529  0.232865864987842738864E-02,
18530  0.236944230779380495146E-02,
18531  0.241029443242563417382E-02,
18532  0.245120955750556483923E-02,
18533  0.249218228238276930060E-02,
18534  0.253320726907925325750E-02,
18535  0.257427923948908888092E-02,
18536  0.261539297272236109225E-02,
18537  0.265654330259352828314E-02,
18538  0.269772511525294586667E-02,
18539  0.273893334695947541201E-02,
18540  0.278016298199139435045E-02,
18541  0.282140905069222207923E-02,
18542  0.286266662764757868253E-02,
18543  0.290393082998878368175E-02,
18544  0.294519681581857582284E-02,
18545  0.298645978275408290247E-02,
18546  0.302771496658198544480E-02,
18547  0.306895764002069252174E-02,
18548  0.311018311158427546158E-02,
18549  0.315138672454287935858E-02,
18550  0.319256385597434736790E-02,
18551  0.323370991590184336368E-02,
18552  0.327482034651233969564E-02,
18553  0.331589062145094394706E-02,
18554  0.335691624518616761342E-02,
18555  0.339789275244138669739E-02,
18556  0.343881570768790591876E-02,
18557  0.347968070469521146972E-02,
18558  0.352048336613417922682E-02,
18559  0.356121934322919357659E-02,
18560  0.360188431545532431869E-02,
18561  0.364247399027690353194E-02,
18562  0.368298410292403911967E-02,
18563  0.372341041620379550870E-02,
18564  0.376374872034296338241E-02,
18565  0.380399483285952829161E-02,
18566  0.384414459846013158917E-02,
18567  0.388419388896099560998E-02,
18568  0.392413860322995774660E-02,
18569  0.396397466714742455513E-02,
18570  0.400369803358421688562E-02,
18571  0.404330468239442998549E-02,
18572  0.408279062042157838350E-02,
18573  0.412215188151643401528E-02,
18574  0.416138452656509745764E-02,
18575  0.420048464352596631772E-02,
18576  0.423944834747438184434E-02,
18577  0.427827178065384480959E-02,
18578  0.431695111253279479928E-02,
18579  0.435548253986604343679E-02,
18580  0.439386228676004195260E-02,
18581  0.443208660474124713206E-02,
18582  0.447015177282692726900E-02,
18583  0.450805409759782158001E-02,
18584  0.454578991327213285488E-02,
18585  0.458335558178039420335E-02,
18586  0.462074749284080687482E-02,
18587  0.465796206403469754658E-02,
18588  0.469499574088179046532E-02,
18589  0.473184499691503264714E-02,
18590  0.476850633375474925263E-02,
18591  0.480497628118194150483E-02,
18592  0.484125139721057135214E-02,
18593  0.487732826815870573054E-02,
18594  0.491320350871841897367E-02,
18595  0.494887376202437487201E-02,
18596  0.498433569972103029914E-02,
18597  0.501958602202842039909E-02,
18598  0.505462145780650125058E-02,
18599  0.508943876461803986674E-02,
18600  0.512403472879005351831E-02,
18601  0.515840616547381084096E-02,
18602  0.519254991870341614863E-02,
18603  0.522646286145300596306E-02,
18604  0.526014189569259311205E-02,
18605  0.529358395244259896547E-02,
18606  0.532678599182711857974E-02,
18607  0.535974500312596681161E-02,
18608  0.539245800482555593606E-02,
18609  0.542492204466865704951E-02,
18610  0.545713419970309863995E-02,
18611  0.548909157632945623482E-02,
18612  0.552079131034778706457E-02,
18613  0.555223056700346326850E-02,
18614  0.558340654103215637610E-02,
18615  0.561431645670402467678E-02,
18616  0.564495756786715368885E-02,
18617  0.567532715799029830087E-02,
18618  0.570542254020497332312E-02,
18619  0.573524105734693719020E-02,
18620  0.576478008199711142954E-02,
18621  0.579403701652197628421E-02,
18622  0.582300929311348057702E-02,
18623  0.585169437382850155033E-02,
18624  0.588008975062788803205E-02,
18625  0.590819294541511788161E-02,
18626  0.593600151007459827614E-02,
18627  0.596351302650963502011E-02,
18628  0.599072510668009471472E-02,
18629  0.601763539263978131522E-02,
18630  0.604424155657354634589E-02,
18631  0.607054130083414983949E-02,
18632  0.609653235797888692923E-02,
18633  0.612221249080599294931E-02,
18634  0.614757949239083790214E-02,
18635  0.617263118612191922727E-02,
18636  0.619736542573665996342E-02,
18637  0.622178009535701763157E-02,
18638  0.624587310952490748541E-02,
18639  0.626964241323744217671E-02,
18640  0.629308598198198836688E-02,
18641  0.631620182177103938227E-02,
18642  0.633898796917690165912E-02,
18643  0.636144249136619145314E-02,
18644  0.638356348613413709795E-02,
18645  0.640534908193868098342E-02,
18646  0.642679743793437438922E-02,
18647  0.644790674400605734710E-02,
18648  0.646867522080231481688E-02,
18649  0.648910111976869964292E-02,
18650  0.650918272318071200827E-02,
18651  0.652891834417652442012E-02,
18652  0.654830632678944064054E-02,
18653  0.656734504598007641819E-02,
18654  0.658603290766824937794E-02,
18655  0.660436834876456498276E-02,
18656  0.662234983720168509457E-02,
18657  0.663997587196526532519E-02,
18658  0.665724498312454708217E-02,
18659  0.667415573186258997654E-02,
18660  0.669070671050613006584E-02,
18661  0.670689654255504925648E-02,
18662  0.672272388271144108036E-02,
18663  0.673818741690825799086E-02,
18664  0.675328586233752529078E-02,
18665  0.676801796747810680683E-02,
18666  0.678238251212300746082E-02,
18667  0.679637830740619795480E-02,
18668  0.681000419582894688374E-02,
18669  0.682325905128564571420E-02,
18670  0.683614177908911221841E-02,
18671  0.684865131599535812903E-02,
18672  0.686078663022780697951E-02,
18673  0.687254672150094831613E-02,
18674  0.688393062104341470995E-02,
18675  0.689493739162046825872E-02,
18676  0.690556612755588354803E-02,
18677  0.691581595475321433825E-02,
18678  0.692568603071643155621E-02,
18679  0.693517554456992049848E-02,
18680  0.694428371707782549438E-02,
18681  0.695300980066273063177E-02,
18682  0.696135307942366551493E-02,
18683  0.696931286915342540213E-02,
18684  0.697688851735519545845E-02,
18685  0.698407940325846925786E-02,
18686  0.699088493783425207545E-02,
18687  0.699730456380953992594E-02,
18688  0.700333775568106572820E-02,
18689  0.700898401972830440494E-02,
18690  0.701424289402572916425E-02,
18691  0.701911394845431165171E-02,
18692  0.702359678471225911031E-02,
18693  0.702769103632498213858E-02,
18694  0.703139636865428709508E-02,
18695  0.703471247890678765907E-02,
18696  0.703763909614153052319E-02,
18697  0.704017598127683066242E-02,
18698  0.704232292709631209597E-02,
18699  0.704407975825415053266E-02,
18700  0.704544633127951476780E-02,
18701  0.704642253458020417748E-02,
18702  0.704700828844548013730E-02,
18703  0.704720354504808967346E-02,
18704  0.704700828844548013730E-02,
18705  0.704642253458020417748E-02,
18706  0.704544633127951476780E-02,
18707  0.704407975825415053266E-02,
18708  0.704232292709631209597E-02,
18709  0.704017598127683066242E-02,
18710  0.703763909614153052319E-02,
18711  0.703471247890678765907E-02,
18712  0.703139636865428709508E-02,
18713  0.702769103632498213858E-02,
18714  0.702359678471225911031E-02,
18715  0.701911394845431165171E-02,
18716  0.701424289402572916425E-02,
18717  0.700898401972830440494E-02,
18718  0.700333775568106572820E-02,
18719  0.699730456380953992594E-02,
18720  0.699088493783425207545E-02,
18721  0.698407940325846925786E-02,
18722  0.697688851735519545845E-02,
18723  0.696931286915342540213E-02,
18724  0.696135307942366551493E-02,
18725  0.695300980066273063177E-02,
18726  0.694428371707782549438E-02,
18727  0.693517554456992049848E-02,
18728  0.692568603071643155621E-02,
18729  0.691581595475321433825E-02,
18730  0.690556612755588354803E-02,
18731  0.689493739162046825872E-02,
18732  0.688393062104341470995E-02,
18733  0.687254672150094831613E-02,
18734  0.686078663022780697951E-02,
18735  0.684865131599535812903E-02,
18736  0.683614177908911221841E-02,
18737  0.682325905128564571420E-02,
18738  0.681000419582894688374E-02,
18739  0.679637830740619795480E-02,
18740  0.678238251212300746082E-02,
18741  0.676801796747810680683E-02,
18742  0.675328586233752529078E-02,
18743  0.673818741690825799086E-02,
18744  0.672272388271144108036E-02,
18745  0.670689654255504925648E-02,
18746  0.669070671050613006584E-02,
18747  0.667415573186258997654E-02,
18748  0.665724498312454708217E-02,
18749  0.663997587196526532519E-02,
18750  0.662234983720168509457E-02,
18751  0.660436834876456498276E-02,
18752  0.658603290766824937794E-02,
18753  0.656734504598007641819E-02,
18754  0.654830632678944064054E-02,
18755  0.652891834417652442012E-02,
18756  0.650918272318071200827E-02,
18757  0.648910111976869964292E-02,
18758  0.646867522080231481688E-02,
18759  0.644790674400605734710E-02,
18760  0.642679743793437438922E-02,
18761  0.640534908193868098342E-02,
18762  0.638356348613413709795E-02,
18763  0.636144249136619145314E-02,
18764  0.633898796917690165912E-02,
18765  0.631620182177103938227E-02,
18766  0.629308598198198836688E-02,
18767  0.626964241323744217671E-02,
18768  0.624587310952490748541E-02,
18769  0.622178009535701763157E-02,
18770  0.619736542573665996342E-02,
18771  0.617263118612191922727E-02,
18772  0.614757949239083790214E-02,
18773  0.612221249080599294931E-02,
18774  0.609653235797888692923E-02,
18775  0.607054130083414983949E-02,
18776  0.604424155657354634589E-02,
18777  0.601763539263978131522E-02,
18778  0.599072510668009471472E-02,
18779  0.596351302650963502011E-02,
18780  0.593600151007459827614E-02,
18781  0.590819294541511788161E-02,
18782  0.588008975062788803205E-02,
18783  0.585169437382850155033E-02,
18784  0.582300929311348057702E-02,
18785  0.579403701652197628421E-02,
18786  0.576478008199711142954E-02,
18787  0.573524105734693719020E-02,
18788  0.570542254020497332312E-02,
18789  0.567532715799029830087E-02,
18790  0.564495756786715368885E-02,
18791  0.561431645670402467678E-02,
18792  0.558340654103215637610E-02,
18793  0.555223056700346326850E-02,
18794  0.552079131034778706457E-02,
18795  0.548909157632945623482E-02,
18796  0.545713419970309863995E-02,
18797  0.542492204466865704951E-02,
18798  0.539245800482555593606E-02,
18799  0.535974500312596681161E-02,
18800  0.532678599182711857974E-02,
18801  0.529358395244259896547E-02,
18802  0.526014189569259311205E-02,
18803  0.522646286145300596306E-02,
18804  0.519254991870341614863E-02,
18805  0.515840616547381084096E-02,
18806  0.512403472879005351831E-02,
18807  0.508943876461803986674E-02,
18808  0.505462145780650125058E-02,
18809  0.501958602202842039909E-02,
18810  0.498433569972103029914E-02,
18811  0.494887376202437487201E-02,
18812  0.491320350871841897367E-02,
18813  0.487732826815870573054E-02,
18814  0.484125139721057135214E-02,
18815  0.480497628118194150483E-02,
18816  0.476850633375474925263E-02,
18817  0.473184499691503264714E-02,
18818  0.469499574088179046532E-02,
18819  0.465796206403469754658E-02,
18820  0.462074749284080687482E-02,
18821  0.458335558178039420335E-02,
18822  0.454578991327213285488E-02,
18823  0.450805409759782158001E-02,
18824  0.447015177282692726900E-02,
18825  0.443208660474124713206E-02,
18826  0.439386228676004195260E-02,
18827  0.435548253986604343679E-02,
18828  0.431695111253279479928E-02,
18829  0.427827178065384480959E-02,
18830  0.423944834747438184434E-02,
18831  0.420048464352596631772E-02,
18832  0.416138452656509745764E-02,
18833  0.412215188151643401528E-02,
18834  0.408279062042157838350E-02,
18835  0.404330468239442998549E-02,
18836  0.400369803358421688562E-02,
18837  0.396397466714742455513E-02,
18838  0.392413860322995774660E-02,
18839  0.388419388896099560998E-02,
18840  0.384414459846013158917E-02,
18841  0.380399483285952829161E-02,
18842  0.376374872034296338241E-02,
18843  0.372341041620379550870E-02,
18844  0.368298410292403911967E-02,
18845  0.364247399027690353194E-02,
18846  0.360188431545532431869E-02,
18847  0.356121934322919357659E-02,
18848  0.352048336613417922682E-02,
18849  0.347968070469521146972E-02,
18850  0.343881570768790591876E-02,
18851  0.339789275244138669739E-02,
18852  0.335691624518616761342E-02,
18853  0.331589062145094394706E-02,
18854  0.327482034651233969564E-02,
18855  0.323370991590184336368E-02,
18856  0.319256385597434736790E-02,
18857  0.315138672454287935858E-02,
18858  0.311018311158427546158E-02,
18859  0.306895764002069252174E-02,
18860  0.302771496658198544480E-02,
18861  0.298645978275408290247E-02,
18862  0.294519681581857582284E-02,
18863  0.290393082998878368175E-02,
18864  0.286266662764757868253E-02,
18865  0.282140905069222207923E-02,
18866  0.278016298199139435045E-02,
18867  0.273893334695947541201E-02,
18868  0.269772511525294586667E-02,
18869  0.265654330259352828314E-02,
18870  0.261539297272236109225E-02,
18871  0.257427923948908888092E-02,
18872  0.253320726907925325750E-02,
18873  0.249218228238276930060E-02,
18874  0.245120955750556483923E-02,
18875  0.241029443242563417382E-02,
18876  0.236944230779380495146E-02,
18877  0.232865864987842738864E-02,
18878  0.228794899365195972378E-02,
18879  0.224731894601603393082E-02,
18880  0.220677418916003329194E-02,
18881  0.216632048404649142727E-02,
18882  0.212596367401472533045E-02,
18883  0.208570968849203942640E-02,
18884  0.204556454679958293446E-02,
18885  0.200553436203751169944E-02,
18886  0.196562534503150547732E-02,
18887  0.192584380831993546204E-02,
18888  0.188619617015808475394E-02,
18889  0.184668895851282540913E-02,
18890  0.180732881501808930079E-02,
18891  0.176812249885838886701E-02,
18892  0.172907689054461607168E-02,
18893  0.169019899554346019117E-02,
18894  0.165149594771914570655E-02,
18895  0.161297501254393423070E-02,
18896  0.157464359003212166189E-02,
18897  0.153650921735128916170E-02,
18898  0.149857957106456636214E-02,
18899  0.146086246895890987689E-02,
18900  0.142336587141720519900E-02,
18901  0.138609788229672549700E-02,
18902  0.134906674928353113127E-02,
18903  0.131228086370221478128E-02,
18904  0.127574875977346947345E-02,
18905  0.123947911332878396534E-02,
18906  0.120348074001265964881E-02,
18907  0.116776259302858043685E-02,
18908  0.113233376051597664917E-02,
18909  0.109720346268191941940E-02,
18910  0.106238104885340071375E-02,
18911  0.102787599466367326179E-02,
18912  0.993697899638760857945E-03,
18913  0.959856485506936206261E-03,
18914  0.926361595613111283368E-03,
18915  0.893223195879324912340E-03,
18916  0.860451377808527848128E-03,
18917  0.828056364077226302608E-03,
18918  0.796048517297550871506E-03,
18919  0.764438352543882784191E-03,
18920  0.733236554224767912055E-03,
18921  0.702453997827572321358E-03,
18922  0.672101776960108194646E-03,
18923  0.642191235948505088403E-03,
18924  0.612734008012225209294E-03,
18925  0.583742058714979703847E-03,
18926  0.555227733977307579715E-03,
18927  0.527203811431658386125E-03,
18928  0.499683553312800484519E-03,
18929  0.472680758429262691232E-03,
18930  0.446209810101403247488E-03,
18931  0.420285716355361231823E-03,
18932  0.394924138246873704434E-03,
18933  0.370141402122251665232E-03,
18934  0.345954492129903871350E-03,
18935  0.322381020652862389664E-03,
18936  0.299439176850911730874E-03,
18937  0.277147657465187357459E-03,
18938  0.255525589595236862014E-03,
18939  0.234592462123925204879E-03,
18940  0.214368090034216937149E-03,
18941  0.194872642236641146532E-03,
18942  0.176126765545083195474E-03,
18943  0.158151830411132242924E-03,
18944  0.140970302204104791413E-03,
18945  0.124606200241498368482E-03,
18946  0.109085545645741522051E-03,
18947  0.944366322532705527066E-04,
18948  0.806899228014035293851E-04,
18949  0.678774554733972416227E-04,
18950  0.560319507856164252140E-04,
18951  0.451863674126296143105E-04,
18952  0.353751372055189588628E-04,
18953  0.266376412339000901358E-04,
18954  0.190213681905875816679E-04,
18955  0.125792781889592743525E-04,
18956  0.736624069102321668857E-05,
18957  0.345456507169149134898E-05,
18958  0.945715933950007048827E-06,
18959  };
18960 
18961  if ( n == 1 )
18962  {
18963  r8vec_copy ( n, w_001, w );
18964  }
18965  else if ( n == 3 )
18966  {
18967  r8vec_copy ( n, w_003, w );
18968  }
18969  else if ( n == 7 )
18970  {
18971  r8vec_copy ( n, w_007, w );
18972  }
18973  else if ( n == 15 )
18974  {
18975  r8vec_copy ( n, w_015, w );
18976  }
18977  else if ( n == 31 )
18978  {
18979  r8vec_copy ( n, w_031, w );
18980  }
18981  else if ( n == 63 )
18982  {
18983  r8vec_copy ( n, w_063, w );
18984  }
18985  else if ( n == 127 )
18986  {
18987  r8vec_copy ( n, w_127, w );
18988  }
18989  else if ( n == 255 )
18990  {
18991  r8vec_copy ( n, w_255, w );
18992  }
18993  else if ( n == 511 )
18994  {
18995  r8vec_copy ( n, w_511, w );
18996  }
18997  else
18998  {
18999  std::cerr << "\n";
19000  std::cerr << "PATTERSON_LOOKUP_WEIGHTS - Fatal error!\n";
19001  std::cerr << " Unexpected value of N = " << n << ".\n";
19002  std::exit ( 1 );
19003  }
19004  return;
19005 }
19006 //**************************************************************************80
19007 
19008 void SandiaRules::patterson_lookup_weights_np ( int n, int np, double p[], double w[] )
19009 
19010 //**************************************************************************80
19011 //
19012 // Purpose:
19013 //
19014 // PATTERSON_LOOKUP_WEIGHTS_NP looks up Patterson quadrature weights.
19015 //
19016 // Discussion:
19017 //
19018 // The allowed orders are 1, 3, 7, 15, 31, 63, 127, 255 and 511.
19019 //
19020 // The weights are positive, symmetric and should sum to 2.
19021 //
19022 // The user must preallocate space for the output array W.
19023 //
19024 // Licensing:
19025 //
19026 // This code is distributed under the GNU LGPL license.
19027 //
19028 // Modified:
19029 //
19030 // 25 April 2011
19031 //
19032 // Author:
19033 //
19034 // John Burkardt
19035 //
19036 // Reference:
19037 //
19038 // Milton Abramowitz, Irene Stegun,
19039 // Handbook of Mathematical Functions,
19040 // National Bureau of Standards, 1964,
19041 // ISBN: 0-486-61272-4,
19042 // LC: QA47.A34.
19043 //
19044 // Arthur Stroud, Don Secrest,
19045 // Gaussian Quadrature Formulas,
19046 // Prentice Hall, 1966,
19047 // LC: QA299.4G3S7.
19048 //
19049 // Parameters:
19050 //
19051 // Input, int N, the order.
19052 // Legal values are 1, 3, 7, 15, 31, 63, 127, 255 or 511.
19053 //
19054 // Input, int NP, the number of parameters.
19055 //
19056 // Input, double P[NP], parameters which are not needed by this function.
19057 //
19058 // Output, double W[N], the weights.
19059 //
19060 {
19061  patterson_lookup_weights ( n, w );
19062 
19063  return;
19064 }
19065 //**************************************************************************80
19066 
19067 int SandiaRules::point_radial_tol_unique_count ( int m, int n, double a[], double tol,
19068  int *seed )
19069 
19070 //**************************************************************************80
19071 //
19072 // Purpose:
19073 //
19074 // POINT_RADIAL_TOL_UNIQUE_COUNT counts the tolerably unique points.
19075 //
19076 // Discussion:
19077 //
19078 // The input data is an M x N array A, representing the M-dimensional
19079 // coordinates of N points.
19080 //
19081 // The output is the number of tolerably unique points in the list.
19082 //
19083 // This program performs the same task as POINT_TOL_UNIQUE_COUNT.
19084 // But that program is guaranteed to use N^2 comparisons.
19085 //
19086 // It is hoped that this function, on the other hand, will tend
19087 // to use O(N) comparisons after an O(NLog(N)) sort.
19088 //
19089 // Licensing:
19090 //
19091 // This code is distributed under the GNU LGPL license.
19092 //
19093 // Modified:
19094 //
19095 // 24 July 2010
19096 //
19097 // Author:
19098 //
19099 // John Burkardt
19100 //
19101 // Parameters:
19102 //
19103 // Input, int M, the number of rows.
19104 //
19105 // Input, int N, the number of columns.
19106 //
19107 // Input, double A[M*N], the array of N columns of data.
19108 //
19109 // Input, double TOL, a tolerance for equality.
19110 //
19111 // Input/output, int *SEED, a seed for the random
19112 // number generator.
19113 //
19114 // Output, int POINT_RADIAL_TOL_UNIQUE_COUNT, the number of tolerably
19115 // unique points.
19116 //
19117 {
19118  double dist;
19119  int hi;
19120  int i;
19121  int *indx;
19122  int j;
19123  int k;
19124  double *r;
19125  bool *unique;
19126  int unique_num;
19127  double *w;
19128  double w_sum;
19129  double *z;
19130 
19131  if ( n <= 0 )
19132  {
19133  unique_num = 0;
19134  return unique_num;
19135  }
19136 //
19137 // Assign a base point Z randomly in the convex hull.
19138 //
19139  w = r8vec_uniform_01_new ( n, seed );
19140  w_sum = r8vec_sum ( n, w );
19141  for ( j = 0; j < n; j++ )
19142  {
19143  w[j] = w[j] / w_sum;
19144  }
19145 
19146  z = new double[m];
19147  for ( i = 0; i < m; i++ )
19148  {
19149  z[i] = 0.0;
19150  for ( j = 0; j < n; j++ )
19151  {
19152  z[i] = z[i] + a[i+j*m] * w[j];
19153  }
19154  }
19155 //
19156 // Compute the radial distance R of each point to Z.
19157 //
19158  r = new double[n];
19159 
19160  for ( j = 0; j < n; j++ )
19161  {
19162  r[j] = 0.0;
19163  for ( i = 0; i < m; i++ )
19164  {
19165  r[j] = r[j] + std::pow ( a[i+j*m] - z[i], 2 );
19166  }
19167  r[j] = std::sqrt ( r[j] );
19168  }
19169 //
19170 // Implicitly sort the R array.
19171 //
19172  indx = r8vec_sort_heap_index_a_new ( n, r );
19173 //
19174 // To determine if a point I is tolerably unique, we only have to check
19175 // whether it is distinct from all points J such that R(I) <= R(J) <= R(J)+TOL.
19176 //
19177  unique_num = 0;
19178 
19179  unique = new bool[n];
19180  for ( i = 0; i < n; i++ )
19181  {
19182  unique[i] = true;
19183  }
19184 
19185  for ( i = 0; i < n; i++ )
19186  {
19187  if ( unique[indx[i]] )
19188  {
19189 //
19190 // Point INDX(I) is unique, in that no earlier point is near it.
19191 //
19192  unique_num = unique_num + 1;
19193 //
19194 // Look for later points which are close to point INDX(I)
19195 // in terms of R.
19196 //
19197  hi = i;
19198 
19199  while ( hi < n - 1 )
19200  {
19201  if ( r[indx[i]] + tol < r[indx[hi+1]] )
19202  {
19203  break;
19204  }
19205  hi = hi + 1;
19206  }
19207 //
19208 // Points INDX(I+1) through INDX(HI) have an R value close to
19209 // point INDX(I). Are they truly close to point INDEX(I)?
19210 //
19211  for ( j = i + 1; j <= hi; j++ )
19212  {
19213  if ( unique[indx[j]] )
19214  {
19215  dist = 0.0;
19216  for ( k = 0; k < m; k++ )
19217  {
19218  dist = dist + std::pow ( a[k+indx[i]*m] - a[k+indx[j]*m], 2 );
19219  }
19220  dist = std::sqrt ( dist );
19221 
19222  if ( dist <= tol )
19223  {
19224  unique[indx[j]] = false;
19225  }
19226  }
19227  }
19228  }
19229  }
19230 
19231  delete [] indx;
19232  delete [] r;
19233  delete [] unique;
19234  delete [] w;
19235  delete [] z;
19236 
19237  return unique_num;
19238 }
19239 //**************************************************************************80
19240 
19241 void SandiaRules::point_radial_tol_unique_count_inc1 ( int m, int n1, double a1[],
19242  double tol, int *seed, double z[], double r1[], int indx1[], bool unique1[],
19243  int *unique_num1 )
19244 
19245 //**************************************************************************80
19246 //
19247 // Purpose:
19248 //
19249 // POINT_RADIAL_TOL_UNIQUE_COUNT_INC1 counts the tolerably unique points.
19250 //
19251 // Discussion:
19252 //
19253 // The input data includes an M x N1 array A1 of a set of N1
19254 // "permanent" points and N2 "temporary" points.
19255 //
19256 // This is a two step version of POINT_RADIAL_TOL_UNIQUE_COUNT_INC.
19257 //
19258 // This means that we want to identify the tolerably unique points
19259 // among the permanent points before processing the temporary points.
19260 //
19261 // If many sets of temporary data are considered, this function will
19262 // do a lot of unnecessary work resorting the permanent data; it would
19263 // be possible to avoid SandiaRules::repetitions of that work at the expense of saving
19264 // various work vectors. This function accepts the overhead of the
19265 // repeated calculations for the benefit of only having to "remember"
19266 // the number of unique points discovered.
19267 //
19268 // Licensing:
19269 //
19270 // This code is distributed under the GNU LGPL license.
19271 //
19272 // Modified:
19273 //
19274 // 01 October 2010
19275 //
19276 // Author:
19277 //
19278 // John Burkardt
19279 //
19280 // Parameters:
19281 //
19282 // Input, int M, the number of rows.
19283 //
19284 // Input, int N1, the number of permanent points.
19285 //
19286 // Input, double A1[M*N1], the permanent points.
19287 //
19288 // Input, double TOL, a tolerance for equality.
19289 //
19290 // Input/output, int *SEED, a seed for the random
19291 // number generator.
19292 //
19293 // Output, double Z[M], a random base vector used to
19294 // linearly sort the data.
19295 //
19296 // Output, double R1[N1], the scalar values assigned to
19297 // the data for sorting.
19298 //
19299 // Output, int INDX1[N1], the ascending sort index
19300 // for A1.
19301 //
19302 // Output, bool UNIQUE1[N1], is TRUE for each unique permanent point.
19303 //
19304 // Output, int *UNIQUE_NUM1, the number of tolerably
19305 // unique permanent points.
19306 //
19307 {
19308  double dist;
19309  int hi;
19310  int i;
19311  //int j;
19312  int j1;
19313  int k1;
19314  double *w;
19315  double w_sum;
19316 //
19317 // Assign a base point Z randomly in the convex hull of the permanent points.
19318 //
19319  w = r8vec_uniform_01_new ( n1, seed );
19320  w_sum = r8vec_sum ( n1, w );
19321  for ( j1 = 0; j1 < n1; j1++ )
19322  {
19323  w[j1] = w[j1] / w_sum;
19324  }
19325  for ( i = 0; i < m; i++ )
19326  {
19327  z[i] = 0.0;
19328  for ( j1 = 0; j1 < n1; j1++ )
19329  {
19330  z[i] = z[i] + a1[i+j1*m] * w[j1];
19331  }
19332  }
19333 //
19334 // Initialize the permanent point data.
19335 //
19336  for ( j1 = 0; j1 < n1; j1++ )
19337  {
19338  r1[j1] = 0.0;
19339  for ( i = 0; i < m; i++ )
19340  {
19341  r1[j1] = r1[j1] + std::pow ( a1[i+j1*m] - z[i], 2 );
19342  }
19343  r1[j1] = std::sqrt ( r1[j1] );
19344  }
19345  r8vec_sort_heap_index_a ( n1, r1, indx1 );
19346 
19347  *unique_num1 = 0;
19348  for ( j1 = 0; j1 < n1; j1++ )
19349  {
19350  unique1[j1] = true;
19351  }
19352 //
19353 // STEP 1:
19354 // Compare PERMANENT POINTS to PERMANENT POINTS.
19355 //
19356  for ( j1 = 0; j1 < n1; j1++ )
19357  {
19358  if ( unique1[indx1[j1]] )
19359  {
19360  *unique_num1 = *unique_num1 + 1;
19361 
19362  hi = j1;
19363 
19364  while ( hi < n1 - 1 )
19365  {
19366  if ( r1[indx1[j1]] + tol < r1[indx1[hi+1]] )
19367  {
19368  break;
19369  }
19370  hi = hi + 1;
19371  }
19372 
19373  for ( k1 = j1 + 1; k1 <= hi; k1++ )
19374  {
19375  if ( unique1[indx1[k1]] )
19376  {
19377  dist = 0.0;
19378  for ( i = 0; i < m; i++ )
19379  {
19380  dist = dist + std::pow ( a1[i+indx1[j1]*m] - a1[i+indx1[k1]*m], 2 );
19381  }
19382  dist = std::sqrt ( dist );
19383 
19384  if ( dist <= tol )
19385  {
19386  unique1[indx1[k1]] = false;
19387  }
19388  }
19389  }
19390  }
19391  }
19392 
19393  delete [] w;
19394 
19395  return;
19396 }
19397 //**************************************************************************80
19398 
19399 void SandiaRules::point_radial_tol_unique_count_inc2 ( int m, int n1, double a1[], int n2,
19400  double a2[], double tol, double z[], double r1[], int indx1[], bool unique1[],
19401  int *unique_num2 )
19402 
19403 //**************************************************************************80
19404 //
19405 // Purpose:
19406 //
19407 // POINT_RADIAL_TOL_UNIQUE_COUNT_INC2 counts the tolerably unique points.
19408 //
19409 // Discussion:
19410 //
19411 // The input data includes an M x N1 array A1 and an M x N2 array A2,
19412 // representing the M-dimensional coordinates of a set of N1
19413 // "permanent" points and N2 "temporary" points.
19414 //
19415 // This is an "incremental" version of POINT_RADIAL_TOL_UNIQUE_COUNT.
19416 //
19417 // This means that we want to identify the tolerably unique points
19418 // among the permanent points before processing the temporary points.
19419 //
19420 // If many sets of temporary data are considered, this function will
19421 // do a lot of unnecessary work resorting the permanent data; it would
19422 // be possible to avoid SandiaRules::repetitions of that work at the expense of saving
19423 // various work vectors. This function accepts the overhead of the
19424 // repeated calculations for the benefit of only having to "remember"
19425 // the number of unique points discovered.
19426 //
19427 // Licensing:
19428 //
19429 // This code is distributed under the GNU LGPL license.
19430 //
19431 // Modified:
19432 //
19433 // 01 October 2010
19434 //
19435 // Author:
19436 //
19437 // John Burkardt
19438 //
19439 // Parameters:
19440 //
19441 // Input, int M, the number of rows.
19442 //
19443 // Input, int N1, the number of permanent points.
19444 //
19445 // Input, double A1[M*N1], the permanent points.
19446 //
19447 // Input, int N2, the number of temporary points.
19448 //
19449 // Input, double A2[M*N2], the temporary points.
19450 //
19451 // Input, double TOL, a tolerance for equality.
19452 //
19453 // Input, double Z[M], a random base vector used to
19454 // linearly sort the data.
19455 //
19456 // Input, double R1[N1], the scalar values assigned to
19457 // the data for sorting.
19458 //
19459 // Input, int INDX1[N1], the ascending sort index
19460 // for A1.
19461 //
19462 // Input, bool UNIQUE1[N1], is TRUE for each unique permanent point.
19463 //
19464 // Output, int *UNIQUE_NUM2, the number of additional
19465 // tolerably unique points if the temporary points are included.
19466 //
19467 {
19468  double dist;
19469  int hi;
19470  int i;
19471  int *indx2;
19472  //int j;
19473  int j1;
19474  int j2;
19475  int j2_hi;
19476  int j2_lo;
19477  //int k1;
19478  int k2;
19479  double r_hi;
19480  double r_lo;
19481  double *r2;
19482  bool *unique2;
19483 //
19484 // Initialize the temporary point data.
19485 //
19486  r2 = new double[n2];
19487  for ( j2 = 0; j2 < n2; j2++ )
19488  {
19489  r2[j2] = 0.0;
19490  for ( i = 0; i < m; i++ )
19491  {
19492  r2[j2] = r2[j2] + std::pow ( a2[i+j2*m] - z[i], 2 );
19493  }
19494  r2[j2] = std::sqrt ( r2[j2] );
19495  }
19496 
19497  indx2 = new int[n2];
19498  r8vec_sort_heap_index_a ( n2, r2, indx2 );
19499 
19500  unique2 = new bool[n2];
19501  for ( j2 = 0; j2 < n2; j2++ )
19502  {
19503  unique2[j2] = true;
19504  }
19505 
19506  *unique_num2 = 0;
19507 //
19508 // STEP 2:
19509 // Use PERMANENT points to eliminate TEMPORARY points.
19510 //
19511  for ( j1 = 0; j1 < n1; j1++ )
19512  {
19513  if ( unique1[indx1[j1]] )
19514  {
19515  r_lo = r1[indx1[j1]] - tol;
19516  r_hi = r1[indx1[j1]] + tol;
19517 
19518  r8vec_index_sorted_range ( n2, r2, indx2, r_lo, r_hi,
19519  &j2_lo, &j2_hi );
19520 
19521  for ( j2 = j2_lo; j2 <= j2_hi; j2++ )
19522  {
19523  if ( unique2[indx2[j2]] )
19524  {
19525  dist = 0.0;
19526  for ( i = 0; i < m; i++ )
19527  {
19528  dist = dist + std::pow ( a1[i+indx1[j1]*m]
19529  - a2[i+indx2[j2]*m], 2 );
19530  }
19531  dist = std::sqrt ( dist );
19532  if ( dist <= tol )
19533  {
19534  unique2[indx2[j2]] = false;
19535  }
19536  }
19537  }
19538  }
19539  }
19540 //
19541 // STEP 3:
19542 // Use TEMPORARY points to eliminate TEMPORARY points.
19543 //
19544  for ( j2 = 0; j2 < n2; j2++ )
19545  {
19546  if ( unique2[indx2[j2]] )
19547  {
19548  *unique_num2 = *unique_num2 + 1;
19549 
19550  hi = j2;
19551 
19552  while ( hi < n2 - 1 )
19553  {
19554  if ( r2[indx2[j2]] + tol < r2[indx2[hi+1]] )
19555  {
19556  break;
19557  }
19558  hi = hi + 1;
19559  }
19560 
19561  for ( k2 = j2 + 1; k2 <= hi; k2++ )
19562  {
19563  if ( unique2[indx2[k2]] )
19564  {
19565  dist = 0.0;
19566  for ( i = 0; i < m; i++ )
19567  {
19568  dist = dist + std::pow ( a2[i+indx2[j2]*m] - a2[i+indx2[k2]*m], 2 );
19569  }
19570  dist = std::sqrt ( dist );
19571 
19572  if ( dist <= tol )
19573  {
19574  unique2[indx2[k2]] = false;
19575  }
19576  }
19577  }
19578  }
19579  }
19580  delete [] indx2;
19581  delete [] r2;
19582  delete [] unique2;
19583 
19584  return;
19585 }
19586 //**************************************************************************80
19587 
19588 int SandiaRules::point_radial_tol_unique_index ( int m, int n, double a[], double tol,
19589  int *seed, int undx[], int xdnu[] )
19590 
19591 //**************************************************************************80
19592 //
19593 // Purpose:
19594 //
19595 // POINT_RADIAL_TOL_UNIQUE_INDEX indexes the tolerably unique points.
19596 //
19597 // Discussion:
19598 //
19599 // The input data is an M x N array A, representing the M-dimensional
19600 // coordinates of N points.
19601 //
19602 // The output is:
19603 // * the number of tolerably unique points in the list;
19604 // * the index, in the list of unique items, of the representatives
19605 // of each point;
19606 // * the index, in A, of the tolerably unique representatives.
19607 //
19608 // Licensing:
19609 //
19610 // This code is distributed under the GNU LGPL license.
19611 //
19612 // Modified:
19613 //
19614 // 28 July 2010
19615 //
19616 // Author:
19617 //
19618 // John Burkardt
19619 //
19620 // Parameters:
19621 //
19622 // Input, int M, the number of rows.
19623 //
19624 // Input, int N, the number of columns.
19625 //
19626 // Input, double A[M*N], the array of N columns of data.
19627 //
19628 // Input, double TOL, a tolerance for equality.
19629 //
19630 // Input/output, int SEED, a seed for the random
19631 // number generator.
19632 //
19633 // Output, int UNDX[UNIQUE_NUM], the index, in A, of the
19634 // tolerably unique points.
19635 //
19636 // Output, int XDNU[N], the index, in UNDX, of the
19637 // tolerably unique point that "represents" this point.
19638 //
19639 // Output, int POINT_RADIAL_TOL_UNIQUE_INDEX, the number of tolerably
19640 // unique points.
19641 //
19642 {
19643  double dist;
19644  int hi;
19645  int i;
19646  int *indx;
19647  int j;
19648  int k;
19649  double *r;
19650  bool *unique;
19651  int unique_num;
19652  double *w;
19653  double w_sum;
19654  double *z;
19655 
19656  if ( n <= 0 )
19657  {
19658  unique_num = 0;
19659  return unique_num;
19660  }
19661 //
19662 // Assign a base point Z randomly in the convex hull.
19663 //
19664  w = r8vec_uniform_01_new ( n, seed );
19665  w_sum = r8vec_sum ( n, w );
19666  for ( j = 0; j < n; j++ )
19667  {
19668  w[j] = w[j] / w_sum;
19669  }
19670 
19671  z = new double[m];
19672  for ( i = 0; i < m; i++ )
19673  {
19674  z[i] = 0.0;
19675  for ( j = 0; j < n; j++ )
19676  {
19677  z[i] = z[i] + a[i+j*m] * w[j];
19678  }
19679  }
19680 //
19681 // Compute the radial distance R of each point to Z.
19682 //
19683  r = new double[n];
19684 
19685  for ( j = 0; j < n; j++ )
19686  {
19687  r[j] = 0.0;
19688  for ( i = 0; i < m; i++ )
19689  {
19690  r[j] = r[j] + std::pow ( a[i+j*m] - z[i], 2 );
19691  }
19692  r[j] = std::sqrt ( r[j] );
19693  }
19694 //
19695 // Implicitly sort the R array.
19696 //
19697  indx = r8vec_sort_heap_index_a_new ( n, r );
19698 //
19699 // To determine if a point I is tolerably unique, we only have to check
19700 // whether it is distinct from all points J such that R(I) <= R(J) <= R(J)+TOL.
19701 //
19702  unique_num = 0;
19703 
19704  unique = new bool[n];
19705  for ( i = 0; i < n; i++ )
19706  {
19707  unique[i] = true;
19708  }
19709 
19710  for ( i = 0; i < n; i++ )
19711  {
19712  if ( unique[indx[i]] )
19713  {
19714 //
19715 // Point INDX(I) is unique, in that no earlier point is near it.
19716 //
19717  xdnu[indx[i]] = unique_num;
19718  undx[unique_num] = indx[i];
19719  unique_num = unique_num + 1;
19720 //
19721 // Look for later points which are close to point INDX(I)
19722 // in terms of R.
19723 //
19724  hi = i;
19725 
19726  while ( hi < n - 1 )
19727  {
19728  if ( r[indx[i]] + tol < r[indx[hi+1]] )
19729  {
19730  break;
19731  }
19732  hi = hi + 1;
19733  }
19734 //
19735 // Points INDX(I+1) through INDX(HI) have an R value close to
19736 // point INDX(I). Are they truly close to point INDEX(I)?
19737 //
19738  for ( j = i + 1; j <= hi; j++ )
19739  {
19740  if ( unique[indx[j]] )
19741  {
19742  dist = 0.0;
19743  for ( k = 0; k < m; k++ )
19744  {
19745  dist = dist + std::pow ( a[k+indx[i]*m] - a[k+indx[j]*m], 2 );
19746  }
19747  dist = std::sqrt ( dist );
19748 
19749  if ( dist <= tol )
19750  {
19751  unique[indx[j]] = false;
19752  xdnu[indx[j]] = xdnu[indx[i]];
19753  }
19754  }
19755  }
19756  }
19757  }
19758 
19759  delete [] indx;
19760  delete [] r;
19761  delete [] unique;
19762  delete [] w;
19763  delete [] z;
19764 
19765  return unique_num;
19766 }
19767 //**************************************************************************80
19768 
19769 void SandiaRules::point_radial_tol_unique_index_inc1 ( int m, int n1, double a1[],
19770  double tol, int *seed, double z[], double r1[], int indx1[], bool unique1[],
19771  int *unique_num1, int undx1[], int xdnu1[] )
19772 
19773 //**************************************************************************80
19774 //
19775 // Purpose:
19776 //
19777 // POINT_RADIAL_TOL_UNIQUE_INDEX_INC1 indexes the tolerably unique points.
19778 //
19779 // Discussion:
19780 //
19781 // The input data includes an M x N1 array A1 of
19782 // "permanent" points.
19783 //
19784 // This is a two step version of POINT_RADIAL_TOL_UNIQUE_INDEX_INC.
19785 //
19786 // The output is:
19787 // * the number of tolerably unique points in the list;
19788 // * the index, in the list of unique items, of the representatives
19789 // of each point;
19790 // * the index, in A1, of the tolerably unique representatives.
19791 //
19792 // Licensing:
19793 //
19794 // This code is distributed under the GNU LGPL license.
19795 //
19796 // Modified:
19797 //
19798 // 02 October 2010
19799 //
19800 // Author:
19801 //
19802 // John Burkardt
19803 //
19804 // Parameters:
19805 //
19806 // Input, int M, the number of rows.
19807 //
19808 // Input, int N1, the number of permanent points.
19809 //
19810 // Input, double A1[M*N1], the permanent points.
19811 //
19812 // Input, double TOL, a tolerance for equality.
19813 //
19814 // Input/output, int *SEED, a seed for the random
19815 // number generator.
19816 //
19817 // Output, double Z[M], a random base vector used to
19818 // linearly sort the data.
19819 //
19820 // Output, double R1[N1], the scalar values assigned to
19821 // the data for sorting.
19822 //
19823 // Output, int INDX1[N1], the ascending sort index for A1.
19824 //
19825 // Output, bool UNIQUE1[N1], is TRUE for unique permanent points.
19826 //
19827 // Output, int *UNIQUE_NUM1, the number of tolerably unique points
19828 // with just the permanent points.
19829 //
19830 // Output, int UNDX1[UNIQUE_NUM1], the index, in A1, of the tolerably
19831 // unique points.
19832 //
19833 // Output, int XDNU1[N1], the index, in UNDX1, of the tolerably unique
19834 // point that "represents" this point.
19835 //
19836 {
19837  double dist;
19838  int hi;
19839  int i;
19840  //int j;
19841  int j1;
19842  int k1;
19843  double *w;
19844  double w_sum;
19845 //
19846 // Assign a base point Z randomly in the convex hull of the permanent points.
19847 //
19848  w = r8vec_uniform_01_new ( n1, seed );
19849  w_sum = r8vec_sum ( n1, w );
19850  for ( j1 = 0; j1 < n1; j1++ )
19851  {
19852  w[j1] = w[j1] / w_sum;
19853  }
19854 
19855  for ( i = 0; i < m; i++ )
19856  {
19857  z[i] = 0.0;
19858  for ( j1 = 0; j1 < n1; j1++ )
19859  {
19860  z[i] = z[i] + a1[i+j1*m] * w[j1];
19861  }
19862  }
19863 //
19864 // Initialize the permanent point data.
19865 //
19866  for ( j1 = 0; j1 < n1; j1++ )
19867  {
19868  r1[j1] = 0.0;
19869  for ( i = 0; i < m; i++ )
19870  {
19871  r1[j1] = r1[j1] + std::pow ( a1[i+j1*m] - z[i], 2 );
19872  }
19873  r1[j1] = std::sqrt ( r1[j1] );
19874  }
19875  r8vec_sort_heap_index_a ( n1, r1, indx1 );
19876 
19877  *unique_num1 = 0;
19878  for ( j1 = 0; j1 < n1; j1++ )
19879  {
19880  unique1[j1] = true;
19881  }
19882 //
19883 // STEP 1:
19884 // Compare PERMANENT POINTS to PERMANENT POINTS.
19885 //
19886  for ( j1 = 0; j1 < n1; j1++ )
19887  {
19888  if ( unique1[indx1[j1]] )
19889  {
19890  xdnu1[indx1[j1]] = *unique_num1;
19891  undx1[*unique_num1] = indx1[j1];
19892  *unique_num1 = *unique_num1 + 1;
19893 
19894  hi = j1;
19895 
19896  while ( hi < n1 - 1 )
19897  {
19898  if ( r1[indx1[j1]] + tol < r1[indx1[hi+1]] )
19899  {
19900  break;
19901  }
19902  hi = hi + 1;
19903  }
19904 
19905  for ( k1 = j1 + 1; k1 <= hi; k1++ )
19906  {
19907  if ( unique1[indx1[k1]] )
19908  {
19909  dist = 0.0;
19910  for ( i = 0; i < m; i++ )
19911  {
19912  dist = dist + std::pow ( a1[i+indx1[j1]*m] - a1[i+indx1[k1]*m], 2 );
19913  }
19914  dist = std::sqrt ( dist );
19915 
19916  if ( dist <= tol )
19917  {
19918  unique1[indx1[k1]] = false;
19919  xdnu1[indx1[k1]] = xdnu1[indx1[j1]];
19920  }
19921  }
19922  }
19923  }
19924  }
19925 
19926  delete [] w;
19927 
19928  return;
19929 }
19930 //**************************************************************************80
19931 
19932 void SandiaRules::point_radial_tol_unique_index_inc2 ( int m, int n1, double a1[], int n2,
19933  double a2[], double tol, double z[], double r1[], int indx1[], bool unique1[],
19934  int unique_num1, int undx1[], int xdnu1[], double r2[],
19935  int indx2[], bool unique2[], int *unique_num2, int undx2[], int xdnu2[] )
19936 
19937 //**************************************************************************80
19938 //
19939 // Purpose:
19940 //
19941 // POINT_RADIAL_TOL_UNIQUE_INDEX_INC2 indexes unique temporary points.
19942 //
19943 // Discussion:
19944 //
19945 // The input data includes an M x N1 array A1 and an M x N2 array A2,
19946 // representing the M-dimensional coordinates of a set of N1
19947 // "permanent" points and N2 "temporary" points.
19948 //
19949 // For notation, we use "A" to describe the M x (N1+N2) array that would be
19950 // formed by starting with A1 and appending A2.
19951 //
19952 // The output is:
19953 // * the number of tolerably unique points in the list;
19954 // * the index, in the list of unique items, of the representatives
19955 // of each point;
19956 // * the index, in A, of the tolerably unique representatives.
19957 //
19958 // Licensing:
19959 //
19960 // This code is distributed under the GNU LGPL license.
19961 //
19962 // Modified:
19963 //
19964 // 08 October 2010
19965 //
19966 // Author:
19967 //
19968 // John Burkardt
19969 //
19970 // Parameters:
19971 //
19972 // Input, int M, the number of rows.
19973 //
19974 // Input, int N1, the number of permanent points.
19975 //
19976 // Input, double A1[M*N1], the permanent points.
19977 //
19978 // Input, int N2, the number of temporary points.
19979 //
19980 // Input, double A2[M*N2], the temporary points.
19981 //
19982 // Input, double TOL, a tolerance for equality.
19983 //
19984 // Input, double Z[M], a random base vector used to
19985 // linearly sort the data.
19986 //
19987 // Input, double R1[N1], the scalar values assigned to
19988 // A1 for sorting.
19989 //
19990 // Input, int INDX1[N1], the ascending sort index for A1.
19991 //
19992 // Input, bool UNIQUE1[N1], is TRUE for unique permanent points.
19993 //
19994 // Input, int UNIQUE_NUM1, the number of tolerably unique permanent points.
19995 //
19996 // Input, int UNDX1[UNIQUE_NUM1],
19997 // the index in A1 of the tolerably unique permanent points.
19998 //
19999 // Input, int XDNU1[N1], the index in UNDX1
20000 // of the tolerably unique permanent point that "represents" this point.
20001 //
20002 // Output, double R2[N2], the scalar values assigned to
20003 // A2 for sorting.
20004 //
20005 // Output, int INDX2[N2], the ascending sort index for A2.
20006 //
20007 // Output, bool UNIQUE2[N2], is TRUE for unique temporary points.
20008 //
20009 // Output, int *UNIQUE_NUM2, the number
20010 // of tolerably unique temporary points.
20011 //
20012 // Output, int UNDX2[UNIQUE_NUM2],
20013 // the index in A2 of the tolerably unique points, incremented by N1.
20014 //
20015 // Output, int XDNU2[N2], the index, in UNDX1
20016 // or UNDX2, of the tolerably unique point that "represents" this
20017 // temporary point. If the value represents an index in UNDX2, this
20018 // can be inferred by the fact that its value is greater than or
20019 // equal to UNIQUE_NUM1. To reference UNDX2, the value should then be
20020 // decremented by UNIQUE_NUM1.
20021 //
20022 {
20023  double dist;
20024  int hi;
20025  int i;
20026  //int j;
20027  int j1;
20028  int j2;
20029  int j2_hi;
20030  int j2_lo;
20031  //int k1;
20032  int k2;
20033  double r_hi;
20034  double r_lo;
20035 //
20036 // Initialize the temporary point data.
20037 //
20038  for ( j2 = 0; j2 < n2; j2++ )
20039  {
20040  r2[j2] = 0.0;
20041  for ( i = 0; i < m; i++ )
20042  {
20043  r2[j2] = r2[j2] + std::pow ( a2[i+j2*m] - z[i], 2 );
20044  }
20045  r2[j2] = std::sqrt ( r2[j2] );
20046  }
20047 
20048  r8vec_sort_heap_index_a ( n2, r2, indx2 );
20049 
20050  for ( j2 = 0; j2 < n2; j2++ )
20051  {
20052  unique2[j2] = true;
20053  }
20054 
20055  *unique_num2 = 0;
20056 //
20057 // STEP 2:
20058 // Use PERMANENT points to eliminate TEMPORARY points.
20059 //
20060  for ( j1 = 0; j1 < n1; j1++ )
20061  {
20062  if ( unique1[indx1[j1]] )
20063  {
20064  r_lo = r1[indx1[j1]] - tol;
20065  r_hi = r1[indx1[j1]] + tol;
20066 
20067  r8vec_index_sorted_range ( n2, r2, indx2, r_lo, r_hi,
20068  &j2_lo, &j2_hi );
20069 
20070  for ( j2 = j2_lo; j2 <= j2_hi; j2++ )
20071  {
20072  if ( unique2[indx2[j2]] )
20073  {
20074  dist = 0.0;
20075  for ( i = 0; i < m; i++ )
20076  {
20077  dist = dist + std::pow ( a1[i+indx1[j1]*m]
20078  - a2[i+indx2[j2]*m], 2 );
20079  }
20080  dist = std::sqrt ( dist );
20081  if ( dist <= tol )
20082  {
20083  unique2[indx2[j2]] = false;
20084  xdnu2[indx2[j2]] = xdnu1[indx1[j1]];
20085  }
20086  }
20087  }
20088  }
20089  }
20090 //
20091 // STEP 3:
20092 // Use TEMPORARY points to eliminate TEMPORARY points.
20093 //
20094  for ( j2 = 0; j2 < n2; j2++ )
20095  {
20096  if ( unique2[indx2[j2]] )
20097  {
20098  xdnu2[indx2[j2]] = unique_num1 + *unique_num2;
20099  undx2[*unique_num2] = indx2[j2] + n1;
20100  *unique_num2 = *unique_num2 + 1;
20101 
20102  hi = j2;
20103 
20104  while ( hi < n2 - 1 )
20105  {
20106  if ( r2[indx2[j2]] + tol < r2[indx2[hi+1]] )
20107  {
20108  break;
20109  }
20110  hi = hi + 1;
20111  }
20112 
20113  for ( k2 = j2 + 1; k2 <= hi; k2++ )
20114  {
20115  if ( unique2[indx2[k2]] )
20116  {
20117  dist = 0.0;
20118  for ( i = 0; i < m; i++ )
20119  {
20120  dist = dist + std::pow ( a2[i+indx2[j2]*m] - a2[i+indx2[k2]*m], 2 );
20121  }
20122  dist = std::sqrt ( dist );
20123 
20124  if ( dist <= tol )
20125  {
20126  unique2[indx2[k2]] = false;
20127  xdnu2[indx2[k2]] = xdnu2[indx2[j2]];
20128  }
20129  }
20130  }
20131  }
20132  }
20133 
20134  return;
20135 }
20136 //**************************************************************************80
20137 
20138 void SandiaRules::point_radial_tol_unique_index_inc3 ( int m, int n1, double a1[],
20139  double r1[], int indx1[], bool unique1[], int unique_num1, int undx1[],
20140  int xdnu1[], int n2, double a2[], double r2[], int indx2[], bool unique2[],
20141  int unique_num2, int undx2[], int xdnu2[], int *n3, double a3[], double r3[],
20142  int indx3[], bool unique3[], int *unique_num3, int undx3[], int xdnu3[] )
20143 
20144 //**************************************************************************80
20145 //
20146 // Purpose:
20147 //
20148 // POINT_RADIAL_TOL_UNIQUE_INDEX_INC3 merges index data.
20149 //
20150 // Discussion:
20151 //
20152 // This function may be called after *INDEX_INC1 has created index
20153 // information for the permanent data, and *INDEX_INC2 has created
20154 // augmenting information for a set of temporary data which now is
20155 // to be merged with the permanent data.
20156 //
20157 // The function merges the data and index information to create a
20158 // new "permanent" data set.
20159 //
20160 // Licensing:
20161 //
20162 // This code is distributed under the GNU LGPL license.
20163 //
20164 // Modified:
20165 //
20166 // 08 October 2010
20167 //
20168 // Author:
20169 //
20170 // John Burkardt
20171 //
20172 // Parameters:
20173 //
20174 // Input, int M, the number of rows.
20175 //
20176 // Input, int N1, the number of permanent points.
20177 //
20178 // Input, double A1[M*N1], the permanent points.
20179 //
20180 // Input, double R1[N1], the scalar values assigned to
20181 // the data for sorting.
20182 //
20183 // Input, int INDX1[N1], the ascending sort index
20184 // for A1.
20185 //
20186 // Input, bool UNIQUE1[N1], is TRUE for each unique permanent point.
20187 //
20188 // Input, int UNIQUE_NUM1, the number
20189 // of tolerably unique points with just the permanent points.
20190 //
20191 // Input, int UNDX1[UNIQUE_NUM1],
20192 // the index in A1 of the tolerably unique points.
20193 //
20194 // Input, int XDNU1[N1], the index in UNDX1
20195 // of the tolerably unique point that "represents" this point.
20196 //
20197 // Input, int N2, the number of temporary points.
20198 //
20199 // Input, double A2[M,N2], the temporary points.
20200 //
20201 // Input, double R2[N2], the scalar values assigned to
20202 // the data for sorting.
20203 //
20204 // Input, int INDX2[N2], the ascending sort index
20205 // for A2.
20206 //
20207 // Input, bool UNIQUE2[N2], is TRUE for each unique temporary point.
20208 //
20209 // Input, int UNIQUE_NUM2, the number
20210 // of tolerably unique temporary points.
20211 //
20212 // Input, int UNDX2[UNIQUE_NUM2],
20213 // the index in A2 of the tolerably unique points, incremented by UNIQUE_NUM1.
20214 //
20215 // Input, int XDNU2[N2], the index in UNDX1 or UNDX2
20216 // of the tolerably unique point that "represents" this point.
20217 //
20218 // Output, int *N3, the number of permanent points.
20219 //
20220 // Output, double A3[M,N3], the permanent points.
20221 //
20222 // Output, double R3[N3], the scalar values assigned to
20223 // the data for sorting.
20224 //
20225 // Output, int INDX3[N3], the ascending sort index
20226 // for A3.
20227 //
20228 // Output, bool UNIQUE3[N3], is TRUE for each unique permanent point.
20229 //
20230 // Output, int *UNIQUE_NUM3, the number
20231 // of tolerably unique points.
20232 //
20233 // Output, int UNDX3[UNIQUE_NUM3],
20234 // the index in A3 of the tolerably unique points.
20235 //
20236 // Output, int XDNU3[N3], the index in UNDX3
20237 // of the tolerably unique point that "represents" this point.
20238 //
20239 {
20240  int i;
20241  int i1;
20242  int i2;
20243  int i3;
20244  double v1;
20245  double v2;
20246 
20247  *n3 = n1 + n2;
20248 
20249  for ( i1 = 0; i1 < n1; i1++ )
20250  {
20251  for ( i = 0; i < m; i++ )
20252  {
20253  a3[i+i1*m] = a1[i+i1*m];
20254  }
20255  }
20256  for ( i2 = 0; i2 < n2; i2++ )
20257  {
20258  i3 = n1 + i2;
20259  for ( i = 0; i < m; i++ )
20260  {
20261  a3[i+i3*m] = a2[i+i2*m];
20262  }
20263  }
20264  for ( i1 = 0; i1 < n1; i1++ )
20265  {
20266  r3[i1]= r1[i1];
20267  }
20268  for ( i2 = 0; i2 < n2; i2++ )
20269  {
20270  i3 = n1 + i2;
20271  r3[i3] = r2[i2];
20272  }
20273 //
20274 // Interleave the two INDX arrays so that INDX3 presents the entries
20275 // of A3 in ascending R3 order.
20276 //
20277  i1 = 0;
20278  i2 = 0;
20279 
20280  for ( i3 = 0; i3 < *n3; i3++ )
20281  {
20282  if ( i1 < n1 )
20283  {
20284  v1 = r1[indx1[i1]];
20285  }
20286  else
20287  {
20288  v1 = r8_huge ( );
20289  }
20290 
20291  if ( i2 < n2 )
20292  {
20293  v2 = r2[indx2[i2]];
20294  }
20295  else
20296  {
20297  v2 = r8_huge ( );
20298  }
20299 
20300  if ( v1 <= v2 )
20301  {
20302  indx3[i3] = indx1[i1];
20303  i1 = i1 + 1;
20304  }
20305  else
20306  {
20307  indx3[i3] = indx2[i2] + n1;
20308  i2 = i2 + 1;
20309  }
20310  }
20311 
20312  *unique_num3 = unique_num1 + unique_num2;
20313 
20314  for ( i1 = 0; i1 < n1; i1++ )
20315  {
20316  unique3[i1] = unique1[i1];
20317  }
20318  for ( i2 = 0; i2 < n2; i2++ )
20319  {
20320  i3 = n1 + i2;
20321  unique3[i3] = unique2[i2];
20322  }
20323 //
20324 // The entries in UNDX2 were already incremented by N2 if they pointed
20325 // to an entry of A2, so all entries in UNDX2 correctly index A3.
20326 //
20327  for ( i1 = 0; i1 < unique_num1; i1++ )
20328  {
20329  undx3[i1] = undx1[i1];
20330  }
20331  for ( i2 = 0; i2 < unique_num2; i2++ )
20332  {
20333  i3 = unique_num1 + i2;
20334  undx3[i3] = undx2[i2];
20335  }
20336 //
20337 // Note that the entries of XDNU2 were already incremented by N2
20338 // so that they correctly index A3, not A2.
20339 //
20340  for ( i1 = 0; i1 < n1; i1++ )
20341  {
20342  xdnu3[i1] = xdnu1[i1];
20343  }
20344  for ( i2 = 0; i2 < n2; i2++ )
20345  {
20346  i3 = n1 + i2;
20347  xdnu3[i3] = xdnu2[i2];
20348  }
20349 
20350  return;
20351 }
20352 //**************************************************************************80
20353 
20354 void SandiaRules::point_unique_index ( int m, int n, double a[], int unique_num, int undx[],
20355  int xdnu[] )
20356 
20357 //**************************************************************************80
20358 //
20359 // Purpose:
20360 //
20361 // POINT_UNIQUE_INDEX indexes unique points.
20362 //
20363 // Discussion:
20364 //
20365 // An R8COL is an M by N array of R8's, regarded as an array of N columns,
20366 // each of length M.
20367 //
20368 // The goal of this routine is to determine a vector UNDX,
20369 // which points to the unique elements of A, in sorted order,
20370 // and a vector XDNU, which identifies, for each entry of A, the index of
20371 // the unique sorted element of A.
20372 //
20373 // This is all done with index vectors, so that the elements of
20374 // A are never moved.
20375 //
20376 // The first step of the algorithm requires the indexed sorting
20377 // of A, which creates arrays INDX and XDNI. (If all the entries
20378 // of A are unique, then these arrays are the same as UNDX and XDNU.)
20379 //
20380 // We then use INDX to examine the entries of A in sorted order,
20381 // noting the unique entries, creating the entries of XDNU and
20382 // UNDX as we go.
20383 //
20384 // Once this process has been completed, the vector A could be
20385 // replaced by a compressed vector XU, containing the unique entries
20386 // of A in sorted order, using the formula
20387 //
20388 // XU(*) = A(UNDX(*)).
20389 //
20390 // We could then, if we wished, reconstruct the entire vector A, or
20391 // any element of it, by index, as follows:
20392 //
20393 // A(I) = XU(XDNU(I)).
20394 //
20395 // We could then replace A by the combination of XU and XDNU.
20396 //
20397 // Later, when we need the I-th entry of A, we can locate it as
20398 // the XDNU(I)-th entry of XU.
20399 //
20400 // Here is an example of a vector A, the sort and inverse sort
20401 // index vectors, and the unique sort and inverse unique sort vectors
20402 // and the compressed unique sorted vector.
20403 //
20404 // I A Indx Xdni XU Undx Xdnu
20405 // ----+-----+-----+-----+--------+-----+-----+
20406 // 0 | 11. 0 0 | 11. 0 0
20407 // 1 | 22. 2 4 | 22. 1 1
20408 // 2 | 11. 5 1 | 33. 3 0
20409 // 3 | 33. 8 7 | 55. 4 2
20410 // 4 | 55. 1 8 | 3
20411 // 5 | 11. 6 2 | 0
20412 // 6 | 22. 7 5 | 1
20413 // 7 | 22. 3 6 | 1
20414 // 8 | 11. 4 3 | 0
20415 //
20416 // INDX(2) = 3 means that sorted item(2) is A(3).
20417 // XDNI(2) = 5 means that A(2) is sorted item(5).
20418 //
20419 // UNDX(3) = 4 means that unique sorted item(3) is at A(4).
20420 // XDNU(8) = 2 means that A(8) is at unique sorted item(2).
20421 //
20422 // XU(XDNU(I))) = A(I).
20423 // XU(I) = A(UNDX(I)).
20424 //
20425 // Licensing:
20426 //
20427 // This code is distributed under the GNU LGPL license.
20428 //
20429 // Modified:
20430 //
20431 // 19 July 2010
20432 //
20433 // Author:
20434 //
20435 // John Burkardt
20436 //
20437 // Parameters:
20438 //
20439 // Input, int M, the dimension of the data values.
20440 //
20441 // Input, int N, the number of data values,
20442 //
20443 // Input, double A[M*N], the data values.
20444 //
20445 // Input, int UNIQUE_NUM, the number of unique values in A.
20446 // This value is only required for languages in which the size of
20447 // UNDX must be known in advance.
20448 //
20449 // Output, int UNDX[UNIQUE_NUM], the UNDX vector.
20450 //
20451 // Output, int XDNU[N], the XDNU vector.
20452 //
20453 {
20454  double diff;
20455  int i;
20456  int *indx;
20457  int j;
20458  int k;
20459 //
20460 // Implicitly sort the array.
20461 //
20462  indx = r8col_sort_heap_index_a ( m, n, a );
20463 //
20464 // Walk through the implicitly sorted array.
20465 //
20466  i = 0;
20467 
20468  j = 0;
20469  undx[j] = indx[i];
20470 
20471  xdnu[indx[i]] = j;
20472 
20473  for ( i = 1; i < n; i++ )
20474  {
20475  diff = 0.0;
20476  for ( k = 0; k < m; k++ )
20477  {
20478  diff = r8_max ( diff,
20479  r8_abs ( a[k+indx[i]*m] - a[k+undx[j]*m] ) );
20480  }
20481  if ( 0.0 < diff )
20482  {
20483  j = j + 1;
20484  undx[j] = indx[i];
20485  }
20486  xdnu[indx[i]] = j;
20487  }
20488  delete [] indx;
20489 
20490  return;
20491 }
20492 //**************************************************************************80
20493 
20494 void SandiaRules::product_mixed_weight ( int dim_num, int order_1d[], int order_nd,
20495  int rule[], double alpha[], double beta[], double weight_nd[] )
20496 
20497 //**************************************************************************80
20498 //
20499 // Purpose:
20500 //
20501 // PRODUCT_MIXED_WEIGHT computes the weights of a mixed product rule.
20502 //
20503 // Discussion:
20504 //
20505 // This routine computes the weights for a quadrature rule which is
20506 // a product of 1D rules of varying order and kind.
20507 //
20508 // The user must preallocate space for the output array WEIGHT_ND.
20509 //
20510 // Licensing:
20511 //
20512 // This code is distributed under the GNU LGPL license.
20513 //
20514 // Modified:
20515 //
20516 // 11 February 2010
20517 //
20518 // Author:
20519 //
20520 // John Burkardt
20521 //
20522 // Parameters:
20523 //
20524 // Input, int DIM_NUM, the spatial dimension.
20525 //
20526 // Input, int ORDER_1D[DIM_NUM], the order of the 1D rules.
20527 //
20528 // Input, int ORDER_ND, the order of the product rule.
20529 //
20530 // Input, int RULE[DIM_NUM], the rule in each dimension.
20531 // 1, "CC", Clenshaw Curtis, Closed Fully Nested rule.
20532 // 2, "F2", Fejer Type 2, Open Fully Nested rule.
20533 // 3, "GP", Gauss Patterson, Open Fully Nested rule.
20534 // 4, "GL", Gauss Legendre, Open Weakly Nested rule.
20535 // 5, "GH", Gauss Hermite, Open Weakly Nested rule.
20536 // 6, "GGH", Generalized Gauss Hermite, Open Weakly Nested rule.
20537 // 7, "LG", Gauss Laguerre, Open Non Nested rule.
20538 // 8, "GLG", Generalized Gauss Laguerre, Open Non Nested rule.
20539 // 9, "GJ", Gauss Jacobi, Open Non Nested rule.
20540 // 10, "GW", Golub Welsch, (presumed) Open Non Nested rule.
20541 // 11, "CC_SE", Clenshaw Curtis Slow Exponential, Closed Fully Nested rule.
20542 // 12, "F2_SE", Fejer Type 2 Slow Exponential, Open Fully Nested rule.
20543 // 13, "GP_SE", Gauss Patterson Slow Exponential, Open Fully Nested rule.
20544 // 14, "CC_ME", Clenshaw Curtis Moderate Exponential, Closed Fully Nested rule.
20545 // 15, "F2_ME", Fejer Type 2 Moderate Exponential, Open Fully Nested rule.
20546 // 16, "GP_ME", Gauss Patterson Moderate Exponential, Open Fully Nested rule.
20547 // 17, "CCN", Clenshaw Curtis Nested, Linear, Closed Fully Nested rule.
20548 //
20549 // Input, double ALPHA[DIM_NUM], BETA[DIM_NUM], parameters used for
20550 // Generalized Gauss Hermite, Generalized Gauss Laguerre,
20551 // and Gauss Jacobi rules.
20552 //
20553 // Output, double WEIGHT_ND[ORDER_ND], the product rule weights.
20554 //
20555 {
20556  int dim;
20557  int i;
20558  double *weight_1d;
20559 
20560  for ( i = 0; i < order_nd; i++ )
20561  {
20562  weight_nd[i] = 1.0;
20563  }
20564 
20565  for ( dim = 0; dim < dim_num; dim++ )
20566  {
20567  weight_1d = new double[order_1d[dim]];
20568 
20569  if ( rule[dim] == 1 )
20570  {
20571  clenshaw_curtis_compute_weights ( order_1d[dim], weight_1d );
20572  }
20573  else if ( rule[dim] == 2 )
20574  {
20575  fejer2_compute_weights ( order_1d[dim], weight_1d );
20576  }
20577  else if ( rule[dim] == 3 )
20578  {
20579  patterson_lookup_weights ( order_1d[dim], weight_1d );
20580  }
20581  else if ( rule[dim] == 4 )
20582  {
20583  legendre_compute_weights ( order_1d[dim], weight_1d );
20584  }
20585  else if ( rule[dim] == 5 )
20586  {
20587  hermite_compute_weights ( order_1d[dim], weight_1d );
20588  }
20589  else if ( rule[dim] == 6 )
20590  {
20591  gen_hermite_compute_weights ( order_1d[dim], alpha[dim], weight_1d );
20592  }
20593  else if ( rule[dim] == 7 )
20594  {
20595  laguerre_compute_weights ( order_1d[dim], weight_1d );
20596  }
20597  else if ( rule[dim] == 8 )
20598  {
20599  gen_laguerre_compute_weights ( order_1d[dim], alpha[dim], weight_1d );
20600  }
20601  else if ( rule[dim] == 9 )
20602  {
20603  jacobi_compute_weights ( order_1d[dim], alpha[dim], beta[dim], weight_1d );
20604  }
20605  else if ( rule[dim] == 10 )
20606  {
20607  std::cerr << "\n";
20608  std::cerr << "PRODUCT_MIXED_WEIGHT - Fatal error!\n";
20609  std::cerr << " Do not know how to set weights for rule 10.\n";
20610  std::exit ( 1 );
20611  }
20612  else if ( rule[dim] == 11 )
20613  {
20614  clenshaw_curtis_compute_weights ( order_1d[dim], weight_1d );
20615  }
20616  else if ( rule[dim] == 12 )
20617  {
20618  fejer2_compute_weights ( order_1d[dim], weight_1d );
20619  }
20620  else if ( rule[dim] == 13 )
20621  {
20622  patterson_lookup_weights ( order_1d[dim], weight_1d );
20623  }
20624  else if ( rule[dim] == 14 )
20625  {
20626  clenshaw_curtis_compute_weights ( order_1d[dim], weight_1d );
20627  }
20628  else if ( rule[dim] == 15 )
20629  {
20630  fejer2_compute_weights ( order_1d[dim], weight_1d );
20631  }
20632  else if ( rule[dim] == 16 )
20633  {
20634  patterson_lookup_weights ( order_1d[dim], weight_1d );
20635  }
20636  else if ( rule[dim] == 17 )
20637  {
20638  ccn_compute_weights ( order_1d[dim], weight_1d );
20639  }
20640  else
20641  {
20642  std::cerr << "\n";
20643  std::cerr << "PRODUCT_MIXED_WEIGHT - Fatal error!\n";
20644  std::cerr << " Unexpected value of RULE[" << dim << "] = "
20645  << rule[dim] << ".\n";
20646  std::exit ( 1 );
20647  }
20648 
20649  r8vec_direct_product2 ( dim, order_1d[dim], weight_1d,
20650  dim_num, order_nd, weight_nd );
20651 
20652  delete [] weight_1d;
20653  }
20654  return;
20655 }
20656 //**************************************************************************80
20657 
20658 double SandiaRules::r8_abs ( double x )
20659 
20660 //**************************************************************************80
20661 //
20662 // Purpose:
20663 //
20664 // R8_ABS returns the absolute value of an R8.
20665 //
20666 // Licensing:
20667 //
20668 // This code is distributed under the GNU LGPL license.
20669 //
20670 // Modified:
20671 //
20672 // 18 February 2008
20673 //
20674 // Author:
20675 //
20676 // John Burkardt
20677 //
20678 // Parameters:
20679 //
20680 // Input, double X, the quantity whose absolute value is desired.
20681 //
20682 // Output, double R8_ABS, the absolute value of X.
20683 //
20684 {
20685  double value;
20686 
20687  if ( 0.0 <= x )
20688  {
20689  value = x;
20690  }
20691  else
20692  {
20693  value = -x;
20694  }
20695  return value;
20696 }
20697 //**************************************************************************80
20698 
20699 double SandiaRules::r8_ceiling ( double x )
20700 
20701 //**************************************************************************80
20702 //
20703 // Purpose:
20704 //
20705 // R8_CEILING rounds an R8 "up" (towards +oo) to the next integer.
20706 //
20707 // Example:
20708 //
20709 // X R8_CEILING(X)
20710 //
20711 // -1.1 -1.0
20712 // -1.0 -1.0
20713 // -0.9 0.0
20714 // -0.1 0.0
20715 // 0.0 0.0
20716 // 0.1 1.0
20717 // 0.9 1.0
20718 // 1.0 1.0
20719 // 1.1 2.0
20720 // 2.9 3.0
20721 // 3.0 3.0
20722 // 3.14159 4.0
20723 //
20724 // Licensing:
20725 //
20726 // This code is distributed under the GNU LGPL license.
20727 //
20728 // Modified:
20729 //
20730 // 01 April 2004
20731 //
20732 // Author:
20733 //
20734 // John Burkardt
20735 //
20736 // Parameters:
20737 //
20738 // Input, double X, the number whose ceiling is desired.
20739 //
20740 // Output, double R8_CEILING, the ceiling of X.
20741 //
20742 {
20743  double value;
20744 
20745  value = ( int ) x;
20746 
20747  if ( value < x )
20748  {
20749  value = value + 1.0;
20750  }
20751 
20752  return value;
20753 }
20754 //**************************************************************************80
20755 
20756 double SandiaRules::r8_choose ( int n, int k )
20757 
20758 //**************************************************************************80
20759 //
20760 // Purpose:
20761 //
20762 // R8_CHOOSE computes the binomial coefficient C(N,K) as an R8.
20763 //
20764 // Discussion:
20765 //
20766 // The value is calculated in such a way as to avoid SandiaRules::overflow and
20767 // roundoff. The calculation is done in R8 arithmetic.
20768 //
20769 // The formula used is:
20770 //
20771 // C(N,K) = N! / ( K! * (N-K)! )
20772 //
20773 // Licensing:
20774 //
20775 // This code is distributed under the GNU LGPL license.
20776 //
20777 // Modified:
20778 //
20779 // 24 March 2008
20780 //
20781 // Author:
20782 //
20783 // John Burkardt
20784 //
20785 // Reference:
20786 //
20787 // ML Wolfson, HV Wright,
20788 // Algorithm 160:
20789 // Combinatorial of M Things Taken N at a Time,
20790 // Communications of the ACM,
20791 // Volume 6, Number 4, April 1963, page 161.
20792 //
20793 // Parameters:
20794 //
20795 // Input, int N, K, the values of N and K.
20796 //
20797 // Output, double R8_CHOOSE, the number of combinations of N
20798 // things taken K at a time.
20799 //
20800 {
20801  int i;
20802  int mn;
20803  int mx;
20804  double value;
20805 
20806  mn = i4_min ( k, n - k );
20807 
20808  if ( mn < 0 )
20809  {
20810  value = 0.0;
20811  }
20812  else if ( mn == 0 )
20813  {
20814  value = 1.0;
20815  }
20816  else
20817  {
20818  mx = i4_max ( k, n - k );
20819  value = ( double ) ( mx + 1 );
20820 
20821  for ( i = 2; i <= mn; i++ )
20822  {
20823  value = ( value * ( double ) ( mx + i ) ) / ( double ) i;
20824  }
20825  }
20826  return value;
20827 }
20828 //**************************************************************************80
20829 
20831 
20832 //**************************************************************************80
20833 //
20834 // Purpose:
20835 //
20836 // R8_EPSILON returns the R8 roundoff unit.
20837 //
20838 // Discussion:
20839 //
20840 // The roundoff unit is a number R which is a power of 2 with the
20841 // property that, to the precision of the computer's arithmetic,
20842 // 1 < 1 + R
20843 // but
20844 // 1 = ( 1 + R / 2 )
20845 //
20846 // Licensing:
20847 //
20848 // This code is distributed under the GNU LGPL license.
20849 //
20850 // Modified:
20851 //
20852 // 18 February 2008
20853 //
20854 // Author:
20855 //
20856 // John Burkardt
20857 //
20858 // Parameters:
20859 //
20860 // Output, double R8_EPSILON, the R8 round-off unit.
20861 //
20862 {
20863  double value;
20864 
20865  value = 1.0;
20866 
20867  while ( 1.0 < ( double ) ( 1.0 + value ) )
20868  {
20869  value = value / 2.0;
20870  }
20871 
20872  value = 2.0 * value;
20873 
20874  return value;
20875 }
20876 //**************************************************************************80
20877 
20879 
20880 //**************************************************************************80
20881 //
20882 // Purpose:
20883 //
20884 // R8_FACTORIAL computes the factorial of N.
20885 //
20886 // Discussion:
20887 //
20888 // factorial ( N ) = product ( 1 <= I <= N ) I
20889 //
20890 // Licensing:
20891 //
20892 // This code is distributed under the GNU LGPL license.
20893 //
20894 // Modified:
20895 //
20896 // 16 January 1999
20897 //
20898 // Author:
20899 //
20900 // John Burkardt
20901 //
20902 // Parameters:
20903 //
20904 // Input, int N, the argument of the factorial function.
20905 // If N is less than 1, the function value is returned as 1.
20906 //
20907 // Output, double R8_FACTORIAL, the factorial function.
20908 //
20909 {
20910  int i;
20911  double value;
20912 
20913  value = 1.0;
20914 
20915  for ( i = 1; i <= n; i++ )
20916  {
20917  value = value * ( double ) ( i );
20918  }
20919 
20920  return value;
20921 }
20922 //**************************************************************************80
20923 
20925 
20926 //**************************************************************************80
20927 //
20928 // Purpose:
20929 //
20930 // R8_FACTORIAL2 computes the double factorial function.
20931 //
20932 // Discussion:
20933 //
20934 // FACTORIAL2( N ) = Product ( N * (N-2) * (N-4) * ... * 2 ) (N even)
20935 // = Product ( N * (N-2) * (N-4) * ... * 1 ) (N odd)
20936 //
20937 // Example:
20938 //
20939 // N FACTORIAL2(N)
20940 //
20941 // 0 1
20942 // 1 1
20943 // 2 2
20944 // 3 3
20945 // 4 8
20946 // 5 15
20947 // 6 48
20948 // 7 105
20949 // 8 384
20950 // 9 945
20951 // 10 3840
20952 //
20953 // Licensing:
20954 //
20955 // This code is distributed under the GNU LGPL license.
20956 //
20957 // Modified:
20958 //
20959 // 22 January 2008
20960 //
20961 // Author:
20962 //
20963 // John Burkardt
20964 //
20965 // Parameters:
20966 //
20967 // Input, int N, the argument of the double factorial
20968 // function. If N is less than 1, R8_FACTORIAL2 is returned as 1.0.
20969 //
20970 // Output, double R8_FACTORIAL2, the double factorial function.
20971 //
20972 {
20973  int n_copy;
20974  double value;
20975 
20976  value = 1.0;
20977 
20978  if ( n < 1 )
20979  {
20980  return value;
20981  }
20982 
20983  n_copy = n;
20984 
20985  while ( 1 < n_copy )
20986  {
20987  value = value * ( double ) n_copy;
20988  n_copy = n_copy - 2;
20989  }
20990 
20991  return value;
20992 }
20993 //**************************************************************************80
20994 
20995 double SandiaRules::r8_floor ( double x )
20996 
20997 //**************************************************************************80
20998 //
20999 // Purpose:
21000 //
21001 // R8_FLOOR rounds an R8 "down" (towards -infinity) to the next integer.
21002 //
21003 // Example:
21004 //
21005 // X R8_FLOOR(X)
21006 //
21007 // -1.1 -2.0
21008 // -1.0 -1.0
21009 // -0.9 -1.0
21010 // -0.1 -1.0
21011 // 0.0 0.0
21012 // 0.1 0.0
21013 // 0.9 0.0
21014 // 1.0 1.0
21015 // 1.1 1.0
21016 // 2.9 2.0
21017 // 3.0 3.0
21018 // 3.14159 3.0
21019 //
21020 // Licensing:
21021 //
21022 // This code is distributed under the GNU LGPL license.
21023 //
21024 // Modified:
21025 //
21026 // 15 April 2007
21027 //
21028 // Author:
21029 //
21030 // John Burkardt
21031 //
21032 // Parameters:
21033 //
21034 // Input, double X, the number whose floor is desired.
21035 //
21036 // Output, double R8_FLOOR, the floor of X.
21037 //
21038 {
21039  double value;
21040 
21041  value = ( int ) x;
21042 
21043  if ( x < value )
21044  {
21045  value = value - 1.0;
21046  }
21047 
21048  return value;
21049 }
21050 //**************************************************************************80
21051 
21052 double SandiaRules::r8_gamma ( double x )
21053 
21054 //**************************************************************************80
21055 //
21056 // Purpose:
21057 //
21058 // R8_GAMMA evaluates Gamma(X) for a real argument.
21059 //
21060 // Discussion:
21061 //
21062 // This routine calculates the gamma function for a real argument X.
21063 //
21064 // Computation is based on an algorithm outlined in reference 1.
21065 // The program uses rational functions that approximate the gamma
21066 // function to at least 20 significant decimal digits. Coefficients
21067 // for the approximation over the interval (1,2) are unpublished.
21068 // Those for the approximation for 12 <= X are from reference 2.
21069 //
21070 // Licensing:
21071 //
21072 // This code is distributed under the GNU LGPL license.
21073 //
21074 // Modified:
21075 //
21076 // 18 January 2008
21077 //
21078 // Author:
21079 //
21080 // Original FORTRAN77 version by William Cody, Laura Stoltz.
21081 // C++ version by John Burkardt.
21082 //
21083 // Reference:
21084 //
21085 // William Cody,
21086 // An Overview of Software Development for Special Functions,
21087 // in Numerical Analysis Dundee, 1975,
21088 // edited by GA Watson,
21089 // Lecture Notes in Mathematics 506,
21090 // Springer, 1976.
21091 //
21092 // John Hart, Ward Cheney, Charles Lawson, Hans Maehly,
21093 // Charles Mesztenyi, John Rice, Henry Thatcher,
21094 // Christoph Witzgall,
21095 // Computer Approximations,
21096 // Wiley, 1968,
21097 // LC: QA297.C64.
21098 //
21099 // Parameters:
21100 //
21101 // Input, double X, the argument of the function.
21102 //
21103 // Output, double R8_GAMMA, the value of the function.
21104 //
21105 {
21106 //
21107 // Coefficients for minimax approximation over (12, INF).
21108 //
21109  double c[7] = {
21110  -1.910444077728E-03,
21111  8.4171387781295E-04,
21112  -5.952379913043012E-04,
21113  7.93650793500350248E-04,
21114  -2.777777777777681622553E-03,
21115  8.333333333333333331554247E-02,
21116  5.7083835261E-03 };
21117  double eps = 2.22E-16;
21118  double fact;
21119  int i;
21120  int n;
21121  double one = 1.0;
21122  double p[8] = {
21123  -1.71618513886549492533811E+00,
21124  2.47656508055759199108314E+01,
21125  -3.79804256470945635097577E+02,
21126  6.29331155312818442661052E+02,
21127  8.66966202790413211295064E+02,
21128  -3.14512729688483675254357E+04,
21129  -3.61444134186911729807069E+04,
21130  6.64561438202405440627855E+04 };
21131  bool parity;
21132  double pi = 3.1415926535897932384626434;
21133  double q[8] = {
21134  -3.08402300119738975254353E+01,
21135  3.15350626979604161529144E+02,
21136  -1.01515636749021914166146E+03,
21137  -3.10777167157231109440444E+03,
21138  2.25381184209801510330112E+04,
21139  4.75584627752788110767815E+03,
21140  -1.34659959864969306392456E+05,
21141  -1.15132259675553483497211E+05 };
21142  double res;
21143  double sqrtpi = 0.9189385332046727417803297;
21144  double sum;
21145  double twelve = 12.0;
21146  double two = 2.0;
21147  double value;
21148  double xbig = 171.624;
21149  double xden;
21150  double xinf = 1.79E+308;
21151  double xminin = 2.23E-308;
21152  double xnum;
21153  double y;
21154  double y1;
21155  double ysq;
21156  double z;
21157 
21158  parity = false;
21159  fact = one;
21160  n = 0;
21161  y = x;
21162 //
21163 // Argument is negative.
21164 //
21165  if ( y <= 0.0 )
21166  {
21167  y = - x;
21168  y1 = ( double ) ( int ) ( y );
21169  res = y - y1;
21170 
21171  if ( res != 0.0 )
21172  {
21173  if ( y1 != ( double ) ( int ) ( y1 * 0.5 ) * two )
21174  {
21175  parity = true;
21176  }
21177 
21178  fact = - pi / std::sin ( pi * res );
21179  y = y + one;
21180  }
21181  else
21182  {
21183  res = xinf;
21184  value = res;
21185  return value;
21186  }
21187  }
21188 //
21189 // Argument is positive.
21190 //
21191  if ( y < eps )
21192  {
21193 //
21194 // Argument < EPS.
21195 //
21196  if ( xminin <= y )
21197  {
21198  res = one / y;
21199  }
21200  else
21201  {
21202  res = xinf;
21203  value = res;
21204  return value;
21205  }
21206  }
21207  else if ( y < twelve )
21208  {
21209  y1 = y;
21210 //
21211 // 0.0 < argument < 1.0.
21212 //
21213  if ( y < one )
21214  {
21215  z = y;
21216  y = y + one;
21217  }
21218 //
21219 // 1.0 < argument < 12.0.
21220 // Reduce argument if necessary.
21221 //
21222  else
21223  {
21224  n = ( int ) ( y ) - 1;
21225  y = y - ( double ) ( n );
21226  z = y - one;
21227  }
21228 //
21229 // Evaluate approximation for 1.0 < argument < 2.0.
21230 //
21231  xnum = 0.0;
21232  xden = one;
21233  for ( i = 0; i < 8; i++ )
21234  {
21235  xnum = ( xnum + p[i] ) * z;
21236  xden = xden * z + q[i];
21237  }
21238  res = xnum / xden + one;
21239 //
21240 // Adjust result for case 0.0 < argument < 1.0.
21241 //
21242  if ( y1 < y )
21243  {
21244  res = res / y1;
21245  }
21246 //
21247 // Adjust result for case 2.0 < argument < 12.0.
21248 //
21249  else if ( y < y1 )
21250  {
21251  for ( i = 1; i <= n; i++ )
21252  {
21253  res = res * y;
21254  y = y + one;
21255  }
21256  }
21257  }
21258  else
21259  {
21260 //
21261 // Evaluate for 12.0 <= argument.
21262 //
21263  if ( y <= xbig )
21264  {
21265  ysq = y * y;
21266  sum = c[6];
21267  for ( i = 0; i < 6; i++ )
21268  {
21269  sum = sum / ysq + c[i];
21270  }
21271  sum = sum / y - y + sqrtpi;
21272  sum = sum + ( y - 0.5 ) * std::log ( y );
21273  res = std::exp ( sum );
21274  }
21275  else
21276  {
21277  res = xinf;
21278  value = res;
21279  return value;
21280  }
21281  }
21282 //
21283 // Final adjustments and return.
21284 //
21285  if ( parity )
21286  {
21287  res = - res;
21288  }
21289 
21290  if ( fact != one )
21291  {
21292  res = fact / res;
21293  }
21294 
21295  value = res;
21296 
21297  return value;
21298 }
21299 //**************************************************************************80
21300 
21302 
21303 //**************************************************************************80
21304 //
21305 // Purpose:
21306 //
21307 // R8_HUGE returns a "huge" R8.
21308 //
21309 // Discussion:
21310 //
21311 // The value returned by this function is NOT required to be the
21312 // maximum representable R8. This value varies from machine to machine,
21313 // from compiler to compiler, and may cause problems when being printed.
21314 // We simply want a "very large" but non-infinite number.
21315 //
21316 // Licensing:
21317 //
21318 // This code is distributed under the GNU LGPL license.
21319 //
21320 // Modified:
21321 //
21322 // 06 October 2007
21323 //
21324 // Author:
21325 //
21326 // John Burkardt
21327 //
21328 // Parameters:
21329 //
21330 // Output, double R8_HUGE, a "huge" R8 value.
21331 //
21332 {
21333  double value;
21334 
21335  value = 1.0E+30;
21336 
21337  return value;
21338 }
21339 //**************************************************************************80
21340 
21341 double SandiaRules::r8_hyper_2f1 ( double a, double b, double c, double x )
21342 
21343 //**************************************************************************80
21344 //
21345 // Purpose:
21346 //
21347 // R8_HYPER_2F1 evaluates the hypergeometric function 2F1(A,B,C,X).
21348 //
21349 // Discussion:
21350 //
21351 // A bug was corrected. A line which read
21352 // c1 = - ( - 1.0, m ) * gc / ( gam * gbm * rm );
21353 // was corrected to read
21354 // c1 = - std::pow ( - 1.0, m ) * gc / ( gam * gbm * rm );
21355 // JVB, 05 July 2009.
21356 //
21357 // A minor bug was corrected. The HW variable, used in several places as
21358 // the "old" value of a quantity being iteratively improved, was not
21359 // being initialized. JVB, 11 February 2008.
21360 //
21361 // The FORTRAN77 original version of this routine is copyrighted by
21362 // Shanjie Zhang and Jianming Jin. However, they give permission to
21363 // incorporate this routine into a user program provided that the copyright
21364 // is acknowledged.
21365 //
21366 // Licensing:
21367 //
21368 // This code is distributed under the GNU LGPL license.
21369 //
21370 // Modified:
21371 //
21372 // 05 July 2009
21373 //
21374 // Author:
21375 //
21376 // Original FORTRAN77 version by Shanjie Zhang, Jianming Jin.
21377 // C++ version by John Burkardt.
21378 //
21379 // Reference:
21380 //
21381 // Shanjie Zhang, Jianming Jin,
21382 // Computation of Special Functions,
21383 // Wiley, 1996,
21384 // ISBN: 0-471-11963-6,
21385 // LC: QA351.C45
21386 //
21387 // Parameters:
21388 //
21389 // Input, double A, B, C, X, the arguments of the function.
21390 // C must not be equal to a nonpositive integer.
21391 // X < 1.
21392 //
21393 // Output, double R8_HYPER_2F1, the value of the function.
21394 //
21395 {
21396  double a0;
21397  double aa;
21398  double bb;
21399  double c0;
21400  double c1;
21401  double el = 0.5772156649015329;
21402  double eps;
21403  double f0;
21404  double f1;
21405  double g0;
21406  double g1;
21407  double g2;
21408  double g3;
21409  double ga;
21410  double gabc;
21411  double gam;
21412  double gb;
21413  double gbm;
21414  double gc;
21415  double gca;
21416  double gcab;
21417  double gcb;
21418  double gm;
21419  double hf;
21420  double hw;
21421  int j;
21422  int k;
21423  bool l0;
21424  bool l1;
21425  bool l2;
21426  bool l3;
21427  bool l4;
21428  bool l5;
21429  int m;
21430  int nm;
21431  double pa;
21432  double pb;
21433  double pi = 3.141592653589793;
21434  double r;
21435  double r0;
21436  double r1;
21437  double rm;
21438  double rp;
21439  double sm;
21440  double sp;
21441  double sp0;
21442  double x1;
21443 
21444  l0 = ( c == ( int ) ( c ) ) && ( c < 0.0 );
21445  l1 = ( 1.0 - x < 1.0E-15 ) && ( c - a - b <= 0.0 );
21446  l2 = ( a == ( int ) ( a ) ) && ( a < 0.0 );
21447  l3 = ( b == ( int ) ( b ) ) && ( b < 0.0 );
21448  l4 = ( c - a == ( int ) ( c - a ) ) && ( c - a <= 0.0 );
21449  l5 = ( c - b == ( int ) ( c - b ) ) && ( c - b <= 0.0 );
21450 
21451  if ( l0 )
21452  {
21453  std::cerr << "\n";
21454  std::cerr << "R8_HYPER_2F1 - Fatal error!\n";
21455  std::cerr << " The hypergeometric series is divergent.\n";
21456  std::cerr << " C is integral and negative.\n";
21457  std::cerr << " C = " << c << "\n";
21458  std::exit ( 1 );
21459  }
21460 
21461  if ( l1 )
21462  {
21463  std::cerr << "\n";
21464  std::cerr << "R8_HYPER_2F1 - Fatal error!\n";
21465  std::cerr << " The hypergeometric series is divergent.\n";
21466  std::cerr << " 1 - X < 0, C - A - B <= 0\n";
21467  std::cerr << " A = " << a << "\n";
21468  std::cerr << " B = " << b << "\n";
21469  std::cerr << " C = " << c << "\n";
21470  std::cerr << " X = " << x << "\n";
21471  std::exit ( 1 );
21472  }
21473 
21474  if ( 0.95 < x )
21475  {
21476  eps = 1.0E-08;
21477  }
21478  else
21479  {
21480  eps = 1.0E-15;
21481  }
21482 
21483  if ( x == 0.0 || a == 0.0 || b == 0.0 )
21484  {
21485  hf = 1.0;
21486  return hf;
21487  }
21488  else if ( 1.0 - x == eps && 0.0 < c - a - b )
21489  {
21490  gc = r8_gamma ( c );
21491  gcab = r8_gamma ( c - a - b );
21492  gca = r8_gamma ( c - a );
21493  gcb = r8_gamma ( c - b );
21494  hf = gc * gcab / ( gca * gcb );
21495  return hf;
21496  }
21497  else if ( 1.0 + x <= eps && r8_abs ( c - a + b - 1.0 ) <= eps )
21498  {
21499  g0 = std::sqrt ( pi ) * std::pow ( 2.0, - a );
21500  g1 = r8_gamma ( c );
21501  g2 = r8_gamma ( 1.0 + a / 2.0 - b );
21502  g3 = r8_gamma ( 0.5 + 0.5 * a );
21503  hf = g0 * g1 / ( g2 * g3 );
21504  return hf;
21505  }
21506  else if ( l2 || l3 )
21507  {
21508  if ( l2 )
21509  {
21510  nm = ( int ) ( r8_abs ( a ) );
21511  }
21512 
21513  if ( l3 )
21514  {
21515  nm = ( int ) ( r8_abs ( b ) );
21516  }
21517 
21518  hf = 1.0;
21519  r = 1.0;
21520 
21521  for ( k = 1; k <= nm; k++ )
21522  {
21523  r = r * ( a + k - 1.0 ) * ( b + k - 1.0 )
21524  / ( k * ( c + k - 1.0 ) ) * x;
21525  hf = hf + r;
21526  }
21527 
21528  return hf;
21529  }
21530  else if ( l4 || l5 )
21531  {
21532  if ( l4 )
21533  {
21534  nm = ( int ) ( r8_abs ( c - a ) );
21535  }
21536 
21537  if ( l5 )
21538  {
21539  nm = ( int ) ( r8_abs ( c - b ) );
21540  }
21541 
21542  hf = 1.0;
21543  r = 1.0;
21544  for ( k = 1; k <= nm; k++ )
21545  {
21546  r = r * ( c - a + k - 1.0 ) * ( c - b + k - 1.0 )
21547  / ( k * ( c + k - 1.0 ) ) * x;
21548  hf = hf + r;
21549  }
21550  hf = std::pow ( 1.0 - x, c - a - b ) * hf;
21551  return hf;
21552  }
21553 
21554  aa = a;
21555  bb = b;
21556  x1 = x;
21557 
21558  if ( x < 0.0 )
21559  {
21560  x = x / ( x - 1.0 );
21561  if ( a < c && b < a && 0.0 < b )
21562  {
21563  a = bb;
21564  b = aa;
21565  }
21566  b = c - b;
21567  }
21568 
21569  if ( 0.75 <= x )
21570  {
21571  gm = 0.0;
21572 
21573  if ( r8_abs ( c - a - b - ( int ) ( c - a - b ) ) < 1.0E-15 )
21574  {
21575  m = ( int ) ( c - a - b );
21576  ga = r8_gamma ( a );
21577  gb = r8_gamma ( b );
21578  gc = r8_gamma ( c );
21579  gam = r8_gamma ( a + m );
21580  gbm = r8_gamma ( b + m );
21581 
21582  pa = r8_psi ( a );
21583  pb = r8_psi ( b );
21584 
21585  if ( m != 0 )
21586  {
21587  gm = 1.0;
21588  }
21589 
21590  for ( j = 1; j <= std::abs ( m ) - 1; j++ )
21591  {
21592  gm = gm * j;
21593  }
21594 
21595  rm = 1.0;
21596  for ( j = 1; j <= std::abs ( m ); j++ )
21597  {
21598  rm = rm * j;
21599  }
21600 
21601  f0 = 1.0;
21602  r0 = 1.0;;
21603  r1 = 1.0;
21604  sp0 = 0.0;;
21605  sp = 0.0;
21606 
21607  if ( 0 <= m )
21608  {
21609  c0 = gm * gc / ( gam * gbm );
21610  c1 = - gc * std::pow ( x - 1.0, m ) / ( ga * gb * rm );
21611 
21612  for ( k = 1; k <= m - 1; k++ )
21613  {
21614  r0 = r0 * ( a + k - 1.0 ) * ( b + k - 1.0 )
21615  / ( k * ( k - m ) ) * ( 1.0 - x );
21616  f0 = f0 + r0;
21617  }
21618 
21619  for ( k = 1; k <= m; k++ )
21620  {
21621  sp0 = sp0 + 1.0 / ( a + k - 1.0 ) + 1.0 / ( b + k - 1.0 )
21622  - 1.0 / ( double ) ( k );
21623  }
21624 
21625  f1 = pa + pb + sp0 + 2.0 * el + std::log ( 1.0 - x );
21626  hw = f1;
21627 
21628  for ( k = 1; k <= 250; k++ )
21629  {
21630  sp = sp + ( 1.0 - a ) / ( k * ( a + k - 1.0 ) )
21631  + ( 1.0 - b ) / ( k * ( b + k - 1.0 ) );
21632 
21633  sm = 0.0;
21634  for ( j = 1; j <= m; j++ )
21635  {
21636  sm = sm + ( 1.0 - a )
21637  / ( ( j + k ) * ( a + j + k - 1.0 ) )
21638  + 1.0 / ( b + j + k - 1.0 );
21639  }
21640 
21641  rp = pa + pb + 2.0 * el + sp + sm + std::log ( 1.0 - x );
21642 
21643  r1 = r1 * ( a + m + k - 1.0 ) * ( b + m + k - 1.0 )
21644  / ( k * ( m + k ) ) * ( 1.0 - x );
21645 
21646  f1 = f1 + r1 * rp;
21647 
21648  if ( r8_abs ( f1 - hw ) < r8_abs ( f1 ) * eps )
21649  {
21650  break;
21651  }
21652  hw = f1;
21653  }
21654  hf = f0 * c0 + f1 * c1;
21655  }
21656  else if ( m < 0 )
21657  {
21658  m = - m;
21659  c0 = gm * gc / ( ga * gb * std::pow ( 1.0 - x, m ) );
21660  c1 = - std::pow ( - 1.0, m ) * gc / ( gam * gbm * rm );
21661 
21662  for ( k = 1; k <= m - 1; k++ )
21663  {
21664  r0 = r0 * ( a - m + k - 1.0 ) * ( b - m + k - 1.0 )
21665  / ( k * ( k - m ) ) * ( 1.0 - x );
21666  f0 = f0 + r0;
21667  }
21668 
21669  for ( k = 1; k <= m; k++ )
21670  {
21671  sp0 = sp0 + 1.0 / ( double ) ( k );
21672  }
21673 
21674  f1 = pa + pb - sp0 + 2.0 * el + std::log ( 1.0 - x );
21675  hw = f1;
21676 
21677  for ( k = 1; k <= 250; k++ )
21678  {
21679  sp = sp + ( 1.0 - a )
21680  / ( k * ( a + k - 1.0 ) )
21681  + ( 1.0 - b ) / ( k * ( b + k - 1.0 ) );
21682 
21683  sm = 0.0;
21684  for ( j = 1; j <= m; j++ )
21685  {
21686  sm = sm + 1.0 / ( double ) ( j + k );
21687  }
21688 
21689  rp = pa + pb + 2.0 * el + sp - sm + std::log ( 1.0 - x );
21690 
21691  r1 = r1 * ( a + k - 1.0 ) * ( b + k - 1.0 )
21692  / ( k * ( m + k ) ) * ( 1.0 - x );
21693 
21694  f1 = f1 + r1 * rp;
21695 
21696  if ( r8_abs ( f1 - hw ) < r8_abs ( f1 ) * eps )
21697  {
21698  break;
21699  }
21700 
21701  hw = f1;
21702  }
21703 
21704  hf = f0 * c0 + f1 * c1;
21705  }
21706  }
21707  else
21708  {
21709  ga = r8_gamma ( a );
21710  gb = r8_gamma ( b );
21711  gc = r8_gamma ( c );
21712  gca = r8_gamma ( c - a );
21713  gcb = r8_gamma ( c - b );
21714  gcab = r8_gamma ( c - a - b );
21715  gabc = r8_gamma ( a + b - c );
21716  c0 = gc * gcab / ( gca * gcb );
21717  c1 = gc * gabc / ( ga * gb ) * std::pow ( 1.0 - x, c - a - b );
21718  hf = 0.0;
21719  hw = hf;
21720  r0 = c0;
21721  r1 = c1;
21722 
21723  for ( k = 1; k <= 250; k++ )
21724  {
21725  r0 = r0 * ( a + k - 1.0 ) * ( b + k - 1.0 )
21726  / ( k * ( a + b - c + k ) ) * ( 1.0 - x );
21727 
21728  r1 = r1 * ( c - a + k - 1.0 ) * ( c - b + k - 1.0 )
21729  / ( k * ( c - a - b + k ) ) * ( 1.0 - x );
21730 
21731  hf = hf + r0 + r1;
21732 
21733  if ( r8_abs ( hf - hw ) < r8_abs ( hf ) * eps )
21734  {
21735  break;
21736  }
21737  hw = hf;
21738  }
21739  hf = hf + c0 + c1;
21740  }
21741  }
21742  else
21743  {
21744  a0 = 1.0;
21745 
21746  if ( a < c && c < 2.0 * a && b < c && c < 2.0 * b )
21747  {
21748  a0 = std::pow ( 1.0 - x, c - a - b );
21749  a = c - a;
21750  b = c - b;
21751  }
21752 
21753  hf = 1.0;
21754  hw = hf;
21755  r = 1.0;
21756 
21757  for ( k = 1; k <= 250; k++ )
21758  {
21759  r = r * ( a + k - 1.0 ) * ( b + k - 1.0 )
21760  / ( k * ( c + k - 1.0 ) ) * x;
21761 
21762  hf = hf + r;
21763 
21764  if ( r8_abs ( hf - hw ) <= r8_abs ( hf ) * eps )
21765  {
21766  break;
21767  }
21768 
21769  hw = hf;
21770  }
21771  hf = a0 * hf;
21772  }
21773 
21774  if ( x1 < 0.0 )
21775  {
21776  x = x1;
21777  c0 = 1.0 / std::pow ( 1.0 - x, aa );
21778  hf = c0 * hf;
21779  }
21780 
21781  a = aa;
21782  b = bb;
21783 
21784  if ( 120 < k )
21785  {
21786  std::cerr << "\n";
21787  std::cerr << "R8_HYPER_2F1 - Warning!\n";
21788  std::cerr << " A large number of iterations were needed.\n";
21789  std::cerr << " The accuracy of the results should be checked.\n";
21790  }
21791 
21792  return hf;
21793 }
21794 //**************************************************************************80
21795 
21796 double SandiaRules::r8_max ( double x, double y )
21797 
21798 //**************************************************************************80
21799 //
21800 // Purpose:
21801 //
21802 // R8_MAX returns the maximum of two R8's.
21803 //
21804 // Licensing:
21805 //
21806 // This code is distributed under the GNU LGPL license.
21807 //
21808 // Modified:
21809 //
21810 // 18 August 2004
21811 //
21812 // Author:
21813 //
21814 // John Burkardt
21815 //
21816 // Parameters:
21817 //
21818 // Input, double X, Y, the quantities to compare.
21819 //
21820 // Output, double R8_MAX, the maximum of X and Y.
21821 //
21822 {
21823  double value;
21824 
21825  if ( y < x )
21826  {
21827  value = x;
21828  }
21829  else
21830  {
21831  value = y;
21832  }
21833  return value;
21834 }
21835 //**************************************************************************80
21836 
21837 double SandiaRules::r8_min ( double x, double y )
21838 
21839 //**************************************************************************80
21840 //
21841 // Purpose:
21842 //
21843 // R8_MIN returns the minimum of two R8's.
21844 //
21845 // Licensing:
21846 //
21847 // This code is distributed under the GNU LGPL license.
21848 //
21849 // Modified:
21850 //
21851 // 31 August 2004
21852 //
21853 // Author:
21854 //
21855 // John Burkardt
21856 //
21857 // Parameters:
21858 //
21859 // Input, double X, Y, the quantities to compare.
21860 //
21861 // Output, double R8_MIN, the minimum of X and Y.
21862 //
21863 {
21864  double value;
21865 
21866  if ( y < x )
21867  {
21868  value = y;
21869  }
21870  else
21871  {
21872  value = x;
21873  }
21874  return value;
21875 }
21876 //**************************************************************************80
21877 
21878 double SandiaRules::r8_mop ( int i )
21879 
21880 //**************************************************************************80
21881 //
21882 // Purpose:
21883 //
21884 // R8_MOP returns the I-th power of -1 as an R8 value.
21885 //
21886 // Discussion:
21887 //
21888 // An R8 is an double value.
21889 //
21890 // Licensing:
21891 //
21892 // This code is distributed under the GNU LGPL license.
21893 //
21894 // Modified:
21895 //
21896 // 16 November 2007
21897 //
21898 // Author:
21899 //
21900 // John Burkardt
21901 //
21902 // Parameters:
21903 //
21904 // Input, int I, the power of -1.
21905 //
21906 // Output, double R8_MOP, the I-th power of -1.
21907 //
21908 {
21909  double value;
21910 
21911  if ( ( i % 2 ) == 0 )
21912  {
21913  value = 1.0;
21914  }
21915  else
21916  {
21917  value = -1.0;
21918  }
21919 
21920  return value;
21921 }
21922 //**************************************************************************80
21923 
21924 double SandiaRules::r8_psi ( double xx )
21925 
21926 //**************************************************************************80
21927 //
21928 // Purpose:
21929 //
21930 // R8_PSI evaluates the function Psi(X).
21931 //
21932 // Discussion:
21933 //
21934 // This routine evaluates the logarithmic derivative of the
21935 // Gamma function,
21936 //
21937 // PSI(X) = d/dX ( GAMMA(X) ) / GAMMA(X)
21938 // = d/dX LN ( GAMMA(X) )
21939 //
21940 // for real X, where either
21941 //
21942 // - XMAX1 < X < - XMIN, and X is not a negative integer,
21943 //
21944 // or
21945 //
21946 // XMIN < X.
21947 //
21948 // Licensing:
21949 //
21950 // This code is distributed under the GNU LGPL license.
21951 //
21952 // Modified:
21953 //
21954 // 09 February 2008
21955 //
21956 // Author:
21957 //
21958 // Original FORTRAN77 version by William Cody.
21959 // C++ version by John Burkardt.
21960 //
21961 // Reference:
21962 //
21963 // William Cody, Anthony Strecok, Henry Thacher,
21964 // Chebyshev Approximations for the Psi Function,
21965 // Mathematics of Computation,
21966 // Volume 27, Number 121, January 1973, pages 123-127.
21967 //
21968 // Parameters:
21969 //
21970 // Input, double XX, the argument of the function.
21971 //
21972 // Output, double R8_PSI, the value of the function.
21973 //
21974 {
21975  double aug;
21976  double den;
21977  int i;
21978  int n;
21979  int nq;
21980  double one = 1.0;
21981  double p1[9] = {
21982  4.5104681245762934160E-03,
21983  5.4932855833000385356,
21984  3.7646693175929276856E+02,
21985  7.9525490849151998065E+03,
21986  7.1451595818951933210E+04,
21987  3.0655976301987365674E+05,
21988  6.3606997788964458797E+05,
21989  5.8041312783537569993E+05,
21990  1.6585695029761022321E+05 };
21991  double p2[7] = {
21992  -2.7103228277757834192,
21993  -1.5166271776896121383E+01,
21994  -1.9784554148719218667E+01,
21995  -8.8100958828312219821,
21996  -1.4479614616899842986,
21997  -7.3689600332394549911E-02,
21998  -6.5135387732718171306E-21 };
21999  double piov4 = 0.78539816339744830962;
22000  double q1[8] = {
22001  9.6141654774222358525E+01,
22002  2.6287715790581193330E+03,
22003  2.9862497022250277920E+04,
22004  1.6206566091533671639E+05,
22005  4.3487880712768329037E+05,
22006  5.4256384537269993733E+05,
22007  2.4242185002017985252E+05,
22008  6.4155223783576225996E-08 };
22009  double q2[6] = {
22010  4.4992760373789365846E+01,
22011  2.0240955312679931159E+02,
22012  2.4736979003315290057E+02,
22013  1.0742543875702278326E+02,
22014  1.7463965060678569906E+01,
22015  8.8427520398873480342E-01 };
22016  double sgn;
22017  double three = 3.0;
22018  double upper;
22019  double value;
22020  double w;
22021  double x;
22022  double x01 = 187.0;
22023  double x01d = 128.0;
22024  double x02 = 6.9464496836234126266E-04;
22025  double xinf = 1.70E+38;
22026  double xlarge = 2.04E+15;
22027  double xmax1 = 3.60E+16;
22028  double xmin1 = 5.89E-39;
22029  double xsmall = 2.05E-09;
22030  double z;
22031 
22032  x = xx;
22033  w = r8_abs ( x );
22034  aug = 0.0;
22035 //
22036 // Check for valid arguments, then branch to appropriate algorithm.
22037 //
22038  if ( xmax1 <= - x || w < xmin1 )
22039  {
22040  if ( 0.0 < x )
22041  {
22042  value = - xinf;
22043  }
22044  else
22045  {
22046  value = xinf;
22047  }
22048  return value;
22049  }
22050 
22051  if ( x < 0.5 )
22052  {
22053 //
22054 // X < 0.5, use reflection formula: psi(1-x) = psi(x) + pi * cot(pi*x)
22055 // Use 1/X for PI*COTAN(PI*X) when XMIN1 < |X| <= XSMALL.
22056 //
22057  if ( w <= xsmall )
22058  {
22059  aug = - one / x;
22060  }
22061 //
22062 // Argument reduction for cotangent.
22063 //
22064  else
22065  {
22066  if ( x < 0.0 )
22067  {
22068  sgn = piov4;
22069  }
22070  else
22071  {
22072  sgn = - piov4;
22073  }
22074 
22075  w = w - ( double ) ( ( int ) ( w ) );
22076  nq = ( int ) ( w * 4.0 );
22077  w = 4.0 * ( w - ( double ) ( nq ) * 0.25 );
22078 //
22079 // W is now related to the fractional part of 4.0 * X.
22080 // Adjust argument to correspond to values in the first
22081 // quadrant and determine the sign.
22082 //
22083  n = nq / 2;
22084 
22085  if ( n + n != nq )
22086  {
22087  w = one - w;
22088  }
22089 
22090  z = piov4 * w;
22091 
22092  if ( ( n % 2 ) != 0 )
22093  {
22094  sgn = - sgn;
22095  }
22096 //
22097 // Determine the final value for -pi * cotan(pi*x).
22098 //
22099  n = ( nq + 1 ) / 2;
22100  if ( ( n % 2 ) == 0 )
22101  {
22102 //
22103 // Check for singularity.
22104 //
22105  if ( z == 0.0 )
22106  {
22107  if ( 0.0 < x )
22108  {
22109  value = -xinf;
22110  }
22111  else
22112  {
22113  value = xinf;
22114  }
22115  return value;
22116  }
22117  aug = sgn * ( 4.0 / std::tan ( z ) );
22118  }
22119  else
22120  {
22121  aug = sgn * ( 4.0 * std::tan ( z ) );
22122  }
22123  }
22124  x = one - x;
22125  }
22126 //
22127 // 0.5 <= X <= 3.0.
22128 //
22129  if ( x <= three )
22130  {
22131  den = x;
22132  upper = p1[0] * x;
22133  for ( i = 1; i <= 7; i++ )
22134  {
22135  den = ( den + q1[i-1] ) * x;
22136  upper = ( upper + p1[i]) * x;
22137  }
22138  den = ( upper + p1[8] ) / ( den + q1[7] );
22139  x = ( x - x01 / x01d ) - x02;
22140  value = den * x + aug;
22141  return value;
22142  }
22143 //
22144 // 3.0 < X.
22145 //
22146  if ( x < xlarge )
22147  {
22148  w = one / ( x * x );
22149  den = w;
22150  upper = p2[0] * w;
22151  for ( i = 1; i <= 5; i++ )
22152  {
22153  den = ( den + q2[i-1] ) * w;
22154  upper = ( upper + p2[i] ) * w;
22155  }
22156  aug = ( upper + p2[6] ) / ( den + q2[5] ) - 0.5 / x + aug;
22157  }
22158 
22159  value = aug + std::log ( x );
22160 
22161  return value;
22162 }
22163 //**************************************************************************80
22164 
22165 double SandiaRules::r8_sign ( double x )
22166 
22167 //**************************************************************************80
22168 //
22169 // Purpose:
22170 //
22171 // R8_SIGN returns the sign of an R8.
22172 //
22173 // Licensing:
22174 //
22175 // This code is distributed under the GNU LGPL license.
22176 //
22177 // Modified:
22178 //
22179 // 18 October 2004
22180 //
22181 // Author:
22182 //
22183 // John Burkardt
22184 //
22185 // Parameters:
22186 //
22187 // Input, double X, the number whose sign is desired.
22188 //
22189 // Output, double R8_SIGN, the sign of X.
22190 //
22191 {
22192  double value;
22193 
22194  if ( x < 0.0 )
22195  {
22196  value = -1.0;
22197  }
22198  else
22199  {
22200  value = 1.0;
22201  }
22202  return value;
22203 }
22204 //**************************************************************************80
22205 
22206 int SandiaRules::r8col_compare ( int m, int n, double a[], int i, int j )
22207 
22208 //**************************************************************************80
22209 //
22210 // Purpose:
22211 //
22212 // R8COL_COMPARE compares two columns in an R8COL.
22213 //
22214 // Discussion:
22215 //
22216 // An R8COL is an M by N array of R8's, regarded as an array of N columns,
22217 // each of length M.
22218 //
22219 // Example:
22220 //
22221 // Input:
22222 //
22223 // M = 3, N = 4, I = 2, J = 4
22224 //
22225 // A = (
22226 // 1. 2. 3. 4.
22227 // 5. 6. 7. 8.
22228 // 9. 10. 11. 12. )
22229 //
22230 // Output:
22231 //
22232 // R8COL_COMPARE = -1
22233 //
22234 // Licensing:
22235 //
22236 // This code is distributed under the GNU LGPL license.
22237 //
22238 // Modified:
22239 //
22240 // 13 September 2005
22241 //
22242 // Author:
22243 //
22244 // John Burkardt
22245 //
22246 // Parameters:
22247 //
22248 // Input, int M, N, the number of rows and columns.
22249 //
22250 // Input, double A[M*N], the M by N array.
22251 //
22252 // Input, int I, J, the columns to be compared.
22253 // I and J must be between 1 and N.
22254 //
22255 // Output, int R8COL_COMPARE, the results of the comparison:
22256 // -1, column I < column J,
22257 // 0, column I = column J,
22258 // +1, column J < column I.
22259 //
22260 {
22261  int k;
22262  int value;
22263 //
22264 // Check.
22265 //
22266  if ( i < 1 || n < i )
22267  {
22268  std::cerr << "\n";
22269  std::cerr << "R8COL_COMPARE - Fatal error!\n";
22270  std::cerr << " Column index I is out of bounds.\n";
22271  std::cerr << " I = " << i << "\n";
22272  std::exit ( 1 );
22273  }
22274 
22275  if ( j < 1 || n < j )
22276  {
22277  std::cerr << "\n";
22278  std::cerr << "R8COL_COMPARE - Fatal error!\n";
22279  std::cerr << " Column index J is out of bounds.\n";
22280  std::cerr << " J = " << j << "\n";
22281  std::exit ( 1 );
22282  }
22283 
22284  value = 0;
22285 
22286  if ( i == j )
22287  {
22288  return value;
22289  }
22290 
22291  k = 0;
22292 
22293  while ( k < m )
22294  {
22295  if ( a[k+(i-1)*m] < a[k+(j-1)*m] )
22296  {
22297  value = -1;
22298  return value;
22299  }
22300  else if ( a[k+(j-1)*m] < a[k+(i-1)*m] )
22301  {
22302  value = +1;
22303  return value;
22304  }
22305  k = k + 1;
22306  }
22307 
22308  return value;
22309 }
22310 //**************************************************************************80
22311 
22312 void SandiaRules::r8col_sort_heap_a ( int m, int n, double a[] )
22313 
22314 //**************************************************************************80
22315 //
22316 // Purpose:
22317 //
22318 // R8COL_SORT_HEAP_A ascending heapsorts an R8COL.
22319 //
22320 // Discussion:
22321 //
22322 // An R8COL is an M by N array of R8's, regarded as an array of N columns,
22323 // each of length M.
22324 //
22325 // In lexicographic order, the statement "X < Y", applied to two real
22326 // vectors X and Y of length M, means that there is some index I, with
22327 // 1 <= I <= M, with the property that
22328 //
22329 // X(J) = Y(J) for J < I,
22330 // and
22331 // X(I) < Y(I).
22332 //
22333 // In other words, the first time they differ, X is smaller.
22334 //
22335 // Licensing:
22336 //
22337 // This code is distributed under the GNU LGPL license.
22338 //
22339 // Modified:
22340 //
22341 // 15 September 2005
22342 //
22343 // Author:
22344 //
22345 // John Burkardt
22346 //
22347 // Parameters:
22348 //
22349 // Input, int M, N, the number of rows and columns.
22350 //
22351 // Input/output, double A[M*N].
22352 // On input, the array of N columns of M-vectors.
22353 // On output, the columns of A have been sorted in lexicographic order.
22354 //
22355 {
22356  int i;
22357  int indx;
22358  int isgn;
22359  int j;
22360 
22361  if ( m <= 0 )
22362  {
22363  return;
22364  }
22365 
22366  if ( n <= 1 )
22367  {
22368  return;
22369  }
22370 //
22371 // Initialize.
22372 //
22373  i = 0;
22374  indx = 0;
22375  isgn = 0;
22376  j = 0;
22377 //
22378 // Call the external heap sorter.
22379 //
22380  for ( ; ; )
22381  {
22382  sort_heap_external ( n, &indx, &i, &j, isgn );
22383 //
22384 // Interchange the I and J objects.
22385 //
22386  if ( 0 < indx )
22387  {
22388  r8col_swap ( m, n, a, i, j );
22389  }
22390 //
22391 // Compare the I and J objects.
22392 //
22393  else if ( indx < 0 )
22394  {
22395  isgn = r8col_compare ( m, n, a, i, j );
22396  }
22397  else if ( indx == 0 )
22398  {
22399  break;
22400  }
22401  }
22402 
22403  return;
22404 }
22405 //**************************************************************************80
22406 
22407 int *SandiaRules::r8col_sort_heap_index_a ( int m, int n, double a[] )
22408 
22409 //**************************************************************************80
22410 //
22411 // Purpose:
22412 //
22413 // R8COL_SORT_HEAP_INDEX_A does an indexed heap ascending sort of an R8COL.
22414 //
22415 // Discussion:
22416 //
22417 // An R8COL is an M by N array of R8's, regarded as an array of N columns,
22418 // each of length M.
22419 //
22420 // The sorting is not actually carried out. Rather an index array is
22421 // created which defines the sorting. This array may be used to sort
22422 // or index the array, or to sort or index related arrays keyed on the
22423 // original array.
22424 //
22425 // A(*,J1) < A(*,J2) if the first nonzero entry of A(*,J1)-A(*,J2)
22426 // is negative.
22427 //
22428 // Once the index array is computed, the sorting can be carried out
22429 // "implicitly:
22430 //
22431 // A(*,INDX(*)) is sorted,
22432 //
22433 // Note that the index vector is 0-based.
22434 //
22435 // Licensing:
22436 //
22437 // This code is distributed under the GNU LGPL license.
22438 //
22439 // Modified:
22440 //
22441 // 01 November 2008
22442 //
22443 // Author:
22444 //
22445 // John Burkardt
22446 //
22447 // Parameters:
22448 //
22449 // Input, int M, the number of rows in each column of A.
22450 //
22451 // Input, int N, the number of columns in A.
22452 //
22453 // Input, double A[M*N], the array.
22454 //
22455 // Output, int SandiaRules::r8col_SORT_HEAP_INDEX_A[N], contains the sort index. The
22456 // I-th column of the sorted array is A(*,INDX(I)).
22457 //
22458 {
22459  double *column;
22460  int i;
22461  int *indx;
22462  int indxt;
22463  int ir;
22464  int isgn;
22465  int j;
22466  int k;
22467  int l;
22468 
22469  if ( n < 1 )
22470  {
22471  return NULL;
22472  }
22473 
22474  indx = new int[n];
22475 
22476  for ( i = 0; i < n; i++ )
22477  {
22478  indx[i] = i;
22479  }
22480 
22481  if ( n == 1 )
22482  {
22483  return indx;
22484  }
22485 
22486  column = new double[m];
22487 
22488  l = n / 2 + 1;
22489  ir = n;
22490 
22491  for ( ; ; )
22492  {
22493  if ( 1 < l )
22494  {
22495  l = l - 1;
22496  indxt = indx[l-1];
22497  for ( k = 0; k < m; k++ )
22498  {
22499  column[k] = a[k+indxt*m];
22500  }
22501  }
22502  else
22503  {
22504  indxt = indx[ir-1];
22505  for ( k = 0; k < m; k++ )
22506  {
22507  column[k] = a[k+indxt*m];
22508  }
22509  indx[ir-1] = indx[0];
22510  ir = ir - 1;
22511 
22512  if ( ir == 1 )
22513  {
22514  indx[0] = indxt;
22515  break;
22516  }
22517  }
22518 
22519  i = l;
22520  j = l + l;
22521 
22522  while ( j <= ir )
22523  {
22524  if ( j < ir )
22525  {
22526  isgn = r8vec_compare ( m, a+indx[j-1]*m, a+indx[j]*m );
22527 
22528  if ( isgn < 0 )
22529  {
22530  j = j + 1;
22531  }
22532  }
22533 
22534  isgn = r8vec_compare ( m, column, a+indx[j-1]*m );
22535 
22536  if ( isgn < 0 )
22537  {
22538  indx[i-1] = indx[j-1];
22539  i = j;
22540  j = j + j;
22541  }
22542  else
22543  {
22544  j = ir + 1;
22545  }
22546  }
22547  indx[i-1] = indxt;
22548  }
22549  delete [] column;
22550 
22551  return indx;
22552 }
22553 //**************************************************************************80
22554 
22555 int SandiaRules::r8col_sorted_unique_count ( int m, int n, double a[], double tol )
22556 
22557 //**************************************************************************80
22558 //
22559 // Purpose:
22560 //
22561 // R8COL_SORTED_UNIQUE_COUNT counts unique elements in a sorted R8COL.
22562 //
22563 // Discussion:
22564 //
22565 // An R8COL is an M by N array of R8's, regarded as an array of N columns,
22566 // each of length M.
22567 //
22568 // The columns of the array may be ascending or descending sorted.
22569 //
22570 // If the tolerance is large enough, then the concept of uniqueness
22571 // can become ambiguous. If we have a tolerance of 1.5, then in the
22572 // list ( 1, 2, 3, 4, 5, 6, 7, 8, 9 ) is it fair to say we have only
22573 // one unique entry? That would be because 1 may be regarded as unique,
22574 // and then 2 is too close to 1 to be unique, and 3 is too close to 2 to
22575 // be unique and so on.
22576 //
22577 // This seems wrongheaded. So I prefer the idea that an item is not
22578 // unique under a tolerance only if it is close to something that IS unique.
22579 // Thus, the unique items are guaranteed to cover the space if we include
22580 // a disk of radius TOL around each one.
22581 //
22582 // Licensing:
22583 //
22584 // This code is distributed under the GNU LGPL license.
22585 //
22586 // Modified:
22587 //
22588 // 01 November 2008
22589 //
22590 // Author:
22591 //
22592 // John Burkardt
22593 //
22594 // Parameters:
22595 //
22596 // Input, int M, N, the number of rows and columns.
22597 //
22598 // Input, double A[M*N], a sorted array, containing
22599 // N columns of data.
22600 //
22601 // Input, double TOL, a tolerance for equality.
22602 //
22603 // Output, int R8COL_SORTED_UNIQUE_COUNT, the number of unique columns.
22604 //
22605 {
22606  double diff;
22607  int i;
22608  int j1;
22609  int j2;
22610  int unique_num;
22611 
22612  unique_num = 0;
22613 
22614  if ( n <= 0 )
22615  {
22616  return unique_num;
22617  }
22618 
22619  unique_num = 1;
22620  j1 = 0;
22621 
22622  for ( j2 = 1; j2 < n; j2++ )
22623  {
22624  diff = 0.0;
22625  for ( i = 0; i < m; i++ )
22626  {
22627  diff = r8_max ( diff, r8_abs ( a[i+j1*m] - a[i+j2*m] ) );
22628  }
22629  if ( tol < diff )
22630  {
22631  unique_num = unique_num + 1;
22632  j1 = j2;
22633  }
22634  }
22635 
22636  return unique_num;
22637 }
22638 //**************************************************************************80
22639 
22640 void SandiaRules::r8col_swap ( int m, int n, double a[], int j1, int j2 )
22641 
22642 //**************************************************************************80
22643 //
22644 // Purpose:
22645 //
22646 // R8COL_SWAP swaps columns J1 and J2 of an R8COL.
22647 //
22648 // Discussion:
22649 //
22650 // An R8COL is an M by N array of R8's, regarded as an array of N columns,
22651 // each of length M.
22652 //
22653 // Example:
22654 //
22655 // Input:
22656 //
22657 // M = 3, N = 4, J1 = 2, J2 = 4
22658 //
22659 // A = (
22660 // 1. 2. 3. 4.
22661 // 5. 6. 7. 8.
22662 // 9. 10. 11. 12. )
22663 //
22664 // Output:
22665 //
22666 // A = (
22667 // 1. 4. 3. 2.
22668 // 5. 8. 7. 6.
22669 // 9. 12. 11. 10. )
22670 //
22671 // Licensing:
22672 //
22673 // This code is distributed under the GNU LGPL license.
22674 //
22675 // Modified:
22676 //
22677 // 23 October 2008
22678 //
22679 // Author:
22680 //
22681 // John Burkardt
22682 //
22683 // Parameters:
22684 //
22685 // Input, int M, N, the number of rows and columns.
22686 //
22687 // Input/output, double A[M*N], the M by N array.
22688 //
22689 // Input, int J1, J2, the columns to be swapped.
22690 // These columns are 1-based.
22691 //
22692 {
22693  int i;
22694  double temp;
22695 
22696  if ( j1 < 1 || n < j1 || j2 < 1 || n < j2 )
22697  {
22698  std::cerr << "\n";
22699  std::cerr << "R8COL_SWAP - Fatal error!\n";
22700  std::cerr << " J1 or J2 is out of bounds.\n";
22701  std::cerr << " J1 = " << j1 << "\n";
22702  std::cerr << " J2 = " << j2 << "\n";
22703  std::cerr << " NCOL = " << n << "\n";
22704  std::exit ( 1 );
22705  }
22706 
22707  if ( j1 == j2 )
22708  {
22709  return;
22710  }
22711 
22712  for ( i = 0; i < m; i++ )
22713  {
22714  temp = a[i+(j1-1)*m];
22715  a[i+(j1-1)*m] = a[i+(j2-1)*m];
22716  a[i+(j2-1)*m] = temp;
22717  }
22718 
22719  return;
22720 }
22721 //**************************************************************************80
22722 
22723 void SandiaRules::r8col_tol_undex ( int m, int n, double a[], int unique_num, double tol,
22724  int undx[], int xdnu[] )
22725 
22726 //**************************************************************************80
22727 //
22728 // Purpose:
22729 //
22730 // R8COL_TOL_UNDEX indexes tolerably unique entries of an R8COL.
22731 //
22732 // Discussion:
22733 //
22734 // An R8COL is an M by N array of R8's, regarded as an array of N columns,
22735 // each of length M.
22736 //
22737 // The goal of this routine is to determine a vector UNDX,
22738 // which points to the unique elements of A, in sorted order,
22739 // and a vector XDNU, which identifies, for each entry of A, the index of
22740 // the unique sorted element of A.
22741 //
22742 // This is all done with index vectors, so that the elements of
22743 // A are never moved.
22744 //
22745 // The first step of the algorithm requires the indexed sorting
22746 // of A, which creates arrays INDX and XDNI. (If all the entries
22747 // of A are unique, then these arrays are the same as UNDX and XDNU.)
22748 //
22749 // We then use INDX to examine the entries of A in sorted order,
22750 // noting the unique entries, creating the entries of XDNU and
22751 // UNDX as we go.
22752 //
22753 // Once this process has been completed, the vector A could be
22754 // replaced by a compressed vector XU, containing the unique entries
22755 // of A in sorted order, using the formula
22756 //
22757 // XU(*) = A(UNDX(*)).
22758 //
22759 // We could then, if we wished, reconstruct the entire vector A, or
22760 // any element of it, by index, as follows:
22761 //
22762 // A(I) = XU(XDNU(I)).
22763 //
22764 // We could then replace A by the combination of XU and XDNU.
22765 //
22766 // Later, when we need the I-th entry of A, we can locate it as
22767 // the XDNU(I)-th entry of XU.
22768 //
22769 // Here is an example of a vector A, the sort and inverse sort
22770 // index vectors, and the unique sort and inverse unique sort vectors
22771 // and the compressed unique sorted vector.
22772 //
22773 // I A Indx Xdni XU Undx Xdnu
22774 // ----+-----+-----+-----+--------+-----+-----+
22775 // 0 | 11. 0 0 | 11. 0 0
22776 // 1 | 22. 2 4 | 22. 1 1
22777 // 2 | 11. 5 1 | 33. 3 0
22778 // 3 | 33. 8 7 | 55. 4 2
22779 // 4 | 55. 1 8 | 3
22780 // 5 | 11. 6 2 | 0
22781 // 6 | 22. 7 5 | 1
22782 // 7 | 22. 3 6 | 1
22783 // 8 | 11. 4 3 | 0
22784 //
22785 // INDX(2) = 3 means that sorted item(2) is A(3).
22786 // XDNI(2) = 5 means that A(2) is sorted item(5).
22787 //
22788 // UNDX(3) = 4 means that unique sorted item(3) is at A(4).
22789 // XDNU(8) = 2 means that A(8) is at unique sorted item(2).
22790 //
22791 // XU(XDNU(I))) = X(I).
22792 // XU(I) = X(UNDX(I)).
22793 //
22794 // Licensing:
22795 //
22796 // This code is distributed under the GNU LGPL license.
22797 //
22798 // Modified:
22799 //
22800 // 19 July 2010
22801 //
22802 // Author:
22803 //
22804 // John Burkardt
22805 //
22806 // Parameters:
22807 //
22808 // Input, int M, the dimension of the data values.
22809 //
22810 // Input, int N, the number of data values,
22811 //
22812 // Input, double A[M*N], the data values.
22813 //
22814 // Input, int UNIQUE_NUM, the number of unique values in A.
22815 // This value is only required for languages in which the size of
22816 // UNDX must be known in advance.
22817 //
22818 // Input, double TOL, a tolerance for equality.
22819 //
22820 // Output, int UNDX[UNIQUE_NUM], the UNDX vector.
22821 //
22822 // Output, int XDNU[N], the XDNU vector.
22823 //
22824 {
22825  double diff;
22826  int i;
22827  int i2;
22828  int *indx;
22829  int j;
22830  int k;
22831  bool unique;
22832 //
22833 // Implicitly sort the array.
22834 //
22835  indx = r8col_sort_heap_index_a ( m, n, a );
22836 //
22837 // Consider entry I = 0.
22838 // It is unique, so set the number of unique items to K.
22839 // Set the K-th unique item to I.
22840 // Set the representative of item I to the K-th unique item.
22841 //
22842  i = 0;
22843  k = 0;
22844  undx[k] = indx[i];
22845  xdnu[indx[i]] = k;
22846 //
22847 // Consider entry I.
22848 //
22849 // If it is unique, increase the unique count K, set the
22850 // K-th unique item to I, and set the representative of I to K.
22851 //
22852 // If it is not unique, set the representative of item I to a
22853 // previously determined unique item that is close to it.
22854 //
22855  for ( i = 1; i < n; i++ )
22856  {
22857  unique = true;
22858  for ( j = 0; j <= k; j++ )
22859  {
22860  diff = 0.0;
22861  for ( i2 = 0; i2 < m; i2++ )
22862  {
22863  diff = r8_max ( diff,
22864  r8_abs ( a[i2+indx[i]*m] - a[i2+undx[j]*m] ) );
22865  }
22866  if ( diff <= tol )
22867  {
22868  unique = false;
22869  xdnu[indx[i]] = j;
22870  break;
22871  }
22872  }
22873  if ( unique )
22874  {
22875  k = k + 1;
22876  undx[k] = indx[i];
22877  xdnu[indx[i]] = k;
22878  }
22879  }
22880  delete [] indx;
22881 
22882  return;
22883 }
22884 //**************************************************************************80
22885 
22886 int SandiaRules::r8col_tol_unique_count ( int m, int n, double a[], double tol )
22887 
22888 //**************************************************************************80
22889 //
22890 // Purpose:
22891 //
22892 // R8COL_TOL_UNIQUE_COUNT counts tolerably unique entries in an R8COL.
22893 //
22894 // Discussion:
22895 //
22896 // An R8COL is an M by N array of R8's, regarded as an array of N columns,
22897 // each of length M.
22898 //
22899 // The columns of the array may be ascending or descending sorted.
22900 //
22901 // If the tolerance is large enough, then the concept of uniqueness
22902 // can become ambiguous. If we have a tolerance of 1.5, then in the
22903 // list ( 1, 2, 3, 4, 5, 6, 7, 8, 9 ) is it fair to say we have only
22904 // one unique entry? That would be because 1 may be regarded as unique,
22905 // and then 2 is too close to 1 to be unique, and 3 is too close to 2 to
22906 // be unique and so on.
22907 //
22908 // This seems wrongheaded. So I prefer the idea that an item is not
22909 // unique under a tolerance only if it is close to something that IS unique.
22910 // Thus, the unique items are guaranteed to cover the space if we include
22911 // a disk of radius TOL around each one.
22912 //
22913 // Licensing:
22914 //
22915 // This code is distributed under the GNU LGPL license.
22916 //
22917 // Modified:
22918 //
22919 // 19 July 2010
22920 //
22921 // Author:
22922 //
22923 // John Burkardt
22924 //
22925 // Parameters:
22926 //
22927 // Input, int M, N, the number of rows and columns.
22928 //
22929 // Input, double A[M*N], the array of N columns of data.
22930 //
22931 // Input, double TOL, a tolerance for equality.
22932 //
22933 // Output, int R8COL_TOL_UNIQUE_COUNT, the number of unique columns.
22934 //
22935 {
22936  double diff;
22937  int i;
22938  int i2;
22939  int *indx;
22940  int j;
22941  int k;
22942  bool unique;
22943  int *undx;
22944 
22945  undx = new int[n];
22946 //
22947 // Implicitly sort the array.
22948 //
22949  indx = r8col_sort_heap_index_a ( m, n, a );
22950 //
22951 // Consider entry I = 0.
22952 // It is unique, so set the number of unique items to K.
22953 // Set the K-th unique item to I.
22954 // Set the representative of item I to the K-th unique item.
22955 //
22956  i = 0;
22957  k = 0;
22958  undx[k] = indx[i];
22959 //
22960 // Consider entry I.
22961 //
22962 // If it is unique, increase the unique count K, set the
22963 // K-th unique item to I, and set the representative of I to K.
22964 //
22965 // If it is not unique, set the representative of item I to a
22966 // previously determined unique item that is close to it.
22967 //
22968  for ( i = 1; i < n; i++ )
22969  {
22970  unique = true;
22971  for ( j = 0; j <= k; j++ )
22972  {
22973  diff = 0.0;
22974  for ( i2 = 0; i2 < m; i2++ )
22975  {
22976  diff = r8_max ( diff,
22977  r8_abs ( a[i2+indx[i]*m] - a[i2+undx[j]*m] ) );
22978  }
22979  if ( diff <= tol )
22980  {
22981  unique = false;
22982  break;
22983  }
22984  }
22985  if ( unique )
22986  {
22987  k = k + 1;
22988  undx[k] = indx[i];
22989  }
22990  }
22991  delete [] indx;
22992  delete [] undx;
22993 
22994  k = k + 1;
22995 
22996  return k;
22997 }
22998 //**************************************************************************80
22999 
23000 void SandiaRules::r8col_undex ( int x_dim, int x_num, double x_val[], int x_unique_num,
23001  double tol, int undx[], int xdnu[] )
23002 
23003 //**************************************************************************80
23004 //
23005 // Purpose:
23006 //
23007 // R8COL_UNDEX returns unique sorted indexes for an R8COL.
23008 //
23009 // Discussion:
23010 //
23011 // An R8COL is an M by N array of R8's, regarded as an array of N columns,
23012 // each of length M.
23013 //
23014 // The goal of this routine is to determine a vector UNDX,
23015 // which points to the unique elements of X, in sorted order,
23016 // and a vector XDNU, which identifies, for each entry of X, the index of
23017 // the unique sorted element of X.
23018 //
23019 // This is all done with index vectors, so that the elements of
23020 // X are never moved.
23021 //
23022 // The first step of the algorithm requires the indexed sorting
23023 // of X, which creates arrays INDX and XDNI. (If all the entries
23024 // of X are unique, then these arrays are the same as UNDX and XDNU.)
23025 //
23026 // We then use INDX to examine the entries of X in sorted order,
23027 // noting the unique entries, creating the entries of XDNU and
23028 // UNDX as we go.
23029 //
23030 // Once this process has been completed, the vector X could be
23031 // replaced by a compressed vector XU, containing the unique entries
23032 // of X in sorted order, using the formula
23033 //
23034 // XU(*) = X(UNDX(*)).
23035 //
23036 // We could then, if we wished, reconstruct the entire vector X, or
23037 // any element of it, by index, as follows:
23038 //
23039 // X(I) = XU(XDNU(I)).
23040 //
23041 // We could then replace X by the combination of XU and XDNU.
23042 //
23043 // Later, when we need the I-th entry of X, we can locate it as
23044 // the XDNU(I)-th entry of XU.
23045 //
23046 // Here is an example of a vector X, the sort and inverse sort
23047 // index vectors, and the unique sort and inverse unique sort vectors
23048 // and the compressed unique sorted vector.
23049 //
23050 // I X Indx Xdni XU Undx Xdnu
23051 // ----+-----+-----+-----+--------+-----+-----+
23052 // 0 | 11. 0 0 | 11. 0 0
23053 // 1 | 22. 2 4 | 22. 1 1
23054 // 2 | 11. 5 1 | 33. 3 0
23055 // 3 | 33. 8 7 | 55. 4 2
23056 // 4 | 55. 1 8 | 3
23057 // 5 | 11. 6 2 | 0
23058 // 6 | 22. 7 5 | 1
23059 // 7 | 22. 3 6 | 1
23060 // 8 | 11. 4 3 | 0
23061 //
23062 // INDX(2) = 3 means that sorted item(2) is X(3).
23063 // XDNI(2) = 5 means that X(2) is sorted item(5).
23064 //
23065 // UNDX(3) = 4 means that unique sorted item(3) is at X(4).
23066 // XDNU(8) = 2 means that X(8) is at unique sorted item(2).
23067 //
23068 // XU(XDNU(I))) = X(I).
23069 // XU(I) = X(UNDX(I)).
23070 //
23071 // Licensing:
23072 //
23073 // This code is distributed under the GNU LGPL license.
23074 //
23075 // Modified:
23076 //
23077 // 02 November 2008
23078 //
23079 // Author:
23080 //
23081 // John Burkardt
23082 //
23083 // Parameters:
23084 //
23085 // Input, int X_DIM, the dimension of the data values.
23086 // (the number of rows in the R8COL).
23087 //
23088 // Input, int X_NUM, the number of data values,
23089 // (the number of columns in the R8COL).
23090 //
23091 // Input, double X_VAL[X_DIM*X_NUM], the data values.
23092 //
23093 // Input, int X_UNIQUE_NUM, the number of unique values in X_VAL.
23094 // This value is only required for languages in which the size of
23095 // UNDX must be known in advance.
23096 //
23097 // Input, double TOL, a tolerance for equality.
23098 //
23099 // Output, int UNDX[X_UNIQUE_NUM], the UNDX vector.
23100 //
23101 // Output, int XDNU[X_NUM], the XDNU vector.
23102 //
23103 {
23104  double diff;
23105  int i;
23106  int *indx;
23107  int j;
23108  int k;
23109 //
23110 // Implicitly sort the array.
23111 //
23112  indx = r8col_sort_heap_index_a ( x_dim, x_num, x_val );
23113 //
23114 // Walk through the implicitly sorted array X.
23115 //
23116  i = 0;
23117 
23118  j = 0;
23119  undx[j] = indx[i];
23120 
23121  xdnu[indx[i]] = j;
23122 
23123  for ( i = 1; i < x_num; i++ )
23124  {
23125  diff = 0.0;
23126  for ( k = 0; k < x_dim; k++ )
23127  {
23128  diff = r8_max ( diff,
23129  r8_abs ( x_val[k+indx[i]*x_dim] - x_val[k+undx[j]*x_dim] ) );
23130  }
23131  if ( tol < diff )
23132  {
23133  j = j + 1;
23134  undx[j] = indx[i];
23135  }
23136  xdnu[indx[i]] = j;
23137  }
23138  delete [] indx;
23139 
23140  return;
23141 }
23142 //**************************************************************************80
23143 
23144 void SandiaRules::r8col_unique_index ( int m, int n, double a[], double tol,
23145  int unique_index[] )
23146 
23147 //**************************************************************************80
23148 //
23149 // Purpose:
23150 //
23151 // R8COL_UNIQUE_INDEX indexes the first occurrence of values in an R8COL.
23152 //
23153 // Discussion:
23154 //
23155 // An R8COL is an M by N array of R8 values.
23156 // It is regarded as an array of N columns of length M.
23157 //
23158 // For element A(1:M,J) of the matrix, UNIQUE_INDEX(J) is the uniqueness
23159 // index of A(1:M,J). That is, if A_UNIQUE contains the unique elements
23160 // of A, gathered in order, then
23161 //
23162 // A_UNIQUE ( 1:M, UNIQUE_INDEX(J) ) = A(1:M,J)
23163 //
23164 // The user must preallocate space for the output array UNIQUE_INDEX.
23165 //
23166 // Licensing:
23167 //
23168 // This code is distributed under the GNU LGPL license.
23169 //
23170 // Modified:
23171 //
23172 // 24 November 2008
23173 //
23174 // Author:
23175 //
23176 // John Burkardt
23177 //
23178 // Parameters:
23179 //
23180 // Input, int M, N, the number of rows and columns of A.
23181 // The length of an "element" of A, and the number of "elements".
23182 //
23183 // Input, double A[M*N], the array.
23184 //
23185 // Input, double TOL, a tolerance for equality.
23186 //
23187 // Output, int UNIQUE_INDEX[N], the unique index.
23188 //
23189 {
23190  double diff;
23191  int i;
23192  int j1;
23193  int j2;
23194  int unique_num;
23195 
23196  for ( j1 = 0; j1 < n; j1++ )
23197  {
23198  unique_index[j1] = -1;
23199  }
23200  unique_num = 0;
23201 
23202  for ( j1 = 0; j1 < n; j1++ )
23203  {
23204  if ( unique_index[j1] == -1 )
23205  {
23206  unique_index[j1] = unique_num;
23207 
23208  for ( j2 = j1 + 1; j2 < n; j2++ )
23209  {
23210  diff = 0.0;
23211  for ( i = 0; i < m; i++ )
23212  {
23213  diff = r8_max ( diff,
23214  r8_abs ( a[i+j1*m] - a[i+j2*m] ) );
23215  }
23216  if ( diff <= tol )
23217  {
23218  unique_index[j2] = unique_num;
23219  }
23220  }
23221  unique_num = unique_num + 1;
23222  }
23223  }
23224  return;
23225 }
23226 //**************************************************************************80
23227 
23228 void SandiaRules::r8mat_transpose_print ( int m, int n, double a[], std::string title )
23229 
23230 //**************************************************************************80
23231 //
23232 // Purpose:
23233 //
23234 // R8MAT_TRANSPOSE_PRINT prints an R8MAT, transposed.
23235 //
23236 // Discussion:
23237 //
23238 // An R8MAT is a doubly dimensioned array of R8 values, stored as a vector
23239 // in column-major order.
23240 //
23241 // Licensing:
23242 //
23243 // This code is distributed under the GNU LGPL license.
23244 //
23245 // Modified:
23246 //
23247 // 10 September 2009
23248 //
23249 // Author:
23250 //
23251 // John Burkardt
23252 //
23253 // Parameters:
23254 //
23255 // Input, int M, N, the number of rows and columns.
23256 //
23257 // Input, double A[M*N], an M by N matrix to be printed.
23258 //
23259 // Input, string TITLE, a title.
23260 //
23261 {
23262  r8mat_transpose_print_some ( m, n, a, 1, 1, m, n, title );
23263 
23264  return;
23265 }
23266 //**************************************************************************80
23267 
23268 void SandiaRules::r8mat_transpose_print_some ( int m, int n, double a[], int ilo, int jlo,
23269  int ihi, int jhi, std::string title )
23270 
23271 //**************************************************************************80
23272 //
23273 // Purpose:
23274 //
23275 // R8MAT_TRANSPOSE_PRINT_SOME prints some of an R8MAT, transposed.
23276 //
23277 // Discussion:
23278 //
23279 // An R8MAT is a doubly dimensioned array of R8 values, stored as a vector
23280 // in column-major order.
23281 //
23282 // Licensing:
23283 //
23284 // This code is distributed under the GNU LGPL license.
23285 //
23286 // Modified:
23287 //
23288 // 10 September 2009
23289 //
23290 // Author:
23291 //
23292 // John Burkardt
23293 //
23294 // Parameters:
23295 //
23296 // Input, int M, N, the number of rows and columns.
23297 //
23298 // Input, double A[M*N], an M by N matrix to be printed.
23299 //
23300 // Input, int ILO, JLO, the first row and column to print.
23301 //
23302 // Input, int IHI, JHI, the last row and column to print.
23303 //
23304 // Input, string TITLE, a title.
23305 //
23306 {
23307 # define INCX 5
23308 
23309  int i;
23310  int i2;
23311  int i2hi;
23312  int i2lo;
23313  int inc;
23314  int j;
23315  int j2hi;
23316  int j2lo;
23317 
23318  std::cout << "\n";
23319  std::cout << title << "\n";
23320 
23321  for ( i2lo = i4_max ( ilo, 1 ); i2lo <= i4_min ( ihi, m ); i2lo = i2lo + INCX )
23322  {
23323  i2hi = i2lo + INCX - 1;
23324  i2hi = i4_min ( i2hi, m );
23325  i2hi = i4_min ( i2hi, ihi );
23326 
23327  inc = i2hi + 1 - i2lo;
23328 
23329  std::cout << "\n";
23330  std::cout << " Row: ";
23331  for ( i = i2lo; i <= i2hi; i++ )
23332  {
23333  std::cout << std::setw(7) << i - 1 << " ";
23334  }
23335  std::cout << "\n";
23336  std::cout << " Col\n";
23337  std::cout << "\n";
23338 
23339  j2lo = i4_max ( jlo, 1 );
23340  j2hi = i4_min ( jhi, n );
23341 
23342  for ( j = j2lo; j <= j2hi; j++ )
23343  {
23344  std::cout << std::setw(5) << j - 1 << ":";
23345  for ( i2 = 1; i2 <= inc; i2++ )
23346  {
23347  i = i2lo - 1 + i2;
23348  std::cout << std::setw(14) << a[(i-1)+(j-1)*m];
23349  }
23350  std::cout << "\n";
23351  }
23352  }
23353 
23354  return;
23355 # undef INCX
23356 }
23357 //**************************************************************************80
23358 
23359 void SandiaRules::r8mat_write ( std::string output_filename, int m, int n, double table[] )
23360 
23361 //**************************************************************************80
23362 //
23363 // Purpose:
23364 //
23365 // R8MAT_WRITE writes an R8MAT file.
23366 //
23367 // Licensing:
23368 //
23369 // This code is distributed under the GNU LGPL license.
23370 //
23371 // Modified:
23372 //
23373 // 11 August 2009
23374 //
23375 // Author:
23376 //
23377 // John Burkardt
23378 //
23379 // Parameters:
23380 //
23381 // Input, string OUTPUT_FILENAME, the output filename.
23382 //
23383 // Input, int M, the spatial dimension.
23384 //
23385 // Input, int N, the number of points.
23386 //
23387 // Input, double TABLE[M*N], the table data.
23388 //
23389 {
23390  int i;
23391  int j;
23392  std::ofstream output;
23393 //
23394 // Open the file.
23395 //
23396  output.open ( output_filename.c_str ( ) );
23397 
23398  if ( !output )
23399  {
23400  std::cerr << "\n";
23401  std::cerr << "R8MAT_WRITE - Fatal error!\n";
23402  std::cerr << " Could not open the output file.\n";
23403  return;
23404  }
23405 //
23406 // Write the data.
23407 //
23408  for ( j = 0; j < n; j++ )
23409  {
23410  for ( i = 0; i < m; i++ )
23411  {
23412  output << " " << std::setw(24) << std::setprecision(16) << table[i+j*m];
23413  }
23414  output << "\n";
23415  }
23416 //
23417 // Close the file.
23418 //
23419  output.close ( );
23420 
23421  return;
23422 }
23423 //**************************************************************************80
23424 
23425 double SandiaRules::r8poly_ant_val ( int n, double poly_cof[], double xval )
23426 
23427 //**************************************************************************80
23428 //
23429 // Purpose:
23430 //
23431 // R8POLY_ANT_VAL evaluates the antiderivative of an R8POLY in standard form.
23432 //
23433 // Discussion:
23434 //
23435 // The constant term of the antiderivative is taken to be zero.
23436 //
23437 // Licensing:
23438 //
23439 // This code is distributed under the GNU LGPL license.
23440 //
23441 // Modified:
23442 //
23443 // 17 June 2011
23444 //
23445 // Author:
23446 //
23447 // John Burkardt
23448 //
23449 // Parameters:
23450 //
23451 // Input, int N, the order of the polynomial.
23452 //
23453 // Input, double POLY_COF[N], the polynomial coefficients. POLY_COF[0]
23454 // is the constant term, and POLY_COF[N-1] is the coefficient of X**(N-1).
23455 //
23456 // Input, double XVAL, the point where the antiderivative is to be
23457 // evaluated.
23458 //
23459 // Output, double R8POLY_ANT_VAL, the value of the antiderivative of the polynomial
23460 // at XVAL.
23461 //
23462 {
23463  int i;
23464  double value;
23465 
23466  value = 0.0;
23467 
23468  for ( i = n - 1; 0 <= i; i-- )
23469  {
23470  value = ( value + poly_cof[i] / ( double ) ( i + 1 ) ) * xval;
23471  }
23472 
23473  return value;
23474 }
23475 //**************************************************************************80
23476 
23477 double *SandiaRules::r8vec_chebyshev_new ( int n, double a_first, double a_last )
23478 
23479 //**************************************************************************80
23480 //
23481 // Purpose:
23482 //
23483 // R8VEC_CHEBYSHEV_NEW creates a vector of Chebyshev spaced values.
23484 //
23485 // Discussion:
23486 //
23487 // An R8VEC is a vector of R8's.
23488 //
23489 // Licensing:
23490 //
23491 // This code is distributed under the GNU LGPL license.
23492 //
23493 // Modified:
23494 //
23495 // 08 June 2011
23496 //
23497 // Author:
23498 //
23499 // John Burkardt
23500 //
23501 // Parameters:
23502 //
23503 // Input, int N, the number of entries in the vector.
23504 //
23505 // Input, double A_FIRST, A_LAST, the first and last entries.
23506 //
23507 // Output, double R8VEC_CHEBYSHEV_NEW[N], a vector of Chebyshev spaced data.
23508 //
23509 {
23510  double *a;
23511  double c;
23512  int i;
23513  double pi = 3.141592653589793;
23514  double theta;
23515 
23516  a = new double[n];
23517 
23518  if ( n == 1 )
23519  {
23520  a[0] = ( a_first + a_last ) / 2.0;
23521  }
23522  else
23523  {
23524  for ( i = 0; i < n; i++ )
23525  {
23526  theta = ( double ) ( n - i - 1 ) * pi / ( double ) ( n - 1 );
23527 
23528  c = std::cos ( theta );
23529 
23530  if ( ( n % 2 ) == 1 )
23531  {
23532  if ( 2 * i + 1 == n )
23533  {
23534  c = 0.0;
23535  }
23536  }
23537 
23538  a[i] = ( ( 1.0 - c ) * a_first
23539  + ( 1.0 + c ) * a_last )
23540  / 2.0;
23541  }
23542  }
23543  return a;
23544 }
23545 //**************************************************************************80
23546 
23547 int SandiaRules::r8vec_compare ( int n, double a[], double b[] )
23548 
23549 //**************************************************************************80
23550 //
23551 // Purpose:
23552 //
23553 // R8VEC_COMPARE compares two R8VEC's.
23554 //
23555 // Discussion:
23556 //
23557 // An R8VEC is a vector of R8's.
23558 //
23559 // The lexicographic ordering is used.
23560 //
23561 // Example:
23562 //
23563 // Input:
23564 //
23565 // A1 = ( 2.0, 6.0, 2.0 )
23566 // A2 = ( 2.0, 8.0, 12.0 )
23567 //
23568 // Output:
23569 //
23570 // ISGN = -1
23571 //
23572 // Licensing:
23573 //
23574 // This code is distributed under the GNU LGPL license.
23575 //
23576 // Modified:
23577 //
23578 // 23 September 2005
23579 //
23580 // Author:
23581 //
23582 // John Burkardt
23583 //
23584 // Parameters:
23585 //
23586 // Input, int N, the number of entries in the vectors.
23587 //
23588 // Input, double A[N], B[N], the vectors to be compared.
23589 //
23590 // Output, int R8VEC_COMPARE, the results of the comparison:
23591 // -1, A is lexicographically less than B,
23592 // 0, A is equal to B,
23593 // +1, A is lexicographically greater than B.
23594 //
23595 {
23596  int isgn;
23597  int k;
23598 
23599  isgn = 0;
23600 
23601  for ( k = 0; k < n; k++ )
23602  {
23603  if ( a[k] < b[k] )
23604  {
23605  isgn = -1;
23606  return isgn;
23607  }
23608  else if ( b[k] < a[k] )
23609  {
23610  isgn = +1;
23611  return isgn;
23612  }
23613  }
23614  return isgn;
23615 }
23616 //**************************************************************************80
23617 
23618 void SandiaRules::r8vec_copy ( int n, double a1[], double a2[] )
23619 
23620 //**************************************************************************80
23621 //
23622 // Purpose:
23623 //
23624 // R8VEC_COPY copies an R8VEC.
23625 //
23626 // Licensing:
23627 //
23628 // This code is distributed under the GNU LGPL license.
23629 //
23630 // Modified:
23631 //
23632 // 03 July 2005
23633 //
23634 // Author:
23635 //
23636 // John Burkardt
23637 //
23638 // Parameters:
23639 //
23640 // Input, int N, the number of entries in the vectors.
23641 //
23642 // Input, double A1[N], the vector to be copied.
23643 //
23644 // Output, double A2[N], the copy of A1.
23645 //
23646 {
23647  int i;
23648 
23649  for ( i = 0; i < n; i++ )
23650  {
23651  a2[i] = a1[i];
23652  }
23653  return;
23654 }
23655 //**************************************************************************80
23656 
23657 double *SandiaRules::r8vec_copy_new ( int n, double a1[] )
23658 
23659 //**************************************************************************80
23660 //
23661 // Purpose:
23662 //
23663 // R8VEC_COPY_NEW copies an R8VEC to a "new" R8VEC.
23664 //
23665 // Discussion:
23666 //
23667 // An R8VEC is a vector of R8's.
23668 //
23669 // Licensing:
23670 //
23671 // This code is distributed under the GNU LGPL license.
23672 //
23673 // Modified:
23674 //
23675 // 03 July 2008
23676 //
23677 // Author:
23678 //
23679 // John Burkardt
23680 //
23681 // Parameters:
23682 //
23683 // Input, int N, the number of entries in the vectors.
23684 //
23685 // Input, double A1[N], the vector to be copied.
23686 //
23687 // Output, double R8VEC_COPY_NEW[N], the copy of A1.
23688 //
23689 {
23690  double *a2;
23691  int i;
23692 
23693  a2 = new double[n];
23694 
23695  for ( i = 0; i < n; i++ )
23696  {
23697  a2[i] = a1[i];
23698  }
23699  return a2;
23700 }
23701 //**************************************************************************80
23702 
23703 double SandiaRules::r8vec_diff_norm_li ( int n, double a[], double b[] )
23704 
23705 //**************************************************************************80
23706 //
23707 // Purpose:
23708 //
23709 // R8VEC_DIFF_NORM_LI returns the L-oo norm of the difference of R8VEC's.
23710 //
23711 // Discussion:
23712 //
23713 // An R8VEC is a vector of R8's.
23714 //
23715 // The vector L-oo norm is defined as:
23716 //
23717 // R8VEC_NORM_LI = max ( 1 <= I <= N ) abs ( A(I) ).
23718 //
23719 // Licensing:
23720 //
23721 // This code is distributed under the GNU LGPL license.
23722 //
23723 // Modified:
23724 //
23725 // 02 April 2010
23726 //
23727 // Author:
23728 //
23729 // John Burkardt
23730 //
23731 // Parameters:
23732 //
23733 // Input, int N, the number of entries in A.
23734 //
23735 // Input, double A[N], B[N], the vectors.
23736 //
23737 // Output, double R8VEC_DIFF_NORM_LI, the L-oo norm of A - B.
23738 //
23739 {
23740  int i;
23741  double value;
23742 
23743  value = 0.0;
23744 
23745  for ( i = 0; i < n; i++ )
23746  {
23747  value = r8_max ( value, r8_abs ( a[i] - b[i] ) );
23748  }
23749  return value;
23750 }
23751 //**************************************************************************80
23752 
23753 void SandiaRules::r8vec_direct_product2 ( int factor_index, int factor_order,
23754  double factor_value[], int factor_num, int point_num, double w[] )
23755 
23756 //**************************************************************************80
23757 //
23758 // Purpose:
23759 //
23760 // R8VEC_DIRECT_PRODUCT2 creates a direct product of R8VEC's.
23761 //
23762 // Discussion:
23763 //
23764 // An R8VEC is a vector of R8's.
23765 //
23766 // To explain what is going on here, suppose we had to construct
23767 // a multidimensional quadrature rule as the product of K rules
23768 // for 1D quadrature.
23769 //
23770 // The product rule will be represented as a list of points and weights.
23771 //
23772 // The J-th item in the product rule will be associated with
23773 // item J1 of 1D rule 1,
23774 // item J2 of 1D rule 2,
23775 // ...,
23776 // item JK of 1D rule K.
23777 //
23778 // In particular,
23779 // X(J) = ( X(1,J1), X(2,J2), ..., X(K,JK))
23780 // and
23781 // W(J) = W(1,J1) * W(2,J2) * ... * W(K,JK)
23782 //
23783 // So we can construct the quadrature rule if we can properly
23784 // distribute the information in the 1D quadrature rules.
23785 //
23786 // This routine carries out that task for the weights W.
23787 //
23788 // Another way to do this would be to compute, one by one, the
23789 // set of all possible indices (J1,J2,...,JK), and then index
23790 // the appropriate information. An advantage of the method shown
23791 // here is that you can process the K-th set of information and
23792 // then discard it.
23793 //
23794 // Example:
23795 //
23796 // Rule 1:
23797 // Order = 4
23798 // W(1:4) = ( 2, 3, 5, 7 )
23799 //
23800 // Rule 2:
23801 // Order = 3
23802 // W(1:3) = ( 11, 13, 17 )
23803 //
23804 // Rule 3:
23805 // Order = 2
23806 // W(1:2) = ( 19, 23 )
23807 //
23808 // Product Rule:
23809 // Order = 24
23810 // W(1:24) =
23811 // ( 2 * 11 * 19 )
23812 // ( 3 * 11 * 19 )
23813 // ( 4 * 11 * 19 )
23814 // ( 7 * 11 * 19 )
23815 // ( 2 * 13 * 19 )
23816 // ( 3 * 13 * 19 )
23817 // ( 5 * 13 * 19 )
23818 // ( 7 * 13 * 19 )
23819 // ( 2 * 17 * 19 )
23820 // ( 3 * 17 * 19 )
23821 // ( 5 * 17 * 19 )
23822 // ( 7 * 17 * 19 )
23823 // ( 2 * 11 * 23 )
23824 // ( 3 * 11 * 23 )
23825 // ( 5 * 11 * 23 )
23826 // ( 7 * 11 * 23 )
23827 // ( 2 * 13 * 23 )
23828 // ( 3 * 13 * 23 )
23829 // ( 5 * 13 * 23 )
23830 // ( 7 * 13 * 23 )
23831 // ( 2 * 17 * 23 )
23832 // ( 3 * 17 * 23 )
23833 // ( 5 * 17 * 23 )
23834 // ( 7 * 17 * 23 )
23835 //
23836 // Licensing:
23837 //
23838 // This code is distributed under the GNU LGPL license.
23839 //
23840 // Modified:
23841 //
23842 // 18 April 2009
23843 //
23844 // Author:
23845 //
23846 // John Burkardt
23847 //
23848 // Parameters:
23849 //
23850 // Input, int FACTOR_INDEX, the index of the factor being processed.
23851 // The first factor processed must be factor 0.
23852 //
23853 // Input, int FACTOR_ORDER, the order of the factor.
23854 //
23855 // Input, double FACTOR_VALUE[FACTOR_ORDER], the factor values for
23856 // factor FACTOR_INDEX.
23857 //
23858 // Input, int FACTOR_NUM, the number of factors.
23859 //
23860 // Input, int POINT_NUM, the number of elements in the direct product.
23861 //
23862 // Input/output, double W[POINT_NUM], the elements of the
23863 // direct product, which are built up gradually.
23864 //
23865 // Local Parameters:
23866 //
23867 // Local, integer START, the first location of a block of values to set.
23868 //
23869 // Local, integer CONTIG, the number of consecutive values to set.
23870 //
23871 // Local, integer SKIP, the distance from the current value of START
23872 // to the next location of a block of values to set.
23873 //
23874 // Local, integer REP, the number of blocks of values to set.
23875 //
23876 {
23877  static int contig = 0;
23878  int i;
23879  int j;
23880  int k;
23881  static int rep = 0;
23882  static int skip = 0;
23883  int start;
23884 
23885  if ( factor_index == 0 )
23886  {
23887  contig = 1;
23888  skip = 1;
23889  rep = point_num;
23890  for ( i = 0; i < point_num; i++ )
23891  {
23892  w[i] = 1.0;
23893  }
23894  }
23895 
23896  rep = rep / factor_order;
23897  skip = skip * factor_order;
23898 
23899  for ( j = 0; j < factor_order; j++ )
23900  {
23901  start = 0 + j * contig;
23902 
23903  for ( k = 1; k <= rep; k++ )
23904  {
23905  for ( i = start; i < start + contig; i++ )
23906  {
23907  w[i] = w[i] * factor_value[j];
23908  }
23909  start = start + skip;
23910  }
23911  }
23912 
23913  contig = contig * factor_order;
23914 
23915  return;
23916 }
23917 //**************************************************************************80
23918 
23919 double SandiaRules::r8vec_dot_product ( int n, double a1[], double a2[] )
23920 
23921 //**************************************************************************80
23922 //
23923 // Purpose:
23924 //
23925 // R8VEC_DOT_PRODUCT computes the dot product of a pair of R8VEC's.
23926 //
23927 // Discussion:
23928 //
23929 // An R8VEC is a vector of R8's.
23930 //
23931 // Licensing:
23932 //
23933 // This code is distributed under the GNU LGPL license.
23934 //
23935 // Modified:
23936 //
23937 // 03 July 2005
23938 //
23939 // Author:
23940 //
23941 // John Burkardt
23942 //
23943 // Parameters:
23944 //
23945 // Input, int N, the number of entries in the vectors.
23946 //
23947 // Input, double A1[N], A2[N], the two vectors to be considered.
23948 //
23949 // Output, double R8VEC_DOT_PRODUCT, the dot product of the vectors.
23950 //
23951 {
23952  int i;
23953  double value;
23954 
23955  value = 0.0;
23956  for ( i = 0; i < n; i++ )
23957  {
23958  value = value + a1[i] * a2[i];
23959  }
23960  return value;
23961 }
23962 //**************************************************************************80
23963 
23964 double SandiaRules::r8vec_i4vec_dot_product ( int n, double r8vec[], int i4vec[] )
23965 
23966 //**************************************************************************80
23967 //
23968 // Purpose:
23969 //
23970 // R8VEC_I4VEC_DOT_PRODUCT computes the dot product of an R8VEC and an I4VEC.
23971 //
23972 // Discussion:
23973 //
23974 // An R8VEC is a vector of R8's.
23975 //
23976 // An I4VEC is a vector of I4's.
23977 //
23978 // Licensing:
23979 //
23980 // This code is distributed under the GNU LGPL license.
23981 //
23982 // Modified:
23983 //
23984 // 30 June 2009
23985 //
23986 // Author:
23987 //
23988 // John Burkardt
23989 //
23990 // Parameters:
23991 //
23992 // Input, int N, the number of entries in the vectors.
23993 //
23994 // Input, double R8VEC[N], the first vector.
23995 //
23996 // Input, int I4VEC[N], the second vector.
23997 //
23998 // Output, double R8VEC_I4VEC_DOT_PRODUCT, the dot product of the vectors.
23999 //
24000 {
24001  int i;
24002  double value;
24003 
24004  value = 0.0;
24005  for ( i = 0; i < n; i++ )
24006  {
24007  value = value + r8vec[i] * ( double ) ( i4vec[i] );
24008  }
24009  return value;
24010 }
24011 //**************************************************************************80
24012 
24013 void SandiaRules::r8vec_index_sorted_range ( int n, double r[], int indx[], double r_lo,
24014  double r_hi, int *i_lo, int *i_hi )
24015 
24016 //**************************************************************************80
24017 //
24018 // Purpose:
24019 //
24020 // R8VEC_INDEX_SORTED_RANGE: search index sorted vector for elements in a range.
24021 //
24022 // Licensing:
24023 //
24024 // This code is distributed under the GNU LGPL license.
24025 //
24026 // Modified:
24027 //
24028 // 27 September 2010
24029 //
24030 // Author:
24031 //
24032 // John Burkardt
24033 //
24034 // Parameters:
24035 //
24036 // Input, int N, the number of items in the vector.
24037 //
24038 // Input, double R[N], the index sorted vector.
24039 //
24040 // Input, int INDX[N], the vector used to sort R.
24041 // The vector R[INDX[*]] is sorted.
24042 //
24043 // Input, double R_LO, R_HI, the limits of the range.
24044 //
24045 // Output, int *I_LO, *I_HI, the range of indices
24046 // so that I_LO <= I <= I_HI => R_LO <= R[INDX[I]] <= R_HI. If no
24047 // values in R lie in the range, then I_HI < I_LO will be returned.
24048 //
24049 {
24050  int i1;
24051  int i2;
24052  int j1;
24053  int j2;
24054 //
24055 // Cases we can handle immediately.
24056 //
24057  if ( r[indx[n-1]] < r_lo )
24058  {
24059  *i_lo = n;
24060  *i_hi = n - 1;
24061  return;
24062  }
24063 
24064  if ( r_hi < r[indx[0]] )
24065  {
24066  *i_lo = 0;
24067  *i_hi = -1;
24068  return;
24069  }
24070 //
24071 // Are there are least two intervals?
24072 //
24073  if ( n == 1 )
24074  {
24075  if ( r_lo <= r[indx[0]] && r[indx[0]] <= r_hi )
24076  {
24077  *i_lo = 0;
24078  *i_hi = 0;
24079  }
24080  else
24081  {
24082  *i_lo = -1;
24083  *i_hi = -2;
24084  }
24085  return;
24086  }
24087 //
24088 // Bracket R_LO.
24089 //
24090  if ( r_lo <= r[indx[0]] )
24091  {
24092  *i_lo = 0;
24093  }
24094  else
24095  {
24096 //
24097 // R_LO is in one of the intervals spanned by R(INDX(J1)) to R(INDX(J2)).
24098 // Examine the intermediate interval [R(INDX(I1)), R(INDX(I1+1))].
24099 // Does R_LO lie here, or below or above?
24100 //
24101  j1 = 0;
24102  j2 = n - 1;
24103  i1 = ( j1 + j2 - 1 ) / 2;
24104  i2 = i1 + 1;
24105 
24106  for ( ; ; )
24107  {
24108  if ( r_lo < r[indx[i1]] )
24109  {
24110  j2 = i1;
24111  i1 = ( j1 + j2 - 1 ) / 2;
24112  i2 = i1 + 1;
24113  }
24114  else if ( r[indx[i2]] < r_lo )
24115  {
24116  j1 = i2;
24117  i1 = ( j1 + j2 - 1 ) / 2;
24118  i2 = i1 + 1;
24119  }
24120  else
24121  {
24122  *i_lo = i1;
24123  break;
24124  }
24125  }
24126  }
24127 //
24128 // Bracket R_HI.
24129 //
24130  if ( r[indx[n-1]] <= r_hi )
24131  {
24132  *i_hi = n - 1;
24133  }
24134  else
24135  {
24136  j1 = *i_lo;
24137  j2 = n - 1;
24138  i1 = ( j1 + j2 - 1 ) / 2;
24139  i2 = i1 + 1;
24140 
24141  for ( ; ; )
24142  {
24143  if ( r_hi < r[indx[i1]] )
24144  {
24145  j2 = i1;
24146  i1 = ( j1 + j2 - 1 ) / 2;
24147  i2 = i1 + 1;
24148  }
24149  else if ( r[indx[i2]] < r_hi )
24150  {
24151  j1 = i2;
24152  i1 = ( j1 + j2 - 1 ) / 2;
24153  i2 = i1 + 1;
24154  }
24155  else
24156  {
24157  *i_hi = i2;
24158  break;
24159  }
24160  }
24161  }
24162 //
24163 // We expect to have computed the largest I_LO and smallest I_HI such that
24164 // R(INDX(I_LO)) <= R_LO <= R_HI <= R(INDX(I_HI))
24165 // but what we want is actually
24166 // R_LO <= R(INDX(I_LO)) <= R(INDX(I_HI)) <= R_HI
24167 // which we can usually get simply by incrementing I_LO and decrementing I_HI.
24168 //
24169  if ( r[indx[*i_lo]] < r_lo )
24170  {
24171  *i_lo = *i_lo + 1;
24172  if ( n - 1 < *i_lo )
24173  {
24174  *i_hi = *i_lo - 1;
24175  }
24176  }
24177 
24178  if ( r_hi < r[indx[*i_hi]] )
24179  {
24180  *i_hi = *i_hi - 1;
24181  if ( i_hi < 0 )
24182  {
24183  *i_lo = *i_hi + 1;
24184  }
24185  }
24186 
24187  return;
24188 }
24189 //**************************************************************************80
24190 
24191 void SandiaRules::r8vec_indexed_heap_d ( int n, double a[], int indx[] )
24192 
24193 //**************************************************************************80
24194 //
24195 // Purpose:
24196 //
24197 // R8VEC_INDEXED_HEAP_D creates a descending heap from an indexed R8VEC.
24198 //
24199 // Discussion:
24200 //
24201 // An R8VEC is a vector of R8's.
24202 //
24203 // An indexed R8VEC is an R8VEC of data values, and an R8VEC of N indices,
24204 // each referencing an entry of the data vector.
24205 //
24206 // The function adjusts the index vector INDX so that, for 1 <= J <= N/2,
24207 // we have:
24208 // A[INDX[2*J+1]] <= A[INDX[J]]
24209 // and
24210 // A[INDX[2*J+2]] <= A[INDX[J]]
24211 //
24212 // Licensing:
24213 //
24214 // This code is distributed under the GNU LGPL license.
24215 //
24216 // Modified:
24217 //
24218 // 18 August 2010
24219 //
24220 // Author:
24221 //
24222 // John Burkardt
24223 //
24224 // Reference:
24225 //
24226 // Albert Nijenhuis, Herbert Wilf,
24227 // Combinatorial Algorithms for Computers and Calculators,
24228 // Academic Press, 1978,
24229 // ISBN: 0-12-519260-6,
24230 // LC: QA164.N54.
24231 //
24232 // Parameters:
24233 //
24234 // Input, int N, the size of the index array.
24235 //
24236 // Input, double A[*], the data vector.
24237 //
24238 // Input/output, int INDX[N], the index array.
24239 // Each entry of INDX must be a valid index for the array A.
24240 // On output, the indices have been reordered into a descending heap.
24241 //
24242 {
24243  int i;
24244  int ifree;
24245  int key;
24246  int m;
24247 //
24248 // Only nodes N/2 - 1 down to 0 can be "parent" nodes.
24249 //
24250  for ( i = ( n / 2 ) - 1; 0 <= i; i-- )
24251  {
24252 //
24253 // Copy the value out of the parent node.
24254 // Position IFREE is now "open".
24255 //
24256  key = indx[i];
24257  ifree = i;
24258 
24259  for ( ; ; )
24260  {
24261 //
24262 // Positions 2*IFREE+1 and 2*IFREE+2 are the descendants of position
24263 // IFREE. (One or both may not exist because they exceed N-1.)
24264 //
24265  m = 2 * ifree + 1;
24266 //
24267 // Does the first position exist?
24268 //
24269  if ( n - 1 < m )
24270  {
24271  break;
24272  }
24273 //
24274 // Does the second position exist?
24275 //
24276  if ( m + 1 <= n - 1 )
24277  {
24278 //
24279 // If both positions exist, take the larger of the two values,
24280 // and update M if necessary.
24281 //
24282  if ( a[indx[m]] < a[indx[m+1]] )
24283  {
24284  m = m + 1;
24285  }
24286  }
24287 //
24288 // If the large descendant is larger than KEY, move it up,
24289 // and update IFREE, the location of the free position, and
24290 // consider the descendants of THIS position.
24291 //
24292  if ( a[indx[m]] <= a[key] )
24293  {
24294  break;
24295  }
24296 
24297  indx[ifree] = indx[m];
24298  ifree = m;
24299  }
24300 //
24301 // Once there is no more shifting to do, KEY moves into the free spot IFREE.
24302 //
24303  indx[ifree] = key;
24304  }
24305 
24306  return;
24307 }
24308 //**************************************************************************80
24309 
24310 int SandiaRules::r8vec_indexed_heap_d_extract ( int *n, double a[], int indx[] )
24311 
24312 //**************************************************************************80
24313 //
24314 // Purpose:
24315 //
24316 // R8VEC_INDEXED_HEAP_D_EXTRACT: extract from heap descending indexed R8VEC.
24317 //
24318 // Discussion:
24319 //
24320 // An R8VEC is a vector of R8's.
24321 //
24322 // An indexed R8VEC is an R8VEC of data values, and an R8VEC of N indices,
24323 // each referencing an entry of the data vector.
24324 //
24325 // The routine finds the maximum value in the heap, returns that value to the
24326 // user, deletes that value from the heap, and restores the heap to its
24327 // proper form.
24328 //
24329 // Note that the argument N must be a variable, which will be decremented
24330 // before return, and that INDX will hold one less value on output than it
24331 // held on input.
24332 //
24333 // This is one of three functions needed to model a priority queue.
24334 //
24335 // Licensing:
24336 //
24337 // This code is distributed under the GNU LGPL license.
24338 //
24339 // Modified:
24340 //
24341 // 18 August 2010
24342 //
24343 // Author:
24344 //
24345 // John Burkardt
24346 //
24347 // Reference:
24348 //
24349 // Thomas Cormen, Charles Leiserson, Ronald Rivest,
24350 // Introduction to Algorithms,
24351 // MIT Press, 2001,
24352 // ISBN: 0262032937,
24353 // LC: QA76.C662.
24354 //
24355 // Parameters:
24356 //
24357 // Input/output, int *N, the number of items in the index vector.
24358 //
24359 // Input, double A[*], the data vector.
24360 //
24361 // Input/output, int INDX[N], the index vector.
24362 //
24363 // Output, int R8VEC_INDEXED_HEAP_D_EXTRACT, the index in A of the item of
24364 // maximum value, which has now been removed from the heap.
24365 //
24366 {
24367  int indx_extract;
24368 
24369  if ( *n < 1 )
24370  {
24371  std::cerr << "\n";
24372  std::cerr << "R8VEC_INDEXED_HEAP_D_EXTRACT - Fatal error!\n";
24373  std::cerr << " The heap is empty.\n";
24374  std::exit ( 1 );
24375  }
24376 //
24377 // Get the index of the maximum value.
24378 //
24379  indx_extract = indx[0];
24380 
24381  if ( *n == 1 )
24382  {
24383  *n = 0;
24384  return indx_extract;
24385  }
24386 //
24387 // Shift the last index down.
24388 //
24389  indx[0] = indx[*n-1];
24390 //
24391 // Restore the heap structure.
24392 //
24393  *n = *n - 1;
24394  r8vec_indexed_heap_d ( *n, a, indx );
24395 
24396  return indx_extract;
24397 }
24398 //**************************************************************************80
24399 
24400 void SandiaRules::r8vec_indexed_heap_d_insert ( int *n, double a[], int indx[],
24401  int indx_insert )
24402 
24403 //**************************************************************************80
24404 //
24405 // Purpose:
24406 //
24407 // R8VEC_INDEXED_HEAP_D_INSERT: insert value into heap descending indexed R8VEC.
24408 //
24409 // Discussion:
24410 //
24411 // An R8VEC is a vector of R8's.
24412 //
24413 // An indexed R8VEC is an R8VEC of data values, and an R8VEC of N indices,
24414 // each referencing an entry of the data vector.
24415 //
24416 // Note that the argument N must be a variable, and will be incremented before
24417 // return, and that INDX must be able to hold one more entry on output than
24418 // it held on input.
24419 //
24420 // This is one of three functions needed to model a priority queue.
24421 //
24422 // Licensing:
24423 //
24424 // This code is distributed under the GNU LGPL license.
24425 //
24426 // Modified:
24427 //
24428 // 18 August 2010
24429 //
24430 // Author:
24431 //
24432 // John Burkardt
24433 //
24434 // Reference:
24435 //
24436 // Thomas Cormen, Charles Leiserson, Ronald Rivest,
24437 // Introduction to Algorithms,
24438 // MIT Press, 2001,
24439 // ISBN: 0262032937,
24440 // LC: QA76.C662.
24441 //
24442 // Parameters:
24443 //
24444 // Input/output, int *N, the number of items in the index vector.
24445 //
24446 // Input, double A[*], the data vector.
24447 //
24448 // Input/output, int INDX[N], the index vector.
24449 //
24450 // Input, int INDX_INSERT, the index in A of the value
24451 // to be inserted into the heap.
24452 //
24453 {
24454  int i;
24455  int parent;
24456 
24457  *n = *n + 1;
24458  i = *n - 1;
24459 
24460  while ( 0 < i )
24461  {
24462  parent = ( i - 1 ) / 2;
24463 
24464  if ( a[indx_insert] <= a[indx[parent]] )
24465  {
24466  break;
24467  }
24468 
24469  indx[i] = indx[parent];
24470  i = parent;
24471  }
24472 
24473  indx[i] = indx_insert;
24474 
24475  return;
24476 }
24477 //**************************************************************************80
24478 
24479 int SandiaRules::r8vec_indexed_heap_d_max ( int n, double a[], int indx[] )
24480 
24481 //**************************************************************************80
24482 //
24483 // Purpose:
24484 //
24485 // R8VEC_INDEXED_HEAP_D_MAX: maximum value in heap descending indexed R8VEC.
24486 //
24487 // Discussion:
24488 //
24489 // An R8VEC is a vector of R8's.
24490 //
24491 // An indexed R8VEC is an R8VEC of data values, and an R8VEC of N indices,
24492 // each referencing an entry of the data vector.
24493 //
24494 // This is one of three functions needed to model a priority queue.
24495 //
24496 // Licensing:
24497 //
24498 // This code is distributed under the GNU LGPL license.
24499 //
24500 // Modified:
24501 //
24502 // 18 August 2010
24503 //
24504 // Author:
24505 //
24506 // John Burkardt
24507 //
24508 // Reference:
24509 //
24510 // Thomas Cormen, Charles Leiserson, Ronald Rivest,
24511 // Introduction to Algorithms,
24512 // MIT Press, 2001,
24513 // ISBN: 0262032937,
24514 // LC: QA76.C662.
24515 //
24516 // Parameters:
24517 //
24518 // Input, int N, the number of items in the index vector.
24519 //
24520 // Input, double A[*], the data vector.
24521 //
24522 // Input, int INDX[N], the index vector.
24523 //
24524 // Output, int R8VEC_INDEXED_HEAP_D_MAX, the index in A of the maximum value
24525 // in the heap.
24526 //
24527 {
24528  int indx_max;
24529 
24530  indx_max = indx[0];
24531 
24532  return indx_max;
24533 }
24534 //**************************************************************************80
24535 
24536 double *SandiaRules::r8vec_legendre_new ( int n, double a_first, double a_last )
24537 
24538 //**************************************************************************80
24539 //
24540 // Purpose:
24541 //
24542 // R8VEC_LEGENDRE_NEW creates a vector of Chebyshev spaced values.
24543 //
24544 // Discussion:
24545 //
24546 // An R8VEC is a vector of R8's.
24547 //
24548 // Licensing:
24549 //
24550 // This code is distributed under the GNU LGPL license.
24551 //
24552 // Modified:
24553 //
24554 // 17 June 2011
24555 //
24556 // Author:
24557 //
24558 // John Burkardt
24559 //
24560 // Parameters:
24561 //
24562 // Input, int N, the number of entries in the vector.
24563 //
24564 // Input, double A_FIRST, A_LAST, the first and last entries.
24565 //
24566 // Output, double R8VEC_LEGENDRE_NEW[N], a vector of Legendre spaced data.
24567 //
24568 {
24569  double *a;
24570  int i;
24571 
24572  a = legendre_zeros ( n );
24573 
24574  for ( i = 0; i < n; i++ )
24575  {
24576  a[i] = ( ( 1.0 - a[i] ) * a_first
24577  + ( 1.0 + a[i] ) * a_last )
24578  / 2.0;
24579  }
24580  return a;
24581 }
24582 //**************************************************************************80
24583 
24584 double *SandiaRules::r8vec_linspace_new ( int n, double a_first, double a_last )
24585 
24586 //**************************************************************************80
24587 //
24588 // Purpose:
24589 //
24590 // R8VEC_LINSPACE_NEW creates a vector of linearly spaced values.
24591 //
24592 // Discussion:
24593 //
24594 // An R8VEC is a vector of R8's.
24595 //
24596 // Licensing:
24597 //
24598 // This code is distributed under the GNU LGPL license.
24599 //
24600 // Modified:
24601 //
24602 // 14 March 2011
24603 //
24604 // Author:
24605 //
24606 // John Burkardt
24607 //
24608 // Parameters:
24609 //
24610 // Input, int N, the number of entries in the vector.
24611 //
24612 // Input, double A_FIRST, A_LAST, the first and last entries.
24613 //
24614 // Output, double R8VEC_LINSPACE_NEW[N], a vector of linearly spaced data.
24615 //
24616 {
24617  double *a;
24618  int i;
24619 
24620  a = new double[n];
24621 
24622  if ( n == 1 )
24623  {
24624  a[0] = ( a_first + a_last ) / 2.0;
24625  }
24626  else
24627  {
24628  for ( i = 0; i < n; i++ )
24629  {
24630  a[i] = ( ( double ) ( n - 1 - i ) * a_first
24631  + ( double ) ( i ) * a_last )
24632  / ( double ) ( n - 1 );
24633  }
24634  }
24635  return a;
24636 }
24637 //**************************************************************************80
24638 
24639 double SandiaRules::r8vec_min ( int n, double r8vec[] )
24640 
24641 //**************************************************************************80
24642 //
24643 // Purpose:
24644 //
24645 // R8VEC_MIN returns the value of the minimum element in an R8VEC.
24646 //
24647 // Discussion:
24648 //
24649 // An R8VEC is a vector of R8's.
24650 //
24651 // Licensing:
24652 //
24653 // This code is distributed under the GNU LGPL license.
24654 //
24655 // Modified:
24656 //
24657 // 02 July 2005
24658 //
24659 // Author:
24660 //
24661 // John Burkardt
24662 //
24663 // Parameters:
24664 //
24665 // Input, int N, the number of entries in the array.
24666 //
24667 // Input, double R8VEC[N], the array to be checked.
24668 //
24669 // Output, double R8VEC_MIN, the value of the minimum element.
24670 //
24671 {
24672  int i;
24673  double value;
24674 
24675  value = r8vec[0];
24676 
24677  for ( i = 1; i < n; i++ )
24678  {
24679  if ( r8vec[i] < value )
24680  {
24681  value = r8vec[i];
24682  }
24683  }
24684  return value;
24685 }
24686 //**************************************************************************80
24687 
24688 double SandiaRules::r8vec_min_pos ( int n, double a[] )
24689 
24690 //**************************************************************************80
24691 //
24692 // Purpose:
24693 //
24694 // R8VEC_MIN_POS returns the minimum positive value of an R8VEC.
24695 //
24696 // Discussion:
24697 //
24698 // An R8VEC is a vector of R8's.
24699 //
24700 // Licensing:
24701 //
24702 // This code is distributed under the GNU LGPL license.
24703 //
24704 // Modified:
24705 //
24706 // 08 November 2009
24707 //
24708 // Author:
24709 //
24710 // John Burkardt
24711 //
24712 // Parameters:
24713 //
24714 // Input, int N, the number of entries.
24715 //
24716 // Input, double A[N], the array.
24717 //
24718 // Output, double R8VEC_MIN_POS, the smallest positive entry,
24719 // or R8_HUGE if no entry is positive.
24720 //
24721 {
24722  int i;
24723  double r8_huge = 1.0E+30;
24724  double value;
24725 
24726  value = r8_huge;
24727 
24728  for ( i = 0; i < n; i++ )
24729  {
24730  if ( 0.0 < a[i] )
24731  {
24732  if ( a[i] < value )
24733  {
24734  value = a[i];
24735  }
24736  }
24737  }
24738  return value;
24739 }
24740 //**************************************************************************80
24741 
24742 void SandiaRules::r8vec_print ( int n, double a[], std::string title )
24743 
24744 //**************************************************************************80
24745 //
24746 // Purpose:
24747 //
24748 // R8VEC_PRINT prints an R8VEC.
24749 //
24750 // Discussion:
24751 //
24752 // An R8VEC is a vector of R8's.
24753 //
24754 // Licensing:
24755 //
24756 // This code is distributed under the GNU LGPL license.
24757 //
24758 // Modified:
24759 //
24760 // 16 August 2004
24761 //
24762 // Author:
24763 //
24764 // John Burkardt
24765 //
24766 // Parameters:
24767 //
24768 // Input, int N, the number of components of the vector.
24769 //
24770 // Input, double A[N], the vector to be printed.
24771 //
24772 // Input, string TITLE, a title.
24773 //
24774 {
24775  int i;
24776 
24777  std::cout << "\n";
24778  std::cout << title << "\n";
24779  std::cout << "\n";
24780  for ( i = 0; i < n; i++ )
24781  {
24782  std::cout << " " << std::setw(8) << i
24783  << ": " << std::setw(14) << a[i] << "\n";
24784  }
24785 
24786  return;
24787 }
24788 //**************************************************************************80
24789 
24790 void SandiaRules::r8vec_scale ( double s, int n, double a[] )
24791 
24792 //**************************************************************************80
24793 //
24794 // Purpose:
24795 //
24796 // R8VEC_SCALE multiples an R8VEC by a scale factor.
24797 //
24798 // Discussion:
24799 //
24800 // An R8VEC is a vector of R8's.
24801 //
24802 // Licensing:
24803 //
24804 // This code is distributed under the GNU LGPL license.
24805 //
24806 // Modified:
24807 //
24808 // 22 September 2011
24809 //
24810 // Author:
24811 //
24812 // John Burkardt
24813 //
24814 // Parameters:
24815 //
24816 // Input, double S, the scale factor.
24817 //
24818 // Input, int N, the number of entries in the vectors.
24819 //
24820 // Input/output, double A[N], the vector to be scaled.
24821 // On output, A[] = S * A[].
24822 //
24823 {
24824  int i;
24825 
24826  for ( i = 0; i < n; i++ )
24827  {
24828  a[i] = s * a[i];
24829  }
24830  return;
24831 }
24832 //**************************************************************************80
24833 
24834 void SandiaRules::r8vec_sort_heap_index_a ( int n, double a[], int indx[] )
24835 
24836 //**************************************************************************80
24837 //
24838 // Purpose:
24839 //
24840 // R8VEC_SORT_HEAP_INDEX_A does an indexed heap ascending sort of an R8VEC
24841 //
24842 // Discussion:
24843 //
24844 // An R8VEC is a vector of R8's.
24845 //
24846 // The sorting is not actually carried out. Rather an index array is
24847 // created which defines the sorting. This array may be used to sort
24848 // or index the array, or to sort or index related arrays keyed on the
24849 // original array.
24850 //
24851 // Once the index array is computed, the sorting can be carried out
24852 // "implicitly:
24853 //
24854 // a(indx(*))
24855 //
24856 // or explicitly, by the call
24857 //
24858 // r8vec_permute ( n, indx, 0, a )
24859 //
24860 // after which a(*) is sorted.
24861 //
24862 // Note that the index vector is 0-based.
24863 //
24864 // Licensing:
24865 //
24866 // This code is distributed under the GNU LGPL license.
24867 //
24868 // Modified:
24869 //
24870 // 02 October 2010
24871 //
24872 // Author:
24873 //
24874 // John Burkardt
24875 //
24876 // Parameters:
24877 //
24878 // Input, int N, the number of entries in the array.
24879 //
24880 // Input, double A[N], an array to be index-sorted.
24881 //
24882 // Output, int INDX[N], contains the sort index. The
24883 // I-th element of the sorted array is A(INDX(I)).
24884 //
24885 {
24886  double aval;
24887  int i;
24888  int indxt;
24889  int ir;
24890  int j;
24891  int l;
24892 
24893  if ( n < 1 )
24894  {
24895  return;
24896  }
24897 
24898  for ( i = 0; i < n; i++ )
24899  {
24900  indx[i] = i;
24901  }
24902 
24903  if ( n == 1 )
24904  {
24905  return;
24906  }
24907 
24908  l = n / 2 + 1;
24909  ir = n;
24910 
24911  for ( ; ; )
24912  {
24913  if ( 1 < l )
24914  {
24915  l = l - 1;
24916  indxt = indx[l-1];
24917  aval = a[indxt];
24918  }
24919  else
24920  {
24921  indxt = indx[ir-1];
24922  aval = a[indxt];
24923  indx[ir-1] = indx[0];
24924  ir = ir - 1;
24925 
24926  if ( ir == 1 )
24927  {
24928  indx[0] = indxt;
24929  break;
24930  }
24931  }
24932 
24933  i = l;
24934  j = l + l;
24935 
24936  while ( j <= ir )
24937  {
24938  if ( j < ir )
24939  {
24940  if ( a[indx[j-1]] < a[indx[j]] )
24941  {
24942  j = j + 1;
24943  }
24944  }
24945 
24946  if ( aval < a[indx[j-1]] )
24947  {
24948  indx[i-1] = indx[j-1];
24949  i = j;
24950  j = j + j;
24951  }
24952  else
24953  {
24954  j = ir + 1;
24955  }
24956  }
24957  indx[i-1] = indxt;
24958  }
24959 
24960  return;
24961 }
24962 //**************************************************************************80
24963 
24965 
24966 //**************************************************************************80
24967 //
24968 // Purpose:
24969 //
24970 // R8VEC_SORT_HEAP_INDEX_A_NEW does an indexed heap ascending sort of an R8VEC
24971 //
24972 // Discussion:
24973 //
24974 // An R8VEC is a vector of R8's.
24975 //
24976 // The sorting is not actually carried out. Rather an index array is
24977 // created which defines the sorting. This array may be used to sort
24978 // or index the array, or to sort or index related arrays keyed on the
24979 // original array.
24980 //
24981 // Once the index array is computed, the sorting can be carried out
24982 // "implicitly:
24983 //
24984 // a(indx(*))
24985 //
24986 // or explicitly, by the call
24987 //
24988 // r8vec_permute ( n, indx, 0, a )
24989 //
24990 // after which a(*) is sorted.
24991 //
24992 // Note that the index vector is 0-based.
24993 //
24994 // Licensing:
24995 //
24996 // This code is distributed under the GNU LGPL license.
24997 //
24998 // Modified:
24999 //
25000 // 02 October 2010
25001 //
25002 // Author:
25003 //
25004 // John Burkardt
25005 //
25006 // Parameters:
25007 //
25008 // Input, int N, the number of entries in the array.
25009 //
25010 // Input, double A[N], an array to be index-sorted.
25011 //
25012 // Output, int R8VEC_SORT_HEAP_INDEX_A_NEW[N], contains the sort index. The
25013 // I-th element of the sorted array is A(INDX(I)).
25014 //
25015 {
25016  double aval;
25017  int i;
25018  int *indx;
25019  int indxt;
25020  int ir;
25021  int j;
25022  int l;
25023 
25024  if ( n < 1 )
25025  {
25026  return NULL;
25027  }
25028 
25029  indx = new int[n];
25030 
25031  for ( i = 0; i < n; i++ )
25032  {
25033  indx[i] = i;
25034  }
25035 
25036  if ( n == 1 )
25037  {
25038  return indx;
25039  }
25040 
25041  l = n / 2 + 1;
25042  ir = n;
25043 
25044  for ( ; ; )
25045  {
25046  if ( 1 < l )
25047  {
25048  l = l - 1;
25049  indxt = indx[l-1];
25050  aval = a[indxt];
25051  }
25052  else
25053  {
25054  indxt = indx[ir-1];
25055  aval = a[indxt];
25056  indx[ir-1] = indx[0];
25057  ir = ir - 1;
25058 
25059  if ( ir == 1 )
25060  {
25061  indx[0] = indxt;
25062  break;
25063  }
25064  }
25065 
25066  i = l;
25067  j = l + l;
25068 
25069  while ( j <= ir )
25070  {
25071  if ( j < ir )
25072  {
25073  if ( a[indx[j-1]] < a[indx[j]] )
25074  {
25075  j = j + 1;
25076  }
25077  }
25078 
25079  if ( aval < a[indx[j-1]] )
25080  {
25081  indx[i-1] = indx[j-1];
25082  i = j;
25083  j = j + j;
25084  }
25085  else
25086  {
25087  j = ir + 1;
25088  }
25089  }
25090  indx[i-1] = indxt;
25091  }
25092 
25093  return indx;
25094 }
25095 //**************************************************************************80
25096 
25097 void SandiaRules::r8vec_stutter ( int n, double a[], int m, double am[] )
25098 
25099 //**************************************************************************80
25100 //
25101 // Purpose:
25102 //
25103 // R8VEC_STUTTER makes a "stuttering" copy of an R8VEC.
25104 //
25105 // Discussion:
25106 //
25107 // An R8VEC is a vector of R8's.
25108 //
25109 // Applying a stuttering factor M of 3, the vector A = ( 1, 5, 8 ) becomes
25110 // AM = ( 1, 1, 1, 5, 5, 5, 8, 8, 8 ).
25111 //
25112 // Licensing:
25113 //
25114 // This code is distributed under the GNU LGPL license.
25115 //
25116 // Modified:
25117 //
25118 // 28 March 2011
25119 //
25120 // Author:
25121 //
25122 // John Burkardt
25123 //
25124 // Parameters:
25125 //
25126 // Input, int N, the size of the input vector.
25127 //
25128 // Input, double A[N], the vector.
25129 //
25130 // Input, int M, the "stuttering factor".
25131 //
25132 // Output, double AM[M*N], the stuttering vector.
25133 //
25134 {
25135  int i;
25136  int j;
25137  int k;
25138 
25139  k = 0;
25140  for ( i = 0; i < n; i++ )
25141  {
25142  for ( j = 0; j < m; j++ )
25143  {
25144  am[k] = a[i];
25145  k = k + 1;
25146  }
25147  }
25148  return;
25149 }
25150 //**************************************************************************80
25151 
25152 double SandiaRules::r8vec_sum ( int n, double a[] )
25153 
25154 //**************************************************************************80
25155 //
25156 // Purpose:
25157 //
25158 // R8VEC_SUM returns the sum of an R8VEC.
25159 //
25160 // Discussion:
25161 //
25162 // An R8VEC is a double precision vector.
25163 //
25164 // Licensing:
25165 //
25166 // This code is distributed under the GNU LGPL license.
25167 //
25168 // Modified:
25169 //
25170 // 15 October 2004
25171 //
25172 // Author:
25173 //
25174 // John Burkardt
25175 //
25176 // Parameters:
25177 //
25178 // Input, int N, the number of entries in the vector.
25179 //
25180 // Input, double A[N], the vector.
25181 //
25182 // Output, double R8VEC_SUM, the sum of the vector.
25183 //
25184 {
25185  int i;
25186  double value;
25187 
25188  value = 0.0;
25189  for ( i = 0; i < n; i++ )
25190  {
25191  value = value + a[i];
25192  }
25193 
25194  return value;
25195 }
25196 //**************************************************************************80
25197 
25198 void SandiaRules::r8vec_uniform_01 ( int n, int *seed, double r[] )
25199 
25200 //**************************************************************************80
25201 //
25202 // Purpose:
25203 //
25204 // R8VEC_UNIFORM_01 returns a unit pseudorandom R8VEC.
25205 //
25206 // Discussion:
25207 //
25208 // This routine implements the recursion
25209 //
25210 // seed = ( 16807 * seed ) mod ( 2^31 - 1 )
25211 // u = seed / ( 2^31 - 1 )
25212 //
25213 // The integer arithmetic never requires more than 32 bits,
25214 // including a sign bit.
25215 //
25216 // Licensing:
25217 //
25218 // This code is distributed under the GNU LGPL license.
25219 //
25220 // Modified:
25221 //
25222 // 19 August 2004
25223 //
25224 // Author:
25225 //
25226 // John Burkardt
25227 //
25228 // Reference:
25229 //
25230 // Paul Bratley, Bennett Fox, Linus Schrage,
25231 // A Guide to Simulation,
25232 // Second Edition,
25233 // Springer, 1987,
25234 // ISBN: 0387964673,
25235 // LC: QA76.9.C65.B73.
25236 //
25237 // Bennett Fox,
25238 // Algorithm 647:
25239 // Implementation and Relative Efficiency of Quasirandom
25240 // Sequence Generators,
25241 // ACM Transactions on Mathematical Software,
25242 // Volume 12, Number 4, December 1986, pages 362-376.
25243 //
25244 // Pierre L'Ecuyer,
25245 // Random Number Generation,
25246 // in Handbook of Simulation,
25247 // edited by Jerry Banks,
25248 // Wiley, 1998,
25249 // ISBN: 0471134031,
25250 // LC: T57.62.H37.
25251 //
25252 // Peter Lewis, Allen Goodman, James Miller,
25253 // A Pseudo-Random Number Generator for the System/360,
25254 // IBM Systems Journal,
25255 // Volume 8, Number 2, 1969, pages 136-143.
25256 //
25257 // Parameters:
25258 //
25259 // Input, int N, the number of entries in the vector.
25260 //
25261 // Input/output, int *SEED, a seed for the random number generator.
25262 //
25263 // Output, double R[N], the vector of pseudorandom values.
25264 //
25265 {
25266  int i;
25267  int i4_huge = 2147483647;
25268  int k;
25269 
25270  if ( *seed == 0 )
25271  {
25272  std::cerr << "\n";
25273  std::cerr << "R8VEC_UNIFORM_01 - Fatal error!\n";
25274  std::cerr << " Input value of SEED = 0.\n";
25275  std::exit ( 1 );
25276  }
25277 
25278  for ( i = 0; i < n; i++ )
25279  {
25280  k = *seed / 127773;
25281 
25282  *seed = 16807 * ( *seed - k * 127773 ) - k * 2836;
25283 
25284  if ( *seed < 0 )
25285  {
25286  *seed = *seed + i4_huge;
25287  }
25288 
25289  r[i] = ( double ) ( *seed ) * 4.656612875E-10;
25290  }
25291 
25292  return;
25293 }
25294 //**************************************************************************80
25295 
25296 double *SandiaRules::r8vec_uniform_01_new ( int n, int *seed )
25297 
25298 //**************************************************************************80
25299 //
25300 // Purpose:
25301 //
25302 // R8VEC_UNIFORM_01_NEW returns a new unit pseudorandom R8VEC.
25303 //
25304 // Discussion:
25305 //
25306 // This routine implements the recursion
25307 //
25308 // seed = ( 16807 * seed ) mod ( 2^31 - 1 )
25309 // u = seed / ( 2^31 - 1 )
25310 //
25311 // The integer arithmetic never requires more than 32 bits,
25312 // including a sign bit.
25313 //
25314 // Licensing:
25315 //
25316 // This code is distributed under the GNU LGPL license.
25317 //
25318 // Modified:
25319 //
25320 // 19 August 2004
25321 //
25322 // Author:
25323 //
25324 // John Burkardt
25325 //
25326 // Reference:
25327 //
25328 // Paul Bratley, Bennett Fox, Linus Schrage,
25329 // A Guide to Simulation,
25330 // Second Edition,
25331 // Springer, 1987,
25332 // ISBN: 0387964673,
25333 // LC: QA76.9.C65.B73.
25334 //
25335 // Bennett Fox,
25336 // Algorithm 647:
25337 // Implementation and Relative Efficiency of Quasirandom
25338 // Sequence Generators,
25339 // ACM Transactions on Mathematical Software,
25340 // Volume 12, Number 4, December 1986, pages 362-376.
25341 //
25342 // Pierre L'Ecuyer,
25343 // Random Number Generation,
25344 // in Handbook of Simulation,
25345 // edited by Jerry Banks,
25346 // Wiley, 1998,
25347 // ISBN: 0471134031,
25348 // LC: T57.62.H37.
25349 //
25350 // Peter Lewis, Allen Goodman, James Miller,
25351 // A Pseudo-Random Number Generator for the System/360,
25352 // IBM Systems Journal,
25353 // Volume 8, Number 2, 1969, pages 136-143.
25354 //
25355 // Parameters:
25356 //
25357 // Input, int N, the number of entries in the vector.
25358 //
25359 // Input/output, int *SEED, a seed for the random number generator.
25360 //
25361 // Output, double R8VEC_UNIFORM_01_NEW[N], the vector of pseudorandom values.
25362 //
25363 {
25364  int i;
25365  int i4_huge = 2147483647;
25366  int k;
25367  double *r;
25368 
25369  if ( *seed == 0 )
25370  {
25371  std::cerr << "\n";
25372  std::cerr << "R8VEC_UNIFORM_01_NEW - Fatal error!\n";
25373  std::cerr << " Input value of SEED = 0.\n";
25374  std::exit ( 1 );
25375  }
25376 
25377  r = new double[n];
25378 
25379  for ( i = 0; i < n; i++ )
25380  {
25381  k = *seed / 127773;
25382 
25383  *seed = 16807 * ( *seed - k * 127773 ) - k * 2836;
25384 
25385  if ( *seed < 0 )
25386  {
25387  *seed = *seed + i4_huge;
25388  }
25389 
25390  r[i] = ( double ) ( *seed ) * 4.656612875E-10;
25391  }
25392 
25393  return r;
25394 }
25395 //**************************************************************************80
25396 
25397 void SandiaRules::r8vec_zero ( int n, double a[] )
25398 
25399 //**************************************************************************80
25400 //
25401 // Purpose:
25402 //
25403 // R8VEC_ZERO zeroes an R8VEC.
25404 //
25405 // Discussion:
25406 //
25407 // An R8VEC is a vector of R8's.
25408 //
25409 // Licensing:
25410 //
25411 // This code is distributed under the GNU LGPL license.
25412 //
25413 // Modified:
25414 //
25415 // 03 July 2005
25416 //
25417 // Author:
25418 //
25419 // John Burkardt
25420 //
25421 // Parameters:
25422 //
25423 // Input, int N, the number of entries in the vector.
25424 //
25425 // Output, double A[N], a vector of zeroes.
25426 //
25427 {
25428  int i;
25429 
25430  for ( i = 0; i < n; i++ )
25431  {
25432  a[i] = 0.0;
25433  }
25434  return;
25435 }
25436 //**************************************************************************80
25437 
25438 void SandiaRules::sort_heap_external ( int n, int *indx, int *i, int *j, int isgn )
25439 
25440 //**************************************************************************80
25441 //
25442 // Purpose:
25443 //
25444 // SORT_HEAP_EXTERNAL externally sorts a list of items into ascending order.
25445 //
25446 // Discussion:
25447 //
25448 // The actual list is not passed to the routine. Hence it may
25449 // consist of integers, reals, numbers, names, etc. The user,
25450 // after each return from the routine, will be asked to compare or
25451 // interchange two items.
25452 //
25453 // The current version of this code mimics the FORTRAN version,
25454 // so the values of I and J, in particular, are FORTRAN indices.
25455 //
25456 // Licensing:
25457 //
25458 // This code is distributed under the GNU LGPL license.
25459 //
25460 // Modified:
25461 //
25462 // 05 February 2004
25463 //
25464 // Author:
25465 //
25466 // Original FORTRAN77 version by Albert Nijenhuis, Herbert Wilf.
25467 // C++ version by John Burkardt
25468 //
25469 // Reference:
25470 //
25471 // Albert Nijenhuis, Herbert Wilf,
25472 // Combinatorial Algorithms,
25473 // Academic Press, 1978, second edition,
25474 // ISBN 0-12-519260-6.
25475 //
25476 // Parameters:
25477 //
25478 // Input, int N, the length of the input list.
25479 //
25480 // Input/output, int *INDX.
25481 // The user must set INDX to 0 before the first call.
25482 // On return,
25483 // if INDX is greater than 0, the user must interchange
25484 // items I and J and recall the routine.
25485 // If INDX is less than 0, the user is to compare items I
25486 // and J and return in ISGN a negative value if I is to
25487 // precede J, and a positive value otherwise.
25488 // If INDX is 0, the sorting is done.
25489 //
25490 // Output, int *I, *J. On return with INDX positive,
25491 // elements I and J of the user's list should be
25492 // interchanged. On return with INDX negative, elements I
25493 // and J are to be compared by the user.
25494 //
25495 // Input, int ISGN. On return with INDX negative, the
25496 // user should compare elements I and J of the list. If
25497 // item I is to precede item J, set ISGN negative,
25498 // otherwise set ISGN positive.
25499 //
25500 {
25501  static int i_save = 0;
25502  static int j_save = 0;
25503  static int k = 0;
25504  static int k1 = 0;
25505  static int n1 = 0;
25506 //
25507 // INDX = 0: This is the first call.
25508 //
25509  if ( *indx == 0 )
25510  {
25511 
25512  i_save = 0;
25513  j_save = 0;
25514  k = n / 2;
25515  k1 = k;
25516  n1 = n;
25517  }
25518 //
25519 // INDX < 0: The user is returning the results of a comparison.
25520 //
25521  else if ( *indx < 0 )
25522  {
25523  if ( *indx == -2 )
25524  {
25525  if ( isgn < 0 )
25526  {
25527  i_save = i_save + 1;
25528  }
25529  j_save = k1;
25530  k1 = i_save;
25531  *indx = -1;
25532  *i = i_save;
25533  *j = j_save;
25534  return;
25535  }
25536 
25537  if ( 0 < isgn )
25538  {
25539  *indx = 2;
25540  *i = i_save;
25541  *j = j_save;
25542  return;
25543  }
25544 
25545  if ( k <= 1 )
25546  {
25547  if ( n1 == 1 )
25548  {
25549  i_save = 0;
25550  j_save = 0;
25551  *indx = 0;
25552  }
25553  else
25554  {
25555  i_save = n1;
25556  j_save = 1;
25557  n1 = n1 - 1;
25558  *indx = 1;
25559  }
25560  *i = i_save;
25561  *j = j_save;
25562  return;
25563  }
25564  k = k - 1;
25565  k1 = k;
25566  }
25567 //
25568 // 0 < INDX: the user was asked to make an interchange.
25569 //
25570  else if ( *indx == 1 )
25571  {
25572  k1 = k;
25573  }
25574 
25575  for ( ; ; )
25576  {
25577 
25578  i_save = 2 * k1;
25579 
25580  if ( i_save == n1 )
25581  {
25582  j_save = k1;
25583  k1 = i_save;
25584  *indx = -1;
25585  *i = i_save;
25586  *j = j_save;
25587  return;
25588  }
25589  else if ( i_save <= n1 )
25590  {
25591  j_save = i_save + 1;
25592  *indx = -2;
25593  *i = i_save;
25594  *j = j_save;
25595  return;
25596  }
25597 
25598  if ( k <= 1 )
25599  {
25600  break;
25601  }
25602 
25603  k = k - 1;
25604  k1 = k;
25605  }
25606 
25607  if ( n1 == 1 )
25608  {
25609  i_save = 0;
25610  j_save = 0;
25611  *indx = 0;
25612  *i = i_save;
25613  *j = j_save;
25614  }
25615  else
25616  {
25617  i_save = n1;
25618  j_save = 1;
25619  n1 = n1 - 1;
25620  *indx = 1;
25621  *i = i_save;
25622  *j = j_save;
25623  }
25624 
25625  return;
25626 }
25627 //**************************************************************************80
25628 
25630 
25631 //**************************************************************************80
25632 //
25633 // Purpose:
25634 //
25635 // TIMESTAMP prints the current YMDHMS date as a time stamp.
25636 //
25637 // Example:
25638 //
25639 // 31 May 2001 09:45:54 AM
25640 //
25641 // Licensing:
25642 //
25643 // This code is distributed under the GNU LGPL license.
25644 //
25645 // Modified:
25646 //
25647 // 08 July 2009
25648 //
25649 // Author:
25650 //
25651 // John Burkardt
25652 //
25653 // Parameters:
25654 //
25655 // None
25656 //
25657 {
25658 # define TIME_SIZE 40
25659 
25660  static char time_buffer[TIME_SIZE];
25661  const struct std::tm *tm_ptr;
25662  //size_t len;
25663  std::time_t now;
25664 
25665  now = std::time ( NULL );
25666  tm_ptr = std::localtime ( &now );
25667 
25668  //len = std::strftime ( time_buffer, TIME_SIZE, "%d %B %Y %I:%M:%S %p", tm_ptr );
25669  std::strftime ( time_buffer, TIME_SIZE, "%d %B %Y %I:%M:%S %p", tm_ptr );
25670 
25671  std::cout << time_buffer << "\n";
25672 
25673  return;
25674 # undef TIME_SIZE
25675 }
25676 
25677 
25678 //**************************************************************************80
25679 void SandiaRules::vec_colex_next3 ( int dim_num, int base[], int a[], bool *more )
25680 //**************************************************************************80
25681 //
25682 // Purpose:
25683 //
25684 // VEC_COLEX_NEXT3 generates vectors in colex order.
25685 //
25686 // Discussion:
25687 //
25688 // The vectors are produced in colexical order, starting with
25689 //
25690 // (1, 1, ...,1),
25691 // (2, 1, ...,1),
25692 // ...
25693 // (BASE(1), 1, ...,1)
25694 //
25695 // (1, 2, ...,1)
25696 // (2, 2, ...,1)
25697 // ...
25698 // (BASE(1), 2, ...,1)
25699 //
25700 // (1, 3, ...,1)
25701 // (2, 3, ...,1)
25702 // ...
25703 // (BASE(1), BASE(2), ...,BASE(DIM_NUM)).
25704 //
25705 // Example:
25706 //
25707 // DIM_NUM = 2,
25708 // BASE = { 3, 3 }
25709 //
25710 // 1 1
25711 // 2 1
25712 // 3 1
25713 // 1 2
25714 // 2 2
25715 // 3 2
25716 // 1 3
25717 // 2 3
25718 // 3 3
25719 //
25720 // Licensing:
25721 //
25722 // This code is distributed under the GNU LGPL license.
25723 //
25724 // Modified:
25725 //
25726 // 19 August 2008
25727 //
25728 // Author:
25729 //
25730 // John Burkardt
25731 //
25732 // Parameters:
25733 //
25734 // Input, int DIM_NUM, the spatial dimension.
25735 //
25736 // Input, int BASE[DIM_NUM], the bases to be used in each dimension.
25737 // In dimension I, entries will range from 1 to BASE[I].
25738 //
25739 // Output, int A[DIM_NUM], the next vector.
25740 //
25741 // Input/output, bool *MORE. Set this variable false before
25742 // the first call. On return, MORE is TRUE if another vector has
25743 // been computed. If MORE is returned FALSE, ignore the output
25744 // vector and stop calling the routine.
25745 //
25746 {
25747  int i;
25748 
25749  if ( !( *more ) )
25750  {
25751  for ( i = 0; i < dim_num; i++ )
25752  {
25753  a[i] = 1;
25754  }
25755  *more = true;
25756  }
25757  else
25758  {
25759  for ( i = 0; i < dim_num; i++ )
25760  {
25761  a[i] = a[i] + 1;
25762 
25763  if ( a[i] <= base[i] )
25764  {
25765  return;
25766  }
25767  a[i] = 1;
25768  }
25769  *more = false;
25770  }
25771 
25772  return;
25773 }
25774 
25775 } // namespace ROL
void r8vec_direct_product2(int factor_index, int factor_order, double factor_value[], int factor_num, int point_num, double w[])
void level_growth_to_order(int dim_num, int level[], int rule[], int growth[], int order[])
void legendre_compute_points_np(int order, int np, double p[], double x[])
void i4mat_transpose_print(int m, int n, int a[], std::string title)
void nco_compute_weights(int n, double w[])
void hermite_compute_np(int order, int np, double p[], double x[], double w[])
void legendre_compute_np(int order, int np, double p[], double x[], double w[])
void r8vec_indexed_heap_d_insert(int *n, double a[], int indx[], int indx_insert)
void binary_vector_next(int n, int bvec[])
void point_radial_tol_unique_index_inc1(int m, int n1, double a1[], double tol, int *seed, double z[], double r1[], int indx1[], bool unique1[], int *unique_num1, int undx1[], int xdnu1[])
void patterson_lookup_weights(int n, double w[])
void chebyshev2_compute_np(int order, int np, double p[], double x[], double w[])
void fejer2_compute(int order, double x[], double w[])
void gegenbauer_compute_np(int order, int np, double p[], double x[], double w[])
void laguerre_compute_points(int order, double x[])
double legendre_integral(int expon)
void gen_hermite_dr_compute(int order, double alpha, double x[], double w[])
void hce_compute_np(int n, int np, double p[], double x[], double w[])
double gegenbauer_integral(int expon, double alpha)
double gen_laguerre_integral(int expon, double alpha)
void gen_laguerre_compute_points(int order, double alpha, double x[])
void laguerre_lookup(int n, double x[], double w[])
void gen_hermite_compute_weights(int order, double alpha, double w[])
void hcc_compute_points(int n, double x[])
void r8vec_print(int n, double a[], std::string title)
void hermite_gk18_lookup_points(int n, double x[])
void ccn_compute_np(int n, int np, double p[], double x[], double w[])
double r8_sign(double x)
void hermite_lookup(int n, double x[], double w[])
void level_to_order_default(int dim_num, int level[], int rule[], int order[])
double r8vec_sum(int n, double a[])
void hermite_lookup_points(int n, double x[])
void chebyshev1_compute_points(int order, double x[])
#define INCX
void r8col_swap(int m, int n, double a[], int j1, int j2)
void sort_heap_external(int n, int *indx, int *i, int *j, int isgn)
double r8_gamma(double x)
double r8_min(double x, double y)
void jacobi_compute_points(int order, double alpha, double beta, double x[])
void laguerre_lookup_weights(int n, double w[])
void hce_compute_points(int n, double x[])
void r8col_unique_index(int m, int n, double a[], double tol, int unique_index[])
void jacobi_compute_weights(int order, double alpha, double beta, double w[])
void level_to_order_exponential(int dim_num, int level[], int rule[], int order[])
void chebyshev1_compute_np(int order, int np, double p[], double x[], double w[])
void gen_laguerre_compute(int order, double alpha, double x[], double w[])
double laguerre_integral(int expon)
void hce_compute_points_np(int n, int np, double p[], double x[])
void hermite_compute_points(int order, double x[])
double * nc_compute_new(int n, double x_min, double x_max, double x[])
void hermite_gk22_lookup_points(int n, double x[])
void gen_hermite_compute(int order, double alpha, double x[], double w[])
int r8col_tol_unique_count(int m, int n, double a[], double tol)
void fejer2_compute_weights(int order, double w[])
void ncoh_compute_points(int n, double x[])
void r8vec_index_sorted_range(int n, double r[], int indx[], double r_lo, double r_hi, int *i_lo, int *i_hi)
void ccn_compute(int n, double x[], double w[])
int * i4vec_copy_new(int n, int a1[])
void hcc_compute(int n, double x[], double w[])
void gegenbauer_root(double *x, int order, double alpha, double *dp2, double *p1, double c[])
void legendre_dr_compute(int order, double x[], double w[])
int r8vec_compare(int n, double a[], double b[])
void legendre_lookup(int n, double x[], double w[])
void r8vec_sort_heap_index_a(int n, double a[], int indx[])
void gegenbauer_recur(double *p2, double *dp2, double *p1, double x, int order, double alpha, double c[])
void legendre_compute_weights(int order, double w[])
double * r8vec_chebyshev_new(int n, double a_first, double a_last)
double gen_hermite_integral(int expon, double alpha)
void gegenbauer_compute_points(int order, double alpha, double x[])
void hermite_interpolant(int n, double x[], double y[], double yp[], double xd[], double yd[], double xdp[], double ydp[])
int i4vec_product(int n, int a[])
void hermite_compute_points_np(int order, int np, double p[], double x[])
int i4_power(int i, int j)
void i4vec_zero(int n, int a[])
void dif_shift_x(int nd, double xd[], double yd[], double xv)
void laguerre_lookup_points(int n, double x[])
void clenshaw_curtis_compute_points_np(int order, int np, double p[], double x[])
void gegenbauer_compute_weights(int order, double alpha, double w[])
void hermite_compute_weights_np(int order, int np, double p[], double w[])
void gen_laguerre_compute_points_np(int order, int np, double p[], double x[])
void patterson_lookup_points(int n, double x[])
void level_to_order_linear(int dim_num, int level[], int rule[], int order[])
int level_to_order_exp_hgk(int level, int growth)
void i4vec_copy(int n, int a1[], int a2[])
void laguerre_compute_weights(int order, double w[])
void hcc_compute_points_np(int n, int np, double p[], double x[])
void dif_shift_zero(int nd, double xd[], double yd[])
void gen_laguerre_compute_weights(int order, double alpha, double w[])
void legendre_lookup_weights(int n, double w[])
void fejer2_compute_points_np(int order, int np, double p[], double x[])
void gen_hermite_compute_points(int order, double alpha, double x[])
double r8_hyper_2f1(double a, double b, double c, double x)
void fejer2_compute_weights_np(int order, int np, double p[], double w[])
int point_radial_tol_unique_index(int m, int n, double a[], double tol, int *seed, int undx[], int xdnu[])
void level_to_order_exponential_slow(int dim_num, int level[], int rule[], int order[])
void clenshaw_curtis_compute_weights(int order, double w[])
double r8_psi(double xx)
void clenshaw_curtis_compute(int order, double x[], double w[])
void ccn_compute_points_np(int n, int np, double p[], double x[])
void fejer2_compute_np(int order, int np, double p[], double x[], double w[])
void point_radial_tol_unique_count_inc1(int m, int n1, double a1[], double tol, int *seed, double z[], double r1[], int indx1[], bool unique1[], int *unique_num1)
void gen_hermite_compute_np(int order, int np, double p[], double x[], double w[])
double jacobi_integral(int expon, double alpha, double beta)
void laguerre_compute_points_np(int order, int np, double p[], double x[])
void laguerre_ss_compute(int order, double x[], double w[])
void laguerre_compute_np(int order, int np, double p[], double x[], double w[])
void i4mat_copy(int m, int n, int a1[], int a2[])
void vec_colex_next3(int dim_num, int base[], int a[], bool *more)
void r8col_undex(int x_dim, int x_num, double x_val[], int x_unique_num, double tol, int undx[], int xdnu[])
double * legendre_zeros(int order)
void gen_laguerre_ss_recur(double *p2, double *dp2, double *p1, double x, int order, double alpha, double b[], double c[])
void point_radial_tol_unique_index_inc3(int m, int n1, double a1[], double r1[], int indx1[], bool unique1[], int unique_num1, int undx1[], int xdnu1[], int n2, double a2[], double r2[], int indx2[], bool unique2[], int unique_num2, int undx2[], int xdnu2[], int *n3, double a3[], double r3[], int indx3[], bool unique3[], int *unique_num3, int undx3[], int xdnu3[])
void ncoh_compute_weights(int n, double w[])
void patterson_lookup(int n, double x[], double w[])
void clenshaw_curtis_compute_weights_np(int order, int np, double p[], double w[])
void ccn_compute_points(int n, double x[])
bool i4vec_any_lt(int n, int a[], int b[])
void gen_hermite_compute_points_np(int order, int np, double p[], double x[])
void gen_laguerre_ss_root(double *x, int order, double alpha, double *dp2, double *p1, double b[], double c[])
void hc_compute_weights_from_points(int nhalf, double x[], double w[])
double * r8vec_uniform_01_new(int n, int *seed)
void hce_compute_weights(int n, double w[])
void imtqlx(int n, double d[], double e[], double z[])
double r8vec_min_pos(int n, double a[])
void hermite_genz_keister_lookup(int n, double x[], double w[])
void hce_compute_weights_np(int n, int np, double p[], double w[])
void hermite_gk24_lookup_points(int n, double x[])
void i4mat_write(std::string output_filename, int m, int n, int table[])
int * i4vec_add_new(int n, int a[], int b[])
void laguerre_compute(int n, double x[], double w[])
void chebyshev2_compute_weights_np(int order, int np, double p[], double w[])
void r8mat_transpose_print_some(int m, int n, double a[], int ilo, int jlo, int ihi, int jhi, std::string title)
void laguerre_compute_weights_np(int order, int np, double p[], double w[])
int level_to_order_linear_nn(int level, int growth)
void jacobi_ss_compute(int order, double alpha, double beta, double x[], double w[])
void gen_laguerre_compute_np(int order, int np, double p[], double x[], double w[])
void hermite_ss_root(double *x, int order, double *dp2, double *p1)
void jacobi_compute(int order, double alpha, double beta, double x[], double w[])
void i4vec_print(int n, int a[], std::string title)
void hce_compute(int n, double x[], double w[])
void hermite_interpolant_rule(int n, double a, double b, double x[], double w[])
void hcc_compute_weights(int n, double w[])
void jacobi_ss_recur(double *p2, double *dp2, double *p1, double x, int order, double alpha, double beta, double b[], double c[])
void nc_compute(int n, double x_min, double x_max, double x[], double w[])
int * i4mat_copy_new(int m, int n, int a1[])
int i4vec_sum(int n, int a[])
void jacobi_compute_points_np(int order, int np, double p[], double x[])
void ccn_compute_weights_np(int n, int np, double p[], double w[])
void chebyshev1_compute_weights(int order, double w[])
int level_to_order_exp_f2(int level, int growth)
int level_to_order_linear_wn(int level, int growth)
void r8vec_zero(int n, double a[])
void legendre_compute_weights_np(int order, int np, double p[], double w[])
void chebyshev1_compute(int order, double x[], double w[])
double r8_abs(double x)
void nco_compute_points(int n, double x[])
void hcc_compute_weights_np(int n, int np, double p[], double w[])
void chebyshev1_compute_weights_np(int order, int np, double p[], double w[])
void hermite_genz_keister_lookup_points(int n, double x[])
void r8col_tol_undex(int x_dim, int x_num, double x_val[], int x_unique_num, double tol, int undx[], int xdnu[])
double r8_choose(int n, int k)
void chebyshev2_compute_points_np(int order, int np, double p[], double x[])
void legendre_lookup_points(int n, double x[])
int r8vec_indexed_heap_d_extract(int *n, double a[], int indx[])
void ncc_compute_weights(int n, double w[])
double * r8vec_legendre_new(int n, double a_first, double a_last)
void r8mat_write(std::string output_filename, int m, int n, double table[])
void r8vec_stutter(int n, double a[], int m, double am[])
void chebyshev2_compute_weights(int order, double w[])
int * r8vec_sort_heap_index_a_new(int n, double a[])
void hermite_genz_keister_lookup_points_np(int n, int np, double p[], double x[])
double hermite_integral(int n)
void laguerre_ss_root(double *x, int order, double *dp2, double *p1, double b[], double c[])
void point_unique_index(int m, int n, double a[], int unique_num, int undx[], int xdnu[])
int level_to_order_exp_gauss(int level, int growth)
int i4_min(int i1, int i2)
void hermite_ss_recur(double *p2, double *dp2, double *p1, double x, int order)
void jacobi_compute_np(int order, int np, double p[], double x[], double w[])
double r8vec_diff_norm_li(int n, double a[], double b[])
int point_radial_tol_unique_count(int m, int n, double a[], double tol, int *seed)
void jacobi_compute_weights_np(int order, int np, double p[], double w[])
void dif_deriv(int nd, double xd[], double yd[], int *ndp, double xdp[], double ydp[])
void hermite_genz_keister_lookup_weights(int n, double w[])
int r8col_compare(int m, int n, double a[], int i, int j)
void hermite_lookup_weights(int n, double w[])
void point_radial_tol_unique_count_inc2(int m, int n1, double a1[], int n2, double a2[], double tol, double z[], double r1[], int indx1[], bool unique1[], int *unique_num2)
int r8col_sorted_unique_count(int m, int n, double a[], double tol)
int level_to_order_exp_gp(int level, int growth)
int i4_max(int i1, int i2)
void laguerre_ss_recur(double *p2, double *dp2, double *p1, double x, int order, double b[], double c[])
void hermite_genz_keister_lookup_weights_np(int n, int np, double p[], double w[])
double r8vec_i4vec_dot_product(int n, double r8vec[], int i4vec[])
void r8vec_copy(int n, double a1[], double a2[])
void patterson_lookup_points_np(int n, int np, double p[], double x[])
void fejer2_compute_points(int order, double x[])
void patterson_lookup_weights_np(int n, int np, double p[], double w[])
int r8vec_indexed_heap_d_max(int n, double a[], int indx[])
int * r8col_sort_heap_index_a(int m, int n, double a[])
double chebyshev1_integral(int expon)
void gegenbauer_compute(int order, double alpha, double x[], double w[])
void clenshaw_curtis_compute_points(int order, double x[])
void legendre_compute_points(int order, double x[])
void r8col_sort_heap_a(int m, int n, double a[])
double * r8vec_linspace_new(int n, double a_first, double a_last)
double r8vec_min(int n, double r8vec[])
void hermite_compute_weights(int order, double w[])
#define TIME_SIZE
void hermite_ss_compute(int order, double x[], double w[])
void ncc_compute_points(int n, double x[])
void chebyshev2_compute(int order, double x[], double w[])
void legendre_compute(int n, double x[], double w[])
double * r8vec_copy_new(int n, double a1[])
void i4mat_transpose_print_some(int m, int n, int a[], int ilo, int jlo, int ihi, int jhi, std::string title)
void r8vec_indexed_heap_d(int n, double a[], int indx[])
void chebyshev1_compute_points_np(int order, int np, double p[], double x[])
void hcc_compute_np(int n, int np, double p[], double x[], double w[])
void product_mixed_weight(int dim_num, int order_1d[], int order_nd, int rule[], double alpha[], double beta[], double weight_nd[])
double r8_ceiling(double x)
double r8_max(double x, double y)
double r8vec_dot_product(int n, double a1[], double a2[])
int level_to_order_exp_cc(int level, int growth)
void dif_to_r8poly(int nd, double xd[], double yd[], double c[])
void ccn_compute_weights(int n, double w[])
void hermite_compute(int order, double x[], double w[])
void gegenbauer_compute_points_np(int order, int np, double p[], double x[])
void gen_laguerre_ss_compute(int order, double alpha, double x[], double w[])
void comp_next(int n, int k, int a[], bool *more, int *h, int *t)
void r8vec_scale(double s, int n, double a[])
void i4vec_min_mv(int m, int n, int u[], int v[], int w[])
void r8mat_transpose_print(int m, int n, double a[], std::string title)
double r8poly_ant_val(int n, double poly_cof[], double xval)
void jacobi_ss_root(double *x, int order, double alpha, double beta, double *dp2, double *p1, double b[], double c[])
void gen_laguerre_compute_weights_np(int order, int np, double p[], double w[])
void r8vec_uniform_01(int n, int *seed, double r[])
void point_radial_tol_unique_index_inc2(int m, int n1, double a1[], int n2, double a2[], double tol, double z[], double r1[], int indx1[], bool unique1[], int unique_num1, int undx1[], int xdnu1[], double r2[], int indx2[], bool unique2[], int *unique_num2, int undx2[], int xdnu2[])
void hermite_interpolant_value(int nd, double xd[], double yd[], double xdp[], double ydp[], int nv, double xv[], double yv[], double yvp[])
void clenshaw_curtis_compute_np(int order, int np, double p[], double x[], double w[])
void gen_hermite_compute_weights_np(int order, int np, double p[], double w[])
double chebyshev2_integral(int expon)
void gegenbauer_compute_weights_np(int order, int np, double p[], double w[])
int i4_choose(int n, int k)
double r8_floor(double x)
void chebyshev2_compute_points(int order, double x[])