SubSystem.h
Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 #ifndef FREEGCS_SUBSYSTEM_H
00024 #define FREEGCS_SUBSYSTEM_H
00025 
00026 #undef min
00027 #undef max
00028 
00029 #include <Eigen/Core>
00030 #include "Constraints.h"
00031 
00032 namespace GCS
00033 {
00034 
00035     class SubSystem
00036     {
00037     private:
00038         int psize, csize;
00039         std::vector<Constraint *> clist;
00040         VEC_pD plist;      
00041         MAP_pD_pD pmap;    
00042         VEC_D pvals;       
00043 
00044         std::map<Constraint *,VEC_pD > c2p; 
00045         std::map<double *,std::vector<Constraint *> > p2c; 
00046         void initialize(VEC_pD ¶ms, MAP_pD_pD &reductionmap); 
00047     public:
00048         SubSystem(std::vector<Constraint *> &clist_, VEC_pD ¶ms);
00049         SubSystem(std::vector<Constraint *> &clist_, VEC_pD ¶ms,
00050                   MAP_pD_pD &reductionmap);
00051         ~SubSystem();
00052 
00053         int pSize() { return psize; };
00054         int cSize() { return csize; };
00055 
00056         void redirectParams();
00057         void revertParams();
00058 
00059         void getParamMap(MAP_pD_pD &pmapOut);
00060         void getParamList(VEC_pD &plistOut);
00061 
00062         void getParams(VEC_pD ¶ms, Eigen::VectorXd &xOut);
00063         void getParams(Eigen::VectorXd &xOut);
00064         void setParams(VEC_pD ¶ms, Eigen::VectorXd &xIn);
00065         void setParams(Eigen::VectorXd &xIn);
00066 
00067         double error();
00068         void calcResidual(Eigen::VectorXd &r);
00069         void calcResidual(Eigen::VectorXd &r, double &err);
00070         void calcJacobi(VEC_pD ¶ms, Eigen::MatrixXd &jacobi);
00071         void calcJacobi(Eigen::MatrixXd &jacobi);
00072         void calcGrad(VEC_pD ¶ms, Eigen::VectorXd &grad);
00073         void calcGrad(Eigen::VectorXd &grad);
00074 
00075         double maxStep(VEC_pD ¶ms, Eigen::VectorXd &xdir);
00076         double maxStep(Eigen::VectorXd &xdir);
00077 
00078         void applySolution();
00079         void analyse(Eigen::MatrixXd &J, Eigen::MatrixXd &ker, Eigen::MatrixXd &img);
00080         void report();
00081 
00082 void printResidual();
00083     };
00084 
00085     double lineSearch(SubSystem *subsys, Eigen::VectorXd &xdir);
00086 
00087 } 
00088 
00089 #endif // FREEGCS_SUBSYSTEM_H