1 // File math_GaussSingleIntegration.cxx
4 Par Gauss le calcul d'une integrale simple se transforme en sommation des
5 valeurs de la fonction donnee aux <Order> points de Gauss affectee des poids
8 Les points et poids de Gauss sont stockes dans GaussPoints.cxx.
9 Les points sont compris entre les valeurs -1 et +1, ce qui necessite un
10 changement de variable pour les faire varier dans l'intervalle [Lower, Upper].
13 On veut calculer Integrale( f(u)* du) entre a et b.
18 1- calcul de la fonction au ieme point de Gauss (apres changement de variable).
20 2- multiplication de cette valeur par le ieme poids de Gauss.
22 3- sommation de toutes ces valeurs.
24 4- retour a l'intervalle [Lower, Upper] de notre integrale.
29 #define No_Standard_RangeError
30 #define No_Standard_OutOfRange
31 #define No_Standard_DimensionError
34 #include <math_GaussSingleIntegration.ixx>
37 #include <math_Vector.hxx>
38 #include <math_Function.hxx>
40 math_GaussSingleIntegration::math_GaussSingleIntegration() : Done(Standard_False)
44 math_GaussSingleIntegration::
45 math_GaussSingleIntegration(math_Function& F,
46 const Standard_Real Lower,
47 const Standard_Real Upper,
48 const Standard_Integer Order)
50 Standard_Integer theOrder = Min(math::GaussPointsMax(), Order);
51 Perform(F, Lower, Upper, theOrder);
54 math_GaussSingleIntegration::
55 math_GaussSingleIntegration(math_Function& F,
56 const Standard_Real Lower,
57 const Standard_Real Upper,
58 const Standard_Integer Order,
59 const Standard_Real Tol)
61 Standard_Integer theOrder = Min(math::GaussPointsMax(), Order);
63 const Standard_Integer IterMax = 13; // Max number of iteration
64 Standard_Integer NIter = 1; // current number of iteration
65 Standard_Integer NbInterval = 1; // current number of subintervals
66 Standard_Real dU,OldLen,Len;
68 Perform(F, Lower, Upper, theOrder);
74 dU = (Upper-Lower)/NbInterval;
75 for (Standard_Integer i=1; i<=NbInterval; i++) {
76 Perform(F, Lower+(i-1)*dU, Lower+i*dU, theOrder);
82 while (fabs(OldLen-Len) > Tol && NIter <= IterMax);
87 void math_GaussSingleIntegration::Perform(math_Function& F,
88 const Standard_Real Lower,
89 const Standard_Real Upper,
90 const Standard_Integer Order)
92 Standard_Real xr, xm, dx;
96 math_Vector GaussP(1, Order);
97 math_Vector GaussW(1, Order);
98 Done = Standard_False;
100 //Recuperation des points de Gauss dans le fichier GaussPoints.
101 math::GaussPoints(Order,GaussP);
102 math::GaussWeights(Order,GaussW);
104 // Calcul de l'integrale aux points de Gauss :
106 // Changement de variable pour la mise a l'echelle [Lower, Upper] :
107 xm = 0.5*(Upper + Lower);
108 xr = 0.5*(Upper - Lower);
111 Standard_Integer ind = Order/2, ind1 = (Order+1)/2;
112 if(ind1 > ind) { // odder case
113 Ok1 = F.Value(xm, Val);
117 // Sommation sur tous les points de Gauss: avec utilisation de la symetrie.
118 for (j = 1; j <= ind; j++) {
120 Ok1 = F.Value(xm-dx, F1);
122 Ok1 = F.Value(xm+dx, F2);
124 // Multiplication par les poids de Gauss.
125 Standard_Real FT = F1+F2;
128 // Mise a l'echelle de l'intervalle [Lower, Upper]
130 Done = Standard_True;
133 void math_GaussSingleIntegration::Dump(Standard_OStream& o) const {
135 o <<"math_GaussSingleIntegration ";
137 o << " Status = Done \n";
138 o << "Integration Value = " << Val<<"\n";
141 o << "Status = not Done \n";