Back to home page

EIC code displayed by LXR

 
 

    


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_FunctionRoot_HeaderFile
0018 #define _math_FunctionRoot_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <Standard_Real.hxx>
0025 #include <Standard_OStream.hxx>
0026 class math_FunctionWithDerivative;
0027 
0028 
0029 
0030 //! This class implements the computation of a root of a function of
0031 //! a single variable which is near an initial guess using a minimization
0032 //! algorithm.Knowledge of the derivative is required. The
0033 //! algorithm used is the same as in
0034 class math_FunctionRoot 
0035 {
0036 public:
0037 
0038   DEFINE_STANDARD_ALLOC
0039 
0040   
0041 
0042   //! The Newton-Raphson method is done to find the root of the function F
0043   //! from the initial guess Guess.The tolerance required on
0044   //! the root is given by Tolerance. Iterations are stopped if
0045   //! the expected solution does not stay in the range A..B.
0046   //! The solution is found when abs(Xi - Xi-1) <= Tolerance;
0047   //! The maximum number of iterations allowed is given by NbIterations.
0048   Standard_EXPORT math_FunctionRoot(math_FunctionWithDerivative& F, const Standard_Real Guess, const Standard_Real Tolerance, const Standard_Integer NbIterations = 100);
0049   
0050 
0051   //! The Newton-Raphson method is done to find the root of the function F
0052   //! from the initial guess Guess.
0053   //! The tolerance required on the root is given by Tolerance.
0054   //! Iterations are stopped if the expected solution does not stay in the
0055   //! range A..B
0056   //! The solution is found when abs(Xi - Xi-1) <= Tolerance;
0057   //! The maximum number of iterations allowed is given by NbIterations.
0058   Standard_EXPORT math_FunctionRoot(math_FunctionWithDerivative& F, const Standard_Real Guess, const Standard_Real Tolerance, const Standard_Real A, const Standard_Real B, const Standard_Integer NbIterations = 100);
0059   
0060   //! Returns true if the computations are successful, otherwise returns false.
0061     Standard_Boolean IsDone() const;
0062   
0063   //! returns the value of the root.
0064   //! Exception NotDone is raised if the root was not found.
0065     Standard_Real Root() const;
0066   
0067   //! returns the value of the derivative at the root.
0068   //! Exception NotDone is raised if the root was not found.
0069     Standard_Real Derivative() const;
0070   
0071   //! returns the value of the function at the root.
0072   //! Exception NotDone is raised if the root was not found.
0073     Standard_Real Value() const;
0074   
0075   //! returns the number of iterations really done on the
0076   //! computation of the Root.
0077   //! Exception NotDone is raised if the root was not found.
0078     Standard_Integer NbIterations() const;
0079   
0080   //! Prints on the stream o information on the current state
0081   //! of the object.
0082   //! Is used to redefine the operator <<.
0083   Standard_EXPORT void Dump (Standard_OStream& o) const;
0084 
0085 
0086 
0087 
0088 protected:
0089 
0090 
0091 
0092 
0093 
0094 private:
0095 
0096 
0097 
0098   Standard_Boolean Done;
0099   Standard_Real TheRoot;
0100   Standard_Real TheError;
0101   Standard_Real TheDerivative;
0102   Standard_Integer NbIter;
0103 
0104 
0105 };
0106 
0107 
0108 #include <math_FunctionRoot.lxx>
0109 
0110 
0111 
0112 
0113 
0114 #endif // _math_FunctionRoot_HeaderFile