Anasazi  Version of the Day
AnasaziStatusTestOutput.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Anasazi: Block Eigensolvers Package
5 // Copyright (2004) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // This library is free software; you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as
12 // published by the Free Software Foundation; either version 2.1 of the
13 // License, or (at your option) any later version.
14 //
15 // This library is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the Free Software
22 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
23 // USA
24 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
25 //
26 // ***********************************************************************
27 // @HEADER
28 //
29 
30 #ifndef ANASAZI_STATUS_TEST_OUTPUT_HPP
31 #define ANASAZI_STATUS_TEST_OUTPUT_HPP
32 
39 #include "AnasaziConfigDefs.hpp"
40 #include "AnasaziTypes.hpp"
41 #include "AnasaziEigensolver.hpp"
42 
43 #include "AnasaziStatusTest.hpp"
44 
45 
46 
47 namespace Anasazi {
48 
58 template <class ScalarType, class MV, class OP>
59 class StatusTestOutput : public StatusTest<ScalarType,MV,OP> {
60 
61  public:
63 
64 
84  int mod = 1,
85  int printStates = Passed)
86  : printer_(printer), test_(test), state_(Undefined), stateTest_(printStates), modTest_(mod), numCalls_(0)
87  { }
88 
90  virtual ~StatusTestOutput() {};
92 
94 
95 
113  TEUCHOS_TEST_FOR_EXCEPTION(test_ == Teuchos::null,StatusTestError,"StatusTestOutput::checkStatus(): child pointer is null.");
114  state_ = test_->checkStatus(solver);
115 
116  if (numCalls_++ % modTest_ == 0) {
117  if ( (state_ & stateTest_) == state_) {
118  if ( printer_->isVerbosity(StatusTestDetails) ) {
119  print( printer_->stream(StatusTestDetails) );
120  }
121  else if ( printer_->isVerbosity(Debug) ) {
122  print( printer_->stream(Debug) );
123  }
124  }
125  }
126 
127  return state_;
128  }
129 
132  return state_;
133  }
134 
136  std::vector<int> whichVecs() const {
137  return std::vector<int>(0);
138  }
139 
141  int howMany() const {
142  return 0;
143  }
144 
146 
147 
149 
150 
156  test_ = test;
157  state_ = Undefined;
158  }
159 
162  return test_;
163  }
164 
166 
167 
169 
170 
175  void reset() {
176  state_ = Undefined;
177  if (test_ != Teuchos::null) {
178  test_->reset();
179  }
180  numCalls_ = 0;
181  }
182 
185  void clearStatus() {
186  state_ = Undefined;
187  if (test_ != Teuchos::null) {
188  test_->clearStatus();
189  }
190  }
191 
193 
195 
196 
198  std::ostream& print(std::ostream& os, int indent = 0) const {
199  std::string ind(indent,' ');
200  os << ind << "- StatusTestOutput: ";
201  switch (state_) {
202  case Passed:
203  os << "Passed" << std::endl;
204  break;
205  case Failed:
206  os << "Failed" << std::endl;
207  break;
208  case Undefined:
209  os << "Undefined" << std::endl;
210  break;
211  }
212  os << ind << " (Num calls,Mod test,State test): " << "(" << numCalls_ << ", " << modTest_ << ",";
213  if (stateTest_ == 0) {
214  os << " none )" << std::endl;
215  }
216  else {
217  if ( (stateTest_ & Passed) == Passed ) os << " Passed";
218  if ( (stateTest_ & Failed) == Failed ) os << " Failed";
219  if ( (stateTest_ & Undefined) == Undefined ) os << " Undefined";
220  os << " )" << std::endl;
221  }
222  // print child, with extra indention
223  test_->print(os,indent+3);
224  return os;
225  }
226 
228 
229  private:
232  TestStatus state_;
233  int stateTest_;
234  int modTest_;
235  int numCalls_;
236 };
237 
238 } // end of Anasazi namespace
239 
240 #endif /* ANASAZI_STATUS_TEST_OUTPUT_HPP */
A special StatusTest for printing other status tests.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Exception thrown to signal error in a status test during Anasazi::StatusTest::checkStatus().
void reset()
Informs the status test that it should reset its internal configuration to the uninitialized state...
TestStatus
Enumerated type used to pass back information from a StatusTest.
Pure virtual base class which describes the basic interface to the iterative eigensolver.
Namespace Anasazi contains the classes, structs, enums and utilities used by the Anasazi package...
void setChild(Teuchos::RCP< StatusTest< ScalarType, MV, OP > > test)
Set child test.
std::ostream & print(std::ostream &os, int indent=0) const
Output formatted description of stopping test to output stream.
Output managers remove the need for the eigensolver to know any information about the required output...
std::vector< int > whichVecs() const
Get the indices for the vectors that passed the test.
Anasazi header file which uses auto-configuration information to include necessary C++ headers...
Types and exceptions used within Anasazi solvers and interfaces.
TestStatus checkStatus(Eigensolver< ScalarType, MV, OP > *solver)
StatusTestOutput(const Teuchos::RCP< OutputManager< ScalarType > > &printer, Teuchos::RCP< StatusTest< ScalarType, MV, OP > > test, int mod=1, int printStates=Passed)
Constructor.
Common interface of stopping criteria for Anasazi&#39;s solvers.
TestStatus getStatus() const
Return the result of the most recent checkStatus call, or undefined if it has not been run...
The Eigensolver is a templated virtual base class that defines the basic interface that any eigensolv...
int howMany() const
Get the number of vectors that passed the test.
virtual ~StatusTestOutput()
Destructor.
Teuchos::RCP< StatusTest< ScalarType, MV, OP > > getChild() const
Get child test.
Declaration and definition of Anasazi::StatusTest.