MBSim

Project Page
multi_dimensional_newton_method.h
00001 /* Copyright (C) 2004-2012 MBSim Development Team
00002  *
00003  * This library is free software; you can redistribute it and/or
00004  * modify it under the terms of the GNU Lesser General Public
00005  * License as published by the Free Software Foundation; either
00006  * version 2.1 of the License, or (at your option) any later version.
00007  *
00008  * This library is distributed in the hope that it will be useful,
00009  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00010  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011  * Lesser General Public License for more details.
00012  *
00013  * You should have received a copy of the GNU Lesser General Public
00014  * License along with this library; if not, write to the Free Software
00015  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
00016  *
00017  * Contact: martin.o.foerg@googlemail.com
00018  */
00019 
00020 #ifndef NUMERICS_NUMERICSMULTIDIMENSIONALNEWTONMETHOD_H_
00021 #define NUMERICS_NUMERICSMULTIDIMENSIONALNEWTONMETHOD_H_
00022 
00023 #include <fmatvec/fmatvec.h>
00024 
00025 #include <map>
00026 
00027 #include <mbsim/numerics/functions/newton_method_jacobian_functions.h>
00028 #include <mbsim/numerics/functions/criteria_functions.h>
00029 #include <mbsim/numerics/functions/damping_functions.h>
00030 
00031 namespace fmatvec {
00032   bool operator<(const fmatvec::Index & i1, const fmatvec::Index & i2);
00033 }
00034 
00035 namespace MBSim {
00036 
00041   class MultiDimensionalNewtonMethod {
00042     public:
00046       MultiDimensionalNewtonMethod();
00047 
00048       virtual ~MultiDimensionalNewtonMethod() {
00049       }
00050 
00051       /* GETTER / SETTER */
00052       int getNumberOfIterations() const {
00053         return iter;
00054       }
00055       int getNumberOfMaximalIterations() const {
00056         return itermax;
00057       }
00058       int getInfo() const {
00059         return info;
00060       }
00061       void setMaximumNumberOfIterations(int itmax_) {
00062         itermax = itmax_;
00063       }
00064       void setFunction(Function<fmatvec::Vec(fmatvec::Vec)> *function_) {
00065         function = function_;
00066       }
00067       void setJacobianFunction(NewtonJacobianFunction * jacobian_) {
00068         jacobian = jacobian_;
00069       }
00070       void setDampingFunction(DampingFunction * damping_) {
00071         damping = damping_;
00072       }
00073       void setCriteriaFunction(CriteriaFunction * criteria_) {
00074         criteria = criteria_;
00075       }
00076       CriteriaFunction * getCriteriaFunction() {
00077         return criteria;
00078       }
00079       /***************************************************/
00080 
00085       fmatvec::Vec solve(const fmatvec::Vec & initialValue);
00086 
00087     private:
00088 
00092       Function<fmatvec::Vec(fmatvec::Vec)> *function;
00093 
00097       NewtonJacobianFunction *jacobian;
00098 
00099       /*
00100        * \brief damping function
00101        */
00102       DampingFunction *damping;
00103 
00104       /*
00105        * \brief criteria function
00106        *
00107        * This function defines the criteria when to stop the Newton algorithm
00108        */
00109       CriteriaFunction *criteria;
00110 
00114       int itermax;
00115 
00116       /*
00117        * \brief number of iterations
00118        */
00119       int iter;
00120 
00121       /*
00122        * \brief information about the result of the method
00123        */
00124       int info;
00125 
00126   };
00127 }
00128 #endif /* NUMERICSMULTIDIMENSIONALNEWTONMETHOD_H_ */