|
|
|||
File indexing completed on 2026-05-13 08:44:07
0001 // Created on: 1991-03-14 0002 // Created by: Laurent PAINNOT 0003 // Copyright (c) 1991-1999 Matra Datavision 0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS 0005 // 0006 // This file is part of Open CASCADE Technology software library. 0007 // 0008 // This library is free software; you can redistribute it and/or modify it under 0009 // the terms of the GNU Lesser General Public License version 2.1 as published 0010 // by the Free Software Foundation, with special exception defined in the file 0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 0012 // distribution for complete text of the license and disclaimer of any warranty. 0013 // 0014 // Alternatively, this file may be used under the terms of Open CASCADE 0015 // commercial license or contractual agreement. 0016 0017 #ifndef _math_NewtonFunctionRoot_HeaderFile 0018 #define _math_NewtonFunctionRoot_HeaderFile 0019 0020 #include <Standard.hxx> 0021 #include <Standard_DefineAlloc.hxx> 0022 0023 #include <Standard_OStream.hxx> 0024 class math_FunctionWithDerivative; 0025 0026 //! This class implements the calculation of a root of a function of 0027 //! a single variable starting from an initial near guess using the 0028 //! Newton algorithm. Knowledge of the derivative is required. 0029 class math_NewtonFunctionRoot 0030 { 0031 public: 0032 DEFINE_STANDARD_ALLOC 0033 0034 //! The Newton method is done to find the root of the function F 0035 //! from the initial guess Guess. 0036 //! The tolerance required on the root is given by Tolerance. 0037 //! The solution is found when : 0038 //! abs(Xi - Xi-1) <= EpsX and abs(F(Xi))<= EpsF 0039 //! The maximum number of iterations allowed is given by NbIterations. 0040 Standard_EXPORT math_NewtonFunctionRoot(math_FunctionWithDerivative& F, 0041 const Standard_Real Guess, 0042 const Standard_Real EpsX, 0043 const Standard_Real EpsF, 0044 const Standard_Integer NbIterations = 100); 0045 0046 //! The Newton method is done to find the root of the function F 0047 //! from the initial guess Guess. 0048 //! The solution must be inside the interval [A, B]. 0049 //! The tolerance required on the root is given by Tolerance. 0050 //! The solution is found when : 0051 //! abs(Xi - Xi-1) <= EpsX and abs(F(Xi))<= EpsF 0052 //! The maximum number of iterations allowed is given by NbIterations. 0053 Standard_EXPORT math_NewtonFunctionRoot(math_FunctionWithDerivative& F, 0054 const Standard_Real Guess, 0055 const Standard_Real EpsX, 0056 const Standard_Real EpsF, 0057 const Standard_Real A, 0058 const Standard_Real B, 0059 const Standard_Integer NbIterations = 100); 0060 0061 //! is used in a sub-class to initialize correctly all the fields 0062 //! of this class. 0063 Standard_EXPORT math_NewtonFunctionRoot(const Standard_Real A, 0064 const Standard_Real B, 0065 const Standard_Real EpsX, 0066 const Standard_Real EpsF, 0067 const Standard_Integer NbIterations = 100); 0068 0069 //! is used internally by the constructors. 0070 Standard_EXPORT void Perform(math_FunctionWithDerivative& F, const Standard_Real Guess); 0071 0072 //! Returns true if the computations are successful, otherwise returns false. 0073 Standard_Boolean IsDone() const; 0074 0075 //! Returns the value of the root of function <F>. 0076 //! Exception NotDone is raised if the root was not found. 0077 Standard_Real Root() const; 0078 0079 //! returns the value of the derivative at the root. 0080 //! Exception NotDone is raised if the root was not found. 0081 Standard_Real Derivative() const; 0082 0083 //! returns the value of the function at the root. 0084 //! Exception NotDone is raised if the root was not found. 0085 Standard_Real Value() const; 0086 0087 //! Returns the number of iterations really done on the 0088 //! computation of the Root. 0089 //! Exception NotDone is raised if the root was not found. 0090 Standard_Integer NbIterations() const; 0091 0092 //! Prints information on the current state of the object. 0093 Standard_EXPORT void Dump(Standard_OStream& o) const; 0094 0095 protected: 0096 private: 0097 Standard_Boolean Done; 0098 Standard_Real X; 0099 Standard_Real Fx; 0100 Standard_Real DFx; 0101 Standard_Integer It; 0102 Standard_Real EpsilonX; 0103 Standard_Real EpsilonF; 0104 Standard_Integer Itermax; 0105 Standard_Real Binf; 0106 Standard_Real Bsup; 0107 }; 0108 0109 #include <math_NewtonFunctionRoot.lxx> 0110 0111 #endif // _math_NewtonFunctionRoot_HeaderFile
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|