Algorithm.h

Go to the documentation of this file.
00001 #pragma once
00002 
00003 
00004 #include <utility>
00005 #include <typeinfo>
00006 #include "cfRandomExperiment.h"
00007 #include "TVector.h"
00008 
00009 
00010 namespace nCenterFocus
00011 {
00012 
00013 
00014 template <int variantCFRandom,  class TPolynomXY, class  TFrommer1, class  TFrommer2>
00015 class CFRandomExperiment;
00016 
00018 
00019 
00020 
00021 
00022 
00024 template <int variant>
00025 class CenterFocusExperiment
00026 {
00027 
00029 
00030         template <int variantCFRandom,  class TPolynomXY, class  TFrommer1, class  TFrommer2>
00031         friend class CFRandomExperiment;
00032 
00033 private:
00034         
00035         #ifdef ALGORITHM_TIMER
00036                 Timer           tim_1_m;
00037                 Timer           tim_2_m;
00038                 double  hamiltonianCheckTime_m;
00039                 double  computeVanishedVocalValuesTime_m;
00040                 double  computeJacobianMatrixTime_m;
00041                 double  computeJacobianRankTime_m;
00042                 double  checkSmoothnessTime_m;
00043                 double  computeQuadricsTime_m;
00044                 double  computeAllFocalValuesTime_m;
00045                 double  addQuadricstatistic_m;
00046 
00047                 double  smoothnessTest_computeJacobiMatrixTime_m;
00048                 double  smoothnessTest_solveLGSTime_m;
00049                 double  smoothnessTest_getJacobianKernelTime_m;
00050                 double  smoothnessTest_addEpsVector_m;
00051                 double  smoothnessTest_copyPolynomTime_m;
00052                 double  smoothnessTest_computeFocalValuesTime_m;
00053                 MtcpManager_g.connectTimer(tim_1_m);
00054                 MtcpManager_g.connectTimer(tim_2_m);
00055 
00056         #endif  
00057 
00059         D_CenterfocusParams const       * cfparams_m;
00060         PrintCenterFocusResults         * resultPrinter_m;
00061 
00062 
00063         long64 inputPointCounter_m;
00064 
00065         D_Eps_Frommer::TPolynomXY  * minusP_polynom_m;
00066         D_Eps_Frommer::TPolynomXY  * Q_polynom_m;
00067 
00068 
00069         DStatistic* st_m;
00070 
00071          
00072 
00073 public: 
00074 
00075         void            printAlgorithmTimings(std::ostream & os) const;
00076 
00077         typedef pair<D_Eps_Frommer::TPolynomXY, D_Eps_Frommer::TPolynomXY> CFEpsPointType;
00078 
00079         const PrintCenterFocusResults & getResultPrinterConstRef() const        {       return  *resultPrinter_m;       };
00080         virtual                 ~CenterFocusExperiment();
00081         DStatistic &            getStatisticRef();
00082 
00083         CenterFocusExperiment( D_CenterfocusParams const  * params, PrintCenterFocusResults * prn);
00084         
00085         
00086         void performExperiment(const D_CenterfocusParams        * params ,
00087                                                 RankStatistic           & fullRankStatistic,
00088                                                 RankStatistic           & subRankStatistic,
00089                                                 LiftAndQuadricsStatistic        &fullQuadricsStatistic,
00090                                                 LiftAndQuadricsStatistic        &subQuadricsStatistic,
00091                                                 FailedLiftStatistic     &liftStatistic
00092                                                 );
00093 
00094         void printVariableOrder(ostream & os);
00095 
00096         void internPrintVariableOrder(ostream & os, const list<CoeffListEntry> & coeffVariablesOrder, string comment);
00097 
00098         long64  getInputPointNum()
00099         {       return inputPointCounter_m ; }
00100 
00101         void    printStageTimings(std::ostream &os) const;
00102 
00103 private:        
00104 
00105         const list<CoeffListEntry> allCoeffVariablesOrder_m;
00106         list<CoeffListEntry> subCoeffVariablesOrder_m; 
00107 
00108 
00109         const D_Eps_Frommer::RingType           * epsRing_m;    
00110         const D_Eps_Frommer::RingType::FieldType      & epsFieldRef_m;
00111         D_Eps_Frommer   *        epsFrommer_m;
00112 
00113 
00114         D_Eps_Frommer   *        epsRegularFrommer_m;
00115 
00116 
00117         D_Frommer* frommer2_m;
00118 
00119         D_Frommer0* frommer0_m;
00120 
00121 
00122         D_Frommer2::RingType* ring2_m ;
00123         D_Frommer0::RingType* ring0_m ;
00124 
00125         const PolynomialRing<typename D_Eps_Frommer::TPolynomXY, typename  D_Eps_Frommer::RingType> polynomialRing_m ;
00126 
00127         const PolynomialRing<typename D_Frommer::TPolynomXY, typename  D_Frommer::RingType> polynomialRing_2_m ;
00128 
00129         const PolynomialRing<typename D_Frommer0::TPolynomXY, typename  D_Frommer0::RingType> polynomialRing_0_m ;
00130 
00131         //long64 experimentCounter_m;
00132 
00133 
00134         
00135         
00136  
00137 
00138 
00141                 template <class TPolynomXY_SRC_Type, class TPolynomXY_DEST_Type>
00142                 void            copyPolynomWithGivenEpsPrecision(       const TPolynomXY_SRC_Type       & srcPol, 
00143                                                                                 TPolynomXY_DEST_Type            & destPol, 
00144                                                                                 int                               epsPrecision );
00145 
00146                 list<CoeffListEntry>     initSubCoeffVariablesOrder( );
00147 
00148                 template <class TPolynomXY_SRC_Type>
00149                 void    polynomSetEpsPrecision( TPolynomXY_SRC_Type  & srcDestPol,  int epsPrecision);
00158                 template <class TPolynomXY_Type, class Matrix_Type >
00159                 Matrix3D<Matrix_Type>* 
00160                                 computeQuadric_computeAlpha(            const TPolynomXY_Type                   & quadricMinusPpol,
00161                                                                                 const TPolynomXY_Type                   & quadricQpol,
00162                                                                                 const Matrix_Type                       & jacobiMat,
00163                                                                                 const Matrix_Type                       & jacobiKernel,
00164                                                                                 const std::list<CoeffListEntry>         & coeffOrder);
00165 
00166 
00167 
00168                 template < class Matrix_Type >
00169                 Matrix3D<Matrix_Type>* 
00170                                 computeQuadric_computeLambda(           const Matrix3D<Matrix_Type>     &alpha );
00171 
00172 
00173                 template <class Matrix_Type >
00174                 Matrix3D<Matrix_Type>*  
00175                                 computeQuadric_computeQuadricSmall(     const Matrix_Type               & jacobiMat,
00176                                                                                 const Matrix3D<Matrix_Type>     &lambda );
00177 
00178                 template < class Matrix_Type >
00179                 Matrix3D<Matrix_Type>*          
00180                                 computeQuadric_computeBigQuadric(       const Matrix3D<Matrix_Type>     & smallQuadric,
00181                                                                                 const Matrix_Type               & jacobiKernel );
00182 
00183 
00184                 template < class Matrix_Type >
00185                  Matrix_Type*   
00186                                 computeQuadric_getLeftInverse(          const Matrix_Type &     jacobiKernel );
00187 
00188 
00189                 template <class TPolynomXY_Type, class Matrix_Type  >
00190                 void                    computeQuadric(                 const TPolynomXY_Type           &p,
00191                                                                                 const TPolynomXY_Type           &q,
00192                                                                                 const Matrix_Type               & jacobiMat,
00193                                                                                 const list<CoeffListEntry>      &    coeffOrder,
00194                                                                                 CFQuadricsResult<Matrix_Type,  Matrix3D<Matrix_Type > >         & quadricResult
00195                                                                 );
00197                 template <class Matrix_Type>
00198                   Matrix_Type*          complementColumns(const Matrix_Type & mat);
00199 
00208                 void            liftTest_invertCoeffVectorInPlace (TVector<typename D_Eps_Frommer::RingType::FieldType> &       vector);
00209 
00210 
00211                 CFEpsPointType
00212                         liftTest_addEpsVector ( const CFEpsPointType            & polynomPair, 
00213                                                         TVector<typename D_Eps_Frommer::RingType::FieldType>            & vector,
00214                                                         const list<CoeffListEntry>                                      & varCoeffOrder,
00215                                                         int                                                                             epsFactorExp    );
00216 
00217                 void            liftTest_eraseEpsPartInPlace (  CFEpsPointType & polynomPair, 
00218                                                                         unsigned short epsPrecision);
00219 
00220 
00221                 TVector<typename D_Eps_Frommer::RingType::FieldType> 
00222                                 liftTest_getFocalValuesEpsPart( D_Eps_Frommer &         epsFrommer, 
00223                                                                                         unsigned int    epsPart);
00224 
00225                 
00226                 template <class PolynomXY_Type, class Matrix_Type , class  TFrommer_Type2>
00227                 bool            liftTest_performSingleTest(     int maxLift,
00228                                                                          TFrommer_Type2         & frommer2,
00229                                                                         const PolynomXY_Type                    & minusP_polynom, 
00230                                                                         const PolynomXY_Type                    & Q_polynom,
00231                                                                         const Matrix_Type                               & jacobiKernel,
00232                                                                         const list<CoeffListEntry>              & varCoeffOrder,
00233                                                                         CFEpsPointType*                         & liftResultRef,
00234                                                                         int                                             & lastLiftNr);
00235                 
00236                 bool 
00237                         liftTest_solveLGS(const TMatrix<  typename D_Eps_Frommer::RingType::FieldType > &jacobiMatrix,
00238                                                 const   TVector<typename D_Eps_Frommer::RingType::FieldType> & rightHandSide,
00239                                                         TVector<typename D_Eps_Frommer::RingType::FieldType> &result);
00240                 
00241                 template <class PolynomXY_Type, class Matrix_Type, class  TFrommer_Type2, class FailedLiftStatisticType>
00242                 bool            performLiftTrials(int maxLift,
00243                                                         int liftTrials,
00244                                                         TFrommer_Type2  & frommer2,
00245                                                         const PolynomXY_Type            & minusP_polynom, 
00246                                                         const PolynomXY_Type            & Q_polynom,
00247                                                         const Matrix_Type                       & jacobiMatrix,
00248                                                         const list<CoeffListEntry>      & varCoeffOrder,
00249                                                         CPointLiftInfo<D_Eps_Frommer, CFEpsPointType>           & pointLiftInfo,
00250                                                         FailedLiftStatisticType                                                 & liftStatistic);
00251 
00252         
00253                 template <class PolynomXY_Type, class Matrix_Type, class  TFrommer_Type2>
00254                 void            liftTest_computeLiftPoints(   int maxLift,
00255                                                                         int liftTrials,
00256                                                                         TFrommer_Type2  & frommer2,
00257                                                                         const PolynomXY_Type            & minusP_polynom, 
00258                                                                          const PolynomXY_Type           & Q_polynom,
00259                                                                          const Matrix_Type              & jacobiMatrix,
00260                                                                         const list<CoeffListEntry>      & varCoeffOrder ,
00261                                                                         vector <CFEpsPointType*>                & liftPoints);
00262 
00263         
00264 
00267 
00268         
00277                 template < class PolynomXY_Type, class  TFrommer_Type1, class  TFrommer_Type2>
00278                 inline void     performRegularExperiment(       
00279                                                                                 TFrommer_Type1  & frommer1, 
00280                                                                                 TFrommer_Type2  & frommer2, 
00281                                                                                 const PolynomialRing<PolynomXY_Type, typename  TFrommer_Type1::RingType> & polynomialRing,
00282                                                                                 const PolynomXY_Type    & minusP_polynom, 
00283                                                                                 const PolynomXY_Type    & Q_polynom,
00284                                                                                 DStatistic              & st, 
00285                                                                                 RankStatistic   & fullRankStatistic,
00286                                                                                 RankStatistic   & subRankStatistic,
00287                                                                                 LiftAndQuadricsStatistic & fullQuadricsStatistic,
00288                                                                                 LiftAndQuadricsStatistic & subQuadricsStatistic,
00289                                                                                 FailedLiftStatistic     &liftStatistic
00290                                                         );
00291         
00297                 bool            randomExperimentWellDefined();
00298 
00299                 void initExperiment(const D_CenterfocusParams *         params  );
00300                 
00301 
00304                 template <class TFrommer,class TPolynomXY_Type >
00305                  TMatrix<typename D_Eps_Frommer::RingType::FieldType>* 
00306                                                 createJacobiMatrix(             TFrommer                & frommer ,
00307                                                                                 const TPolynomXY_Type   & p,
00308                                                                                 const TPolynomXY_Type   & q ,
00309                                                                                 int                             reqVanishedFocalValuesCount, 
00310                                                                                 const list<CoeffListEntry>      & coeffOrder);
00311 
00312 
00313                 template <class PolynomXY_Type, class Ring_Type> 
00314                 inline bool                     isHamiltonianComponent( const PolynomXY_Type    &        minusP_polynom ,
00315                                                                                         const PolynomXY_Type    & Q_polynom,
00316                                                                                         const Ring_Type &               ring1);
00317 
00318                  
00322 };
00323 
00324 
00325 
00326 #include "Algorithm.hpp"
00327 
00328 } // end namespace nCenterFocus;
00329 
00330 
Generated on Tue Nov 23 13:10:51 2010 for centerfocus by  doxygen 1.6.3