|
||||
File indexing completed on 2025-01-18 10:04:14
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_BissecNewton_HeaderFile 0018 #define _math_BissecNewton_HeaderFile 0019 0020 #include <Standard.hxx> 0021 #include <Standard_DefineAlloc.hxx> 0022 #include <Standard_Handle.hxx> 0023 0024 #include <math_Status.hxx> 0025 #include <Standard_Real.hxx> 0026 #include <Standard_OStream.hxx> 0027 class math_FunctionWithDerivative; 0028 0029 0030 0031 //! This class implements a combination of Newton-Raphson and bissection 0032 //! methods to find the root of the function between two bounds. 0033 //! Knowledge of the derivative is required. 0034 class math_BissecNewton 0035 { 0036 public: 0037 0038 DEFINE_STANDARD_ALLOC 0039 0040 0041 //! Constructor. 0042 //! @param theXTolerance - algorithm tolerance. 0043 Standard_EXPORT math_BissecNewton(const Standard_Real theXTolerance); 0044 0045 0046 //! A combination of Newton-Raphson and bissection methods is done to find 0047 //! the root of the function F between the bounds Bound1 and Bound2 0048 //! on the function F. 0049 //! The tolerance required on the root is given by TolX. 0050 //! The solution is found when: 0051 //! abs(Xi - Xi-1) <= TolX and F(Xi) * F(Xi-1) <= 0 0052 //! The maximum number of iterations allowed is given by NbIterations. 0053 Standard_EXPORT void Perform (math_FunctionWithDerivative& F, const Standard_Real Bound1, const Standard_Real Bound2, const Standard_Integer NbIterations = 100); 0054 0055 0056 //! This method is called at the end of each iteration to check if the 0057 //! solution has been found. 0058 //! It can be redefined in a sub-class to implement a specific test to 0059 //! stop the iterations. 0060 virtual Standard_Boolean IsSolutionReached (math_FunctionWithDerivative& theFunction); 0061 0062 //! Tests is the root has been successfully found. 0063 Standard_Boolean IsDone() const; 0064 0065 //! returns the value of the root. 0066 //! Exception NotDone is raised if the minimum was not found. 0067 Standard_Real Root() const; 0068 0069 //! returns the value of the derivative at the root. 0070 //! Exception NotDone is raised if the minimum was not found. 0071 Standard_Real Derivative() const; 0072 0073 //! returns the value of the function at the root. 0074 //! Exception NotDone is raised if the minimum was not found. 0075 Standard_Real Value() const; 0076 0077 //! Prints on the stream o information on the current state 0078 //! of the object. 0079 //! Is used to redifine the operator <<. 0080 Standard_EXPORT void Dump (Standard_OStream& o) const; 0081 0082 //! Destructor 0083 Standard_EXPORT virtual ~math_BissecNewton(); 0084 0085 0086 0087 0088 protected: 0089 0090 0091 0092 math_Status TheStatus; 0093 Standard_Real XTol; 0094 Standard_Real x; 0095 Standard_Real dx; 0096 Standard_Real f; 0097 Standard_Real df; 0098 0099 0100 private: 0101 0102 0103 0104 Standard_Boolean Done; 0105 0106 0107 }; 0108 0109 0110 #include <math_BissecNewton.lxx> 0111 0112 0113 0114 0115 0116 #endif // _math_BissecNewton_HeaderFile
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |