queso-0.51.1
List of all members
QUESO::UniformLegendre1DQuadrature Class Reference

Class for Legendre-Gauss quadrature rule for one-dimensional functions. More...

#include <1DQuadrature.h>

Inheritance diagram for QUESO::UniformLegendre1DQuadrature:
Inheritance graph
[legend]
Collaboration diagram for QUESO::UniformLegendre1DQuadrature:
Collaboration graph
[legend]

Public Member Functions

Constructor/Destructor methods
 UniformLegendre1DQuadrature (double minDomainValue, double maxDomainValue, unsigned int order, bool densityIsNormalized)
 Default constructor. More...
 
 ~UniformLegendre1DQuadrature ()
 Destructor. More...
 
Mathematical methods
void dumbRoutine () const
 A bogus method. More...
 
- Public Member Functions inherited from QUESO::Base1DQuadrature
 Base1DQuadrature (double minDomainValue, double maxDomainValue, unsigned int order)
 Default constructor. More...
 
virtual ~Base1DQuadrature ()
 Virtual destructor. More...
 
double minDomainValue () const
 Returns the minimum value of the domain of the (one-dimensional) function. More...
 
double maxDomainValue () const
 Returns the maximum value of the domain of the (one-dimensional) function. More...
 
unsigned int order () const
 Returns the order of the quadrature rule. More...
 
const std::vector< double > & positions () const
 Array of the positions for the numerical integration. More...
 
const std::vector< double > & weights () const
 Array of the weights used in the numerical integration. More...
 

Additional Inherited Members

- Protected Attributes inherited from QUESO::Base1DQuadrature
double m_minDomainValue
 
double m_maxDomainValue
 
unsigned int m_order
 
std::vector< double > m_positions
 
std::vector< double > m_weights
 

Detailed Description

Class for Legendre-Gauss quadrature rule for one-dimensional functions.

In a general Gaussian quadrature rule, an definite integral of $ f(x)$ is first approximated over the interval [-1,1] by a polynomial approximable function $ g(x)$ and a known weighting function $ W(x)$:

\[\int_{-1}^1 f(x) \, dx = \int_{-1}^1 W(x) g(x) \, dx\]

Those are then approximated by a sum of function values at specified points $ x_i $ multiplied by some weights $ w_i $:

\[ \int_{-1}^1 W(x) g(x) \, dx \approx \sum_{i=1}^n w_i g(x_i) \]

In the case of Gauss-Legendre quadrature, the weighting function $ W(x) = 1 $, so we can approximate an integral of $ f(x) $ with:

\[ \int_{-1}^1 f(x)\,dx \approx \sum_{i=1}^n w_i f(x_i) \]

The abscissas for quadrature order $ n $ are given by the roots of the Legendre polynomials $ P_n(x)$, which occur symmetrically about 0. The weights are

