All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
nonlinear_algebra.h
1 /* Copyright (C) 2004-2009 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 NONLINEAR_ALGEBRA_H_
21 #define NONLINEAR_ALGEBRA_H_
22 
23 #include "fmatvec/fmatvec.h"
24 #include "mbsim/functions/function.h"
25 
26 namespace MBSim {
27 
33  class RegulaFalsi {
34  public:
35  /*
36  * \brief constructor
37  * \param root function
38  */
39  RegulaFalsi(Function<double(double)> *f);
40 
41  /* GETTER / SETTER */
42  int getNumberOfIterations() const { return it; };
43  int getInfo() const { return info; };
44  void setMaximumNumberOfIterations(int itmax_) { itmax = itmax_; }
45  void setTolerance(double tol_) { tol = tol_; }
46  /***************************************************/
47 
53  double solve(double a, double b);
54 
55  private:
60 
64  int itmax, it, info;
65 
69  double tol;
70  };
71 
78  public:
79  /*
80  * \brief constructor
81  * \param fct pointer to used fix-point-function
82  */
84 
85  /* GETTER / SETTER */
86  /*
87  * \brief returns info of iteration progress
88  * info == 0 : a solution has been found
89  * info == -1: no converge
90  * info == 1: process (seems to) converge but hasn't finished
91  */
92  int getInfo() {
93  return info;
94  }
95  std::vector<double> getNorms() {
96  return norms;
97  }
98  double getNumberOfIterations() {
99  return iter;
100  }
101  double getNumberOfMaximalIterations() {
102  return itermax;
103  }
104  void setNumberOfMaximalIterations(int itermax_) {
105  itermax = itermax_;
106  }
107  double getTolerance() {
108  return tol;
109  }
110  void setTolerance(double tol_) {
111  tol = tol_;
112  }
113  /*******************/
114 
115  fmatvec::Vec solve(const fmatvec::Vec &initialGuess);
116 
117  private:
122 
126  double tol;
127 
131  int iter;
132 
136  double itermax;
137 
141  std::vector<double> norms;
142 
146  int info;
147  };
148 
154  class NewtonMethod {
155  public:
156  /*
157  * \brief constructor
158  * \param root function
159  * \param Jacobian matrix
160  */
161  NewtonMethod(Function<double(double)> *fct_, Function<double(double)> *jac_=0);
162 
163  /* GETTER / SETTER */
164  int getNumberOfIterations() const { return iter; }
165  int getInfo() const { return info; }
166  void setMaximumNumberOfIterations(int itmax_) { itmax = itmax_; }
167  void setMaximumDampingSteps(int kmax_) { kmax = kmax_; }
168  void setTolerance(double tol_) { tol = tol_; }
169  /***************************************************/
170 
175  double solve(const double &x);
176 
177  private:
182 
187 
191  int itmax, iter, kmax, info;
192 
196  double tol;
197  };
198 
205  public:
206  /*
207  * \brief constructor
208  * \param root function
209  * \param Jacobian matrix
210  */
212 
213  /* GETTER / SETTER */
214  int getNumberOfIterations() const { return iter; }
215  int getNumberOfMaximalIterations() const { return itmax; }
216  int getInfo() const { return info; }
217  std::vector<double> getNorms() { return norms; }
218  void setMaximumNumberOfIterations(int itmax_) { itmax = itmax_; }
219  void setMaximumDampingSteps(int kmax_) { kmax = kmax_; }
220  void setTolerance(double tol_) { tol = tol_; }
221  void setLinearAlgebra(int linAlg_) { linAlg = linAlg_; }
222  /***************************************************/
223 
228  fmatvec::Vec solve(const fmatvec::Vec &x);
229 
230  private:
235 
240 
244  int itmax, iter, kmax, info;
245 
249  std::vector<double> norms;
250 
254  double tol;
255 
256  int linAlg;
257  };
258 
259 }
260 
261 #endif /* NONLINEAR_ALGEBRA_H_ */
262 
int iter
number of iterations
Definition: nonlinear_algebra.h:131
Newton method for one-dimensional root-finding.
Definition: nonlinear_algebra.h:154
Function< fmatvec::SqrMat(fmatvec::Vec)> * jac
Jacobian matrix.
Definition: nonlinear_algebra.h:239
std::vector< double > norms
vector of norms
Definition: nonlinear_algebra.h:141
double solve(const double &x)
solve nonlinear root function
Definition: nonlinear_algebra.cc:116
int itmax
maximum number of iterations, actual number of iterations, information about success (0 = ok...
Definition: nonlinear_algebra.h:64
Function< double(double)> * func
root function
Definition: nonlinear_algebra.h:59
int itmax
maximum number of iterations, actual number of iterations, maximum number of damping steps...
Definition: nonlinear_algebra.h:244
int itmax
maximum number of iterations, actual number of iterations, maximum number of damping steps...
Definition: nonlinear_algebra.h:191
int info
information variable about success of iteration
Definition: nonlinear_algebra.h:146
double tol
tolerance
Definition: nonlinear_algebra.h:254
double solve(double a, double b)
solve nonlinear root function
Definition: nonlinear_algebra.cc:35
double tol
tolerance
Definition: nonlinear_algebra.h:196
double itermax
maximal iterations
Definition: nonlinear_algebra.h:136
Regular Falsi for one-dimensional root-finding.
Definition: nonlinear_algebra.h:33
Newton method for multi-dimensional root-finding.
Definition: nonlinear_algebra.h:204
fmatvec::Vec solve(const fmatvec::Vec &x)
solve nonlinear root function
Definition: nonlinear_algebra.cc:181
Definition: planar_contour.h:31
FixpointIteration for multi-dimensional fixpoint-finding.
Definition: nonlinear_algebra.h:77
std::vector< double > norms
vector of norms for each iteration step
Definition: nonlinear_algebra.h:249
Function< fmatvec::Vec(fmatvec::Vec)> * fct
root function
Definition: nonlinear_algebra.h:234
Function< double(double)> * fct
root function
Definition: nonlinear_algebra.h:181
double tol
tolerance
Definition: nonlinear_algebra.h:126
double tol
tolerance
Definition: nonlinear_algebra.h:69
Function< double(double)> * jac
Jacobian matrix.
Definition: nonlinear_algebra.h:186

Impressum / Disclaimer / Datenschutz Generated by doxygen 1.8.5 Valid HTML