MtxIntDiff::QuadGauss Function

Overload List

#SignatureDescription
1double QuadGauss(TRealFunction Fun, double lb, double ub, TVec *BasePoints, TVec *Weights, int Parts);Numerical integration by using regular Gaussian quadrature scheme.
2double 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)).
3double 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.
4double 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.

Overload 1: double QuadGauss(TRealFunction Fun, double lb, double ub, TVec *BasePoints, TVec *Weights, int Parts);

Numerical integration by using regular Gaussian quadrature scheme.

#NameTypeDescription
1FunTRealFunction
2lbdouble
3ubdouble
4BasePointsTVec *
5WeightsTVec *
6Partsint

Returns: the numerical approximate on integral of function Fun between limits lb and ub.

Remarks:

Check the following link to learn more about this algorithm

Examples
#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);
}
See Also: MtxIntDiff::Romberg, MtxIntDiff::WeightsGauss, MtxIntDiff::WeightsNewtonCotes, MtxIntDiff::WeightsChebyshevGauss
Declared in Dew::Math::Units::MtxIntDiff · Dew.Math/Units.MtxIntDiff.h · Cross-compiler

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)).

#NameTypeDescription
1FunTRealFunction
2lbdouble
3ubdouble
4ConstantsTVec *
5ObjConstconst DewArray<tObject *> &
6BasePointsTVec *
7WeightsTVec *
8Partsint
Examples
#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);
}
Declared in Dew::Math::Units::MtxIntDiff · Dew.Math/Units.MtxIntDiff.h · Cross-compiler

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.

#NameTypeDescription
1FunTRealFunction
2lbdouble
3ubdouble
4ConstantsTVec *
5ObjConstconst DewArray<tObject *> &
6StopReasonTIntStopReason &
7FloatPrecisionconst TMtxFloatPrecision
8QMethod = TQuadMethod::qmGaussTQuadMethod
9Tolerance = 1.0E-4double
10MaxIter = 8int

Returns: the numerical approximate on integral of function Fun between limits lb and ub.

Remarks:

This version calculates base points and weights on the fly.

See Also: MtxIntDiff::Romberg
Declared in Dew::Math::Units::MtxIntDiff · Dew.Math/Units.MtxIntDiff.h · Cross-compiler

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.

#NameTypeDescription
1FunTRealFunction
2lbdouble
3ubdouble
4StopReasonTIntStopReason &
5FloatPrecisionconst TMtxFloatPrecision
6QMethod = TQuadMethod::qmGaussTQuadMethod
7Tolerance = 1.0E-4double
8MaxIter = 8int

Returns: the numerical approximate on integral of function Fun between limits lb and ub.

Remarks:

This version calculates base points and weights on the fly.

Note
Use this overload if integrating function is defined only by double parameter(s).

Examples
#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);
}
Declared in Dew::Math::Units::MtxIntDiff · Dew.Math/Units.MtxIntDiff.h · Cross-compiler