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 }
00099
00101
00102
00106 void setMaxIters(int maxIters) {
00107 state_ = Undefined;
00108 maxIters_ = maxIters;
00109 }
00110
00112 int getMaxIters() {return maxIters_;}
00113
00117 void setNegate(bool negate) {
00118 state_ = Undefined;
00119 negate_ = negate;
00120 }
00121
00123 bool getNegate() const {
00124 return negate_;
00125 }
00126
00128
00130
00131
00132
00137 void reset() {
00138 state_ = Undefined;
00139 }
00140
00142
00147 void clearStatus() {
00148 state_ = Undefined;
00149 }
00150
00152
00154
00155
00157 ostream& print(ostream& os, int indent = 0) const {
00158 string ind(indent,' ');
00159 os << ind << "- StatusTestMaxIters: ";
00160 switch (state_) {
00161 case Passed:
00162 os << "Passed" << endl;
00163 break;
00164 case Failed:
00165 os << "Failed" << endl;
00166 break;
00167 case Undefined:
00168 os << "Undefined" << endl;
00169 break;
00170 }
00171 os << ind << " MaxIters: " << maxIters_ << endl;
00172 return os;
00173 }
00174
00176 private:
00177 int maxIters_;
00178 TestStatus state_;
00179 bool negate_;
00180
00181 };
00182
00183 }
00184
00185 #endif