Anasazi
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
src
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
18
19
20
#include "
AnasaziStatusTest.hpp
"
21
22
40
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
66
TestStatus
checkStatus
(
Eigensolver<ScalarType,MV,OP>
* solver ) {
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
76
TestStatus
getStatus
()
const
{
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 */
AnasaziStatusTest.hpp
Declaration and definition of Anasazi::StatusTest.
Anasazi::Eigensolver
The Eigensolver is a templated virtual base class that defines the basic interface that any eigensolv...
Definition
AnasaziEigensolver.hpp:35
Anasazi::Eigensolver::getNumIters
virtual int getNumIters() const =0
Get the current iteration count.
Anasazi::StatusTest::StatusTest
StatusTest()
Constructor.
Definition
AnasaziStatusTest.hpp:50
Anasazi::StatusTestMaxIters::print
std::ostream & print(std::ostream &os, int indent=0) const
Output formatted description of stopping test to output stream.
Definition
AnasaziStatusTestMaxIters.hpp:149
Anasazi::StatusTestMaxIters::whichVecs
std::vector< int > whichVecs() const
Get the indices for the vectors that passed the test.
Definition
AnasaziStatusTestMaxIters.hpp:81
Anasazi::StatusTestMaxIters::clearStatus
void clearStatus()
Clears the results of the last status test.
Definition
AnasaziStatusTestMaxIters.hpp:139
Anasazi::StatusTestMaxIters::setMaxIters
void setMaxIters(int maxIters)
Set the maximum number of iterations.
Definition
AnasaziStatusTestMaxIters.hpp:98
Anasazi::StatusTestMaxIters::getMaxIters
int getMaxIters()
Get the maximum number of iterations.
Definition
AnasaziStatusTestMaxIters.hpp:104
Anasazi::StatusTestMaxIters::setNegate
void setNegate(bool negate)
Set the negation policy for the status test.
Definition
AnasaziStatusTestMaxIters.hpp:109
Anasazi::StatusTestMaxIters::getStatus
TestStatus getStatus() const
Return the result of the most recent checkStatus call.
Definition
AnasaziStatusTestMaxIters.hpp:76
Anasazi::StatusTestMaxIters::getNegate
bool getNegate() const
Get the negation policy for the status test.
Definition
AnasaziStatusTestMaxIters.hpp:115
Anasazi::StatusTestMaxIters::reset
void reset()
Informs the status test that it should reset its internal configuration to the uninitialized state.
Definition
AnasaziStatusTestMaxIters.hpp:129
Anasazi::StatusTestMaxIters::checkStatus
TestStatus checkStatus(Eigensolver< ScalarType, MV, OP > *solver)
Check status as defined by test.
Definition
AnasaziStatusTestMaxIters.hpp:66
Anasazi::StatusTestMaxIters::~StatusTestMaxIters
virtual ~StatusTestMaxIters()
Destructor.
Definition
AnasaziStatusTestMaxIters.hpp:57
Anasazi::StatusTestMaxIters::StatusTestMaxIters
StatusTestMaxIters(int maxIter, bool negate=false)
Constructor.
Definition
AnasaziStatusTestMaxIters.hpp:52
Anasazi::StatusTestMaxIters::howMany
int howMany() const
Get the number of vectors that passed the test.
Definition
AnasaziStatusTestMaxIters.hpp:86
Anasazi
Namespace Anasazi contains the classes, structs, enums and utilities used by the Anasazi package.
Anasazi::TestStatus
TestStatus
Enumerated type used to pass back information from a StatusTest.
Definition
AnasaziTypes.hpp:110
Anasazi::Undefined
@ Undefined
Definition
AnasaziTypes.hpp:113
Anasazi::Passed
@ Passed
Definition
AnasaziTypes.hpp:111
Anasazi::Failed
@ Failed
Definition
AnasaziTypes.hpp:112
Generated by
1.17.0