Overload List
Overload 1: double QuadGauss(TRealFunction Fun, double lb, double ub, TVec *BasePoints, TVec *Weights, int Parts);
Numerical integration by using regular Gaussian quadrature scheme.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | Fun | TRealFunction | |
| 2 | lb | double | |
| 3 | ub | double | |
| 4 | BasePoints | TVec * | |
| 5 | Weights | TVec * | |
| 6 | Parts | int |
Returns: the numerical approximate on integral of function Fun between limits lb and ub.
Check the following link to learn more about this algorithm
#include "MtxExpr.h"
#include "MtxVec.h"
#include "Units.Math387.h"
#include "Units.MtxIntDiff.h"
using namespace Dew;
using namespace Dew::Math;
using namespace Dew::Math::Units;
using namespace Dew::Math::Units::Math387;
static double IntFun(TVec* Parameters, TVec* c, const DewArray<tObject*>& o)
{
double x = (*Parameters)[0];
return Sin(x)*Exp(-x*x);
}
void Example()
{
Vector bpoints(0);
Vector weights(0);
MtxIntDiff::WeightsGauss(10, bpoints, weights);
double area = MtxIntDiff::QuadGauss(IntFun, -0.5*PI, PI, bpoints, weights, 64);
}
Overload 2: double QuadGauss(TRealFunction Fun, double lb, double ub, TVec *Constants, const DewArray<tObject *> &ObjConst, TVec *BasePoints, TVec *Weights, int Parts);
Numerical integration by using regular Gaussian quadrature scheme (Fun defined only with double(s)).
| # | Name | Type | Description |
|---|---|---|---|
| 1 | Fun | TRealFunction | |
| 2 | lb | double | |
| 3 | ub | double | |
| 4 | Constants | TVec * | |
| 5 | ObjConst | const DewArray<tObject *> & | |
| 6 | BasePoints | TVec * | |
| 7 | Weights | TVec * | |
| 8 | Parts | int |
#include "MtxIntDiff.h"
#include "MtxVec.h"
#include "Units.Math387.h"
#include "Units.MtxIntDiff.h"
using namespace Dew;
using namespace Dew::Math;
using namespace Dew::Math::Units::Math387;
using namespace Dew::Math::Units::MtxIntDiff;
// Integrating function
static double IntFunc(TVec* Parameters, TVec* Constants, const DewArray<tObject*>& ObjConst)
{
double x;
x = (*Parameters)[0];
return Sin(x)*Exp(-x*x);
}
// Integrate
void Example()
{
double area;
TIntStopReason sr;
area = QuadGauss(IntFunc, -0.5*PI, PI, sr, TMtxFloatPrecision::mvDouble);
}
Overload 3: double QuadGauss(TRealFunction Fun, double lb, double ub, TVec *Constants, const DewArray<tObject *> &ObjConst, TIntStopReason &StopReason, const TMtxFloatPrecision FloatPrecision, TQuadMethod QMethod = TQuadMethod::qmGauss, double Tolerance = 1.0E-4, int MaxIter = 8);
Evaluate the numerical integral between lower and upper bound using Gauss quadrature algorithm.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | Fun | TRealFunction | |
| 2 | lb | double | |
| 3 | ub | double | |
| 4 | Constants | TVec * | |
| 5 | ObjConst | const DewArray<tObject *> & | |
| 6 | StopReason | TIntStopReason & | |
| 7 | FloatPrecision | const TMtxFloatPrecision | |
| 8 | QMethod = TQuadMethod::qmGauss | TQuadMethod | |
| 9 | Tolerance = 1.0E-4 | double | |
| 10 | MaxIter = 8 | int |
Returns: the numerical approximate on integral of function Fun between limits lb and ub.
This version calculates base points and weights on the fly.
Overload 4: double QuadGauss(TRealFunction Fun, double lb, double ub, TIntStopReason &StopReason, const TMtxFloatPrecision FloatPrecision, TQuadMethod QMethod = TQuadMethod::qmGauss, double Tolerance = 1.0E-4, int MaxIter = 8);
Integration by using Gauss quadrature algorithm with no additional parameters for Fun.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | Fun | TRealFunction | |
| 2 | lb | double | |
| 3 | ub | double | |
| 4 | StopReason | TIntStopReason & | |
| 5 | FloatPrecision | const TMtxFloatPrecision | |
| 6 | QMethod = TQuadMethod::qmGauss | TQuadMethod | |
| 7 | Tolerance = 1.0E-4 | double | |
| 8 | MaxIter = 8 | int |
Returns: the numerical approximate on integral of function Fun between limits lb and ub.
This version calculates base points and weights on the fly.
Note
Use this overload if integrating function is defined only by double parameter(s).
#include "MtxIntDiff.h"
#include "MtxVec.h"
#include "Units.Math387.h"
#include "Units.MtxIntDiff.h"
using namespace Dew;
using namespace Dew::Math;
using namespace Dew::Math::Units;
using namespace Dew::Math::Units::Math387;
static double IntFun(TVec* Parameters, TVec* c, const DewArray<tObject*>& o)
{
double x = (*Parameters)[0];
return Sin(x)*Exp(-x*x);
}
void Example()
{
TIntStopReason sr;
double area = MtxIntDiff::QuadGauss(IntFun, -0.5*PI, PI, sr, TMtxFloatPrecision::mvDouble, TQuadMethod::qmGauss, 1.0e-4, 8);
}