Integration of OCCT 6.5.0 from SVN
[occt.git] / src / AppParCurves / AppParCurves_BSpGradient_BFGS.gxx
1 // File:        AppParCurves_BSpGradient_BFGS.gxx
2 // Created:     Thu Dec 16 13:02:58 1999
3 // Author:      Atelier CAS2000
4 //              <cas@cageox.paris1.matra-dtv.fr>
5
6
7
8 // Redefinition de math_BFGS:
9 // ==========================
10
11 AppParCurves_BSpGradient_BFGS::AppParCurves_BSpGradient_BFGS(math_MultipleVarFunctionWithGradient& F,
12                                                              const math_Vector& StartingPoint,
13                                                              const Standard_Real Tolerance3d,
14                                                              const Standard_Real Tolerance2d,
15                                                              const Standard_Real Eps,
16                                                              const Standard_Integer NbIterations):
17        math_BFGS(F, Eps, NbIterations, Eps),
18        myTol3d(Tolerance3d),
19        myTol2d(Tolerance2d) 
20 {
21   
22   Perform(F, StartingPoint);
23 }
24
25 Standard_Boolean AppParCurves_BSpGradient_BFGS::IsSolutionReached(math_MultipleVarFunctionWithGradient& F) const {
26   Standard_Boolean Result, Result2;
27   AppParCurves_BSpParFunction *F1 = (AppParCurves_BSpParFunction*) &F;
28   
29   Result = (2.0 * fabs(TheMinimum - PreviousMinimum) <= 
30             1.e-10 * (fabs(TheMinimum) + fabs(PreviousMinimum))+1.e-12) ;
31   Standard_Real MErr3d = F1->MaxError3d();
32   Standard_Real MErr2d = F1->MaxError2d();    
33   Result2 = ((MErr3d <= myTol3d) && (MErr2d <= myTol2d));
34   
35   return (Result || Result2);
36 }
37
38
39