00001 #pragma once
00002
00003 #include "Parameterlist.h"
00004 namespace nCenterFocus
00005 {
00006
00009
00011
00012
00013 template <class FocalValueType>
00014 class FocalValuesInfo
00015 {
00016 protected:
00017 int vanishedFocalValuesNum_m;
00018 vector<FocalValueType> focalValueList_m;
00019
00020
00021 public:
00022 FocalValuesInfo(): vanishedFocalValuesNum_m(-1)
00023 {
00024 focalValueList_m.resize(0);
00025 }
00026
00027 vector<FocalValueType>& getFocalValuesRef() { return focalValueList_m; }
00028
00029 const vector<FocalValueType>& getConstFocalValuesRef() const { return focalValueList_m; }
00030
00031 int getVanishedFocalValuesNum() const
00032 {
00033 return vanishedFocalValuesNum_m;
00034 }
00035
00036 void setVanishedFocalValuesNum(int vanishedFocalValuesNum)
00037 {
00038 vanishedFocalValuesNum_m = vanishedFocalValuesNum;
00039 }
00040
00041
00042 void print(ostream & os) const
00043 {
00044 os << vanishedFocalValuesNum_m << ", -- # (first focal values = 0) " << std::endl;
00045 os << " {";
00046
00047 int computedVocalValuesNum = focalValueList_m.size() ;
00048 for (int i = 1; i<= computedVocalValuesNum; i++)
00049 {
00050
00051 if (i>1)
00052 os << ", ";
00053
00054 os << focalValueList_m[ i-1 ] ;
00055 }
00056 os << " } -- focal values " << std::endl;
00057 }
00058 };
00059
00060
00061 template <class EpsFrommerType, class CFLiftPointType>
00062 class CPointLiftInfo
00063 {
00064 protected:
00065
00066 bool liftTestPassed_m ;
00067 int maxLift_m;
00068 int minFailedLiftNr_m;
00069 int maxFailedLiftNr_m;
00070 int firstFailedTrialNr_m;
00071
00072 int failedTrialCount_m;
00073
00074
00076 vector<CFLiftPointType*> liftPoints_m;
00077 const EpsFrommerType & epsFrommer_m;
00078
00079
00080
00081
00082 CPointLiftInfo() : liftTestPassed_m(true),
00083 maxLift_m(0),
00084 minFailedLiftNr_m (-1),
00085 maxFailedLiftNr_m (-1),
00086 firstFailedTrialNr_m(-1),
00087 failedTrialCount_m (0),
00088
00089 epsFrommer_m(NULL)
00090 { }
00091 public:
00092
00093
00094 CPointLiftInfo( int maxLift,
00095 const EpsFrommerType & epsFrommer) : liftTestPassed_m(true),
00096 maxLift_m(maxLift),
00097 minFailedLiftNr_m (-1),
00098 maxFailedLiftNr_m (-1),
00099 firstFailedTrialNr_m(-1),
00100 failedTrialCount_m (0),
00101 epsFrommer_m(epsFrommer)
00102 { }
00103
00104 void clear()
00105 {
00106 minFailedLiftNr_m = -1;
00107 maxFailedLiftNr_m = -1;
00108 firstFailedTrialNr_m = - 1;
00109 failedTrialCount_m = 0;
00110 liftTestPassed_m = true;
00111 }
00112
00113 void setMaxLift(int maxLift)
00114 {
00115 maxLift_m = maxLift;
00116 }
00117
00118 virtual ~CPointLiftInfo()
00119 {
00120 for (size_t i=0; i<liftPoints_m.size(); i++)
00121 {
00122 if (liftPoints_m[ i ] != NULL)
00123 {
00124 delete liftPoints_m[ i ];
00125 liftPoints_m[ i ] = NULL;
00126 }
00127 }
00128 }
00129
00130 vector<CFLiftPointType*> & getLiftPointsRef() { return liftPoints_m; }
00131
00132 void numGtZero(int num) const
00133 {
00134 assert(num>0);
00135 }
00136
00137 void numGEZero(int num) const
00138 {
00139 assert(num>=0);
00140 }
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152 void setLiftTestPassed (bool liftTestPassed) { liftTestPassed_m = liftTestPassed; }
00153
00154
00155
00156 void setMinFailedLiftNr (int minFailedLiftNr)
00157 {
00158 #ifdef SAFE
00159 numGtZero(minFailedLiftNr);
00160 #endif
00161 minFailedLiftNr_m = minFailedLiftNr;
00162 }
00163
00164 void setMaxFailedLiftNr (int maxFailedLiftNr)
00165 {
00166 #ifdef SAFE
00167 numGtZero(maxFailedLiftNr);
00168 #endif
00169 maxFailedLiftNr_m = maxFailedLiftNr;
00170 }
00171
00172 void setFirstFailedTrialNr (int firstFailedTrialNr)
00173 {
00174 #ifdef SAFE
00175 numGtZero(firstFailedTrialNr);
00176 #endif
00177 firstFailedTrialNr_m = firstFailedTrialNr;
00178 }
00179
00180 void setFailedTrialCount (int failedTrialCount)
00181 {
00182 #ifdef SAFE
00183 numGEZero(failedTrialCount);
00184 #endif
00185 failedTrialCount_m = failedTrialCount;
00186 }
00187
00188 bool liftTestPassed() const { return liftTestPassed_m; }
00189
00190 int getMinFailedLiftNr() const { return minFailedLiftNr_m; }
00191
00192 int getMaxFailedLiftNr() const { return maxFailedLiftNr_m; }
00193
00194 int getFirstFailedTrialNr() const { return firstFailedTrialNr_m; }
00195
00196 int getFailedTrialCount() const { return failedTrialCount_m; }
00197
00198
00199 void setLiftPoints(const vector<CFLiftPointType*> & liftPoints)
00200 {
00201 liftPoints_m = liftPoints;
00202 }
00203
00204 void print(ostream & os) const
00205 {
00206 printLiftTestResult( os,
00207 *this,
00208 liftPoints_m,
00209 epsFrommer_m );
00210 }
00211
00214 void printLiftPoints(ostream & os, const vector<CFLiftPointType*> & liftPoints, const EpsFrommerType & epsFrommerRef) const
00215 {
00216
00217
00218 os << " --startLiftPoints \n ";
00219 os << " { ";
00220 int oldEpsPrecision = epsFrommerRef.getRingRef().getEpsPrecision();
00221
00222 epsFrommerRef.getRingRef().setEpsPrecision( maxLift_m );
00223
00224 const PolynomialRing<typename EpsFrommerType::TPolynomXY, typename EpsFrommerType::RingType> epsPolynomialRing (epsFrommerRef.getRingRef() );
00225 for (size_t i=0; i<liftPoints.size();i++)
00226 {
00227 printPolynomCoefficients(os, epsPolynomialRing.addInv( (*liftPoints[i]).first), (*liftPoints[i]).second );
00228
00229 if ( i != (liftPoints.size()-1) )
00230 os << " , ";
00231 }
00232
00233 epsFrommerRef.getRingRef().setEpsPrecision( oldEpsPrecision );
00234
00235 os << " } --endLiftPoints \n ";
00236 }
00237
00238
00239 void printLiftTestResult( ostream & os,
00240 const CPointLiftInfo< EpsFrommerType, CFLiftPointType> & pointLiftInfo,
00241 const vector<CFLiftPointType*> & liftPoints ,
00242 const EpsFrommerType & epsFrommerRef ) const
00243 {
00244 os << "{";
00245 if ( pointLiftInfo.liftTestPassed() )
00246 {
00247 os << " true, ";
00248 os << " , , , ,";
00249 }
00250 else
00251 {
00252 os << " false, ";
00253 os << pointLiftInfo.getMinFailedLiftNr() << ",";
00254 os << pointLiftInfo.getMaxFailedLiftNr() << ",";
00255 os << pointLiftInfo.getFailedTrialCount() << ",";
00256 os << pointLiftInfo.getFirstFailedTrialNr() << ",";
00257 }
00258
00260 if ( liftPoints.size() > 0 )
00261 printLiftPoints(os, liftPoints, epsFrommerRef);
00262
00263
00264 os << " } ";
00265 }
00266
00267
00269 void printPolynomCoefficients( ostream & os,
00270 const typename EpsFrommerType::TPolynomXY & P_polynom_ref,
00271 const typename EpsFrommerType::TPolynomXY & Q_polynom_ref) const
00272 {
00273 os << "{ " << std::endl;
00274
00275 bool mitKomma = true;
00276 int i;
00277
00278 for (i = 2; i<= P_polynom_ref.getDegree(); i ++)
00279 {
00280 P_polynom_ref.OutputPureCoefficients(os, i, 1);
00281
00282 if (i == P_polynom_ref.getDegree() )
00283 mitKomma=0;
00284
00285 Q_polynom_ref.OutputPureCoefficients(os, i, mitKomma);
00286 }
00287
00288 os << "}";
00289 }
00290 };
00291
00292
00293 template < class MatrixType, class Matrix3DType >
00294 class CFQuadricsResult
00295 {
00296 private:
00297 CFQuadricsResult(const CFQuadricsResult & res);
00298
00299 protected:
00300
00301 const MatrixType & jacobianMatrix_m;
00302 const list<CoeffListEntry> & coeffVariablesOrder_m;
00303
00304 const Matrix3DType * quadricsBig_m;
00305 const Matrix3DType * quadricsSmall_m;
00306
00307
00308 public:
00309
00310 CFQuadricsResult(const MatrixType & jacobianMatrix,
00311 const list<CoeffListEntry> & coeffVariablesOrder): jacobianMatrix_m(jacobianMatrix),
00312 coeffVariablesOrder_m( coeffVariablesOrder ),
00313 quadricsBig_m(NULL),
00314 quadricsSmall_m(NULL)
00315 {
00316 }
00317
00318
00319 void setQuadrics(Matrix3DType* quadricsBig, Matrix3DType* quadricsSmall)
00320 {
00321 quadricsBig_m = quadricsBig;
00322 quadricsSmall_m = quadricsSmall;
00323 }
00324
00325 const list<CoeffListEntry> & getCoeffVariablesOrderRef() const
00326 {
00327 return coeffVariablesOrder_m;
00328 }
00329
00330 const Matrix3DType * getQuadricsBig() const { return quadricsBig_m; }
00331 const Matrix3DType * getQuadricsSmall() const { return quadricsSmall_m; }
00332
00333
00334 virtual ~CFQuadricsResult()
00335 {
00336 if (quadricsBig_m != NULL) { delete quadricsBig_m; quadricsBig_m = NULL; }
00337 if (quadricsSmall_m != NULL) { delete quadricsSmall_m; quadricsSmall_m = NULL; }
00338 }
00339
00340
00341 inline void printQuadricsSmall( ostream & os, const Matrix3DType* quadricSmall, string comment) const
00342 {
00343 os << std::endl << "-- " << comment << " :" <<endl;
00344 assert( quadricSmall!=NULL );
00345 os << "{ ";
00346 for (unsigned int depth = 0; depth<quadricSmall->getZNum(); depth++ )
00347 {
00348 if (depth !=0 )
00349 os << " , " << std::endl;
00350
00351 for (unsigned int row = 0; row< quadricSmall->getRowNum(); row++)
00352 {
00353 for (unsigned int col = 0; col< quadricSmall->getColNum(); col++)
00354 {
00355 if (col !=0 || row!=0 )
00356 os << " + ";
00357 os << "(" << quadricSmall->getVal(row, col, depth) << ")" << "*tt_" << row+1 << "*tt_"<< col+1;
00358 }
00359 }
00360
00361 }
00362 os << " } --" << comment << " end" << endl;
00363 }
00364
00365
00366 inline void printLinearBig( ostream & os,
00367 const MatrixType * jacobiMatrix,
00368 const list<CoeffListEntry> & coeffVariablesOrder ) const
00369 {
00370 assert(jacobiMatrix!=NULL);
00371
00372 MatrixType* jacobiRowBasis = jacobiMatrix->getRowBasis();
00373
00374
00375 os << "-- LinearBig :" <<endl;
00376 os << "{ ";
00377
00378 assert( coeffVariablesOrder.size()==jacobiMatrix->getColNum() );
00379 assert( coeffVariablesOrder.size()==jacobiRowBasis->getColNum() );
00380 list<CoeffListEntry>::const_iterator coeffIt;
00381 for (unsigned int row = 0; row< jacobiRowBasis->getRowNum(); row++)
00382 {
00383 if ( row!=0 )
00384 os << " , " << std::endl;
00385
00386 coeffIt= coeffVariablesOrder.begin();
00387
00388 for (unsigned int col = 0; col< jacobiRowBasis->getColNum(); col++, coeffIt++)
00389 {
00390 assert( coeffIt != coeffVariablesOrder.end() );
00391
00392 if ( col!=0 )
00393 os << " + ";
00394
00395 os << "("<< jacobiRowBasis->getVal(row, col) << ")";
00396 if ((*coeffIt).isPMonom() )
00397 os << "*pp";
00398 else
00399 os << "*qq";
00400 os << "_{";
00401 os << (*coeffIt).x_exp;
00402 os << ",";
00403 os << (*coeffIt).y_exp;
00404 os << "}";
00405 }
00406 }
00407 os << "} "<< "-- LinearBig end" << std::endl;
00408 delete jacobiRowBasis; jacobiRowBasis=NULL;
00409 return;
00410 }
00411
00412
00413 inline void printQuadricsBig( ostream & os,
00414 const Matrix3DType* quadricsBig,
00415 const list<CoeffListEntry> & coeffVariablesOrder ) const
00416 {
00417 assert(quadricsBig!=NULL);
00418
00419 os << endl << "-- QuadricsBig :" << std::endl;
00420 os << "{ ";
00421
00422 for (unsigned int depth = 0; depth<quadricsBig->getZNum(); depth++ )
00423 {
00424 if (depth !=0 )
00425 os << " , " << std::endl;
00426
00427 list<CoeffListEntry>::const_iterator rowCoeffIt= coeffVariablesOrder.begin();
00428
00429 for (unsigned int row = 0; row< quadricsBig->getRowNum(); row++, rowCoeffIt++)
00430 {
00431 assert( rowCoeffIt != coeffVariablesOrder.end() );
00432 list<CoeffListEntry>::const_iterator colCoeffIt = coeffVariablesOrder.begin();
00433 for (unsigned int col = 0; col< quadricsBig->getColNum(); col++, colCoeffIt++)
00434 {
00435 assert( colCoeffIt != coeffVariablesOrder.end() );
00436 if (col !=0 || row!=0 )
00437 os << " + ";
00438 os << "(" << quadricsBig->getVal(row, col, depth) << ")";
00439 if ((*rowCoeffIt).isPMonom() )
00440 os << "*pp";
00441 else
00442 os << "*qq";
00443 os << "_{";
00444 os << (*rowCoeffIt).x_exp;
00445 os << ",";
00446 os << (*rowCoeffIt).y_exp;
00447 os << "}";
00448
00449 if ((*colCoeffIt).isPMonom() )
00450 os << "*pp";
00451 else
00452 os << "*qq";
00453 os << "_{";
00454 os << (*colCoeffIt).x_exp;
00455 os << ",";
00456 os << (*colCoeffIt).y_exp;
00457 os << "}";
00458 }
00459 }
00460
00461 }
00462 os << "} " << "-- QuadricsBig end" << std::endl;
00463 return;
00464 }
00465
00466
00467
00468 inline void printTangentCone2( ostream & os,
00469 const MatrixType * jacobiMatrix,
00470 const Matrix3DType * quadricsBig,
00471 const list<CoeffListEntry> & coeffVariablesOrder ,
00472 const string comment) const
00473 {
00474 os << "-- " <<comment <<" :" <<endl;
00475 os << "{ ";
00476 printLinearBig(os, jacobiMatrix, coeffVariablesOrder );
00477 os << ", ";
00478 printQuadricsBig(os, quadricsBig, coeffVariablesOrder );
00479 os << "} -- " <<comment <<" end " << endl;
00480 }
00481
00483 void print(ostream & os, string prefix ) const
00484 {
00485 assert( quadricsBig_m!=NULL );
00486 assert( quadricsSmall_m!=NULL );
00487 os << "{";
00488 printQuadricsSmall( os, quadricsSmall_m ,string(prefix+"QuadricsSmall"));
00489 os << ", "<< std::endl;
00490 printTangentCone2( os, & jacobianMatrix_m, quadricsBig_m, coeffVariablesOrder_m, string(prefix+"TangentCone2") );
00491 os << " } ";
00492 }
00493
00494 };
00495
00496
00498 template < class Matrix_Type >
00499 class CFJacobianInfo
00500 {
00501 protected:
00502 const Matrix_Type * jacobianMatrix_m;
00503 int jacobianRank_m;
00504
00505 CFJacobianInfo() : jacobianMatrix_m(NULL), jacobianRank_m(-1)
00506 {}
00507
00508 public:
00509 virtual ~CFJacobianInfo() {}
00510
00511
00512 CFJacobianInfo(const Matrix_Type * jacobian, int rank) : jacobianMatrix_m( jacobian), jacobianRank_m(rank)
00513 {}
00514
00515 void setJacobianMatrix(Matrix_Type * jacobian)
00516 {
00517 jacobianMatrix_m = jacobian;
00518 }
00519
00520 void setJacobianRank(int jacobianRank)
00521 {
00522 jacobianRank_m = jacobianRank;
00523 }
00524
00525
00526
00527 int getJacobianRank() const { return jacobianRank_m; }
00528 const Matrix_Type * getJacobianPtr() const { return jacobianMatrix_m; }
00529
00530
00531 void print(ostream & os, string prefix) const
00532 {
00533 os << " {" << std::endl;
00534
00535 jacobianMatrix_m-> printValueInMacaulayStyle(os);
00536
00537 os << ", "<< jacobianRank_m << " -- " << prefix << "_jacobian_matrix, rank" << std::endl;
00538 os << "}" << std::endl;
00539 }
00540
00541 };
00542
00543
00547
00548
00549
00550
00551
00552
00553
00554 template < class PolynomXY_Type,
00555 class FocalValuesInfoType,
00556 class CFJacobianInfoType,
00557 class CFQuadricsResultType,
00558 class CPointLiftInfoType
00559 >
00560 class CFSingleResult
00561 {
00562
00563 const PolynomXY_Type * P_polynom_m;
00564 const PolynomXY_Type * Q_polynom_m;
00565
00566 const FocalValuesInfoType* focalValuesInfo_m;
00567
00568 const CPointLiftInfoType* pointFullLiftInfo_m;
00569 const CPointLiftInfoType* pointSubLiftInfo_m;
00570
00571 const CFJacobianInfoType * jacobianInfo_m;
00572 const CFJacobianInfoType * subJacobianInfo_m;
00573
00574
00575 const CFQuadricsResultType* fullQuadricsResult_m;
00576 const CFQuadricsResultType* subQuadricsResult_m;
00577
00578 long64 pointID_m;
00579
00580 public:
00581 CFSingleResult() : P_polynom_m ( NULL ), Q_polynom_m ( NULL ),
00582 focalValuesInfo_m ( NULL ),
00583 pointFullLiftInfo_m ( NULL ), pointSubLiftInfo_m ( NULL ),
00584 jacobianInfo_m ( NULL ), subJacobianInfo_m ( NULL ),
00585 fullQuadricsResult_m ( NULL ),subQuadricsResult_m ( NULL ), pointID_m(-1)
00586 {}
00587
00588 void setFullQuadrics( const CFQuadricsResultType* fullQuadricsResult)
00589 {
00590 fullQuadricsResult_m = fullQuadricsResult;
00591 }
00592
00593 void setSubQuadrics( const CFQuadricsResultType* subQuadricsResult)
00594 {
00595 subQuadricsResult_m = subQuadricsResult;
00596 }
00597
00598 void setPolynoms(const PolynomXY_Type & P_polynom, const PolynomXY_Type & Q_polynom)
00599 {
00600 P_polynom_m = & P_polynom;
00601 Q_polynom_m = & Q_polynom;
00602 }
00603
00604 void setPointID(long64 pid)
00605 {
00606 pointID_m=pid;
00607 }
00608
00609 void setJacobianInfo(const CFJacobianInfoType *jacobianInfo)
00610 {
00611 jacobianInfo_m = jacobianInfo;
00612 }
00613
00614 void setSubJacobianInfo(const CFJacobianInfoType *jacobianInfo)
00615 {
00616 subJacobianInfo_m = jacobianInfo;
00617 }
00618
00619 void setFullLiftInfo(const CPointLiftInfoType* pointFullLiftInfo)
00620 {
00621 pointFullLiftInfo_m = pointFullLiftInfo;
00622 }
00623
00624
00625
00626
00627
00628
00629 void setFocalValuesInfo(const FocalValuesInfoType* focalValuesInfo)
00630 {
00631 focalValuesInfo_m = focalValuesInfo;
00632 }
00633
00634
00635 void printPolynomCoefficients( ostream & os,
00636 const PolynomXY_Type & P_polynom_ref,
00637 const PolynomXY_Type & Q_polynom_ref) const
00638 {
00639 os << "{ " << std::endl;
00640
00641 bool mitKomma = true;
00642 int i;
00643
00644 for (i = 2; i<= P_polynom_ref.getDegree(); i ++)
00645 {
00646 P_polynom_ref.OutputPureCoefficients(os, i, 1);
00647
00648 if (i == P_polynom_ref.getDegree() )
00649 mitKomma=0;
00650
00651 Q_polynom_ref.OutputPureCoefficients(os, i, mitKomma);
00652 }
00653 os << "}";
00654 }
00655
00657 void print(ostream & os)
00658 {
00659 os << "{";
00660
00661
00662 assert( P_polynom_m != NULL);
00663 assert( Q_polynom_m != NULL);
00664
00665 printPolynomCoefficients(os, *P_polynom_m, *Q_polynom_m);
00666
00667 os << ", ";
00668 os << pointID_m << " , " ;
00669
00670 assert( focalValuesInfo_m != NULL);
00671 focalValuesInfo_m->print(os);
00672
00673
00674 assert( jacobianInfo_m != NULL);
00675 assert( subJacobianInfo_m != NULL);
00676
00677 assert( jacobianInfo_m->getJacobianPtr() != NULL);
00678 os << ", { ";
00679 jacobianInfo_m->print(os, "full");
00680
00681 if ( subJacobianInfo_m->getJacobianPtr() != NULL &&
00682 (subJacobianInfo_m->getJacobianPtr() != jacobianInfo_m->getJacobianPtr() )
00683 )
00684 {
00685 os << ", ";
00686 subJacobianInfo_m->print(os, "sub");
00687 }
00688 os << "}" << std::endl;
00689
00690
00691
00692
00693
00694
00695 assert( fullQuadricsResult_m != NULL);
00696 assert( subQuadricsResult_m != NULL);
00697 os << ", {";
00698 fullQuadricsResult_m->print( os, "full");
00699
00700
00701 if ( fullQuadricsResult_m->getCoeffVariablesOrderRef().size() > subQuadricsResult_m->getCoeffVariablesOrderRef().size() &&
00702 subQuadricsResult_m->getCoeffVariablesOrderRef().size() > 0)
00703 {
00704 os << ", ";
00705 subQuadricsResult_m->print( os, "sub");
00706 }
00707 os << "}";
00708
00709 os << ", \n";
00710
00711
00712 assert( pointFullLiftInfo_m != NULL);
00713 pointFullLiftInfo_m->print(os);
00714
00715 os << "}";
00716 }
00717
00719 void printSmoothnessTestResult(ostream & os)
00720 {
00721 os << "{";
00722
00723
00724 assert( P_polynom_m != NULL);
00725 assert( Q_polynom_m != NULL);
00726
00727 printPolynomCoefficients(os, *P_polynom_m, *Q_polynom_m);
00728
00729 os << ", ";
00730 os << pointID_m << " , " ;
00731
00732
00733 assert( pointFullLiftInfo_m != NULL);
00734 pointFullLiftInfo_m->print(os);
00735
00736 os << "}";
00737 }
00738 };
00739
00741 class PrintCenterFocusResults
00742 {
00743 private :
00744
00745 mutable ostream & os_m;
00746 mutable ostream & err_m;
00747 bool firstResult_m;
00748
00749 public :
00750 PrintCenterFocusResults(ostream &os, ostream &_err) :os_m(os), err_m(_err), firstResult_m(true) {}
00751 PrintCenterFocusResults(ostream &os) :os_m(os), err_m(std::cerr), firstResult_m(true) {}
00752
00753
00754 virtual ~PrintCenterFocusResults()
00755 {
00756
00757
00758 }
00759
00760
00761 void printHeader(D_CenterfocusParams const & paramReader_ref, bool inputFromStd=false);
00762
00763 void startPrintingResults();
00764
00765 void endPrintingResults();
00766
00767 void beginSingleResultPrint();
00768
00769
00770
00771 void printTail(ostream &oFile_ref) const;
00772 void printSmoothnessTestTail(ostream &oFile_ref) const;
00773
00774
00775 template <class PolynomXY_Type>
00776 void printPolynoms( ostream & os_ref,
00777 const PolynomXY_Type & p_ref ,
00778 const PolynomXY_Type & q_ref ,
00779 string comment) const;
00780
00781 template <class PolynomXY_Type>
00782 void printPolynoms( const PolynomXY_Type &p_ref ,
00783 const PolynomXY_Type &q_ref ,
00784 string comment)
00785 {
00786 printPolynoms(os_m, p_ref,q_ref,comment);
00787 };
00788
00789 #ifdef TIMER
00790 void outputTimerInfo(ostream & os, Timer &tim);
00791 void outputTimerInfo(Timer &tim);
00792 #endif
00793
00794
00795 #ifdef COUNT
00796
00797 void outputOperationsCount(ostream & os);
00798 void outputOperationsCount();
00799 #endif
00800
00801
00802 void printRandomSeed(long randomSeed)
00803 {
00804 os_m << "-- " << randomSeed << endl;
00805 }
00806
00807
00808 };
00809
00810
00811
00812
00813
00816 void PrintCenterFocusResults::printHeader(D_CenterfocusParams const & paramReader_ref, bool inputFromStd)
00817 {
00818
00819 if (!inputFromStd)
00820 paramReader_ref.printParameters(os_m);
00821
00822 }
00823
00824 void PrintCenterFocusResults::startPrintingResults()
00825 {
00826 os_m << std::endl << "L = { " << std::endl;
00827 }
00828
00829
00830 void PrintCenterFocusResults::beginSingleResultPrint()
00831 {
00832 if (!firstResult_m) os_m << "," << std::endl;
00833
00834 firstResult_m = false;
00835 }
00836
00838 void PrintCenterFocusResults::endPrintingResults()
00839 {
00840 firstResult_m = true ;
00841 os_m << "};" <<std::endl;
00842 }
00843
00844
00845
00846 #ifdef TIMER
00847 void PrintCenterFocusResults::outputTimerInfo(ostream & os,Timer &tim)
00848 {
00849 os << "---Usertime: " << tim.usertime() << "sec." << std::endl;
00850 os << "---Sysime: " << tim.systime() << "sec." << std::endl;
00851 os << "---Realtime: " << tim.realtime() << "sec." << std::endl;
00852 }
00853 void PrintCenterFocusResults::outputTimerInfo(Timer &tim)
00854 {
00855 outputTimerInfo(os_m, tim);
00856
00857 }
00858 #endif
00859
00860
00861 #ifdef COUNT
00862
00863 void PrintCenterFocusResults::outputOperationsCount(ostream & os)
00864 {
00866 os << "-- accMultCount " << accMultCount << std::endl;
00867 os << "-- accMultf1 " << accMultf1 << std::endl;
00868 os << "-- accMultf2 " << accMultf2 << std::endl;
00869
00870 os << "-- addCount " << addCount << std::endl;
00871 os << "-- multCount " << multCount << std::endl;
00872 os << "-- divCount " << divCount << std::endl;
00873 os << "-- memAccess " << memAccess << std::endl;
00874 os << "-- memRef " << memRef << std::endl;
00875 os << "-- bitwiseAND " << bitwiseAND << std::endl;
00876 os << "-- bitwiseOR " << bitwiseOR << std::endl;
00877 os << "-- bitwiseShift " << bitwiseShift << std::endl;
00878 }
00879 void PrintCenterFocusResults::outputOperationsCount( )
00880 {
00881 outputOperationsCount(os_m);
00882 }
00883 #endif
00884
00885
00886
00887 template <class PolynomXY_Type>
00888 void PrintCenterFocusResults::printPolynoms( ostream & os,
00889 const PolynomXY_Type & p_ref ,
00890 const PolynomXY_Type & q_ref ,
00891 string comment) const
00892 {
00893 os << comment ;
00894 os << "\nP: " ;
00895 p_ref.output(os);
00896 os << "\nQ: " ;
00897 q_ref.output(os);
00898 os << std::endl;
00899 os << std::endl;
00900 os << std::endl;
00901 os << std::endl;
00902 os << std::endl;
00903 os << std::endl;
00904 }
00905
00906
00907 void PrintCenterFocusResults::printTail(ostream &oFile) const
00908 {
00909 oFile << std::endl << "if MacaulayDefinitions then {\n \
00910 -------------------\n \
00911 -- further rings --\n \
00912 -------------------\n \
00913 -- coordinates of the plane\n \
00914 Rcf = Fp[x,y];\n \
00915 -- differentials\n \
00916 Dcf = Fp[dx,dy,SkewCommutative => true];\n \
00917 -- differentials with Field-coefficients\n \
00918 RDcf = Rcf ** Dcf; --Rcf ** Dcf==Fp[x, y, dx, dy]\n \
00919 -- differentials with epsilon-coefficients\n \
00920 SRDcf = Scf ** Rcf ** Dcf;\n \
00921 -- differntials with variable coefficients\n \
00922 PQRDcf = PQcf ** Rcf ** Dcf;\n \
00923 -- generic differential Form\n \
00924 -- indizes anhand des Grads dynamisch.\n \
00925 -- generic differential Form (Check signs!)\n \
00926 Fcf = sum apply({{2,0},{1,1},{0,2},{3,0},{2,1},{1,2},{0,3}},\n \
00927 i->x^(i#0)*y^(i#1)*(pp_i*dx+qq_i*dy))+x*dx+y*dy;\n \
00928 -------------------------\n \
00929 -- extract information --\n \
00930 -------------------------\n \
00931 getDBPointID = l ->l#1;\
00932 -- the given point as a list\n \
00933 pointListCF = l -> apply(l#0,i->apply(i,j->sub(j,Scf)));\n \
00934 -- the given point as a matrix\n \
00935 -- order as in RCF\n \
00936 pointMatrixCF = l -> matrix {flatten pointListCF(l)};\n \
00937 -- the given point as a differential Form\n \
00938 pointDiffCF = l -> sub(Fcf,sub(pointMatrixCF(l),SRDcf)|sub(vars RDcf,SRDcf));\n \
00939 -- number of consecutive focal values that have zero constant term\n \
00940 -- at given point\n \
00941 numberZeroValuesCF = (l) -> l#2;\n \
00942 -- focal values\n \
00943 focalValuesCF = (l) -> transpose sub(matrix{l#3},Scf);\n \
00944 focalValuesListCF = (l) -> apply(#l#3, i-> sub(l#3#i,Scf));\n \
00945 \
00946 -- liftPoints \n \
00947 liftPointsCF = l -> apply(l#6#5,h->apply(h,i->apply(i,j->sub(j,Scf))));\n \
00948 liftPointsMatrixCF = l -> flatten apply(#l#6#5, j->matrix {flatten (liftPointsCF(l))#j });\n \
00949 liftPointsDiffCF = l -> flatten apply(#l#6#5, j-> sub(Fcf,sub((liftPointsMatrixCF(l))#j,SRDcf)|sub(vars RDcf,SRDcf)));\n \
00950 smallestObservedFailedLiftNr = l->l#6#1;\n \
00951 maxObservedFailedLiftNr = l->l#6#2;\n \
00952 firstFailedTrialNr = l->l#6#3;\n \
00953 failedTrialCount = l->l#6#4;\n \
00954 liftTestPassed = l->l#6#0 ;\n \
00955 \
00956 -- Jacobi matrix at given point\n \
00957 -- rows : focal values\n \
00958 -- columns: variables as in RCF\n \
00959 \
00960 jacobiMatrixCF = (l) -> sub( l#4#0#0,Fp);\n \
00961 -- The rank of the Jacobi matrix\n \
00962 \
00963 rankJacobiCF = (l) -> l#4#0#1;\n \
00964 \
00965 subJacobiMatrixCF = (l) -> sub( l#4#1#0,Fp);\n \
00966 -- The rank of the Jacobi matrix\n \
00967 \
00968 rankSubJacobiCF = (l) -> l#4#1#1;\n \
00969 \
00970 tangent2Tcf = (l) -> sub(ideal l#5#0#0,Tcf);\n \
00971 -- the linear Part of the tangent cone\n \
00972 -- in pp-qq variables\n \
00973 tangent1PQcf = (l) -> sub(ideal l#5#0#1#0,PQcf);\n \
00974 -- the quadratic Part of the tangent cone\n \
00975 -- in pp-qq variables\n \
00976 tangent2PQcf = (l) -> sub(ideal l#5#0#1#1,PQcf);\n \
00977 quadricsRank = (l) ->#l#5#0#1#1; \n \
00978 -- both parts of the tangent cone\n \
00979 -- in pp-qq variables\n \
00980 tangent12PQcf = (l) -> tangent1PQcf(l) + tangent2PQcf(l);\n \
00981 -- the same only for variables that are chosen randomly\n \
00982 tangent2subTcf = (l) -> sub(ideal l#5#1#0,Tcf);\n \
00983 tangent1subPQcf = (l) -> sub(ideal l#5#1#1#0,PQcf);\n \
00984 tangent2subPQcf = (l) -> sub(ideal l#5#1#1#1,PQcf);\n \
00985 tangent12subPQcf = (l) -> tangent1subPQcf(l) + tangent2subPQcf(l);\n \
00986 subQuadricsRank = (l) -> #l#5#1#1#1; \n \
00987 } --fi MacaulayDefinitions\n ";
00988 oFile << std::endl;
00989 return;
00990 }
00991
00992
00993 void PrintCenterFocusResults::printSmoothnessTestTail(ostream &oFile) const
00994 {
00995 oFile << std::endl << "if MacaulayDefinitions then {\n \
00996 -------------------\n \
00997 -- further rings --\n \
00998 -------------------\n \
00999 -- coordinates of the plane\n \
01000 Rcf = Fp[x,y];\n \
01001 -- differentials\n \
01002 Dcf = Fp[dx,dy,SkewCommutative => true];\n \
01003 -- differentials with Field-coefficients\n \
01004 RDcf = Rcf ** Dcf; --Rcf ** Dcf==Fp[x, y, dx, dy]\n \
01005 -- differentials with epsilon-coefficients\n \
01006 SRDcf = Scf ** Rcf ** Dcf;\n \
01007 -- differntials with variable coefficients\n \
01008 PQRDcf = PQcf ** Rcf ** Dcf;\n \
01009 -- generic differential Form\n \
01010 -- indizes anhand des Grads dynamisch.\n \
01011 -- generic differential Form (Check signs!)\n \
01012 Fcf = sum apply({{2,0},{1,1},{0,2},{3,0},{2,1},{1,2},{0,3}},\n \
01013 i->x^(i#0)*y^(i#1)*(pp_i*dx+qq_i*dy))+x*dx+y*dy;\n \
01014 -------------------------\n \
01015 -- extract information --\n \
01016 -------------------------\n \
01017 getDBPointID = l ->l#1;\
01018 -- the given point as a list\n \
01019 pointListCF = l -> apply(l#0,i->apply(i,j->sub(j,Scf)));\n \
01020 -- the given point as a matrix\n \
01021 -- order as in RCF\n \
01022 pointMatrixCF = l -> matrix {flatten pointListCF(l)};\n \
01023 -- the given point as a differential Form\n \
01024 pointDiffCF = l -> sub(Fcf,sub(pointMatrixCF(l),SRDcf)|sub(vars RDcf,SRDcf));\n \
01025 -- number of consecutive focal values that have zero constant term\n \
01026 -- at given point\n \
01027 smallestObservedFailedLiftNr = l->l#2#1;\n \
01028 maxObservedFailedLiftNr = l->l#2#2;\n \
01029 firstFailedTrialNr = l->l#2#3;\n \
01030 failedTrialCount = l->l#2#4;\n \
01031 liftTestPassed = l->l#2#0 ;\n \
01032 liftPointsCF = l -> apply(l#2#5,h->apply(h,i->apply(i,j->sub(j,Scf))));\n \
01033 liftPointsMatrixCF = l -> flatten apply(#l#2#5, j->matrix {flatten (liftPointsCF(l))#j });\n \
01034 liftPointsDiffCF = l -> flatten apply(#l#2#5, j-> sub(Fcf,sub((liftPointsMatrixCF(l))#j,SRDcf)|sub(vars RDcf,SRDcf)));\n \
01035 -- rows : focal values\n \
01036 -- columns: variables as in RCF\n \
01037 } --fi MacaulayDefinitions\n ";
01038 oFile << std::endl;
01039 return;
01040 }
01041
01042
01043 }
01044
01045