Gobelijn API documentation  - generated for commit a0cbea7
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros Pages
UA_CoMP::Num::AdaptiveQuadrature< QuadRule1, QuadRule2, ConvergencePolicy, CellCountPolicy > Class Template Reference

The AdaptiveQuadrature is a host class with policy classes QuadRule1, QuadRule2, ErrorPolicy and ConvergencePolicy. More...

#include <AdaptiveQuadrature.h>

Inheritance diagram for UA_CoMP::Num::AdaptiveQuadrature< QuadRule1, QuadRule2, ConvergencePolicy, CellCountPolicy >:
Inheritance graph
Collaboration diagram for UA_CoMP::Num::AdaptiveQuadrature< QuadRule1, QuadRule2, ConvergencePolicy, CellCountPolicy >:
Collaboration graph

Public Types

using first_rule = AQRule1< QuadRule1 >
 
using second_rule = AQRule2< QuadRule2 >
 

Public Member Functions

 AdaptiveQuadrature (double convergenceTolerance, unsigned int initialCellCount, unsigned int cellCountLimit)
 Constructor initializes everything. More...
 
AQRule1< QuadRule1 > & rule1 ()
 Return a reference to the first sum rule subobject. More...
 
AQRule2< QuadRule2 > & rule2 ()
 Return a reference to the second sum rule subobject. More...
 
template<typename Integrand >
std::tuple< bool, typename
Integrand::result_type,
typename
Integrand::result_type,
unsigned int > 
evaluate (typename Integrand::argument_type l, typename Integrand::argument_type r, Integrand ftor) const
 Evaluates the quadrature for a functor based on comparing two sum rules. More...
 
template<typename Integrand >
Integrand::result_type operator() (typename Integrand::argument_type l, typename Integrand::argument_type r, Integrand ftor) const
 Simplified version of the evaluate member function, returns only second sum value. More...
 
double getConvergenceTolerance () const
 Return the convergence tolerance. More...
 
unsigned int getInitialCellCount () const
 Return the initial cell count. More...
 
unsigned int getCellCountLimit () const
 Return the cell count limit. More...
 
void setConvergenceTolerance (double x)
 Set the convergence tolerance. More...
 
void setInitialCellCount (unsigned int i)
 Set initial cell count. More...
 
void setCellCountLimit (unsigned int i)
 Set cell count limit. More...
 

Private Attributes

double fConvergenceTolerance
 
unsigned int fInitialCellCount
 
unsigned int fCellCountLimit
 

Detailed Description

template<typename QuadRule1, typename QuadRule2 = Bisector<QuadRule1>, typename ConvergencePolicy = ComboDifference, typename CellCountPolicy = OnViolationThrow>
class UA_CoMP::Num::AdaptiveQuadrature< QuadRule1, QuadRule2, ConvergencePolicy, CellCountPolicy >

The AdaptiveQuadrature is a host class with policy classes QuadRule1, QuadRule2, ErrorPolicy and ConvergencePolicy.

All of their interfaces are exposed through public inheritance. The host class also has a template member function with the integrand as template parameter. It evaluates the integral by dividing the integration domain into cells and applying two quadrature rules (QuadRule1 and QuadRule2) on each cell. If both sums agree according to the approximation expressed in ConvergencePolicy, they are accepted as contribution to the integral. If not the cell is bisected and the same procedure is applied to the smaller cells. Thus the cellsize adapts locally to the rate of change of the integrand. Re CellCount: The cellCount is monitored and the ''cellCount <= cellCountLimit'' is an invariant. If the algorithm threatens to break it then, depending on the policy an exception is thrown, or the program exits or the quadrature proceeds with the current pattern of cells without further subdivision. All of this can be achieved with reasonably generic assertion like policy class that is used to test the invariant and reacts if the condition is violated. It has to implement a member bool check(bool b) that returns the value of b, but may be throwing, exiting etc as side effect. An alternative would have been an OnCellCountViolation class with a member function bool check(unsigned int cellCount) However I do not really anticipate any real use for the additional flexibility this provides. I mean, what can you do but check cellCount <= cellCountLimit ? Re ConvergencePolicy: Now this is a different kettle of fish: there are probably many ways you could evaluate a convergence criterion. Absolute difference and Combo difference seem good candidates, but there's also Relative difference, Relative and Absolute difference at the same time ... I want to preserve flexibility here, so the policy class needs to have a constructor storing all those numbers related to the criterion. Hence the policy simply has to have a member function bool check(double sum1, double sum2) instead of a static member. It can have as many data members and getter/setters as it wants but must also provide a default constructor.

