Anasazi  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
AnasaziStatusTestMaxIters.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Anasazi: Block Eigensolvers Package
4 //
5 // Copyright 2004 NTESS and the Anasazi contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 //
10 
11 #ifndef ANASAZI_STATUS_TEST_MAXITER_HPP
12 #define ANASAZI_STATUS_TEST_MAXITER_HPP
13 
20 #include "AnasaziStatusTest.hpp"
21 
22 
41 namespace Anasazi {
42 
43 
44 template <class ScalarType, class MV, class OP>
45 class StatusTestMaxIters : public StatusTest<ScalarType,MV,OP> {
46 
47  public:
49 
50 
52  StatusTestMaxIters(int maxIter, bool negate = false) : state_(Undefined), negate_(negate) {
53  setMaxIters(maxIter);
54  };
55 
57  virtual ~StatusTestMaxIters() {};
59 
61 
62 
67  state_ = (solver->getNumIters() >= maxIters_) ? Passed : Failed;
68  if (negate_) {
69  if (state_ == Passed) state_ = Failed;
70  else state_ = Passed;
71  }
72  return state_;
73  }
74 
77  return state_;
78  }
79 
81  std::vector<int> whichVecs() const {
82  return std::vector<int>(0);
83  }
84 
86  int howMany() const {
87  return 0;
88  }
89 
91 
93 
94 
98  void setMaxIters(int maxIters) {
99  state_ = Undefined;
100  maxIters_ = maxIters;
101  }
102 
104  int getMaxIters() {return maxIters_;}
105 
109  void setNegate(bool negate) {
110  state_ = Undefined;
111  negate_ = negate;
112  }
113 
115  bool getNegate() const {
116  return negate_;
117  }
118 
120 
122 
123 
129  void reset() {
130  state_ = Undefined;
131  }
132 
134 
139  void clearStatus() {
140  state_ = Undefined;
141  }
142 
144 
146 
147 
149  std::ostream& print(std::ostream& os, int indent = 0) const {
150  std::string ind(indent,' ');
151  os << ind << "- StatusTestMaxIters: ";
152  switch (state_) {
153  case Passed:
154  os << "Passed" << std::endl;
155  break;
156  case Failed:
157  os << "Failed" << std::endl;
158  break;
159  case Undefined:
160  os << "Undefined" << std::endl;
161  break;
162  }
163  os << ind << " MaxIters: " << maxIters_ << std::endl;
164  return os;
165  }
166 
168  private:
169  int maxIters_;
170  TestStatus state_;
171  bool negate_;
172 
173 };
174 
175 } // end of Anasazi namespace
176 
177 #endif /* ANASAZI_STATUS_TEST_MAXITER_HPP */
std::vector< int > whichVecs() const
Get the indices for the vectors that passed the test.
int getMaxIters()
Get the maximum number of iterations.
TestStatus
Enumerated type used to pass back information from a StatusTest.
StatusTestMaxIters(int maxIter, bool negate=false)
Constructor.
void clearStatus()
Clears the results of the last status test.
void setNegate(bool negate)
Set the negation policy for the status test.
void reset()
Informs the status test that it should reset its internal configuration to the uninitialized state...
TestStatus getStatus() const
Return the result of the most recent checkStatus call.
A status test for testing the number of iterations.
void setMaxIters(int maxIters)
Set the maximum number of iterations.
std::ostream & print(std::ostream &os, int indent=0) const
Output formatted description of stopping test to output stream.
TestStatus checkStatus(Eigensolver< ScalarType, MV, OP > *solver)
Check status as defined by test.
Common interface of stopping criteria for Anasazi&#39;s solvers.
int howMany() const
Get the number of vectors that passed the test.
virtual int getNumIters() const =0
Get the current iteration count.
bool getNegate() const
Get the negation policy for the status test.
The Eigensolver is a templated virtual base class that defines the basic interface that any eigensolv...
Declaration and definition of Anasazi::StatusTest.