ROL
ROL_BurkardtRules.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 
52 #ifndef ROL_BURKARDTRULES_HPP
53 #define ROL_BURKARDTRULES_HPP
54 
55 #include "ROL_Types.hpp"
56 #include "Teuchos_Assert.hpp"
57 //#include <fstream>
58 //#include <string>
59 
60 namespace ROL {
61 
65  enum EROLBurkardt {
77  };
78 
79  inline std::string EROLBurkardtToString(EROLBurkardt rule) {
80  std::string retString;
81  switch(rule) {
82  case BURK_CHEBYSHEV1: retString = "Gauss-Chebyshev Type 1"; break;
83  case BURK_CHEBYSHEV2: retString = "Gauss-Chebyshev Type 2"; break;
84  case BURK_CLENSHAWCURTIS: retString = "Clenshaw-Curtis"; break;
85  case BURK_FEJER2: retString = "Fejer Type 2"; break;
86  case BURK_LEGENDRE: retString = "Gauss-Legendre"; break;
87  case BURK_PATTERSON: retString = "Gauss-Patterson"; break;
88  case BURK_TRAPEZOIDAL: retString = "Trapezoidal Rule"; break;
89  case BURK_HERMITE: retString = "Gauss-Hermite"; break;
90  case BURK_GENZKEISTER: retString = "Hermite-Genz-Keister"; break;
91  case BURK_LAGUERRE: retString = "Gauss-Laguerre"; break;
92  default: retString = "INVALID EROLBurkardt";
93  }
94  return retString;
95  }
96 
98  return type = static_cast<EROLBurkardt>(type+1);
99  }
100 
101  inline EROLBurkardt operator++(EROLBurkardt &type, int) {
102  EROLBurkardt oldval = type;
103  ++type;
104  return oldval;
105  }
106 
117 
118  public:
119 
120  /* HELPER FUNCTIONS */
121  template<class Real>
122  static void imtqlx ( int n, Real d[], Real e[], Real z[] );
123  template<class Real> static Real r8_epsilon( Real one );
124  template<class Real> static Real r8_sign( Real x );
125 
126  /* COMPUTE CHEBYSHEV TYPE 1 NODES AND WEIGHTS */
127  /* Integrates functions on [-1,1] weighted by w(x) = 1/sqrt(1-x^2) */
130  template<class Real>
131  static void chebyshev1_compute ( int order, Real x[], Real w[] );
134  template<class Real>
135  static void chebyshev1_compute_points ( int order, Real x[] );
138  template<class Real>
139  static void chebyshev1_compute_weights ( int order, Real w[] );
140 
141  /* COMPUTE CHEBYSHEV TYPE 2 NODES AND WEIGHTS */
142  /* Integrates functions on [-1,1] weighted by w(x) = sqrt(1-x^2) */
145  template<class Real>
146  static void chebyshev2_compute ( int order, Real x[], Real w[] );
149  template<class Real>
150  static void chebyshev2_compute_points ( int order, Real x[] );
153  template<class Real>
154  static void chebyshev2_compute_weights ( int order, Real w[] );
155 
156  /* COMPUTE CLENSHAW CURTIS NODES AND WEIGHTS */
157  /* Integrates functions on [-1,1] weighted by w(x) = 1 */
160  template<class Real>
161  static void clenshaw_curtis_compute ( int order, Real x[], Real w[] );
164  template<class Real>
165  static void clenshaw_curtis_compute_points ( int order, Real x[] );
168  template<class Real>
169  static void clenshaw_curtis_compute_weights ( int order, Real w[] );
170 
171  /* COMPUTE FEJER TYPE 2 NODES AND WEIGHTS */
172  /* Integrates functions on [-1,1] weighted by w(x) = 1 */
175  template<class Real>
176  static void fejer2_compute ( int order, Real x[], Real w[] );
179  template<class Real>
180  static void fejer2_compute_points ( int order, Real x[] );
183  template<class Real>
184  static void fejer2_compute_weights ( int order, Real w[] );
185 
186  /* COMPUTE GAUSS HERMITE NODES AND WEIGHTS */
187  /* Integrates functions on (-oo,oo) weighted by w(x) = exp(-x^2) */
190  template<class Real>
191  static void hermite_compute ( int order, Real x[], Real w[] );
194  template<class Real>
195  static void hermite_compute_points ( int order, Real x[] );
198  template<class Real>
199  static void hermite_compute_weights ( int order, Real w[] );
200 
203  template<class Real>
204  static void hermite_lookup ( int n, Real x[], Real w[] );
207  template<class Real>
208  static void hermite_lookup_points ( int n, Real x[] );
211  template<class Real>
212  static void hermite_lookup_weights ( int n, Real w[] );
213 
214  /* COMPUTE GENZ KEISTER NODES AND WEIGHTS */
215  /* Integrates functions on (-oo,oo) weighted by w(x) = exp(-x^2) */
218  template<class Real>
219  static void hermite_genz_keister_lookup ( int n, Real x[], Real w[] );
222  template<class Real>
223  static void hermite_genz_keister_lookup_points ( int n, Real x[] );
226  template<class Real>
227  static void hermite_genz_keister_lookup_weights ( int n, Real w[] );
228 
229  /* COMPUTE GAUSS LAGUERRE NODES AND WEIGHTS */
230  /* Integrates functons on [0,oo) weighted by w(x) = exp(-x) */
233  template<class Real>
234  static void laguerre_compute ( int n, Real x[], Real w[] );
237  template<class Real>
238  static void laguerre_compute_points ( int order, Real x[] );
241  template<class Real>
242  static void laguerre_compute_weights ( int order, Real w[] );
243 
246  template<class Real>
247  static void laguerre_lookup ( int n, Real x[], Real w[] );
250  template<class Real>
251  static void laguerre_lookup_points ( int n, Real x[] );
254  template<class Real>
255  static void laguerre_lookup_weights ( int n, Real w[] );
256 
257  /* COMPUTE GAUSS LEGENDRE NODES AND WEIGHTS */
258  /* Integrates functions on [-1,1] weighted by w(x) = 1 */
261  template<class Real>
262  static void legendre_compute ( int n, Real x[], Real w[] );
265  template<class Real>
266  static void legendre_compute_points ( int order, Real x[] );
269  template<class Real>
270  static void legendre_compute_weights ( int order, Real w[] );
271 
274  template<class Real>
275  static void legendre_lookup ( int n, Real x[], Real w[] );
278  template<class Real>
279  static void legendre_lookup_points ( int n, Real x[] );
282  template<class Real>
283  static void legendre_lookup_weights ( int n, Real w[] );
284 
285  /* COMPUTE GAUSS PATTERSON NODES AND WEIGHTS */
286  /* Integrates functions on [-1,1] weighted by w(x) = 1 */
289  template<class Real>
290  static void patterson_lookup ( int n, Real x[], Real w[] );
293  template<class Real>
294  static void patterson_lookup_points ( int n, Real x[] );
297  template<class Real>
298  static void patterson_lookup_weights ( int n, Real w[] );
299 
300  /* COMPUTE TRAPEZOIDAL RULE NODES AND WEIGHTS */
301  /* Integrates functions on [-1,1] weighted by w(x) = 1 */
304  template<class Real>
305  static void trapezoidal_compute ( int n, Real x[], Real w[] );
308  template<class Real>
309  static void trapezoidal_compute_points ( int order, Real x[] );
312  template<class Real>
313  static void trapezoidal_compute_weights ( int order, Real w[] );
314 
315  }; // class ROLBurkardtRules
316 
317 } // end ROL namespace
318 
319 // include templated definitions
320 #include "ROL_BurkardtRulesDef.hpp"
321 
322 #endif
static void legendre_lookup(int n, Real x[], Real w[])
Gauss-Legendre; returns points and weights.
static void imtqlx(int n, Real d[], Real e[], Real z[])
static void fejer2_compute_weights(int order, Real w[])
Fejer type 2; returns weights.
static void trapezoidal_compute(int n, Real x[], Real w[])
Trapezoidal rule; returns points and weights.
static void chebyshev2_compute_points(int order, Real x[])
Gauss-Chebyshev of Type 2; returns points.
Definition file for integration rules provided by John Burkardt. <>
static void hermite_genz_keister_lookup_points(int n, Real x[])
Hermite-Genz-Keister; returns points.
static void laguerre_lookup_points(int n, Real x[])
Gauss-Laguerre; returns points.
static void laguerre_compute_points(int order, Real x[])
Gauss-Laguerre; returns points.
EROLBurkardt
Enumeration of integration rules provided by John Burkardt.
static void laguerre_compute_weights(int order, Real w[])
Gauss-Laguerre; returns weights.
Contains definitions of custom data types in ROL.
static void chebyshev1_compute_weights(int order, Real w[])
Gauss-Chebyshev of Type 1; returns weights.
EROLBurkardt & operator++(EROLBurkardt &type)
static void hermite_genz_keister_lookup(int n, Real x[], Real w[])
Hermite-Genz-Keister; returns points and weights.
static void patterson_lookup_points(int n, Real x[])
Gauss-Patterson; returns points.
static void chebyshev1_compute_points(int order, Real x[])
Gauss-Chebyshev of Type 1; returns points.
static void hermite_compute_weights(int order, Real w[])
Gauss-Hermite; returns weights.
static void hermite_lookup(int n, Real x[], Real w[])
Gauss-Hermite; returns points and weights.
static void legendre_lookup_weights(int n, Real w[])
Gauss-Legendre; returns weights.
static void chebyshev1_compute(int order, Real x[], Real w[])
Gauss-Chebyshev of Type 1; returns points and weights.
static void chebyshev2_compute(int order, Real x[], Real w[])
Gauss-Chebyshev of Type 2; returns points and weights.
static void trapezoidal_compute_points(int order, Real x[])
Trapezoidal rule; returns points.
static void hermite_genz_keister_lookup_weights(int n, Real w[])
Hermite-Genz-Keister; returns weights.
Providing integration rules, created by John Burkardt, Scientific Computing, Florida State University...
static void hermite_lookup_points(int n, Real x[])
Gauss-Hermite; returns points.
static void legendre_compute_weights(int order, Real w[])
Gauss-Legendre; returns weights.
static void laguerre_lookup_weights(int n, Real w[])
Gauss-Laguerre; returns weights.
static void trapezoidal_compute_weights(int order, Real w[])
Trapezoidal rule; returns weights.
static void clenshaw_curtis_compute(int order, Real x[], Real w[])
Clenshaw-Curtis; returns points and weights.
static void hermite_compute_points(int order, Real x[])
Gauss-Hermite; returns points.
static void legendre_compute(int n, Real x[], Real w[])
Gauss-Legendre; returns points and weights.
static Real r8_epsilon(Real one)
static void clenshaw_curtis_compute_points(int order, Real x[])
Clenshaw-Curtis; returns points.
static void clenshaw_curtis_compute_weights(int order, Real w[])
Clenshaw-Curtis; returns weights.
static void laguerre_compute(int n, Real x[], Real w[])
Gauss-Laguerre; returns points and weights.
static void hermite_compute(int order, Real x[], Real w[])
Gauss-Hermite; returns points and weights.
static void laguerre_lookup(int n, Real x[], Real w[])
Gauss-Laguerre; returns points and weights.
static void fejer2_compute(int order, Real x[], Real w[])
Fejer type 2; returns points and weights.
std::string EROLBurkardtToString(EROLBurkardt rule)
static void legendre_compute_points(int order, Real x[])
Gauss-Legendre; returns points.
static void patterson_lookup(int n, Real x[], Real w[])
Gauss-Patterson; returns points and weights.
static void chebyshev2_compute_weights(int order, Real w[])
Gauss-Chebyshev of Type 2; returns weights.
static void fejer2_compute_points(int order, Real x[])
Fejer type 2; returns points.
static void hermite_lookup_weights(int n, Real w[])
Gauss-Hermite; returns weights.
static void legendre_lookup_points(int n, Real x[])
Gauss-Legendre; returns points.
static void patterson_lookup_weights(int n, Real w[])
Gauss-Patterson; returns weights.