43 #ifndef ANASAZI_STATUS_TEST_COMBO_HPP 44 #define ANASAZI_STATUS_TEST_COMBO_HPP 54 #include "Teuchos_Array.hpp" 74 template <
class ScalarType,
class MV,
class OP>
78 typedef Teuchos::Array< Teuchos::RCP< StatusTest<ScalarType,MV,OP> > > STPArray;
92 #ifndef DOXYGEN_SHOULD_SKIP_THIS 94 typedef Teuchos::Array< Teuchos::RCP< StatusTest<ScalarType,MV,OP> > > t_arr;
95 typedef std::vector< Teuchos::RCP< StatusTest<ScalarType,MV,OP> > > st_vector;
96 typedef typename st_vector::iterator iterator;
97 typedef typename st_vector::const_iterator const_iterator;
99 #endif // DOXYGEN_SHOULD_SKIP_THIS 178 Teuchos::Array<Teuchos::RCP<StatusTest<ScalarType,MV,OP> > >
getTests()
const {
return tests_;}
185 tests_.push_back(test);
219 std::ostream&
print(std::ostream& os,
int indent = 0)
const;
232 std::vector<int> ind_;
237 template <
class ScalarType,
class MV,
class OP>
240 typename STPArray::iterator iter1;
241 iter1 = std::find(tests_.begin(),tests_.end(),test);
242 if (iter1 != tests_.end()) {
249 template <
class ScalarType,
class MV,
class OP>
254 state_ = evalOR(solver);
257 state_ = evalAND(solver);
260 state_ = evalSEQOR(solver);
263 state_ = evalSEQAND(solver);
270 template <
class ScalarType,
class MV,
class OP>
274 typedef typename STPArray::iterator iter;
275 for (iter i=tests_.begin(); i != tests_.end(); i++) {
280 template <
class ScalarType,
class MV,
class OP>
284 typedef typename STPArray::iterator iter;
285 for (iter i=tests_.begin(); i != tests_.end(); i++) {
290 template <
class ScalarType,
class MV,
class OP>
292 std::string ind(indent,
' ');
293 os << ind <<
"- StatusTestCombo: ";
296 os <<
"Passed" << std::endl;
299 os <<
"Failed" << std::endl;
302 os <<
"Undefined" << std::endl;
306 typedef typename STPArray::const_iterator const_iter;
307 for (const_iter i=tests_.begin(); i != tests_.end(); i++) {
308 (*i)->print(os,indent+2);
313 template <
class ScalarType,
class MV,
class OP>
316 typedef typename STPArray::iterator iter;
317 for (iter i=tests_.begin(); i != tests_.end(); i++) {
319 if (i == tests_.begin()) {
320 ind_ = (*i)->whichVecs();
322 std::sort(ind_.begin(),ind_.end());
328 std::vector<int> iwv = (*i)->whichVecs();
329 std::sort(iwv.begin(),iwv.end());
330 std::vector<int> tmp(ind_.size() + iwv.size());
331 std::vector<int>::iterator end;
332 end = std::set_union(ind_.begin(),ind_.end(),iwv.begin(),iwv.end(),tmp.begin());
333 tmp.resize(end - tmp.begin());
341 TEUCHOS_TEST_FOR_EXCEPTION(r !=
Failed,StatusTestError,
342 "Anasazi::StatusTestCombo::evalOR(): child test gave invalid return");
348 template <
class ScalarType,
class MV,
class OP>
349 TestStatus StatusTestCombo<ScalarType,MV,OP>::evalSEQOR( Eigensolver<ScalarType,MV,OP>* solver ) {
351 typedef typename STPArray::iterator iter;
352 for (iter i=tests_.begin(); i != tests_.end(); i++) {
354 if (i == tests_.begin()) {
355 ind_ = (*i)->whichVecs();
357 std::sort(ind_.begin(),ind_.end());
363 std::vector<int> iwv = (*i)->whichVecs();
364 std::sort(iwv.begin(),iwv.end());
365 std::vector<int> tmp(ind_.size() + iwv.size());
366 std::vector<int>::iterator end;
367 end = std::set_union(ind_.begin(),ind_.end(),iwv.begin(),iwv.end(),tmp.begin());
368 tmp.resize(end - tmp.begin());
377 TEUCHOS_TEST_FOR_EXCEPTION(r !=
Failed,StatusTestError,
378 "Anasazi::StatusTestCombo::evalSEQOR(): child test gave invalid return");
384 template <
class ScalarType,
class MV,
class OP>
385 TestStatus StatusTestCombo<ScalarType,MV,OP>::evalAND( Eigensolver<ScalarType,MV,OP>* solver ) {
387 typedef typename STPArray::iterator iter;
388 for (iter i=tests_.begin(); i != tests_.end(); i++) {
390 if (i == tests_.begin()) {
391 ind_ = (*i)->whichVecs();
393 std::sort(ind_.begin(),ind_.end());
399 std::vector<int> iwv = (*i)->whichVecs();
400 std::sort(iwv.begin(),iwv.end());
401 std::vector<int> tmp(ind_.size() + iwv.size());
402 std::vector<int>::iterator end;
403 end = std::set_intersection(ind_.begin(),ind_.end(),iwv.begin(),iwv.end(),tmp.begin());
404 tmp.resize(end - tmp.begin());
412 TEUCHOS_TEST_FOR_EXCEPTION(r !=
Passed,StatusTestError,
413 "Anasazi::StatusTestCombo::evalAND(): child test gave invalid return");
419 template <
class ScalarType,
class MV,
class OP>
420 TestStatus StatusTestCombo<ScalarType,MV,OP>::evalSEQAND( Eigensolver<ScalarType,MV,OP>* solver ) {
422 typedef typename STPArray::iterator iter;
423 for (iter i=tests_.begin(); i != tests_.end(); i++) {
425 if (i == tests_.begin()) {
426 ind_ = (*i)->whichVecs();
428 std::sort(ind_.begin(),ind_.end());
434 std::vector<int> iwv = (*i)->whichVecs();
435 std::sort(iwv.begin(),iwv.end());
436 std::vector<int> tmp(ind_.size() + iwv.size());
437 std::vector<int>::iterator end;
438 end = std::set_intersection(ind_.begin(),ind_.end(),iwv.begin(),iwv.end(),tmp.begin());
439 tmp.resize(end - tmp.begin());
448 TEUCHOS_TEST_FOR_EXCEPTION(r !=
Passed,StatusTestError,
449 "Anasazi::StatusTestCombo::evalAND(): child test gave invalid return");
TestStatus getStatus() const
Return the result of the most recent checkStatus call.
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.
std::ostream & print(std::ostream &os, int indent=0) const
Output formatted description of stopping test to output stream.
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.
void reset()
Informs the status test that it should reset its internal configuration to the uninitialized state...
ComboType getComboType() const
Get the maximum number of iterations.
TestStatus
Enumerated type used to pass back information from a StatusTest.
Namespace Anasazi contains the classes, structs, enums and utilities used by the Anasazi package...
int howMany() const
Get the number of vectors that passed the test.
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< int > whichVecs() const
Get the indices for the vectors that passed the test.
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.
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.