AnasaziStatusTestMaxIters.hpp

Go to the documentation of this file.
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00023 // USA
00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
00025 //
00026 // ***********************************************************************
00027 // @HEADER
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   std::ostream& print(std::ostream& os, int indent = 0) const {
00158     std::string ind(indent,' ');
00159     os << ind << "- StatusTestMaxIters: ";
00160     switch (state_) {
00161     case Passed:
00162       os << "Passed" << std::endl;
00163       break;
00164     case Failed:
00165       os << "Failed" << std::endl;
00166       break;
00167     case Undefined:
00168       os << "Undefined" << std::endl;
00169       break;
00170     }
00171     os << ind << "  MaxIters: " << maxIters_ << std::endl;
00172     return os;
00173   }
00174  
00176   private:
00177   int maxIters_;
00178   TestStatus state_;
00179   bool negate_;
00180 
00181 };
00182 
00183 } // end of Anasazi namespace
00184 
00185 #endif /* ANASAZI_STATUS_TEST_MAXITER_HPP */

Generated on Tue Oct 20 12:45:18 2009 for Anasazi by doxygen 1.4.7