AnasaziStatusTestMaxIters.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_MAXITER_HPP
00031 #define ANASAZI_STATUS_TEST_MAXITER_HPP
00032
00039 #include "AnasaziStatusTest.hpp"
00040
00041
00060 namespace Anasazi {
00061
00062
00063 template <class ScalarType, class MV, class OP>
00064 class StatusTestMaxIters : public StatusTest<ScalarType,MV,OP> {
00065
00066 public:
00068
00069
00071 StatusTestMaxIters(int maxIter, bool negate = false) : state_(Undefined), negate_(negate) {
00072 setMaxIters(maxIter);
00073 };
00074
00076 virtual ~StatusTestMaxIters() {};
00078
00080
00081
00085 TestStatus checkStatus( Eigensolver<ScalarType,MV,OP>* solver ) {
00086 state_ = (solver->getNumIters() >= maxIters_) ? Passed : Failed;
00087 if (negate_) {
00088 if (state_ == Passed) state_ = Failed;
00089 else state_ = Passed;
00090 }
00091 return state_;
00092 }
00093
00095 TestStatus getStatus() const {
00096 return state_;
00097 }
00098
00100 std::vector<int> whichVecs() const {
00101 return std::vector<int>(0);
00102 }
00103
00105 int howMany() const {
00106 return 0;
00107 }
00108
00110
00112
00113
00117 void setMaxIters(int maxIters) {
00118 state_ = Undefined;
00119 maxIters_ = maxIters;
00120 }
00121
00123 int getMaxIters() {return maxIters_;}
00124
00128 void setNegate(bool negate) {
00129 state_ = Undefined;
00130 negate_ = negate;
00131 }
00132
00134 bool getNegate() const {
00135 return negate_;
00136 }
00137
00139
00141
00142
00143
00148 void reset() {
00149 state_ = Undefined;
00150 }
00151
00153
00158 void clearStatus() {
00159 state_ = Undefined;
00160 }
00161
00163
00165
00166
00168 std::ostream& print(std::ostream& os, int indent = 0) const {
00169 std::string ind(indent,' ');
00170 os << ind << "- StatusTestMaxIters: ";
00171 switch (state_) {
00172 case Passed:
00173 os << "Passed" << std::endl;
00174 break;
00175 case Failed:
00176 os << "Failed" << std::endl;
00177 break;
00178 case Undefined:
00179 os << "Undefined" << std::endl;
00180 break;
00181 }
00182 os << ind << " MaxIters: " << maxIters_ << std::endl;
00183 return os;
00184 }
00185
00187 private:
00188 int maxIters_;
00189 TestStatus state_;
00190 bool negate_;
00191
00192 };
00193
00194 }
00195
00196 #endif