|
|
|||
Warning, file /include/opencascade/math_NewtonFunctionSetRoot.hxx was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 // Created on: 1991-05-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_NewtonFunctionSetRoot_HeaderFile 0018 #define _math_NewtonFunctionSetRoot_HeaderFile 0019 0020 #include <Standard.hxx> 0021 #include <Standard_DefineAlloc.hxx> 0022 0023 #include <Standard_Integer.hxx> 0024 #include <math_Vector.hxx> 0025 #include <math_IntegerVector.hxx> 0026 #include <math_Matrix.hxx> 0027 #include <Standard_OStream.hxx> 0028 class math_FunctionSetWithDerivatives; 0029 0030 //! This class computes the root of a set of N functions of N variables, 0031 //! knowing an initial guess at the solution and using the 0032 //! Newton Raphson algorithm. Knowledge of all the partial 0033 //! derivatives (Jacobian) is required. 0034 class math_NewtonFunctionSetRoot 0035 { 0036 public: 0037 DEFINE_STANDARD_ALLOC 0038 0039 //! Initialize correctly all the fields of this class. 0040 //! The range (1, F.NbVariables()) must be especially respected for 0041 //! all vectors and matrix declarations. 0042 Standard_EXPORT math_NewtonFunctionSetRoot(math_FunctionSetWithDerivatives& theFunction, 0043 const math_Vector& theXTolerance, 0044 const double theFTolerance, 0045 const int theNbIterations = 100); 0046 0047 //! This constructor should be used in a sub-class to initialize 0048 //! correctly all the fields of this class. 0049 //! The range (1, F.NbVariables()) must be especially respected for 0050 //! all vectors and matrix declarations. 0051 //! The method SetTolerance must be called before performing the algorithm. 0052 Standard_EXPORT math_NewtonFunctionSetRoot(math_FunctionSetWithDerivatives& theFunction, 0053 const double theFTolerance, 0054 const int theNbIterations = 100); 0055 0056 //! Destructor 0057 Standard_EXPORT virtual ~math_NewtonFunctionSetRoot(); 0058 0059 //! Initializes the tolerance values for the unknowns. 0060 Standard_EXPORT void SetTolerance(const math_Vector& XTol); 0061 0062 //! The Newton method is done to improve the root of the function 0063 //! from the initial guess point. The solution is found when: 0064 //! abs(Xj - Xj-1)(i) <= XTol(i) and abs(Fi) <= FTol for all i; 0065 Standard_EXPORT void Perform(math_FunctionSetWithDerivatives& theFunction, 0066 const math_Vector& theStartingPoint); 0067 0068 //! The Newton method is done to improve the root of the function 0069 //! from the initial guess point. Bounds may be given, to constrain the solution. 0070 //! The solution is found when: 0071 //! abs(Xj - Xj-1)(i) <= XTol(i) and abs(Fi) <= FTol for all i; 0072 Standard_EXPORT void Perform(math_FunctionSetWithDerivatives& theFunction, 0073 const math_Vector& theStartingPoint, 0074 const math_Vector& theInfBound, 0075 const math_Vector& theSupBound); 0076 0077 //! This method is called at the end of each iteration to check if the 0078 //! solution is found. 0079 //! Vectors DeltaX, Fvalues and Jacobian Matrix are consistent with the 0080 //! possible solution Vector Sol and can be inspected to decide whether 0081 //! the solution is reached or not. 0082 virtual bool IsSolutionReached(math_FunctionSetWithDerivatives& F); 0083 0084 //! Returns true if the computations are successful, otherwise returns false. 0085 bool IsDone() const; 0086 0087 //! Returns the value of the root of function F. 0088 //! Exceptions 0089 //! StdFail_NotDone if the algorithm fails (and IsDone returns false). 0090 const math_Vector& Root() const; 0091 0092 //! outputs the root vector in Root. 0093 //! Exception NotDone is raised if the root was not found. 0094 //! Exception DimensionError is raised if the range of Root is 0095 //! not equal to the range of the StartingPoint. 0096 void Root(math_Vector& Root) const; 0097 0098 //! Outputs the state number associated with the solution 0099 //! vector root. 0100 int StateNumber() const; 0101 0102 //! Returns the matrix value of the derivative at the root. 0103 //! Exception NotDone is raised if the root was not found. 0104 const math_Matrix& Derivative() const; 0105 0106 //! Outputs the matrix value of the derivative at the root in 0107 //! Der. 0108 //! Exception NotDone is raised if the root was not found. 0109 //! Exception DimensionError is raised if the range of Der is 0110 //! not equal to the range of the StartingPoint. 0111 void Derivative(math_Matrix& Der) const; 0112 0113 //! Returns the vector value of the error done on the 0114 //! functions at the root. 0115 //! Exception NotDone is raised if the root was not found. 0116 const math_Vector& FunctionSetErrors() const; 0117 0118 //! Outputs the vector value of the error done on the 0119 //! functions at the root in Err. 0120 //! Exception NotDone is raised if the root was not found. 0121 //! Exception DimensionError is raised if the range of Err is 0122 //! not equal to the range of the StartingPoint. 0123 void FunctionSetErrors(math_Vector& Err) const; 0124 0125 //! Returns the number of iterations really done 0126 //! during the computation of the Root. 0127 //! Exception NotDone is raised if the root was not found. 0128 int NbIterations() const; 0129 0130 //! Prints information on the current state of the object. 0131 //! Is used to redefine the operator <<. 0132 Standard_EXPORT void Dump(Standard_OStream& o) const; 0133 0134 protected: 0135 math_Vector TolX; 0136 double TolF; 0137 math_IntegerVector Indx; 0138 math_Vector Scratch; 0139 math_Vector Sol; 0140 math_Vector DeltaX; 0141 math_Vector FValues; 0142 math_Matrix Jacobian; 0143 0144 private: 0145 bool Done; 0146 int State; 0147 int Iter; 0148 int Itermax; 0149 }; 0150 0151 #include <math_NewtonFunctionSetRoot.lxx> 0152 0153 #endif // _math_NewtonFunctionSetRoot_HeaderFile
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|