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
//
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_MAXITER_HPP
44
#define ANASAZI_STATUS_TEST_MAXITER_HPP
45
50
51
52
#include "
AnasaziStatusTest.hpp
"
53
54
72
73
namespace
Anasazi
{
74
75
76
template
<
class
ScalarType,
class
MV,
class
OP>
77
class
StatusTestMaxIters
:
public
StatusTest
<ScalarType,MV,OP> {
78
79
public
:
81
82
84
StatusTestMaxIters
(
int
maxIter,
bool
negate =
false
) : state_(
Undefined
), negate_(negate) {
85
setMaxIters
(maxIter);
86
};
87
89
virtual
~StatusTestMaxIters
() {};
91
93
94
98
TestStatus
checkStatus
(
Eigensolver<ScalarType,MV,OP>
* solver ) {
99
state_ = (solver->
getNumIters
() >= maxIters_) ?
Passed
:
Failed
;
100
if
(negate_) {
101
if
(state_ ==
Passed
) state_ =
Failed
;
102
else
state_ =
Passed
;
103
}
104
return
state_;
105
}
106
108
TestStatus
getStatus
()
const
{
109
return
state_;
110
}
111
113
std::vector<int>
whichVecs
()
const
{
114
return
std::vector<int>(0);
115
}
116
118
int
howMany
()
const
{
119
return
0;
120
}
121
123
125
126
130
void
setMaxIters
(
int
maxIters) {
131
state_ =
Undefined
;
132
maxIters_ = maxIters;
133
}
134
136
int
getMaxIters
() {
return
maxIters_;}
137
141
void
setNegate
(
bool
negate) {
142
state_ =
Undefined
;
143
negate_ = negate;
144
}
145
147
bool
getNegate
()
const
{
148
return
negate_;
149
}
150
152
154
155
161
void
reset
() {
162
state_ =
Undefined
;
163
}
164
166
171
void
clearStatus
() {
172
state_ =
Undefined
;
173
}
174
176
178
179
181
std::ostream&
print
(std::ostream& os,
int
indent = 0)
const
{
182
std::string ind(indent,
' '
);
183
os << ind <<
"- StatusTestMaxIters: "
;
184
switch
(state_) {
185
case
Passed
:
186
os <<
"Passed"
<< std::endl;
187
break
;
188
case
Failed
:
189
os <<
"Failed"
<< std::endl;
190
break
;
191
case
Undefined
:
192
os <<
"Undefined"
<< std::endl;
193
break
;
194
}
195
os << ind <<
" MaxIters: "
<< maxIters_ << std::endl;
196
return
os;
197
}
198
200
private
:
201
int
maxIters_;
202
TestStatus
state_;
203
bool
negate_;
204
205
};
206
207
}
// end of Anasazi namespace
208
209
#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:67
Anasazi::Eigensolver::getNumIters
virtual int getNumIters() const =0
Get the current iteration count.
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:181
Anasazi::StatusTestMaxIters::whichVecs
std::vector< int > whichVecs() const
Get the indices for the vectors that passed the test.
Definition
AnasaziStatusTestMaxIters.hpp:113
Anasazi::StatusTestMaxIters::clearStatus
void clearStatus()
Clears the results of the last status test.
Definition
AnasaziStatusTestMaxIters.hpp:171
Anasazi::StatusTestMaxIters::setMaxIters
void setMaxIters(int maxIters)
Set the maximum number of iterations.
Definition
AnasaziStatusTestMaxIters.hpp:130
Anasazi::StatusTestMaxIters::getMaxIters
int getMaxIters()
Get the maximum number of iterations.
Definition
AnasaziStatusTestMaxIters.hpp:136
Anasazi::StatusTestMaxIters::setNegate
void setNegate(bool negate)
Set the negation policy for the status test.
Definition
AnasaziStatusTestMaxIters.hpp:141
Anasazi::StatusTestMaxIters::getStatus
TestStatus getStatus() const
Return the result of the most recent checkStatus call.
Definition
AnasaziStatusTestMaxIters.hpp:108
Anasazi::StatusTestMaxIters::getNegate
bool getNegate() const
Get the negation policy for the status test.
Definition
AnasaziStatusTestMaxIters.hpp:147
Anasazi::StatusTestMaxIters::reset
void reset()
Informs the status test that it should reset its internal configuration to the uninitialized state.
Definition
AnasaziStatusTestMaxIters.hpp:161
Anasazi::StatusTestMaxIters::checkStatus
TestStatus checkStatus(Eigensolver< ScalarType, MV, OP > *solver)
Check status as defined by test.
Definition
AnasaziStatusTestMaxIters.hpp:98
Anasazi::StatusTestMaxIters::~StatusTestMaxIters
virtual ~StatusTestMaxIters()
Destructor.
Definition
AnasaziStatusTestMaxIters.hpp:89
Anasazi::StatusTestMaxIters::StatusTestMaxIters
StatusTestMaxIters(int maxIter, bool negate=false)
Constructor.
Definition
AnasaziStatusTestMaxIters.hpp:84
Anasazi::StatusTestMaxIters::howMany
int howMany() const
Get the number of vectors that passed the test.
Definition
AnasaziStatusTestMaxIters.hpp:118
Anasazi::StatusTest::StatusTest
StatusTest()
Constructor.
Definition
AnasaziStatusTest.hpp:82
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:142
Anasazi::Undefined
@ Undefined
Definition
AnasaziTypes.hpp:145
Anasazi::Passed
@ Passed
Definition
AnasaziTypes.hpp:143
Anasazi::Failed
@ Failed
Definition
AnasaziTypes.hpp:144
Generated by
1.17.0