Anasazi Version of the Day
Loading...
Searching...
No Matches
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 with Sandia Corporation,
8// the U.S. Government retains certain rights in this software.
9//
10// Redistribution and use in source and binary forms, with or without
11// modification, are permitted provided that the following conditions are
12// met:
13//
14// 1. Redistributions of source code must retain the above copyright
15// notice, this list of conditions and the following disclaimer.
16//
17// 2. Redistributions in binary form must reproduce the above copyright
18// notice, this list of conditions and the following disclaimer in the
19// documentation and/or other materials provided with the distribution.
20//
21// 3. Neither the name of the Corporation nor the names of the
22// contributors may be used to endorse or promote products derived from
23// this software without specific prior written permission.
24//
25// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36//
37// Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38//
39// ***********************************************************************
40// @HEADER
41//
42
43#ifndef ANASAZI_STATUS_TEST_OUTPUT_HPP
44#define ANASAZI_STATUS_TEST_OUTPUT_HPP
45
52#include "AnasaziConfigDefs.hpp"
53#include "AnasaziTypes.hpp"
55
56#include "AnasaziStatusTest.hpp"
57
58
59
60namespace Anasazi {
61
71template <class ScalarType, class MV, class OP>
72class StatusTestOutput : public StatusTest<ScalarType,MV,OP> {
73
74 public:
76
77
95 StatusTestOutput(const Teuchos::RCP<OutputManager<ScalarType> > &printer,
96 Teuchos::RCP<StatusTest<ScalarType,MV,OP> > test,
97 int mod = 1,
98 int printStates = Passed)
99 : printer_(printer), test_(test), state_(Undefined), stateTest_(printStates), modTest_(mod), numCalls_(0)
100 { }
101
103 virtual ~StatusTestOutput() {};
105
107
108
125 TestStatus checkStatus( Eigensolver<ScalarType,MV,OP>* solver ) {
126 TEUCHOS_TEST_FOR_EXCEPTION(test_ == Teuchos::null,StatusTestError,"StatusTestOutput::checkStatus(): child pointer is null.");
127 state_ = test_->checkStatus(solver);
128
129 if (numCalls_++ % modTest_ == 0) {
130 if ( (state_ & stateTest_) == state_) {
131 if ( printer_->isVerbosity(StatusTestDetails) ) {
132 print( printer_->stream(StatusTestDetails) );
133 }
134 else if ( printer_->isVerbosity(Debug) ) {
135 print( printer_->stream(Debug) );
136 }
137 }
138 }
139
140 return state_;
141 }
142
145 return state_;
146 }
147
149 std::vector<int> whichVecs() const {
150 return std::vector<int>(0);
151 }
152
154 int howMany() const {
155 return 0;
156 }
157
159
160
162
163
168 void setChild(Teuchos::RCP<StatusTest<ScalarType,MV,OP> > test) {
169 test_ = test;
170 state_ = Undefined;
171 }
172
174 Teuchos::RCP<StatusTest<ScalarType,MV,OP> > getChild() const {
175 return test_;
176 }
177
179
180
182
183
188 void reset() {
189 state_ = Undefined;
190 if (test_ != Teuchos::null) {
191 test_->reset();
192 }
193 numCalls_ = 0;
194 }
195
198 void clearStatus() {
199 state_ = Undefined;
200 if (test_ != Teuchos::null) {
201 test_->clearStatus();
202 }
203 }
204
206
208
209
211 std::ostream& print(std::ostream& os, int indent = 0) const {
212 std::string ind(indent,' ');
213 os << ind << "- StatusTestOutput: ";
214 switch (state_) {
215 case Passed:
216 os << "Passed" << std::endl;
217 break;
218 case Failed:
219 os << "Failed" << std::endl;
220 break;
221 case Undefined:
222 os << "Undefined" << std::endl;
223 break;
224 }
225 os << ind << " (Num calls,Mod test,State test): " << "(" << numCalls_ << ", " << modTest_ << ",";
226 if (stateTest_ == 0) {
227 os << " none )" << std::endl;
228 }
229 else {
230 if ( (stateTest_ & Passed) == Passed ) os << " Passed";
231 if ( (stateTest_ & Failed) == Failed ) os << " Failed";
232 if ( (stateTest_ & Undefined) == Undefined ) os << " Undefined";
233 os << " )" << std::endl;
234 }
235 // print child, with extra indention
236 test_->print(os,indent+3);
237 return os;
238 }
239
241
242 private:
243 Teuchos::RCP<OutputManager<ScalarType> > printer_;
244 Teuchos::RCP<StatusTest<ScalarType,MV,OP> > test_;
245 TestStatus state_;
246 int stateTest_;
247 int modTest_;
248 int numCalls_;
249};
250
251} // end of Anasazi namespace
252
253#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.
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.