11 #ifndef ANASAZI_STATUS_TEST_COMBO_HPP
12 #define ANASAZI_STATUS_TEST_COMBO_HPP
42 template <
class ScalarType,
class MV,
class OP>
60 #ifndef DOXYGEN_SHOULD_SKIP_THIS
63 typedef std::vector< Teuchos::RCP< StatusTest<ScalarType,MV,OP> > > st_vector;
64 typedef typename st_vector::iterator iterator;
65 typedef typename st_vector::const_iterator const_iterator;
67 #endif // DOXYGEN_SHOULD_SKIP_THIS
187 std::ostream&
print(std::ostream& os,
int indent = 0)
const;
200 std::vector<int> ind_;
205 template <
class ScalarType,
class MV,
class OP>
209 iter1 = std::find(tests_.begin(),tests_.end(),test);
210 if (iter1 != tests_.end()) {
217 template <
class ScalarType,
class MV,
class OP>
222 state_ = evalOR(solver);
225 state_ = evalAND(solver);
228 state_ = evalSEQOR(solver);
231 state_ = evalSEQAND(solver);
238 template <
class ScalarType,
class MV,
class OP>
243 for (iter i=tests_.begin(); i != tests_.end(); i++) {
248 template <
class ScalarType,
class MV,
class OP>
253 for (iter i=tests_.begin(); i != tests_.end(); i++) {
258 template <
class ScalarType,
class MV,
class OP>
260 std::string ind(indent,
' ');
261 os << ind <<
"- StatusTestCombo: ";
264 os <<
"Passed" << std::endl;
267 os <<
"Failed" << std::endl;
270 os <<
"Undefined" << std::endl;
275 for (const_iter i=tests_.begin(); i != tests_.end(); i++) {
276 (*i)->print(os,indent+2);
281 template <
class ScalarType,
class MV,
class OP>
284 typedef typename STPArray::iterator iter;
285 for (iter i=tests_.begin(); i != tests_.end(); i++) {
287 if (i == tests_.begin()) {
288 ind_ = (*i)->whichVecs();
290 std::sort(ind_.begin(),ind_.end());
296 std::vector<int> iwv = (*i)->whichVecs();
297 std::sort(iwv.begin(),iwv.end());
298 std::vector<int> tmp(ind_.size() + iwv.size());
299 std::vector<int>::iterator end;
300 end = std::set_union(ind_.begin(),ind_.end(),iwv.begin(),iwv.end(),tmp.begin());
301 tmp.resize(end - tmp.begin());
310 "Anasazi::StatusTestCombo::evalOR(): child test gave invalid return");
316 template <
class ScalarType,
class MV,
class OP>
317 TestStatus StatusTestCombo<ScalarType,MV,OP>::evalSEQOR( Eigensolver<ScalarType,MV,OP>* solver ) {
319 typedef typename STPArray::iterator iter;
320 for (iter i=tests_.begin(); i != tests_.end(); i++) {
322 if (i == tests_.begin()) {
323 ind_ = (*i)->whichVecs();
325 std::sort(ind_.begin(),ind_.end());
331 std::vector<int> iwv = (*i)->whichVecs();
332 std::sort(iwv.begin(),iwv.end());
333 std::vector<int> tmp(ind_.size() + iwv.size());
334 std::vector<int>::iterator end;
335 end = std::set_union(ind_.begin(),ind_.end(),iwv.begin(),iwv.end(),tmp.begin());
336 tmp.resize(end - tmp.begin());
346 "Anasazi::StatusTestCombo::evalSEQOR(): child test gave invalid return");
352 template <
class ScalarType,
class MV,
class OP>
353 TestStatus StatusTestCombo<ScalarType,MV,OP>::evalAND( Eigensolver<ScalarType,MV,OP>* solver ) {
355 typedef typename STPArray::iterator iter;
356 for (iter i=tests_.begin(); i != tests_.end(); i++) {
358 if (i == tests_.begin()) {
359 ind_ = (*i)->whichVecs();
361 std::sort(ind_.begin(),ind_.end());
367 std::vector<int> iwv = (*i)->whichVecs();
368 std::sort(iwv.begin(),iwv.end());
369 std::vector<int> tmp(ind_.size() + iwv.size());
370 std::vector<int>::iterator end;
371 end = std::set_intersection(ind_.begin(),ind_.end(),iwv.begin(),iwv.end(),tmp.begin());
372 tmp.resize(end - tmp.begin());
381 "Anasazi::StatusTestCombo::evalAND(): child test gave invalid return");
387 template <
class ScalarType,
class MV,
class OP>
388 TestStatus StatusTestCombo<ScalarType,MV,OP>::evalSEQAND( Eigensolver<ScalarType,MV,OP>* solver ) {
390 typedef typename STPArray::iterator iter;
391 for (iter i=tests_.begin(); i != tests_.end(); i++) {
393 if (i == tests_.begin()) {
394 ind_ = (*i)->whichVecs();
396 std::sort(ind_.begin(),ind_.end());
402 std::vector<int> iwv = (*i)->whichVecs();
403 std::sort(iwv.begin(),iwv.end());
404 std::vector<int> tmp(ind_.size() + iwv.size());
405 std::vector<int>::iterator end;
406 end = std::set_intersection(ind_.begin(),ind_.end(),iwv.begin(),iwv.end(),tmp.begin());
407 tmp.resize(end - tmp.begin());
417 "Anasazi::StatusTestCombo::evalAND(): child test gave invalid return");
void clearStatus()
Clears the results of the last status test.
void setTests(Teuchos::Array< Teuchos::RCP< StatusTest< ScalarType, MV, OP > > > tests)
Set the tests This also resets the test status to Undefined.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
StatusTestCombo(ComboType type, Teuchos::Array< Teuchos::RCP< StatusTest< ScalarType, MV, OP > > > tests)
Constructor specifying the StatusTestCombo::ComboType and the tests.
Status test for forming logical combinations of other status tests.
virtual ~StatusTestCombo()
Destructor.
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
Enumerated type used to pass back information from a StatusTest.
std::ostream & print(std::ostream &os, int indent=0) const
Output formatted description of stopping test to output stream.
TestStatus checkStatus(Eigensolver< ScalarType, MV, OP > *solver)
Teuchos::Array< Teuchos::RCP< StatusTest< ScalarType, MV, OP > > > getTests() const
Get the tests.
void removeTest(const Teuchos::RCP< StatusTest< ScalarType, MV, OP > > &test)
Removes a test from the combination, if it exists in the tester.
std::vector< Teuchos::RCP< StatusTest< ScalarType, MV, OP > > >::const_iterator const_iterator
void push_back(const value_type &x)
int howMany() const
Get the number of vectors that passed the test.
ComboType getComboType() const
Get the maximum number of iterations.
void setComboType(ComboType type)
Set the maximum number of iterations. This also resets the test status to Undefined.
Types and exceptions used within Anasazi solvers and interfaces.
ComboType
Enumerated type to list the types of StatusTestCombo combo types.
Common interface of stopping criteria for Anasazi's solvers.
std::vector< Teuchos::RCP< StatusTest< ScalarType, MV, OP > > >::iterator iterator
void addTest(Teuchos::RCP< StatusTest< ScalarType, MV, OP > > test)
Add a test to the combination.
The Eigensolver is a templated virtual base class that defines the basic interface that any eigensolv...
StatusTestCombo()
Default constructor has no tests and initializes to StatusTestCombo::ComboType StatusTestCombo::OR.
Declaration and definition of Anasazi::StatusTest.
TestStatus getStatus() const
Return the result of the most recent checkStatus call.