30 #ifndef ANASAZI_STATUS_TEST_RESNORM_HPP
31 #define ANASAZI_STATUS_TEST_RESNORM_HPP
76 template <
class ScalarType,
class MV,
class OP>
161 whichNorm_ = whichNorm;
209 std::ostream&
print(std::ostream& os,
int indent = 0)
const;
215 std::vector<int> ind_;
219 bool throwExceptionOnNaN_;
223 template <
class ScalarType,
class MV,
class OP>
225 : state_(
Undefined), tol_(tol), quorum_(quorum), scaled_(scaled), whichNorm_(whichNorm), throwExceptionOnNaN_(throwExceptionOnNaN)
228 template <
class ScalarType,
class MV,
class OP>
233 std::vector<MagnitudeType> res;
237 std::vector<Value<ScalarType> > vals = solver->
getRitzValues();
238 switch (whichNorm_) {
242 vals.resize(res.size());
247 vals.resize(res.size());
258 for (
unsigned int i=0; i<res.size(); i++) {
259 MagnitudeType tmp = lapack.
LAPY2(vals[i].realpart,vals[i].imagpart);
261 if ( tmp != MT::zero() ) {
269 ind_.resize(res.size());
270 for (
unsigned int i=0; i<res.size(); i++) {
272 "StatusTestResNorm::checkStatus(): residual norm is nan or inf" );
279 int need = (quorum_ == -1) ? res.size() : quorum_;
285 template <
class ScalarType,
class MV,
class OP>
288 std::string ind(indent,
' ');
289 os << ind <<
"- StatusTestResNorm: ";
292 os <<
"Passed" << std::endl;
295 os <<
"Failed" << std::endl;
298 os <<
"Undefined" << std::endl;
301 os << ind <<
" (Tolerance,WhichNorm,Scaled,Quorum): "
303 switch (whichNorm_) {
311 os <<
",RITZRES_2NORM";
314 os <<
"," << (scaled_ ?
"true" :
"false")
319 os << ind <<
" Which vectors: ";
320 if (ind_.size() > 0) {
321 for (
unsigned int i=0; i<ind_.size(); i++) os << ind_[i] <<
" ";
325 os <<
"[empty]" << std::endl;
virtual std::vector< typename Teuchos::ScalarTraits< ScalarType >::magnitudeType > getResNorms()=0
Get the current residual norms.
bool getScale()
Returns true if the test scales the norms by the eigenvalue estimates (relative scale).
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)
TestStatus getStatus() const
Return the result of the most recent checkStatus call, or undefined if it has not been run...
void setTolerance(typename Teuchos::ScalarTraits< ScalarType >::magnitudeType tol)
Set tolerance. This also resets the test status to Undefined.
An exception class parent to all Anasazi exceptions.
void reset()
Informs the status test that it should reset its internal configuration to the uninitialized state...
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.
ResType getWhichNorm()
Return the residual norm used by the status test.
virtual ~StatusTestResNorm()
Destructor.
virtual std::vector< typename Teuchos::ScalarTraits< ScalarType >::magnitudeType > getRitzRes2Norms()=0
ResNormNaNError is thrown from StatusTestResNorm::checkStatus() when a NaN ("not a number") is detect...
Teuchos::ScalarTraits< ScalarType >::magnitudeType getTolerance()
Get tolerance.
virtual std::vector< typename Teuchos::ScalarTraits< ScalarType >::magnitudeType > getRes2Norms()=0
int howMany() const
Get the number of vectors that passed the test.
TestStatus checkStatus(Eigensolver< ScalarType, MV, OP > *solver)
void setQuorum(int quorum)
Set quorum.
A pure virtual class for defining the status tests for the Anasazi iterative solvers.
A status test for testing the norm of the eigenvectors residuals.
void setScale(bool relscale)
Instruct test to scale norms by eigenvalue estimates (relative scale). This also resets the test stat...
StatusTestResNorm(typename Teuchos::ScalarTraits< ScalarType >::magnitudeType tol, int quorum=-1, ResType whichNorm=RES_ORTH, bool scaled=true, bool throwExceptionOnNaN=true)
Constructor.
std::vector< int > whichVecs() const
Get the indices for the vectors that passed the test.
The Eigensolver is a templated virtual base class that defines the basic interface that any eigensolv...
void setWhichNorm(ResType whichNorm)
Set the residual norm to be used by the status test.
ScalarType LAPY2(const ScalarType x, const ScalarType y) const
void clearStatus()
Clears the results of the last status test.
Pure virtual base class for defining the status testing capabilities of Anasazi.
int getQuorum() const
Get quorum.