Definition at line 125 of file AdaptiveQuadrature.h.

Member Typedef Documentation

template<typename QuadRule1, typename QuadRule2 = Bisector<QuadRule1>, typename ConvergencePolicy = ComboDifference, typename CellCountPolicy = OnViolationThrow>
using UA_CoMP::Num::AdaptiveQuadrature< QuadRule1, QuadRule2, ConvergencePolicy, CellCountPolicy >::first_rule = AQRule1<QuadRule1>

Definition at line 131 of file AdaptiveQuadrature.h.

template<typename QuadRule1, typename QuadRule2 = Bisector<QuadRule1>, typename ConvergencePolicy = ComboDifference, typename CellCountPolicy = OnViolationThrow>
using UA_CoMP::Num::AdaptiveQuadrature< QuadRule1, QuadRule2, ConvergencePolicy, CellCountPolicy >::second_rule = AQRule2<QuadRule2>

Definition at line 132 of file AdaptiveQuadrature.h.

Constructor & Destructor Documentation

template<typename QuadRule1, typename QuadRule2 = Bisector<QuadRule1>, typename ConvergencePolicy = ComboDifference, typename CellCountPolicy = OnViolationThrow>
UA_CoMP::Num::AdaptiveQuadrature< QuadRule1, QuadRule2, ConvergencePolicy, CellCountPolicy >::AdaptiveQuadrature ( double  convergenceTolerance,
unsigned int  initialCellCount,
unsigned int  cellCountLimit 
)
inline

Constructor initializes everything.

Definition at line 137 of file AdaptiveQuadrature.h.

Member Function Documentation

template<typename QuadRule1, typename QuadRule2 = Bisector<QuadRule1>, typename ConvergencePolicy = ComboDifference, typename CellCountPolicy = OnViolationThrow>
AQRule1<QuadRule1>& UA_CoMP::Num::AdaptiveQuadrature< QuadRule1, QuadRule2, ConvergencePolicy, CellCountPolicy >::rule1 ( )
inline

Return a reference to the first sum rule subobject.

Returns
Reference to first sum rule.
Exceptions
None.

Definition at line 150 of file AdaptiveQuadrature.h.

template<typename QuadRule1, typename QuadRule2 = Bisector<QuadRule1>, typename ConvergencePolicy = ComboDifference, typename CellCountPolicy = OnViolationThrow>
AQRule2<QuadRule2>& UA_CoMP::Num::AdaptiveQuadrature< QuadRule1, QuadRule2, ConvergencePolicy, CellCountPolicy >::rule2 ( )
inline

Return a reference to the second sum rule subobject.

Returns
Reference to first sum rule.
Exceptions
None.

Definition at line 157 of file AdaptiveQuadrature.h.

template<typename QuadRule1 , typename QuadRule2 , typename ConvergencePolicy , typename CellCountPolicy >
template<typename Integrand >
std::tuple< bool, typename Integrand::result_type, typename Integrand::result_type, unsigned int > UA_CoMP::Num::AdaptiveQuadrature< QuadRule1, QuadRule2, ConvergencePolicy, CellCountPolicy >::evaluate ( typename Integrand::argument_type  l,
typename Integrand::argument_type  r,
Integrand  ftor 
) const

Evaluates the quadrature for a functor based on comparing two sum rules.

