void WeightsNewtonCotes(int PolyOrder, TVec *Points, TVec *Weights, const TMtxFloatPrecision FloatPrecision = TMtxFloatPrecision::mvDouble);
Newton-Cotes base points and weights.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | PolyOrder | int | Defines the interpolating polynomial order. |
| 2 | Points | TVec * | Returns base points coordinate. |
| 3 | Weights | TVec * | Returns weights. |
| 4 | FloatPrecision = TMtxFloatPrecision::mvDouble | const TMtxFloatPrecision | Specifies the precision of the weights to be returned. |
Remarks:
Uses the Newton-Cotes formulas to calculate base points and weights for numerical integration. Check the following link to learn more about Newton-Cotes formulas.
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;
using namespace Dew::Math::Units::MtxIntDiff;
// Integrating function
static double IntFunc(TVec* Parameters, TVec* c, const DewArray<tObject*>& o)
{
double x = (*Parameters)[0];
return Sin(x);
}
// Integrate
void Example()
{
Vector bpoints(0);
Vector weights(0);
MtxIntDiff::WeightsNewtonCotes(2, bpoints, weights); // 2 means Simpson
double area = QuadGauss(IntFunc, 0, PI, bpoints, weights, 1);
}
Declared in Dew::Math::Units::MtxIntDiff · Dew.Math/Units.MtxIntDiff.h · Cross-compiler