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   }
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 } // end of Anasazi namespace
00195 
00196 #endif /* ANASAZI_STATUS_TEST_MAXITER_HPP */

Generated on Wed May 12 21:24:34 2010 for Anasazi by  doxygen 1.4.7