43 #ifndef ANASAZI_STATUS_TEST_ORDEREDRESNORM_HPP
44 #define ANASAZI_STATUS_TEST_ORDEREDRESNORM_HPP
82 template <
class ScalarType,
class MV,
class OP>
173 test_->clearStatus();
182 ivals_.resize(rvals_.size(),
MT::zero());
211 std::ostream&
print(std::ostream& os,
int indent = 0)
const;
216 std::vector<int> ind_;
218 std::vector<MagnitudeType> rvals_, ivals_;
224 template <
class ScalarType,
class MV,
class OP>
226 : state_(
Undefined), ind_(0), quorum_(quorum), rvals_(0), ivals_(0), sorter_(sorter), test_(test)
232 template <
class ScalarType,
class MV,
class OP>
259 test_->checkStatus(solver);
260 std::vector<int> cwhch( test_->whichVecs() );
263 std::vector<Value<ScalarType> > solval = solver->
getRitzValues();
264 int numsolval = solval.size();
265 int numauxval = rvals_.size();
266 int numallval = numsolval + numauxval;
268 if (numallval == 0) {
274 std::vector<MagnitudeType> allvalr(numallval), allvali(numallval);
276 for (
int i=0; i<numsolval; ++i) {
277 allvalr[i] = solval[i].realpart;
278 allvali[i] = solval[i].imagpart;
281 std::copy(rvals_.begin(),rvals_.end(),allvalr.begin()+numsolval);
282 std::copy(ivals_.begin(),ivals_.end(),allvali.begin()+numsolval);
285 std::vector<int> perm(numallval);
286 sorter_->sort(allvalr,allvali,Teuchos::rcpFromRef(perm),numallval);
289 std::vector<int> allpass(cwhch.size() + numauxval);
290 std::copy(cwhch.begin(),cwhch.end(),allpass.begin());
291 for (
int i=0; i<numauxval; i++) {
292 allpass[cwhch.size()+i] = -(i+1);
296 int numsig = quorum_ < numallval ? quorum_ : numallval;
298 std::vector<int> mostsig(numsig);
299 for (
int i=0; i<numsig; ++i) {
300 mostsig[i] = perm[i];
303 if (mostsig[i] >= numsolval) {
304 mostsig[i] = mostsig[i]-numsolval-numauxval;
313 std::vector<int>::iterator end;
314 std::sort(mostsig.begin(),mostsig.end());
315 std::sort(allpass.begin(),allpass.end());
316 end = std::set_intersection(mostsig.begin(),mostsig.end(),allpass.begin(),allpass.end(),ind_.begin());
317 ind_.resize(end - ind_.begin());
320 if (ind_.size() >= (
unsigned int)quorum_) {
330 template <
class ScalarType,
class MV,
class OP>
333 std::string ind(indent,
' ');
335 os << ind <<
"- StatusTestWithOrdering: ";
338 os <<
"Passed" << std::endl;
341 os <<
"Failed" << std::endl;
344 os <<
"Undefined" << std::endl;
348 os << ind <<
" Quorum: " << quorum_ << std::endl;
350 os << ind <<
" Auxiliary values: ";
351 if (rvals_.size() > 0) {
352 for (
unsigned int i=0; i<rvals_.size(); i++) {
353 os <<
"(" << rvals_[i] <<
", " << ivals_[i] <<
") ";
358 os <<
"[empty]" << std::endl;
362 os << ind <<
" Which vectors: ";
363 if (ind_.size() > 0) {
364 for (
unsigned int i=0; i<ind_.size(); i++) os << ind_[i] <<
" ";
368 os <<
"[empty]" << std::endl;
372 test_->print(os,indent+2);
virtual std::vector< Value< ScalarType > > getRitzValues()=0
Get the Ritz values from the previous iteration.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Exception thrown to signal error in a status test during Anasazi::StatusTest::checkStatus().
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)
void getAuxVals(std::vector< typename Teuchos::ScalarTraits< ScalarType >::magnitudeType > &rvals, std::vector< typename Teuchos::ScalarTraits< ScalarType >::magnitudeType > &ivals) const
Get the auxiliary eigenvalues.
std::vector< int > whichVecs() const
Get the indices for the vectors that passed the test.
StatusTestWithOrdering(Teuchos::RCP< StatusTest< ScalarType, MV, OP > > test, Teuchos::RCP< SortManager< typename Teuchos::ScalarTraits< ScalarType >::magnitudeType > > sorter, int quorum=-1)
Constructor.
void setAuxVals(const std::vector< typename Teuchos::ScalarTraits< ScalarType >::magnitudeType > &rvals, const std::vector< typename Teuchos::ScalarTraits< ScalarType >::magnitudeType > &ivals)
Set the auxiliary eigenvalues.
A status test for testing the norm of the eigenvectors residuals along with a set of auxiliary eigenv...
TestStatus getStatus() const
Return the result of the most recent checkStatus call, or undefined if it has not been run...
void setQuorum(int quorum)
Set quorum.
void reset()
Informs the status test that it should reset its internal configuration to the uninitialized state...
void setAuxVals(const std::vector< typename Teuchos::ScalarTraits< ScalarType >::magnitudeType > &vals)
Set the auxiliary eigenvalues.
Anasazi's templated pure virtual class for managing the sorting of approximate eigenvalues computed b...
int getQuorum() const
Get quorum.
virtual ~StatusTestWithOrdering()
Destructor.
void clearStatus()
Clears the results of the last status test.
Common interface of stopping criteria for Anasazi's solvers.
int howMany() const
Get the number of vectors that passed the test.
The Eigensolver is a templated virtual base class that defines the basic interface that any eigensolv...
Declaration and definition of Anasazi::StatusTest.