![]() |
User Manual, Developers Guide and API Documentation |
![]() |
00001 /******************************************************************************* 00002 * This file is part of openWNS (open Wireless Network Simulator) 00003 * _____________________________________________________________________________ 00004 * 00005 * Copyright (C) 2004-2007 00006 * Chair of Communication Networks (ComNets) 00007 * Kopernikusstr. 16, D-52074 Aachen, Germany 00008 * phone: ++49-241-80-27910, 00009 * fax: ++49-241-80-22242 00010 * email: info@openwns.org 00011 * www: http://www.openwns.org 00012 * _____________________________________________________________________________ 00013 * 00014 * openWNS is free software; you can redistribute it and/or modify it under the 00015 * terms of the GNU Lesser General Public License version 2 as published by the 00016 * Free Software Foundation; 00017 * 00018 * openWNS is distributed in the hope that it will be useful, but WITHOUT ANY 00019 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 00020 * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 00021 * details. 00022 * 00023 * You should have received a copy of the GNU Lesser General Public License 00024 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00025 * 00026 ******************************************************************************/ 00027 00028 #include <WNS/evaluation/statistics/dlre.hpp> 00029 00030 #include <cmath> 00031 #include <algorithm> 00032 00033 using namespace std; 00034 using namespace wns::evaluation::statistics; 00035 00037 DLRE::DLRE(vector<double> xValuesArr, 00038 int level, 00039 double error, 00040 double preFirst, 00041 string name, 00042 string description, 00043 bool forceRminusAOK, 00044 int maxNrv, 00045 int skipInterval, 00046 formatType format) 00047 : StatEval(format, name, description), 00048 results_(NULL), 00049 relErrMax_(error), 00050 maxNrv_(maxNrv), 00051 wastedLeft_(0), 00052 wastedRight_(0), 00053 h_(0), 00054 xOffset_(0), 00055 xMin_(0.0), 00056 xMax_(0.0), 00057 indexMin_(0), 00058 indexMax_(level), 00059 equiDist_(false), 00060 intSize_(0.0), 00061 curIndex_(0), 00062 preRv_(preFirst), 00063 preIndex_(0), 00064 base_(1.0), 00065 reason_(ok), 00066 curLevelIndex_(0), 00067 skipInterval_(skipInterval), 00068 forceRminusAOK_(forceRminusAOK), 00069 phase_(initialize) 00070 { 00071 this->initNonEqui(level, xValuesArr, preFirst); 00072 } 00073 00074 void 00075 DLRE::initNonEqui(int level, 00076 vector<double> xValuesArr, 00077 double preFirst) 00078 { 00079 indexMax_ = level; 00080 00081 assure(level > 1, "Number of levels must be larger than 1"); 00082 00083 // one element more because of getIndex_ 00084 results_ = new Result [level + 1]; 00085 00086 if (xValuesArr.empty()) 00087 { 00088 // fill results_[].x with default-values 00089 // 0 ... level-1 00090 for (int i = 0; i <= level; i++) 00091 { 00092 results_[i].x_ = i; 00093 results_[i].h_ = 0; 00094 results_[i].sumh_ = 0; 00095 results_[i].c_ = 0; 00096 } 00097 00098 xMin_ = 0.0; 00099 xMax_ = level - 1; 00100 intSize_ = 1.0; 00101 equiDist_ = true; 00102 } 00103 else 00104 { 00105 int i = 0; 00106 while((i < xValuesArr.size()) and (i < level)) 00107 { 00108 results_[i].x_ = xValuesArr[i]; 00109 results_[i].h_ = 0; 00110 results_[i].c_ = 0; 00111 ++i; 00112 } 00113 00114 results_[level].h_ = 0; 00115 results_[level].c_ = 0; 00116 xMin_ = results_[0].x_; 00117 xMax_ = results_[level - 1].x_; 00118 intSize_ = 0.0; 00119 equiDist_ = false; 00120 } 00121 00122 if (preFirst < xMin_) 00123 { 00124 preIndex_ = indexMin_; 00125 } 00126 else if (preFirst > xMax_) 00127 { 00128 preIndex_ = indexMax_ - 1; 00129 } 00130 else 00131 { 00132 preIndex_ = 0; 00133 while (preIndex_ < level) 00134 { 00135 if (fabs(results_[preIndex_].x_ - preFirst) < getMaxError<double>()) 00136 { 00137 break; 00138 } 00139 else 00140 { 00141 preIndex_++; 00142 } 00143 } 00144 } 00145 00146 // state of beginning 00147 curLevelIndex_ = indexMin_; 00148 } 00149 00150 00152 DLRE::DLRE(double xMin, 00153 double xMax, 00154 double intSize, 00155 double error, 00156 double preFirst, 00157 string name, 00158 string description, 00159 bool forceRminusAOK, 00160 int maxNrv, 00161 int skipInterval, 00162 formatType format) 00163 : StatEval(format, name, description), 00164 results_(NULL), 00165 relErrMax_(error), 00166 maxNrv_(maxNrv), 00167 wastedLeft_(0), 00168 wastedRight_(0), 00169 h_(0), 00170 xOffset_(0), 00171 xMin_(xMin), 00172 xMax_(xMax), 00173 indexMin_(0), 00174 indexMax_(0), 00175 equiDist_(true), 00176 intSize_(intSize), 00177 curIndex_(0), 00178 preRv_(preFirst), 00179 preIndex_(0), 00180 base_(1.0), 00181 reason_(ok), 00182 curLevelIndex_(0), 00183 skipInterval_(skipInterval), 00184 forceRminusAOK_(forceRminusAOK), 00185 phase_(initialize) 00186 { 00187 this->initEqui(xMin_, xMax_, intSize_, preFirst); 00188 } 00189 00190 void 00191 DLRE::initEqui(double xMin, 00192 double xMax, 00193 double intSize, 00194 double preFirst) 00195 { 00196 assure(intSize > 0, "Interval width must be > 0!"); 00197 assure(xMin < xMax, "xMin must be smaller than xMax"); 00198 00199 double tmp = (xMax - xMin) / intSize; 00200 int level = tmp + 1; 00201 00202 assure(level > 1, "Settings for xMax, xMin, intSize results in less than 2 levels"); 00203 00204 indexMax_ = level; 00205 results_ = new Result [level + 1]; 00206 00207 for (int i = 0; i <= level; i++) 00208 { 00209 results_[i].x_ = (i * intSize) + xMin; 00210 results_[i].h_ = 0; 00211 results_[i].sumh_ = 0; 00212 results_[i].c_ = 0; 00213 } 00214 00215 if (preFirst < xMin_) 00216 { 00217 preIndex_ = indexMin_; 00218 } 00219 else if (preFirst > xMax_) 00220 { 00221 preIndex_ = indexMax_; 00222 } 00223 else 00224 { 00225 preIndex_ = 0; 00226 while (preIndex_ < level) 00227 { 00228 if (results_[preIndex_].x_ == preFirst) 00229 { 00230 break; 00231 } 00232 else 00233 { 00234 preIndex_++; 00235 } 00236 } 00237 } 00238 } 00239 00240 DLRE::DLRE(const wns::pyconfig::View& config) : 00241 StatEval(config), 00242 results_(NULL), 00243 relErrMax_(config.get<double>("maxError")), 00244 maxNrv_(UINT_MAX), 00245 wastedLeft_(0), 00246 wastedRight_(0), 00247 h_(0), 00248 xOffset_(0), 00249 xMin_(-1.0), 00250 xMax_(-1.0), 00251 indexMin_(0), 00252 indexMax_(0), 00253 equiDist_(true), 00254 intSize_(-1.0), 00255 curIndex_(0), 00256 preRv_(config.get<double>("initValue")), 00257 preIndex_(0), 00258 base_(1.0), 00259 reason_(ok), 00260 curLevelIndex_(0), 00261 skipInterval_(config.get<int>("skipInterval")), 00262 forceRminusAOK_(config.get<bool>("forceRminusAOK")), 00263 phase_(initialize) 00264 { 00265 if (config.get<string>("maxNumTrials") != "infinity") 00266 { 00267 maxNrv_ = config.get<int>("maxNumTrials"); 00268 } 00269 00270 if (config.get<string>("distances") == "equi") 00271 { 00272 // equidistant x-values 00273 equiDist_ = true; 00274 xMin_ = config.get<double>("xMin"); 00275 xMax_ = config.get<double>("xMax"); 00276 intSize_ = config.get<double>("intervalWidth"); 00277 00278 this->initEqui(xMin_, 00279 xMax_, 00280 intSize_, 00281 config.get<double>("initValue") ); 00282 00283 } 00284 else if (config.get<string>("distances") == "nonequi") 00285 { 00286 // non-equidistant x-values 00287 equiDist_ = false; 00288 vector<double> xValuesArr; 00289 int numXValues = config.len("xValues"); 00290 for (int ii=0; ii<numXValues; ++ii) 00291 { 00292 xValuesArr.push_back(config.get<double>("xValues",ii)); 00293 } 00294 00295 this->initNonEqui(numXValues, 00296 xValuesArr, 00297 config.get<double>("initValue")); 00298 } 00299 else 00300 { 00301 string errorString = ("Unknown 'distances' setting '" + config.get<string>("distances") + "'\n"); 00302 throw(wns::Exception(errorString)); 00303 } 00304 } 00305 00306 00308 DLRE::~DLRE() 00309 { 00310 delete [] results_; 00311 } 00312 00314 void DLRE::reset() 00315 { 00316 StatEval::reset(); 00317 00318 h_ = 0; 00319 wastedRight_ = 0; 00320 wastedLeft_ = 0; 00321 phase_ = initialize; 00322 00323 for (int i = indexMin_; i < indexMax_; i++) 00324 { 00325 results_[i].h_ = 0; 00326 results_[i].c_ = 0; 00327 results_[i].sumh_ = 0; 00328 } 00329 } 00330 00331 00333 void DLRE::setBase(double newBase) 00334 { 00335 base_ = newBase; 00336 } 00337 00339 void DLRE::changeError(double newError) 00340 { 00341 relErrMax_ = newError; 00342 } 00343 00345 double DLRE::curXLev() 00346 { 00347 return results_[curLevelIndex_].x_; 00348 } 00349 00350 00352 double DLRE::p(double xt) 00353 { 00354 00355 int index = getIndex(xt); 00356 00357 if((numTrials_ > 0) and (index >= 0)) 00358 { 00359 return (double)(results_[index].h_) / (double)numTrials_; 00360 } 00361 else 00362 { 00363 return(0.0); 00364 } 00365 } 00366 00368 int DLRE::minIndex() const 00369 { 00370 return indexMin_; 00371 } 00372 00374 int DLRE::maxIndex() const 00375 { 00376 return indexMax_ - 1; 00377 } 00378 00379 00380 00382 DLRE::ResultLine::ResultLine() 00383 : vf_(0.0), 00384 x_(0.0), 00385 relErr_(0.0), 00386 rho_(0.0), 00387 sigRho_(0.0), 00388 nx_(0) 00389 {} 00390 00391 00395 bool DLRE::ResultLine::operator != (const ResultLine& aLineRef) 00396 const 00397 { 00398 const ResultLine* ptr = &aLineRef; 00399 00400 return not 00401 ((fabs(x_ - ptr->x_) < getMaxError<double>()) and 00402 (fabs(vf_ - ptr->vf_) < getMaxError<double>()) and 00403 (fabs(relErr_ - ptr->relErr_) < getMaxError<double>()) and 00404 (fabs(rho_ - ptr->rho_) < getMaxError<double>()) and 00405 (fabs(sigRho_ - ptr->sigRho_) < getMaxError<double>()) and 00406 (fabs(double(nx_ - ptr->nx_)) < getMaxError<double>())); 00407 } 00408 00409 const int DLRE::largeSampleNumTrials_ = 1000; 00410 const int DLRE::largeSampleNumSortedValues_ = 100; 00411 const int DLRE::largeSampleNumTransitions_ = 10; 00412 00414 int DLRE::getIndex(double value) const 00415 { 00416 if (value < xMin_) 00417 { 00418 return lower; 00419 } 00420 else if (value > xMax_) 00421 { 00422 return greater; 00423 } 00424 else if (equiDist_) 00425 { 00426 int index = std::min(int(indexMin_ + (value - xMin_) / intSize_), 00427 int((indexMax_ - 1))); 00428 00429 return index; 00430 00431 return (fabs(value - results_[index].x_) < getMaxError<double>()) ? 00432 index : int(noIndex); 00433 } 00434 else 00435 { 00436 // search the correct index (you know a better algorithm ? - Send it !) 00437 Result* start = results_; 00438 Result* end = results_ + indexMax_; 00439 Result* lauf; 00440 register int step; 00441 00442 while ((step = (end - start)) >= 1) 00443 { 00444 // `>>1' equals `/2' but is faster 00445 lauf = start + (step >> 1); 00446 if (fabs(lauf->x_ - value) < getMaxError<double>()) 00447 { 00448 return (step >> 1) + (start - results_); 00449 } 00450 else if (lauf->x_ > value) 00451 { 00452 if (end - lauf > 0) 00453 end = lauf; 00454 else 00455 return noIndex; 00456 } 00457 else if (lauf->x_ < value) 00458 { 00459 if (lauf - start > 0) 00460 start = lauf; 00461 else 00462 return noIndex; 00463 } 00464 } 00465 00466 return noIndex; 00467 } 00468 } 00469 00470 00471 00473 void DLRE::printAll(ostream& aStreamRef, 00474 functionType aFunctionType, 00475 const double yMin) const 00476 { 00477 string prefix(prefix_ + " "); 00478 string separator = prefix + "---------------------------------------------------------------------------"; 00479 string long_separator = separator + "---------\n"; 00480 separator += "\n"; 00481 00482 string errorString; 00483 string eval_type_string; 00484 string function_string; 00485 int i; 00486 00487 switch (aFunctionType) 00488 { 00489 case df: 00490 eval_type_string = prefix + "Evaluation: DLREF"; 00491 errorString = "I/O Error: Can't dump DLREF results"; 00492 function_string = "F"; 00493 break; 00494 case cdf: 00495 eval_type_string = prefix + "Evaluation: DLREG"; 00496 errorString = "I/O Error: Can't dump DLREG results"; 00497 function_string = "G"; 00498 break; 00499 case pf: 00500 eval_type_string = prefix + "Evaluation: DLREP"; 00501 errorString = "I/O Error: Can't dump DLREP results"; 00502 function_string = "P"; 00503 break; 00504 default: 00505 throw(wns::Exception("DLRE: Unknown function type")); 00506 } 00507 00508 printBanner(aStreamRef, eval_type_string, errorString); 00509 00510 if (not aStreamRef) 00511 { 00512 throw(wns::Exception(errorString)); 00513 } 00514 00515 aStreamRef << separator << prefix; 00516 aStreamRef << " DLRE" << function_string << " statistics" << endl 00517 << prefix << endl; 00518 00519 aStreamRef << prefix << setprecision(4); 00520 aStreamRef.setf(ios::right); 00521 aStreamRef << " lower border: " << xMin_ << endl 00522 << prefix << " upper border: " << xMax_ << endl 00523 << prefix << " number of intervals: " << indexMax_ << endl; 00524 00525 if (equiDist_) 00526 { 00527 aStreamRef << prefix << " interval size: " << intSize_ << endl; 00528 } 00529 else 00530 { 00531 aStreamRef << prefix << endl 00532 << prefix << "non-equidistant x values, provided x values: " << endl 00533 << prefix; 00534 for (int i = 0; i < indexMax_; i++) 00535 { 00536 if (i % 10 == 0) 00537 { 00538 aStreamRef << endl << prefix; 00539 } 00540 00541 aStreamRef << results_[i].x_ << " "; 00542 } 00543 aStreamRef << endl << prefix << endl; 00544 } 00545 00546 aStreamRef << prefix << " maximum number of samples: "; 00547 00548 if (maxNrv_ == UINT_MAX) 00549 { 00550 aStreamRef << "infinity"; 00551 } 00552 else 00553 { 00554 aStreamRef << maxNrv_; 00555 } 00556 aStreamRef << endl 00557 << prefix << " maximum relative error [%]: " << resetiosflags(ios::scientific) << setiosflags(ios::fixed) << relErrMax_ * 100.0 << endl 00558 << prefix << resetiosflags(ios::fixed) << resetiosflags(ios::scientific) << (format_ == fixed ? setiosflags(ios::fixed) : setiosflags(ios::scientific)); 00559 00560 aStreamRef << endl << prefix << " large sample condition r - a >= 10 "; 00561 00562 if (not forceRminusAOK_) 00563 { 00564 aStreamRef << "not "; 00565 } 00566 aStreamRef << "enforced." << endl; 00567 00568 aStreamRef << separator << prefix << " DLRE" << function_string << " Data" << endl 00569 << prefix << endl; 00570 00571 aStreamRef << prefix << " evaluated levels: "; 00572 if (aFunctionType == cdf) 00573 { 00574 aStreamRef << curLevelIndex_ << endl; 00575 } 00576 else 00577 { 00578 aStreamRef << indexMax_ - curLevelIndex_ - 1 << endl; 00579 } 00580 00581 aStreamRef.setf(ios::fixed); 00582 aStreamRef << setprecision(2) << prefix << " Underflows: " << wastedLeft_ << endl; 00583 aStreamRef << prefix << " Overflows: " << wastedRight_ << endl << prefix << endl; 00584 00585 aStreamRef << prefix; 00586 switch(phase_) 00587 { 00588 case initialize: 00589 aStreamRef << "Initialization phase not completed, collecting samples." << endl; 00590 break; 00591 case iterate: 00592 aStreamRef << "Iteration phase not completed, collecting samples." << endl; 00593 break; 00594 case finish: 00595 switch (reason_) 00596 { 00597 case ok: 00598 aStreamRef << "All levels completed." << endl; 00599 break; 00600 case minimum: 00601 aStreamRef << "Evaluated till minimum y value = " << setprecision(10) << yMin << "." << endl; 00602 break; 00603 case last: 00604 aStreamRef << "Last level cannot be calculated." << endl; 00605 break; 00606 default: 00607 break; 00608 } 00609 break; 00610 default: 00611 break; 00612 } 00613 00614 // an evaluation without values does not make sense 00615 if (not numTrials_) 00616 { 00617 return; 00618 } 00619 00620 00621 aStreamRef << setprecision(7) << long_separator 00622 << prefix + " mean local " 00623 << " deviation number of number of" 00624 << endl 00625 << prefix + "ordinate abscissa relative correlation" 00626 << " from mean trials per transitions relative error" 00627 << endl 00628 << prefix + " error coefficient" 00629 << " local c.c. interval per interval within limit" 00630 << endl 00631 << prefix + "" 00632 << endl 00633 << prefix + "" 00634 << function_string 00635 << "(x) x d(x) rho(x) " 00636 << " sigma(x) " 00637 << "n(x) " 00638 << "t(x)" 00639 << endl 00640 << prefix + " " 00641 << function_string 00642 << " " 00643 << function_string 00644 << " rho" 00645 << endl 00646 << prefix + "" 00647 << endl 00648 << resetiosflags(ios::fixed) << resetiosflags(ios::scientific) 00649 << (format_ == fixed ? setiosflags(ios::fixed) : 00650 setiosflags(ios::scientific)); 00651 00652 if (not aStreamRef) 00653 { 00654 throw(wns::Exception(errorString)); 00655 } 00656 00657 00658 // print first level 00659 if(false) 00660 { 00661 double f = 0.0, x = 0.0; 00662 string infinity; 00663 00664 if (aFunctionType == cdf) 00665 { 00666 f = 1.0; 00667 x = minValue_; 00668 } 00669 else if (aFunctionType == df) 00670 { 00671 f = 0.0; 00672 x = minValue_; 00673 } 00674 else if (aFunctionType == pf) 00675 { 00676 f = 0.0; 00677 x = minValue_; 00678 } 00679 00680 aStreamRef << resetiosflags(ios::right) 00681 << setiosflags(ios::left) 00682 << setw(15) 00683 << f * base_; 00684 if (not aStreamRef) 00685 { 00686 throw(wns::Exception(errorString)); 00687 } 00688 if (x == DBL_MAX or x == -DBL_MAX) 00689 { 00690 if (x == DBL_MAX) 00691 { 00692 infinity = "+infinity "; 00693 } 00694 else 00695 { 00696 infinity = "-infinity "; 00697 } 00698 aStreamRef << infinity; 00699 } 00700 else 00701 { 00702 aStreamRef << resetiosflags(ios::left) 00703 << setiosflags(ios::right) 00704 << setw(14) 00705 << x; 00706 } 00707 if (not aStreamRef) 00708 { 00709 throw(wns::Exception(errorString)); 00710 } 00711 aStreamRef << " not_available not_available not_available " 00712 << resetiosflags(ios::right) 00713 << setiosflags(ios::left) 00714 << setw(10) 00715 << results_[0].h_ 00716 << " not_available y" 00717 << endl; 00718 if (not aStreamRef) 00719 { 00720 throw(wns::Exception(errorString)); 00721 } 00722 } 00723 00724 // Print levels between the first and last index 00725 for (i = indexMin_; i < indexMax_; i++) 00726 { 00727 printLevel(aStreamRef, i, errorString, false, aFunctionType); 00728 } 00729 00730 // Print last level (cdf/df -> f = 0.0, pf -> f = maxProbability) 00731 if(false and not(aFunctionType == pf and not numTrials_)) 00732 { 00733 double f, x; 00734 if (aFunctionType == cdf) 00735 { 00736 f = 0.0; 00737 x = maxValue_; 00738 } 00739 else if (aFunctionType == df) 00740 { 00741 f = 1.0; 00742 x = maxValue_; 00743 } 00744 else if (aFunctionType == pf) 00745 { 00746 f = (double(results_[curLevelIndex_ + 1].h_) / double(numTrials_)); 00747 x = maxValue_; 00748 } 00749 00750 aStreamRef << prefix + " " 00751 << resetiosflags(ios::right) 00752 << setiosflags(ios::left) 00753 << setw(15 - prefix.length() - 1) 00754 << f * base_; 00755 00756 if (not aStreamRef) 00757 { 00758 throw(wns::Exception(errorString)); 00759 } 00760 00761 if (x == DBL_MAX or x == -DBL_MAX) 00762 { 00763 string infinity; 00764 00765 if (x == DBL_MAX) 00766 { 00767 infinity = "+infinity "; 00768 } 00769 else 00770 { 00771 infinity = "-infinity "; 00772 } 00773 aStreamRef << infinity; 00774 } 00775 else 00776 { 00777 aStreamRef << resetiosflags(ios::left) 00778 << setiosflags(ios::right) 00779 << setw(14) 00780 << x; 00781 } 00782 if (not aStreamRef) 00783 { 00784 throw(wns::Exception(errorString)); 00785 } 00786 aStreamRef << " not_available not_available not_available " 00787 << resetiosflags(ios::right) 00788 << setiosflags(ios::left) 00789 << setw(10) 00790 << results_[curLevelIndex_ + 1].h_ 00791 << " " 00792 << setw(10) 00793 << results_[curLevelIndex_ + 1].c_ 00794 << " y" 00795 << endl; 00796 if (not aStreamRef) 00797 { 00798 throw(wns::Exception(errorString)); 00799 } 00800 } 00801 00802 00803 aStreamRef << long_separator; 00804 if (not aStreamRef) 00805 { 00806 throw(wns::Exception(errorString)); 00807 } 00808 } 00809 00810 00812 bool DLRE::checkLargeSample(int index) const 00813 { 00814 return 00815 (phase_ == initialize and numTrials_ >= largeSampleNumTrials_) or 00816 ((phase_ == iterate or phase_ == finish) and 00817 ((numTrials_ >= largeSampleNumTrials_) and 00818 (results_[index].sumh_ >= largeSampleNumSortedValues_) and 00819 ((numTrials_ - results_[index].sumh_) >= largeSampleNumSortedValues_) and 00820 (results_[index].c_ >= largeSampleNumTransitions_) and 00821 // ai == ci +- 1, so we do not need to check ai 00822 (not forceRminusAOK_ or 00823 ((((results_[index].sumh_ - results_[index].c_) >= largeSampleNumTransitions_) or 00824 (index > indexMax_ - 3) ) and 00825 // again, we assume ai == ci 00826 (((numTrials_ - results_[index].sumh_ - results_[index].c_) >= largeSampleNumTransitions_) or 00827 (index < indexMin_ + 3) 00828 ) 00829 ) 00830 ) 00831 ) 00832 ); 00833 00834 } 00835 00837 DLRE::Result::Result() 00838 : x_(0.0), 00839 h_(0), 00840 sumh_(0), 00841 c_(0) 00842 {} 00843 00844 00848 bool DLRE::Result::operator != (const Result& other) const 00849 { 00850 return not ((fabs(x_ - other.x_) < getMaxError<double>()) and 00851 (h_ == other.h_) and 00852 (sumh_ == other.sumh_) and 00853 (c_ == other.c_)); 00854 } 00855 00856 00857 00858 00859 00861 void DLRE::printLevel(ostream& stream, 00862 int level, 00863 const string& errorString, 00864 bool discretePointFlag, 00865 functionType functionType) const 00866 { 00867 string prefix(prefix_ + " "); 00868 00869 bool evaluated = (phase_ == finish) or (checkLargeSample(level)); 00870 ResultLine line; 00871 getResultLine(level, line); 00872 00873 if (not evaluated) 00874 { 00875 if (not stream) 00876 { 00877 throw(wns::Exception(errorString)); 00878 } 00879 } 00880 00881 if((not evaluated) or (line.relErr_ > relErrMax_)) 00882 { 00883 stream << prefix; 00884 } 00885 00886 stream << resetiosflags(ios::right) 00887 << setiosflags(ios::left) 00888 << (evaluated ? setw(15) : setw(15-prefix.length())) 00889 << line.vf_ 00890 << resetiosflags(ios::left) 00891 << setiosflags(ios::right) 00892 << setw(14) 00893 << line.x_ 00894 << " "; 00895 00896 if (not stream) 00897 { 00898 throw(wns::Exception(errorString)); 00899 } 00900 00901 if (evaluated and line.relErr_ >= 0.0) 00902 { 00903 stream << setw(14) 00904 << line.relErr_ 00905 << " "; 00906 } 00907 else 00908 { 00909 stream << setw(14) 00910 << line.relErr_ 00911 << " "; 00912 //stream << " not_available "; 00913 } 00914 00915 if (not stream) 00916 { 00917 throw(wns::Exception(errorString)); 00918 } 00919 00920 00921 if (evaluated) 00922 { 00923 stream << setw(14) 00924 << line.rho_; 00925 } 00926 else 00927 { 00928 stream << " not_available"; 00929 } 00930 if (not stream) 00931 { 00932 throw(wns::Exception(errorString)); 00933 } 00934 00935 00936 if (not evaluated or line.sigRho_ < 0.0) 00937 { 00938 stream << " not_available"; 00939 } 00940 else 00941 { 00942 stream << " " 00943 << setw(14) 00944 << line.sigRho_; 00945 } 00946 if (not stream) 00947 { 00948 throw(wns::Exception(errorString)); 00949 } 00950 00951 00952 stream << " " 00953 << resetiosflags(ios::right) 00954 << setiosflags(ios::left) 00955 << setw(10) 00956 << line.nx_ 00957 << " " 00958 << setw(10) 00959 << results_[level].c_ 00960 << " "; 00961 00962 if ((not evaluated) or line.relErr_ > relErrMax_) 00963 { 00964 stream << "n"; 00965 } 00966 else 00967 { 00968 stream << "y"; 00969 } 00970 stream << endl; 00971 } 00972
1.5.5