00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef NONLINEAR_ALGEBRA_H_
00021 #define NONLINEAR_ALGEBRA_H_
00022
00023 #include "fmatvec/fmatvec.h"
00024 #include "fmatvec/function.h"
00025
00026 namespace MBSim {
00027
00033 class RegulaFalsi {
00034 public:
00035
00036
00037
00038
00039 RegulaFalsi(fmatvec::Function<double(double)> *f);
00040
00041
00042 int getNumberOfIterations() const { return it; };
00043 int getInfo() const { return info; };
00044 void setMaximumNumberOfIterations(int itmax_) { itmax = itmax_; }
00045 void setTolerance(double tol_) { tol = tol_; }
00046
00047
00053 double solve(double a, double b);
00054
00055 private:
00059 fmatvec::Function<double(double)> *func;
00060
00064 int itmax, it, info;
00065
00069 double tol;
00070 };
00071
00077 class MultiDimFixPointIteration {
00078 public:
00079
00080
00081
00082
00083 MultiDimFixPointIteration(fmatvec::Function<fmatvec::Vec(fmatvec::Vec)> *function_);
00084
00085
00086
00087
00088
00089
00090
00091
00092 int getInfo() {
00093 return info;
00094 }
00095 std::vector<double> getNorms() {
00096 return norms;
00097 }
00098 double getNumberOfIterations() {
00099 return iter;
00100 }
00101 double getNumberOfMaximalIterations() {
00102 return itermax;
00103 }
00104 void setNumberOfMaximalIterations(int itermax_) {
00105 itermax = itermax_;
00106 }
00107 double getTolerance() {
00108 return tol;
00109 }
00110 void setTolerance(double tol_) {
00111 tol = tol_;
00112 }
00113
00114
00115 fmatvec::Vec solve(const fmatvec::Vec &initialGuess);
00116
00117 private:
00121 fmatvec::Function<fmatvec::Vec(fmatvec::Vec)> *function;
00122
00126 double tol;
00127
00131 int iter;
00132
00136 double itermax;
00137
00141 std::vector<double> norms;
00142
00146 int info;
00147 };
00148
00154 class NewtonMethod {
00155 public:
00156
00157
00158
00159
00160
00161 NewtonMethod(fmatvec::Function<double(double)> *fct_, fmatvec::Function<double(double)> *jac_=0);
00162
00163
00164 int getNumberOfIterations() const { return iter; }
00165 int getInfo() const { return info; }
00166 void setMaximumNumberOfIterations(int itmax_) { itmax = itmax_; }
00167 void setMaximumDampingSteps(int kmax_) { kmax = kmax_; }
00168 void setTolerance(double tol_) { tol = tol_; }
00169
00170
00175 double solve(const double &x);
00176
00177 private:
00181 fmatvec::Function<double(double)> *fct;
00182
00186 fmatvec::Function<double(double)> *jac;
00187
00191 int itmax, iter, kmax, info;
00192
00196 double tol;
00197 };
00198
00204 class MultiDimNewtonMethod {
00205 public:
00206
00207
00208
00209
00210
00211 MultiDimNewtonMethod(fmatvec::Function<fmatvec::Vec(fmatvec::Vec)> *fct_, fmatvec::Function<fmatvec::SqrMat(fmatvec::Vec)> *jac_=0);
00212
00213
00214 int getNumberOfIterations() const { return iter; }
00215 int getNumberOfMaximalIterations() const { return itmax; }
00216 int getInfo() const { return info; }
00217 std::vector<double> getNorms() { return norms; }
00218 void setMaximumNumberOfIterations(int itmax_) { itmax = itmax_; }
00219 void setMaximumDampingSteps(int kmax_) { kmax = kmax_; }
00220 void setTolerance(double tol_) { tol = tol_; }
00221 void setLinearAlgebra(int linAlg_) { linAlg = linAlg_; }
00222
00223
00228 fmatvec::Vec solve(const fmatvec::Vec &x);
00229
00230 private:
00234 fmatvec::Function<fmatvec::Vec(fmatvec::Vec)> *fct;
00235
00239 fmatvec::Function<fmatvec::SqrMat(fmatvec::Vec)> *jac;
00240
00244 int itmax, iter, kmax, info;
00245
00249 std::vector<double> norms;
00250
00254 double tol;
00255
00256 int linAlg;
00257 };
00258
00259 }
00260
00261 #endif
00262