AnasaziStatusTestOutput.hpp
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
00024
00025
00026
00027
00028
00029
00030 #ifndef ANASAZI_STATUS_TEST_OUTPUT_HPP
00031 #define ANASAZI_STATUS_TEST_OUTPUT_HPP
00032
00039 #include "AnasaziConfigDefs.hpp"
00040 #include "AnasaziTypes.hpp"
00041 #include "AnasaziEigensolver.hpp"
00042
00043 #include "AnasaziStatusTest.hpp"
00044
00045
00046
00047 namespace Anasazi {
00048
00058 template <class ScalarType, class MV, class OP>
00059 class StatusTestOutput : public StatusTest<ScalarType,MV,OP> {
00060
00061 public:
00063
00064
00082 StatusTestOutput(const Teuchos::RCP<OutputManager<ScalarType> > &printer,
00083 Teuchos::RCP<StatusTest<ScalarType,MV,OP> > test,
00084 int mod = 1,
00085 int printStates = Passed)
00086 : printer_(printer), test_(test), state_(Undefined), stateTest_(printStates), modTest_(mod), numCalls_(0)
00087 { }
00088
00090 virtual ~StatusTestOutput() {};
00092
00094
00095
00112 TestStatus checkStatus( Eigensolver<ScalarType,MV,OP>* solver ) {
00113 TEST_FOR_EXCEPTION(test_ == Teuchos::null,StatusTestError,"StatusTestOutput::checkStatus(): child pointer is null.");
00114 state_ = test_->checkStatus(solver);
00115
00116 if (numCalls_++ % modTest_ == 0) {
00117 if ( (state_ & stateTest_) == state_) {
00118 if ( printer_->isVerbosity(StatusTestDetails) ) {
00119 print( printer_->stream(StatusTestDetails) );
00120 }
00121 else if ( printer_->isVerbosity(Debug) ) {
00122 print( printer_->stream(Debug) );
00123 }
00124 }
00125 }
00126
00127 return state_;
00128 }
00129
00131 TestStatus getStatus() const {
00132 return state_;
00133 }
00134
00136 std::vector<int> whichVecs() const {
00137 return std::vector<int>(0);
00138 }
00139
00141 int howMany() const {
00142 return 0;
00143 }
00144
00146
00147
00149
00150
00155 void setChild(Teuchos::RCP<StatusTest<ScalarType,MV,OP> > test) {
00156 test_ = test;
00157 state_ = Undefined;
00158 }
00159
00161 Teuchos::RCP<StatusTest<ScalarType,MV,OP> > getChild() const {
00162 return test_;
00163 }
00164
00166
00167
00169
00170
00175 void reset() {
00176 state_ = Undefined;
00177 if (test_ != Teuchos::null) {
00178 test_->reset();
00179 }
00180 numCalls_ = 0;
00181 }
00182
00185 void clearStatus() {
00186 state_ = Undefined;
00187 if (test_ != Teuchos::null) {
00188 test_->clearStatus();
00189 }
00190 }
00191
00193
00195
00196
00198 std::ostream& print(std::ostream& os, int indent = 0) const {
00199 std::string ind(indent,' ');
00200 os << ind << "- StatusTestOutput: ";
00201 switch (state_) {
00202 case Passed:
00203 os << "Passed" << std::endl;
00204 break;
00205 case Failed:
00206 os << "Failed" << std::endl;
00207 break;
00208 case Undefined:
00209 os << "Undefined" << std::endl;
00210 break;
00211 }
00212 os << ind << " (Num calls,Mod test,State test): " << "(" << numCalls_ << ", " << modTest_ << ",";
00213 if (stateTest_ == 0) {
00214 os << " none )" << std::endl;
00215 }
00216 else {
00217 if ( (stateTest_ & Passed) == Passed ) os << " Passed";
00218 if ( (stateTest_ & Failed) == Failed ) os << " Failed";
00219 if ( (stateTest_ & Undefined) == Undefined ) os << " Undefined";
00220 os << " )" << std::endl;
00221 }
00222
00223 test_->print(os,indent+3);
00224 return os;
00225 }
00226
00228
00229 private:
00230 Teuchos::RCP<OutputManager<ScalarType> > printer_;
00231 Teuchos::RCP<StatusTest<ScalarType,MV,OP> > test_;
00232 TestStatus state_;
00233 int stateTest_;
00234 int modTest_;
00235 int numCalls_;
00236 };
00237
00238 }
00239
00240 #endif