30 #ifndef ANASAZI_STATUS_TEST_COMBO_HPP 31 #define ANASAZI_STATUS_TEST_COMBO_HPP 61 template <
class ScalarType,
class MV,
class OP>
79 #ifndef DOXYGEN_SHOULD_SKIP_THIS 82 typedef std::vector< Teuchos::RCP< StatusTest<ScalarType,MV,OP> > > st_vector;
83 typedef typename st_vector::iterator iterator;
84 typedef typename st_vector::const_iterator const_iterator;
86 #endif // DOXYGEN_SHOULD_SKIP_THIS 206 std::ostream&
print(std::ostream& os,
int indent = 0)
const;
219 std::vector<int> ind_;
224 template <
class ScalarType,
class MV,
class OP>
228 iter1 = std::find(tests_.begin(),tests_.end(),test);
229 if (iter1 != tests_.end()) {
236 template <
class ScalarType,
class MV,
class OP>
241 state_ = evalOR(solver);
244 state_ = evalAND(solver);
247 state_ = evalSEQOR(solver);
250 state_ = evalSEQAND(solver);
257 template <
class ScalarType,
class MV,
class OP>
262 for (iter i=tests_.begin(); i != tests_.end(); i++) {
267 template <
class ScalarType,
class MV,
class OP>
272 for (iter i=tests_.begin(); i != tests_.end(); i++) {
277 template <
class ScalarType,
class MV,
class OP>
279 std::string ind(indent,
' ');
280 os << ind <<
"- StatusTestCombo: ";
283 os <<
"Passed" << std::endl;
286 os <<
"Failed" << std::endl;
289 os <<
"Undefined" << std::endl;
294 for (const_iter i=tests_.begin(); i != tests_.end(); i++) {
295 (*i)->print(os,indent+2);
300 template <
class ScalarType,
class MV,
class OP>
303 typedef typename STPArray::iterator iter;
304 for (iter i=tests_.begin(); i != tests_.end(); i++) {
306 if (i == tests_.begin()) {
307 ind_ = (*i)->whichVecs();
309 std::sort(ind_.begin(),ind_.end());
315 std::vector<int> iwv = (*i)->whichVecs();
316 std::sort(iwv.begin(),iwv.end());
317 std::vector<int> tmp(ind_.size() + iwv.size());
318 std::vector<int>::iterator end;
319 end = std::set_union(ind_.begin(),ind_.end(),iwv.begin(),iwv.end(),tmp.begin());
320 tmp.resize(end - tmp.begin());
329 "Anasazi::StatusTestCombo::evalOR(): child test gave invalid return");
335 template <
class ScalarType,
class MV,
class OP>
336 TestStatus StatusTestCombo<ScalarType,MV,OP>::evalSEQOR( Eigensolver<ScalarType,MV,OP>* solver ) {
338 typedef typename STPArray::iterator iter;
339 for (iter i=tests_.begin(); i != tests_.end(); i++) {
341 if (i == tests_.begin()) {
342 ind_ = (*i)->whichVecs();
344 std::sort(ind_.begin(),ind_.end());
350 std::vector<int> iwv = (*i)->whichVecs();
351 std::sort(iwv.begin(),iwv.end());
352 std::vector<int> tmp(ind_.size() + iwv.size());
353 std::vector<int>::iterator end;
354 end = std::set_union(ind_.begin(),ind_.end(),iwv.begin(),iwv.end(),tmp.begin());
355 tmp.resize(end - tmp.begin());
365 "Anasazi::StatusTestCombo::evalSEQOR(): child test gave invalid return");
371 template <
class ScalarType,
class MV,
class OP>
372 TestStatus StatusTestCombo<ScalarType,MV,OP>::evalAND( Eigensolver<ScalarType,MV,OP>* solver ) {
374 typedef typename STPArray::iterator iter;
375 for (iter i=tests_.begin(); i != tests_.end(); i++) {
377 if (i == tests_.begin()) {
378 ind_ = (*i)->whichVecs();
380 std::sort(ind_.begin(),ind_.end());
386 std::vector<int> iwv = (*i)->whichVecs();
387 std::sort(iwv.begin(),iwv.end());
388 std::vector<int> tmp(ind_.size() + iwv.size());
389 std::vector<int>::iterator end;
390 end = std::set_intersection(ind_.begin(),ind_.end(),iwv.begin(),iwv.end(),tmp.begin());
391 tmp.resize(end - tmp.begin());
400 "Anasazi::StatusTestCombo::evalAND(): child test gave invalid return");
406 template <
class ScalarType,
class MV,
class OP>
407 TestStatus StatusTestCombo<ScalarType,MV,OP>::evalSEQAND( Eigensolver<ScalarType,MV,OP>* solver ) {
409 typedef typename STPArray::iterator iter;
410 for (iter i=tests_.begin(); i != tests_.end(); i++) {
412 if (i == tests_.begin()) {
413 ind_ = (*i)->whichVecs();
415 std::sort(ind_.begin(),ind_.end());
421 std::vector<int> iwv = (*i)->whichVecs();
422 std::sort(iwv.begin(),iwv.end());
423 std::vector<int> tmp(ind_.size() + iwv.size());
424 std::vector<int>::iterator end;
425 end = std::set_intersection(ind_.begin(),ind_.end(),iwv.begin(),iwv.end(),tmp.begin());
426 tmp.resize(end - tmp.begin());
436 "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.
#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.
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< Teuchos::RCP< StatusTest< ScalarType, MV, OP > > >::const_iterator const_iterator
std::vector< int > whichVecs() const
Get the indices for the vectors that passed the test.
void push_back(const value_type &x)
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.