|
Anasazi
Version of the Day
|
00001 // @HEADER 00002 // *********************************************************************** 00003 // 00004 // Anasazi: Block Eigensolvers Package 00005 // Copyright (2004) Sandia Corporation 00006 // 00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive 00008 // license for use of this work by or on behalf of the U.S. Government. 00009 // 00010 // This library is free software; you can redistribute it and/or modify 00011 // it under the terms of the GNU Lesser General Public License as 00012 // published by the Free Software Foundation; either version 2.1 of the 00013 // License, or (at your option) any later version. 00014 // 00015 // This library is distributed in the hope that it will be useful, but 00016 // WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 // Lesser General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Lesser General Public 00021 // License along with this library; if not, write to the Free Software 00022 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 00023 // USA 00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 00025 // 00026 // *********************************************************************** 00027 // @HEADER 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 TEUCHOS_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 // print child, with extra indention 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 } // end of Anasazi namespace 00239 00240 #endif /* ANASAZI_STATUS_TEST_OUTPUT_HPP */
1.7.6.1