Intg Class Template Reference

Abstract class template supports calculations of definite integrals for user-supplied functions. More...

#include <Intg.h>

Inherits Base.

Inherited by Romb, Simp, and Trap.

Inheritance diagram for Intg:

Inheritance graph
[legend]
List of all members.

Public Types

enum  CTYPE { TRAPEZOID = 0, SIMPSON, ROMBERG, CTYPE_CNT }
 CTYPE_CNT
 LOOP_CURRENT = 0
 LOOP_MAXIMUM
 ROMBERG
 SIMPSON
 TRAPEZOID = 0
enum  VTYPE { LOOP_CURRENT = 0, LOOP_MAXIMUM, VTYPE_CNT }
 VTYPE_CNT

Public Member Functions

yType eval (xType x1, xType x2) throw (IntgErr)
yType evalIntegrand (xType x) const
int getCount (enum Intg< xType, yType >::VTYPE vType) const
xType getError (void) const
enum Intg< xType, yType
>::CTYPE 
getMethod (void) const
virtual bool setCount (int nMaximum)
bool setEpsilon (xType dEps)

Static Public Attributes

static const int DEF_LOOP_MAX = 20

Protected Member Functions

 Intg (const Intg &ig)
 Intg (yType(&rFn)(xType), xType dEps)
virtual yType intgMethod (void)=0 throw (IntgErr)
yType refine (int ninc)
 ~Intg (void)

Protected Attributes

enum Intg< xType, yType
>::CTYPE 
cTyp
xType eps
int nCount [VTYPE_CNT]

Detailed Description

template<typename xType, typename yType>
class calc::Intg< xType, yType >

Abstract class template supports calculations of definite integrals for user-supplied functions.

Object instantiation of this class should be made only through classes which inherit this class.

The declaration typename <xType> specifies the form of independent variables used in integral calculations. The declaration typename <yType> specifies the form of solution variables used in integral calculations. In general, the <yType> variables should be the equal or superset of the <xType> variables.

See the cited References to obtain more information on the mathematical theory applied here.

Author
efgeorge
Date
2006/07/19 13:21:43
Revision
1.3
Examples:

example_Intg.txt.


Member Enumeration Documentation

enum CTYPE

Enumeration indicates the class index of the integration method used.

Enumerator:
TRAPEZOID  index of a calc::Trap object using the trapezoid rule
SIMPSON  index of a calc::Simp object using Simpson's rule
ROMBERG  index of a calc::Romb object using Romberg's method
CTYPE_CNT  class type index count

enum VTYPE

Enumeration indicates the variable index of the object property.

Enumerator:
LOOP_CURRENT  index of the current loop count used in the previous integration evaluation
LOOP_MAXIMUM  index of the loop count limit used for the integration evaluations
VTYPE_CNT  variable type index count


Constructor & Destructor Documentation

Intg ( yType(&)(xType)  rFn,
xType  dEps 
) [protected]

Constructor initializes a function integration object.

Parameters:
rFn a reference to an integrand evaluation function
dEps required error of the calculated integral (|y| units)
Remarks:
  • The specified integration tolerance dEps must be greater than zero.
  • The specified function rFn(x) calculates an integrand value given an independent variable value.
  • The function rFn(x) accepts a single independent value (x units).
  • The function rFn(x) returns a single valued integrand value (y units) at the specified point x.
  • Function declaration: yType fn(xType x);

Intg ( const Intg< xType, yType > &  ig  )  [protected]

Copy constructor initializes a function integration object from the specified existing integration object.

Parameters:
ig a reference to a function integration object

~Intg ( void   )  [protected]

Destructor is a place holder, no dynamic memory is allocated.


Member Function Documentation

yType eval ( xType  x1,
xType  x2 
) throw (IntgErr)

Function integrates the specified integrand function with the current integration method using decreasing step size until the specified error limit is achieved.

Parameters:
x1 integral lower bound (x units)
x2 integral upper bound (x units)
Returns:
the calculated value of the definite integral (x*y units)
Exceptions:
IntgErr type of object thrown

yType evalIntegrand ( xType  x  )  const

Function evaluates the user specified integrand function at the specified value x.

Parameters:
x value at which to evaluate the integrand function (x units)
Returns:
calculated integrand function value (y units)

int getCount ( enum Intg< xType, yType >::VTYPE  vType  )  const

Function returns loop information pertaining to algorithm iterations.

Parameters:
vType variable index indentifying the type of data
Returns:
the loop count property of the object
Remarks:
  • Valid loop values should be above 0.
  • If the object is not initialized, -1 is returned.
  • If the object does not have the variable identified by vType, -1 is returned.

xType getError ( void   )  const

Function returns the current error criterion used in integration evaluation.

Returns:
error tolerance of the integration value (|y| units)

enum Intg< xType, yType >::CTYPE getMethod ( void   )  const

Function returns an enumeration index indicating the calculation method used in the integration evaluation.

Returns:
an index of the enumeration Intg::CTYPE identifying the integration method of the integration object
Remarks:
The integration method index (Intg::CTYPE) can be one of the following values:
  • TRAPEZOID (trapezoid rule - linear approximation)
  • SIMPSON (Simpson's rule - quadratic approximation)
  • ROMBERG (Romberg's method - extrapolated error approximation)

virtual yType intgMethod ( void   )  throw (IntgErr) [protected, pure virtual]

Virtual function integrates the specified user function with a specific method.

Returns:
the calculated integration value using the class integration method (x*y units)
Exceptions:
IntgErr type of object thrown

yType refine ( int  ninc  )  [protected]

Function improves integration by adding 2^(ninc-1) integration evaluation steps using the trapezoid rule.

Parameters:
ninc integration refinement index
Returns:
integral value with improved accuracy (x*y units)

bool setCount ( int  nMaximum  )  [virtual]

Virtual function sets the current maximum loop count used in the integration evaluation.

Parameters:
nMaximum the maximum loop count value
Returns:
status flag
  • false (successful execution)
  • true (execution error, parameter not set)
Remarks:
The loop count value nMaximum must be greater than zero.

Reimplemented in Romb.

bool setEpsilon ( xType  dEps  ) 

Function sets the current error criterion used in integration evaluation.

Parameters:
dEps error tolerance of the integration value (|y| units)
Returns:
status flag
  • false (successful execution)
  • true (execution error, parameter not set)
Remarks:
The tolerance value of dEps must be greater than zero.


Member Data Documentation

enum Intg< xType, yType >::CTYPE cTyp [protected]

class type index

const int DEF_LOOP_MAX = 20 [static]

default maximum iteration loop count

xType eps [protected]

required error of integral (|y| units)

int nCount[VTYPE_CNT] [protected]

variable values of integration


The documentation for this class was generated from the following files:
Generated on Wed Jul 19 09:24:11 2006 for CalcLib by  doxygen 1.4.7