11 #ifndef ANASAZI_STATUS_TEST_ORDEREDRESNORM_HPP
12 #define ANASAZI_STATUS_TEST_ORDEREDRESNORM_HPP
50 template <
class ScalarType,
class MV,
class OP>
141 test_->clearStatus();
150 ivals_.resize(rvals_.size(),
MT::zero());
179 std::ostream&
print(std::ostream& os,
int indent = 0)
const;
184 std::vector<int> ind_;
186 std::vector<MagnitudeType> rvals_, ivals_;
192 template <
class ScalarType,
class MV,
class OP>
194 : state_(
Undefined), ind_(0), quorum_(quorum), rvals_(0), ivals_(0), sorter_(sorter), test_(test)
200 template <
class ScalarType,
class MV,
class OP>
227 test_->checkStatus(solver);
228 std::vector<int> cwhch( test_->whichVecs() );
231 std::vector<Value<ScalarType> > solval = solver->
getRitzValues();
232 int numsolval = solval.size();
233 int numauxval = rvals_.size();
234 int numallval = numsolval + numauxval;
236 if (numallval == 0) {
242 std::vector<MagnitudeType> allvalr(numallval), allvali(numallval);
244 for (
int i=0; i<numsolval; ++i) {
245 allvalr[i] = solval[i].realpart;
246 allvali[i] = solval[i].imagpart;
249 std::copy(rvals_.begin(),rvals_.end(),allvalr.begin()+numsolval);
250 std::copy(ivals_.begin(),ivals_.end(),allvali.begin()+numsolval);
253 std::vector<int> perm(numallval);
254 sorter_->sort(allvalr,allvali,Teuchos::rcpFromRef(perm),numallval);
257 std::vector<int> allpass(cwhch.size() + numauxval);
258 std::copy(cwhch.begin(),cwhch.end(),allpass.begin());
259 for (
int i=0; i<numauxval; i++) {
260 allpass[cwhch.size()+i] = -(i+1);
264 int numsig = quorum_ < numallval ? quorum_ : numallval;
266 std::vector<int> mostsig(numsig);
267 for (
int i=0; i<numsig; ++i) {
268 mostsig[i] = perm[i];
271 if (mostsig[i] >= numsolval) {
272 mostsig[i] = mostsig[i]-numsolval-numauxval;
281 std::vector<int>::iterator end;
282 std::sort(mostsig.begin(),mostsig.end());
283 std::sort(allpass.begin(),allpass.end());
284 end = std::set_intersection(mostsig.begin(),mostsig.end(),allpass.begin(),allpass.end(),ind_.begin());
285 ind_.resize(end - ind_.begin());
288 if (ind_.size() >= (
unsigned int)quorum_) {
298 template <
class ScalarType,
class MV,
class OP>
301 std::string ind(indent,
' ');
303 os << ind <<
"- StatusTestWithOrdering: ";
306 os <<
"Passed" << std::endl;
309 os <<
"Failed" << std::endl;
312 os <<
"Undefined" << std::endl;
316 os << ind <<
" Quorum: " << quorum_ << std::endl;
318 os << ind <<
" Auxiliary values: ";
319 if (rvals_.size() > 0) {
320 for (
unsigned int i=0; i<rvals_.size(); i++) {
321 os <<
"(" << rvals_[i] <<
", " << ivals_[i] <<
") ";
326 os <<
"[empty]" << std::endl;
330 os << ind <<
" Which vectors: ";
331 if (ind_.size() > 0) {
332 for (
unsigned int i=0; i<ind_.size(); i++) os << ind_[i] <<
" ";
336 os <<
"[empty]" << std::endl;
340 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.