Returns
True iff both approximating sums satisfy the convergence criterion.
Parameters
lLeft boundary of integration interval.
rRight boundary of integration interval.
ftorIntegrand.
Exceptions
Dependson policies used.

Definition at line 205 of file AdaptiveQuadrature.h.

References sum().

Here is the call graph for this function:

template<typename QuadRule1 , typename QuadRule2 , typename ConvergencePolicy , typename ErrorPolicy >
template<typename Integrand >
Integrand::result_type UA_CoMP::Num::AdaptiveQuadrature< QuadRule1, QuadRule2, ConvergencePolicy, ErrorPolicy >::operator() ( typename Integrand::argument_type  l,
typename Integrand::argument_type  r,
Integrand  ftor 
) const
inline

Simplified version of the evaluate member function, returns only second sum value.

See Also
evaluate
Returns
Value for quadrature.
Parameters
lLeft boundary of integration interval.
rRight boundary of integration interval.
ftorIntegrand.

Definition at line 287 of file AdaptiveQuadrature.h.

template<typename QuadRule1, typename QuadRule2 = Bisector<QuadRule1>, typename ConvergencePolicy = ComboDifference, typename CellCountPolicy = OnViolationThrow>
double UA_CoMP::Num::AdaptiveQuadrature< QuadRule1, QuadRule2, ConvergencePolicy, CellCountPolicy >::getConvergenceTolerance ( ) const
inline

Return the convergence tolerance.

Definition at line 170 of file AdaptiveQuadrature.h.

template<typename QuadRule1, typename QuadRule2 = Bisector<QuadRule1>, typename ConvergencePolicy = ComboDifference, typename CellCountPolicy = OnViolationThrow>
unsigned int UA_CoMP::Num::AdaptiveQuadrature< QuadRule1, QuadRule2, ConvergencePolicy, CellCountPolicy >::getInitialCellCount ( ) const
inline

Return the initial cell count.

Definition at line 173 of file AdaptiveQuadrature.h.

template<typename QuadRule1, typename QuadRule2 = Bisector<QuadRule1>, typename ConvergencePolicy = ComboDifference, typename CellCountPolicy = OnViolationThrow>
unsigned int UA_CoMP::Num::AdaptiveQuadrature< QuadRule1, QuadRule2, ConvergencePolicy, CellCountPolicy >::getCellCountLimit ( ) const
inline

Return the cell count limit.

Definition at line 176 of file AdaptiveQuadrature.h.

template<typename QuadRule1, typename QuadRule2 = Bisector<QuadRule1>, typename ConvergencePolicy = ComboDifference, typename CellCountPolicy = OnViolationThrow>
void UA_CoMP::Num::AdaptiveQuadrature< QuadRule1, QuadRule2, ConvergencePolicy, CellCountPolicy >::setConvergenceTolerance ( double  x)
inline

Set the convergence tolerance.

Definition at line 179 of file AdaptiveQuadrature.h.

Referenced by main().

Here is the caller graph for this function:

template<typename QuadRule1, typename QuadRule2 = Bisector<QuadRule1>, typename ConvergencePolicy = ComboDifference, typename CellCountPolicy = OnViolationThrow>
void UA_CoMP::Num::AdaptiveQuadrature< QuadRule1, QuadRule2, ConvergencePolicy, CellCountPolicy >::setInitialCellCount ( unsigned int  i)
inline

Set initial cell count.

Definition at line 182 of file AdaptiveQuadrature.h.

Referenced by main().

Here is the caller graph for this function:

template<typename QuadRule1, typename QuadRule2 = Bisector<QuadRule1>, typename ConvergencePolicy = ComboDifference, typename CellCountPolicy = OnViolationThrow>
void UA_CoMP::Num::AdaptiveQuadrature< QuadRule1, QuadRule2, ConvergencePolicy, CellCountPolicy >::setCellCountLimit ( unsigned int  i)
inline

Set cell count limit.

Definition at line 185 of file AdaptiveQuadrature.h.

Member Data Documentation


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