Anasazi Version of the Day
Loading...
Searching...
No Matches
AnasaziStatusTestOutput.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_OUTPUT_HPP
12#define ANASAZI_STATUS_TEST_OUTPUT_HPP
13
20#include "AnasaziConfigDefs.hpp"
21#include "AnasaziTypes.hpp"
23
24#include "AnasaziStatusTest.hpp"
25
26
27
28namespace Anasazi {
29
39template <class ScalarType, class MV, class OP>
40class StatusTestOutput : public StatusTest<ScalarType,MV,OP> {
41
42 public:
44
45
63 StatusTestOutput(const Teuchos::RCP<OutputManager<ScalarType> > &printer,
64 Teuchos::RCP<StatusTest<ScalarType,MV,OP> > test,
65 int mod = 1,
66 int printStates = Passed)
67 : printer_(printer), test_(test), state_(Undefined), stateTest_(printStates), modTest_(mod), numCalls_(0)
68 { }
69
71 virtual ~StatusTestOutput() {};
73
75
76
94 TEUCHOS_TEST_FOR_EXCEPTION(test_ == Teuchos::null,StatusTestError,"StatusTestOutput::checkStatus(): child pointer is null.");
95 state_ = test_->checkStatus(solver);
96
97 if (numCalls_++ % modTest_ == 0) {
98 if ( (state_ & stateTest_) == state_) {
99 if ( printer_->isVerbosity(StatusTestDetails) ) {
100 print( printer_->stream(StatusTestDetails) );
101 }
102 else if ( printer_->isVerbosity(Debug) ) {
103 print( printer_->stream(Debug) );
104 }
105 }
106 }
107
108 return state_;
109 }
110
113 return state_;
114 }
115
117 std::vector<int> whichVecs() const {
118 return std::vector<int>(0);
119 }
120
122 int howMany() const {
123 return 0;
124 }
125
127
128
130
131
136 void setChild(Teuchos::RCP<StatusTest<ScalarType,MV,OP> > test) {
137 test_ = test;
138 state_ = Undefined;
139 }
140
142 Teuchos::RCP<StatusTest<ScalarType,MV,OP> > getChild() const {
143 return test_;
144 }
145
147
148
150
151
156 void reset() {
157 state_ = Undefined;
158 if (test_ != Teuchos::null) {
159 test_->reset();
160 }
161 numCalls_ = 0;
162 }
163
166 void clearStatus() {
167 state_ = Undefined;
168 if (test_ != Teuchos::null) {
169 test_->clearStatus();
170 }
171 }
172
174
176
177
179 std::ostream& print(std::ostream& os, int indent = 0) const {
180 std::string ind(indent,' ');
181 os << ind << "- StatusTestOutput: ";
182 switch (state_) {
183 case Passed:
184 os << "Passed" << std::endl;
185 break;
186 case Failed:
187 os << "Failed" << std::endl;
188 break;
189 case Undefined:
190 os << "Undefined" << std::endl;
191 break;
192 }
193 os << ind << " (Num calls,Mod test,State test): " << "(" << numCalls_ << ", " << modTest_ << ",";
194 if (stateTest_ == 0) {
195 os << " none )" << std::endl;
196 }
197 else {
198 if ( (stateTest_ & Passed) == Passed ) os << " Passed";
199 if ( (stateTest_ & Failed) == Failed ) os << " Failed";
200 if ( (stateTest_ & Undefined) == Undefined ) os << " Undefined";
201 os << " )" << std::endl;
202 }
203 // print child, with extra indention
204 test_->print(os,indent+3);
205 return os;
206 }
207
209
210 private:
211 Teuchos::RCP<OutputManager<ScalarType> > printer_;
212 Teuchos::RCP<StatusTest<ScalarType,MV,OP> > test_;
213 TestStatus state_;
214 int stateTest_;
215 int modTest_;
216 int numCalls_;
217};
218
219} // end of Anasazi namespace
220
221#endif /* ANASAZI_STATUS_TEST_OUTPUT_HPP */
Anasazi header file which uses auto-configuration information to include necessary C++ headers.
Pure virtual base class which describes the basic interface to the iterative eigensolver.
Declaration and definition of Anasazi::StatusTest.
Types and exceptions used within Anasazi solvers and interfaces.
The Eigensolver is a templated virtual base class that defines the basic interface that any eigensolv...
Output managers remove the need for the eigensolver to know any information about the required output...
Exception thrown to signal error in a status test during Anasazi::StatusTest::checkStatus().
A special StatusTest for printing other status tests.
int howMany() const
Get the number of vectors that passed the test.
StatusTestOutput(const Teuchos::RCP< OutputManager< ScalarType > > &printer, Teuchos::RCP< StatusTest< ScalarType, MV, OP > > test, int mod=1, int printStates=Passed)
Constructor.
void setChild(Teuchos::RCP< StatusTest< ScalarType, MV, OP > > test)
Set child test.
std::vector< int > whichVecs() const
Get the indices for the vectors that passed the test.
void reset()
Informs the status test that it should reset its internal configuration to the uninitialized state.
TestStatus checkStatus(Eigensolver< ScalarType, MV, OP > *solver)
std::ostream & print(std::ostream &os, int indent=0) const
Output formatted description of stopping test to output stream.
TestStatus getStatus() const
Return the result of the most recent checkStatus call, or undefined if it has not been run.
Teuchos::RCP< StatusTest< ScalarType, MV, OP > > getChild() const
Get child test.
Common interface of stopping criteria for Anasazi's solvers.
Namespace Anasazi contains the classes, structs, enums and utilities used by the Anasazi package.
TestStatus
Enumerated type used to pass back information from a StatusTest.