43 #ifndef ANASAZI_STATUS_TEST_ORDEREDRESNORM_HPP 44 #define ANASAZI_STATUS_TEST_ORDEREDRESNORM_HPP 54 #include "Teuchos_ScalarTraits.hpp" 55 #include "Teuchos_LAPACK.hpp" 83 template <
class ScalarType,
class MV,
class OP>
87 typedef typename Teuchos::ScalarTraits<ScalarType>::magnitudeType MagnitudeType;
88 typedef Teuchos::ScalarTraits<MagnitudeType> MT;
174 test_->clearStatus();
181 void setAuxVals(
const std::vector<
typename Teuchos::ScalarTraits<ScalarType>::magnitudeType> &vals) {
183 ivals_.resize(rvals_.size(),MT::zero());
191 void setAuxVals(
const std::vector<
typename Teuchos::ScalarTraits<ScalarType>::magnitudeType> &rvals,
const std::vector<
typename Teuchos::ScalarTraits<ScalarType>::magnitudeType> &ivals) {
201 void getAuxVals(std::vector<
typename Teuchos::ScalarTraits<ScalarType>::magnitudeType> &rvals, std::vector<
typename Teuchos::ScalarTraits<ScalarType>::magnitudeType> &ivals)
const {
212 std::ostream&
print(std::ostream& os,
int indent = 0)
const;
217 std::vector<int> ind_;
219 std::vector<MagnitudeType> rvals_, ivals_;
220 Teuchos::RCP<SortManager<typename Teuchos::ScalarTraits<ScalarType>::magnitudeType> > sorter_;
221 Teuchos::RCP<StatusTest<ScalarType,MV,OP> > test_;
225 template <
class ScalarType,
class MV,
class OP>
227 : state_(
Undefined), ind_(0), quorum_(quorum), rvals_(0), ivals_(0), sorter_(sorter), test_(test)
229 TEUCHOS_TEST_FOR_EXCEPTION(sorter_ == Teuchos::null,
StatusTestError,
"StatusTestWithOrdering::constructor() was passed null pointer for constituent SortManager.");
230 TEUCHOS_TEST_FOR_EXCEPTION(test_ == Teuchos::null,
StatusTestError,
"StatusTestWithOrdering::constructor() was passed null pointer for constituent StatusTest.");
233 template <
class ScalarType,
class MV,
class OP>
260 test_->checkStatus(solver);
261 std::vector<int> cwhch( test_->whichVecs() );
264 std::vector<Value<ScalarType> > solval = solver->
getRitzValues();
265 int numsolval = solval.size();
266 int numauxval = rvals_.size();
267 int numallval = numsolval + numauxval;
269 if (numallval == 0) {
275 std::vector<MagnitudeType> allvalr(numallval), allvali(numallval);
277 for (
int i=0; i<numsolval; ++i) {
278 allvalr[i] = solval[i].realpart;
279 allvali[i] = solval[i].imagpart;
282 std::copy(rvals_.begin(),rvals_.end(),allvalr.begin()+numsolval);
283 std::copy(ivals_.begin(),ivals_.end(),allvali.begin()+numsolval);
286 std::vector<int> perm(numallval);
287 sorter_->sort(allvalr,allvali,Teuchos::rcpFromRef(perm),numallval);
290 std::vector<int> allpass(cwhch.size() + numauxval);
291 std::copy(cwhch.begin(),cwhch.end(),allpass.begin());
292 for (
int i=0; i<numauxval; i++) {
293 allpass[cwhch.size()+i] = -(i+1);
297 int numsig = quorum_ < numallval ? quorum_ : numallval;
299 std::vector<int> mostsig(numsig);
300 for (
int i=0; i<numsig; ++i) {
301 mostsig[i] = perm[i];
304 if (mostsig[i] >= numsolval) {
305 mostsig[i] = mostsig[i]-numsolval-numauxval;
314 std::vector<int>::iterator end;
315 std::sort(mostsig.begin(),mostsig.end());
316 std::sort(allpass.begin(),allpass.end());
317 end = std::set_intersection(mostsig.begin(),mostsig.end(),allpass.begin(),allpass.end(),ind_.begin());
318 ind_.resize(end - ind_.begin());
321 if (ind_.size() >= (
unsigned int)quorum_) {
331 template <
class ScalarType,
class MV,
class OP>
334 std::string ind(indent,
' ');
336 os << ind <<
"- StatusTestWithOrdering: ";
339 os <<
"Passed" << std::endl;
342 os <<
"Failed" << std::endl;
345 os <<
"Undefined" << std::endl;
349 os << ind <<
" Quorum: " << quorum_ << std::endl;
351 os << ind <<
" Auxiliary values: ";
352 if (rvals_.size() > 0) {
353 for (
unsigned int i=0; i<rvals_.size(); i++) {
354 os <<
"(" << rvals_[i] <<
", " << ivals_[i] <<
") ";
359 os <<
"[empty]" << std::endl;
363 os << ind <<
" Which vectors: ";
364 if (ind_.size() > 0) {
365 for (
unsigned int i=0; i<ind_.size(); i++) os << ind_[i] <<
" ";
369 os <<
"[empty]" << std::endl;
373 test_->print(os,indent+2);
virtual std::vector< Value< ScalarType > > getRitzValues()=0
Get the Ritz values from the previous iteration.
TestStatus getStatus() const
Return the result of the most recent checkStatus call, or undefined if it has not been run...
std::ostream & print(std::ostream &os, int indent=0) const
Output formatted description of stopping test to output stream.
Exception thrown to signal error in a status test during Anasazi::StatusTest::checkStatus().
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...
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.
int getQuorum() const
Get quorum.
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...
int howMany() const
Get the number of vectors that passed the test.
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...
virtual ~StatusTestWithOrdering()
Destructor.
void clearStatus()
Clears the results of the last status test.
Common interface of stopping criteria for Anasazi's solvers.
The Eigensolver is a templated virtual base class that defines the basic interface that any eigensolv...
Declaration and definition of Anasazi::StatusTest.