\[ w_i = \frac{2}{(1-x_i^2)[P'_n(x_i)]^2}=\frac{2(1-x_i^2)}{(n+1)^2[P_{n+1}(x_i)]^2} \]

Several authors give a table of abscissas and weights:

$ n $$ x_i $$ w_i $
2 $ \pm \frac{1}{3}\sqrt{3} $ $ 1 $
3 $ 0 $ $ \frac{8}{9} $
$ \pm \frac{1}{5} \sqrt{15} $ $ \frac{5}{9} $
4 $ \pm \frac{1}{35}\sqrt{525-70\sqrt{30}} $ $ \frac{1}{36}(18+\sqrt{30})$
$ \pm \frac{1}{35}\sqrt{525+70\sqrt{30}} $ $ \frac{1}{36}(18-\sqrt{30})$
5 $ 0 $ $ \frac{128}{225}$
$ \pm \frac{1}{21}\sqrt{245-14\sqrt{70}} $ $ \frac{1}{900}(322+13\sqrt{70})$
$ \pm \frac{1}{21}\sqrt{245+14\sqrt{70}} $ $ \frac{1}{900}(322-13\sqrt{70})$
See Also
Weisstein, Eric W. "Legendre-Gauss Quadrature." From MathWorld–A Wolfram Web Resource. http://mathworld.wolfram.com/Legendre-GaussQuadrature.html.

Definition at line 162 of file 1DQuadrature.h.

Constructor & Destructor Documentation

QUESO::UniformLegendre1DQuadrature::UniformLegendre1DQuadrature ( double  minDomainValue,
double  maxDomainValue,
unsigned int  order,
bool  densityIsNormalized 
)

Default constructor.

Constructs a Gaussian-Legendre quadrature of order order, in the interval [minDomainValue,maxDomainValue]. Valid values for the order of the quadrature rule are: 1-7, 10-12, 16. This method scales the abscissas (positions) of the quadrature from the interval [-1,1] to [minDomainValue,maxDomainValue], and the parameter densityIsNormalized determines whether the weights should be scaled as well.

Definition at line 133 of file 1DQuadrature.C.

References QUESO::Base1DQuadrature::m_maxDomainValue, QUESO::Base1DQuadrature::m_minDomainValue, QUESO::Base1DQuadrature::m_order, QUESO::Base1DQuadrature::m_positions, QUESO::Base1DQuadrature::m_weights, UQ_FATAL_TEST_MACRO, and QUESO::UQ_UNAVAILABLE_RANK.

138  :
140 {
141  m_positions.resize(m_order+1,0.); // Yes, '+1'
142  m_weights.resize (m_order+1,0.); // Yes, '+1'
143 
144  // http://www.holoborodko.com/pavel/?page_id=679
145  switch (m_order) { // eep2011
146  case 1:
147  m_weights [0] = 1.;
148  m_weights [1] = 1.;
149 
150  m_positions[0] = -1./sqrt(3.);
151  m_positions[1] = 1./sqrt(3.);
152  break;
153 
154  case 2:
155  m_weights [0] = 5./9.;
156  m_weights [1] = 8./9.;
157  m_weights [2] = 5./9.;
158 
159  m_positions[0] = -sqrt(.6);
160  m_positions[1] = 0.;
161  m_positions[2] = sqrt(.6);
162  break;
163 
164  case 3:
165  m_weights [0] = 0.5 - sqrt(30.)/36.;
166  m_weights [1] = 0.5 + sqrt(30.)/36.;
167  m_weights [2] = 0.5 + sqrt(30.)/36.;
168  m_weights [3] = 0.5 - sqrt(30.)/36.;
169 
170  m_positions[0] = -sqrt(3.+2.*sqrt(1.2))/sqrt(7.);
171  m_positions[1] = -sqrt(3.-2.*sqrt(1.2))/sqrt(7.);
172  m_positions[2] = sqrt(3.-2.*sqrt(1.2))/sqrt(7.);
173  m_positions[3] = sqrt(3.+2.*sqrt(1.2))/sqrt(7.);
174  break;
175 
176  case 4:
177  m_weights [0] = (322.-13.*sqrt(70.))/900.; // 0.236926885
178  m_weights [1] = (322.+13.*sqrt(70.))/900.; // 0.478628670
179  m_weights [2] = 128./225.; // 0.568888889
180  m_weights [3] = (322.+13.*sqrt(70.))/900.;
181  m_weights [4] = (322.-13.*sqrt(70.))/900.;
182 
183  m_positions[0] = -sqrt(5.+2.*sqrt(10./7.))/3.;
184  m_positions[1] = -sqrt(5.-2.*sqrt(10./7.))/3.;
185  m_positions[2] = 0.;
186  m_positions[3] = sqrt(5.-2.*sqrt(10./7.))/3.;
187  m_positions[4] = sqrt(5.+2.*sqrt(10./7.))/3.;
188  break;
189 
190  case 5:
191  m_weights [0] = 0.1713244923791703450402961;
192  m_weights [1] = 0.3607615730481386075698335;
193  m_weights [2] = 0.4679139345726910473898703;
194  m_weights [3] = 0.4679139345726910473898703;
195  m_weights [4] = 0.3607615730481386075698335;
196  m_weights [5] = 0.1713244923791703450402961;
197 
198  m_positions[0] = -0.9324695142031520278123016;
199  m_positions[1] = -0.6612093864662645136613996;
200  m_positions[2] = -0.2386191860831969086305017;
201  m_positions[3] = 0.2386191860831969086305017;
202  m_positions[4] = 0.6612093864662645136613996;
203  m_positions[5] = 0.9324695142031520278123016;
204  break;
205 
206  case 6:
207  m_weights [0] = 0.1294849661688696932706114;
208  m_weights [1] = 0.2797053914892766679014678;
209  m_weights [2] = 0.3818300505051189449503698;
210  m_weights [3] = 0.4179591836734693877551020;
211  m_weights [4] = 0.3818300505051189449503698;
212  m_weights [5] = 0.2797053914892766679014678;
213  m_weights [6] = 0.1294849661688696932706114;
214 
215  m_positions[0] = -0.9491079123427585245261897;
216  m_positions[1] = -0.7415311855993944398638648;
217  m_positions[2] = -0.4058451513773971669066064;
218  m_positions[3] = 0.;
219  m_positions[4] = 0.4058451513773971669066064;
220  m_positions[5] = 0.7415311855993944398638648;
221  m_positions[6] = 0.9491079123427585245261897;
222  break;
223 
224  case 7:
225  m_weights [0] = 0.10122854;
226  m_weights [1] = 0.22238103;
227  m_weights [2] = 0.31370665;
228  m_weights [3] = 0.36268378;
229  m_weights [4] = 0.36268378;
230  m_weights [5] = 0.31370665;
231  m_weights [6] = 0.22238103;
232  m_weights [7] = 0.10122854;
233 
234  m_positions[0] = -0.96028986;
235  m_positions[1] = -0.79666648;
236  m_positions[2] = -0.52553241;
237  m_positions[3] = -0.18343464;
238  m_positions[4] = 0.18343464;
239  m_positions[5] = 0.52553241;
240  m_positions[6] = 0.79666648;
241  m_positions[7] = 0.96028986;
242  break;
243 
244  case 10:
245  m_weights [ 0] = 0.0556685671161736664827537;
246  m_weights [ 1] = 0.1255803694649046246346943;
247  m_weights [ 2] = 0.1862902109277342514260976;
248  m_weights [ 3] = 0.2331937645919904799185237;
249  m_weights [ 4] = 0.2628045445102466621806889;
250  m_weights [ 5] = 0.2729250867779006307144835;
251  m_weights [ 6] = 0.2628045445102466621806889;
252  m_weights [ 7] = 0.2331937645919904799185237;
253  m_weights [ 8] = 0.1862902109277342514260976;
254  m_weights [ 9] = 0.1255803694649046246346943;
255  m_weights [10] = 0.0556685671161736664827537;
256 
257  m_positions[ 0] = -0.9782286581460569928039380;
258  m_positions[ 1] = -0.8870625997680952990751578;
259  m_positions[ 2] = -0.7301520055740493240934163;
260  m_positions[ 3] = -0.5190961292068118159257257;
261  m_positions[ 4] = -0.2695431559523449723315320;
262  m_positions[ 5] = 0.;
263  m_positions[ 6] = 0.2695431559523449723315320;
264  m_positions[ 7] = 0.5190961292068118159257257;
265  m_positions[ 8] = 0.7301520055740493240934163;
266  m_positions[ 9] = 0.8870625997680952990751578;
267  m_positions[10] = 0.9782286581460569928039380;
268  break;
269 
270  case 11:
271  m_weights [ 0] = 0.0471753363865118271946160;
272  m_weights [ 1] = 0.1069393259953184309602547;
273  m_weights [ 2] = 0.1600783285433462263346525;
274  m_weights [ 3] = 0.2031674267230659217490645;
275  m_weights [ 4] = 0.2334925365383548087608499;
276  m_weights [ 5] = 0.2491470458134027850005624;
277  m_weights [ 6] = 0.2491470458134027850005624;
278  m_weights [ 7] = 0.2334925365383548087608499;
279  m_weights [ 8] = 0.2031674267230659217490645;
280  m_weights [ 9] = 0.1600783285433462263346525;
281  m_weights [10] = 0.1069393259953184309602547;
282  m_weights [11] = 0.0471753363865118271946160;
283 
284  m_positions[ 0] = -0.9815606342467192506905491;
285  m_positions[ 1] = -0.9041172563704748566784659;
286  m_positions[ 2] = -0.7699026741943046870368938;
287  m_positions[ 3] = -0.5873179542866174472967024;
288  m_positions[ 4] = -0.3678314989981801937526915;
289  m_positions[ 5] = -0.1252334085114689154724414;
290  m_positions[ 6] = 0.1252334085114689154724414;
291  m_positions[ 7] = 0.3678314989981801937526915;
292  m_positions[ 8] = 0.5873179542866174472967024;
293  m_positions[ 9] = 0.7699026741943046870368938;
294  m_positions[10] = 0.9041172563704748566784659;
295  m_positions[11] = 0.9815606342467192506905491;
296  break;
297 
298  case 12:
299  m_weights [ 0] = 0.0404840047653158795200216;
300  m_weights [ 1] = 0.0921214998377284479144218;
301  m_weights [ 2] = 0.1388735102197872384636018;
302  m_weights [ 3] = 0.1781459807619457382800467;
303  m_weights [ 4] = 0.2078160475368885023125232;
304  m_weights [ 5] = 0.2262831802628972384120902;
305  m_weights [ 6] = 0.2325515532308739101945895;
306  m_weights [ 7] = 0.2262831802628972384120902;
307  m_weights [ 8] = 0.2078160475368885023125232;
308  m_weights [ 9] = 0.1781459807619457382800467;
309  m_weights [10] = 0.1388735102197872384636018;
310  m_weights [11] = 0.0921214998377284479144218;
311  m_weights [12] = 0.0404840047653158795200216;
312 
313  m_positions[ 0] = -0.9841830547185881494728294;
314  m_positions[ 1] = -0.9175983992229779652065478;
315  m_positions[ 2] = -0.8015780907333099127942065;
316  m_positions[ 3] = -0.6423493394403402206439846;
317  m_positions[ 4] = -0.4484927510364468528779129;
318  m_positions[ 5] = -0.2304583159551347940655281;
319  m_positions[ 6] = 0.;
320  m_positions[ 7] = 0.2304583159551347940655281;
321  m_positions[ 8] = 0.4484927510364468528779129;
322  m_positions[ 9] = 0.6423493394403402206439846;
323  m_positions[10] = 0.8015780907333099127942065;
324  m_positions[11] = 0.9175983992229779652065478;
325  m_positions[12] = 0.9841830547185881494728294;
326  break;
327 #if 0
328  case 13:
329  m_weights [ 0] = ;
330  m_weights [ 1] = ;
331  m_weights [ 2] = ;
332  m_weights [ 3] = ;
333  m_weights [ 4] = ;
334  m_weights [ 5] = ;
335  m_weights [ 6] = ;
336  m_weights [ 7] = ;
337  m_weights [ 8] = ;
338  m_weights [ 9] = ;
339  m_weights [10] = ;
340  m_weights [11] = ;
341  m_weights [12] = ;
342  m_weights [13] = ;
343 
344  m_positions[ 0] = -;
345  m_positions[ 1] = -;
346  m_positions[ 2] = -;
347  m_positions[ 3] = -;
348  m_positions[ 4] = -;
349  m_positions[ 5] = -;
350  m_positions[ 6] = -;
351  m_positions[ 7] = ;
352  m_positions[ 8] = ;
353  m_positions[ 9] = ;
354  m_positions[10] = ;
355  m_positions[11] = ;
356  m_positions[12] = ;
357  m_positions[13] = ;
358  break;
359 #endif
360 #if 0
361  14 ±0.1080549487073436620662447 0.2152638534631577901958764
362  ±0.3191123689278897604356718 0.2051984637212956039659241
363  ±0.5152486363581540919652907 0.1855383974779378137417166
364  ±0.6872929048116854701480198 0.1572031671581935345696019
365  ±0.8272013150697649931897947 0.1215185706879031846894148
366  ±0.9284348836635735173363911 0.0801580871597602098056333
367  ±0.9862838086968123388415973 0.0351194603317518630318329
368 #endif
369 
370  case 16:
371  m_weights [ 0] = 0.0241483028685479319601100;
372  m_weights [ 1] = 0.0554595293739872011294402;
373  m_weights [ 2] = 0.0850361483171791808835354;
374  m_weights [ 3] = 0.1118838471934039710947884;
375  m_weights [ 4] = 0.1351363684685254732863200;
376  m_weights [ 5] = 0.1540457610768102880814316;
377  m_weights [ 6] = 0.1680041021564500445099707;
378  m_weights [ 7] = 0.1765627053669926463252710;
379  m_weights [ 8] = 0.1794464703562065254582656;
380  m_weights [ 9] = 0.1765627053669926463252710;
381  m_weights [10] = 0.1680041021564500445099707;
382  m_weights [11] = 0.1540457610768102880814316;
383  m_weights [12] = 0.1351363684685254732863200;
384  m_weights [13] = 0.1118838471934039710947884;
385  m_weights [14] = 0.0850361483171791808835354;
386  m_weights [15] = 0.0554595293739872011294402;
387  m_weights [16] = 0.0241483028685479319601100;
388 
389  m_positions[ 0] = -0.9905754753144173356754340;
390  m_positions[ 1] = -0.9506755217687677612227170;
391  m_positions[ 2] = -0.8802391537269859021229557;
392  m_positions[ 3] = -0.7815140038968014069252301;
393  m_positions[ 4] = -0.6576711592166907658503022;
394  m_positions[ 5] = -0.5126905370864769678862466;
395  m_positions[ 6] = -0.3512317634538763152971855;
396  m_positions[ 7] = -0.1784841814958478558506775;
397  m_positions[ 8] = 0.;
398  m_positions[ 9] = 0.1784841814958478558506775;
399  m_positions[10] = 0.3512317634538763152971855;
400  m_positions[11] = 0.5126905370864769678862466;
401  m_positions[12] = 0.6576711592166907658503022;
402  m_positions[13] = 0.7815140038968014069252301;
403  m_positions[14] = 0.8802391537269859021229557;
404  m_positions[15] = 0.9506755217687677612227170;
405  m_positions[16] = 0.9905754753144173356754340;
406  break;
407 
408  default:
409  std::cerr << "In UniformLegendre1DQuadrature::constructor()"
410  << ": m_order = " << m_order
411  << std::endl;
412  UQ_FATAL_TEST_MACRO(true,
414  "UniformLegendre1DQuadrature::constructor()",
415  "order not supported");
416  break;
417  }
418 
419  // Scale positions from the interval [-1, 1] to the interval [min,max]
420  for (unsigned int j = 0; j < m_positions.size(); ++j) {
422  if (densityIsNormalized) {
423  // Since \rho is "1/\Delta", we just multiply by ".5"
424  m_weights[j] *= .5;
425  }
426  else {
427  // Since \rho is "1", we multiply by ".5 * \Delta"
429  }
430  }
431 }
Base1DQuadrature(double minDomainValue, double maxDomainValue, unsigned int order)
Default constructor.
Definition: 1DQuadrature.C:32
std::vector< double > m_weights
Definition: 1DQuadrature.h:86
const int UQ_UNAVAILABLE_RANK
Definition: Defines.h:74
double maxDomainValue() const
Returns the maximum value of the domain of the (one-dimensional) function.
Definition: 1DQuadrature.C:64
std::vector< double > m_positions
Definition: 1DQuadrature.h:85
unsigned int order() const
Returns the order of the quadrature rule.
Definition: 1DQuadrature.C:70
double minDomainValue() const
Returns the minimum value of the domain of the (one-dimensional) function.
Definition: 1DQuadrature.C:58
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:223
QUESO::UniformLegendre1DQuadrature::~UniformLegendre1DQuadrature ( )

Destructor.

Definition at line 433 of file 1DQuadrature.C.

434 {
435 }

Member Function Documentation

void QUESO::UniformLegendre1DQuadrature::dumbRoutine ( ) const
virtual

A bogus method.

Implements QUESO::Base1DQuadrature.

Definition at line 438 of file 1DQuadrature.C.

439 {
440  return;
441 }

The documentation for this class was generated from the following files:

Generated on Thu Apr 23 2015 19:26:17 for queso-0.51.1 by  doxygen 1.8.5