MBSim

Project Page
multi_dimensional_newton_method.h
1 /* Copyright (C) 2004-2012 MBSim Development Team
2  *
3  * This library is free software; you can redistribute it and/or
4  * modify it under the terms of the GNU Lesser General Public
5  * License as published by the Free Software Foundation; either
6  * version 2.1 of the License, or (at your option) any later version.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public
14  * License along with this library; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16  *
17  * Contact: martin.o.foerg@googlemail.com
18  */
19 
20 #ifndef NUMERICS_NUMERICSMULTIDIMENSIONALNEWTONMETHOD_H_
21 #define NUMERICS_NUMERICSMULTIDIMENSIONALNEWTONMETHOD_H_
22 
23 #include <fmatvec.h>
24 
25 #include <map>
26 
27 #include <mbsim/numerics/functions/newton_method_jacobian_functions.h>
28 #include <mbsim/numerics/functions/criteria_functions.h>
29 #include <mbsim/numerics/functions/damping_functions.h>
30 
31 namespace fmatvec {
32  bool operator<(const fmatvec::Index & i1, const fmatvec::Index & i2);
33 }
34 
35 namespace MBSim {
36 
42  public:
47 
48  virtual ~MultiDimensionalNewtonMethod() {
49  }
50 
51  /* GETTER / SETTER */
52  int getNumberOfIterations() const {
53  return iter;
54  }
55  int getNumberOfMaximalIterations() const {
56  return itermax;
57  }
58  int getInfo() const {
59  return info;
60  }
61  void setMaximumNumberOfIterations(int itmax_) {
62  itermax = itmax_;
63  }
64  void setFunction(Function1<fmatvec::Vec, fmatvec::Vec> *function_) {
65  function = function_;
66  }
67  void setJacobianFunction(NewtonJacobianFunction * jacobian_) {
68  jacobian = jacobian_;
69  }
70  void setDampingFunction(DampingFunction * damping_) {
71  damping = damping_;
72  }
73  void setCriteriaFunction(CriteriaFunction * criteria_) {
74  criteria = criteria_;
75  }
76  CriteriaFunction * getCriteriaFunction() {
77  return criteria;
78  }
79  /***************************************************/
80 
85  fmatvec::Vec solve(const fmatvec::Vec & initialValue);
86 
87  private:
88 
93 
98 
99  /*
100  * \brief damping function
101  */
102  DampingFunction *damping;
103 
104  /*
105  * \brief criteria function
106  *
107  * This function defines the criteria when to stop the Newton algorithm
108  */
109  CriteriaFunction *criteria;
110 
114  int itermax;
115 
116  /*
117  * \brief number of iterations
118  */
119  int iter;
120 
121  /*
122  * \brief information about the result of the method
123  */
124  int info;
125 
126  };
127 }
128 #endif /* NUMERICSMULTIDIMENSIONALNEWTONMETHOD_H_ */