You are here: Symbol Reference > MtxIntDiff Namespace > Functions > MtxIntDiff.WeightsGauss Function
MtxVec VCL
ContentsIndex
PreviousUpNext
MtxIntDiff.WeightsGauss Function

Gauss base points and weights.

Pascal
procedure WeightsGauss(NumPoints: Integer; const Points: TVec; const Weights: TVec; const FloatPrecision: TMtxFloatPrecision = mvDouble);

Calculates base points and weight factors by using the so called Gauss algorithm given by Davis and Rabinowitz in 'Methods of Numerical Integration', page 365, Academic Press, 1975.

Use a ten point Gauss formula to evaluate six(x) on interval [0,PI]. For start use only one subsection. 

 

// Integrating function function IntFunc(const Parameters: TVec; Const Constants: TVec; const ObjConst: Array of TObject): double; var x: double; begin x := Parameters[0]; IntFunc := Sin(x); end; // Integrate procedure DoIntegrate; var bpoints,weights: Vector; area: double; begin WeightsGauss(10,bpoints,weights); area := QuadGauss(IntFunc,0,PI,bpoints,weights,1); end;
#include "MtxExpr.hpp" #include "Math387.hpp" #include "MtxIntDiff.hpp" // Integrating function double __fastcall IntFun(TVec * const Parameters, TVec * const Constants, System::TObject* const * ObjConst, const int ObjConst_Size) { double x = (*Parameters)[0]; return Math.Sin(x)*Math.Exp(-x*x); } void __fastcall Example(); { sVector bpoints, weights; WeightsGauss(10,bpoints,weights); double area = QuadGauss(IntFun,-0.5*PI,PI,bpoints,weights,64); }
Examples on GitHub
Copyright (c) 1999-2025 by Dew Research. All rights reserved.
What do you think about this topic? Send feedback!